diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-03-24 11:57:50 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-03-24 11:57:50 +0300 |
commit | a2138eb93b9a5e4ad182dcad2059481e7d9f6eb3 (patch) | |
tree | ead16940c656314ae75441a38c4f738ee741c081 | |
parent | 6c7158b24a08e281736dee81a9fe98146982d58b (diff) | |
download | ydb-a2138eb93b9a5e4ad182dcad2059481e7d9f6eb3.tar.gz |
intermediate changes
ref:38621335ecd9e555f527a1d0da589e6042d8f9d1
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | build/plugins/rodata.py | 168 | ||||
-rw-r--r-- | build/scripts/rodata2asm.py | 31 | ||||
-rw-r--r-- | build/scripts/rodata2cpp.py | 34 | ||||
-rw-r--r-- | build/ya.conf.json | 2 | ||||
-rw-r--r-- | build/ymake.core.conf | 28 | ||||
-rw-r--r-- | library/cpp/unicode/punycode/CMakeLists.txt | 5 | ||||
-rw-r--r-- | library/cpp/uri/CMakeLists.txt | 5 |
8 files changed, 99 insertions, 176 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ccd7ed05d14..9cc23cd1561 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,6 @@ conan_cmake_configure( bison/3.5.3 c-ares/1.17.2 libiconv/1.15 - libidn/1.36 openssl/1.1.1l ragel/6.10 yasm/1.3.0 @@ -144,7 +143,6 @@ conan_cmake_configure( "res, * -> ./bin/bison/res" OPTIONS libiconv:shared=True - libidn:shared=True ) conan_cmake_autodetect(settings) conan_cmake_install( diff --git a/build/plugins/rodata.py b/build/plugins/rodata.py deleted file mode 100644 index 3ecb0f9a839..00000000000 --- a/build/plugins/rodata.py +++ /dev/null @@ -1,168 +0,0 @@ -import argparse -import os - -import _common as common -import _import_wrapper as iw - - -class ROData(iw.CustomCommand): - def __init__(self, path, unit): - self._path = path - self._flags = [] - - prefix = unit.get('ASM_PREFIX') - - if prefix: - self._flags += ['--prefix=' + prefix] - - self._pre_include = [] - - flags = unit.get('YASM_FLAGS') - if flags: - self.parse_flags(path, unit, collections.deque(flags.split(' '))) - - if unit.enabled('DARWIN') or unit.enabled('IOS'): - self._platform = ['DARWIN', 'UNIX'] - self._fmt = 'macho' - elif unit.enabled('WIN64') or unit.enabled('CYGWIN'): - self._platform = ['WIN64'] - self._fmt = 'win' - elif unit.enabled('WIN32'): - self._platform = ['WIN32'] - self._fmt = 'win' - else: - self._platform = ['UNIX'] - self._fmt = 'elf' - - if 'elf' in self._fmt: - self._flags += ['-g', 'dwarf2'] - - self._fmt += unit.get('HARDWARE_ARCH') - self._type = unit.get('HARDWARE_TYPE') - - if unit.enabled('DARWIN') or unit.enabled('IOS') or (unit.enabled('WINDOWS') and unit.enabled('ARCH_TYPE_32')): - self._prefix = '_' - else: - self._prefix = '' - - def parse_flags(self, path, unit, flags): - while flags: - flag = flags.popleft() - if flag.startswith('-I'): - raise Exception('Use ADDINCL macro') - - if flag.startswith('-P'): - preinclude = flag[2:] or flags.popleft() - self._pre_include += unit.resolve_include([(get_retargeted(path, unit)), preinclude]) - self._flags += ['-P', preinclude] - continue - - self._flags.append(flag) - - def descr(self): - return 'AS', self._path, 'light-green' - - def flags(self): - return self._flags + self._platform + [self._fmt, self._type] - - def tools(self): - return ['contrib/tools/yasm'] - - def input(self): - return common.make_tuples(self._pre_include + [self._path]) - - def output(self): - return common.make_tuples([common.tobuilddir(common.stripext(self._path)) + '.o']) - - def requested_vars(self): - return [('includes', '_ASM__INCLUDE')] - - def run(self, extra_args, binary): - in_file = self.resolve_path(common.get(self.input, 0)) - in_file_no_ext = common.stripext(in_file) - file_name = os.path.basename(in_file_no_ext) - file_size = os.path.getsize(in_file) - tmp_file = self.resolve_path(common.get(self.output, 0) + '.asm') - - parser = argparse.ArgumentParser(prog='rodata.py', add_help=False) - parser.add_argument('--includes', help='module\'s addincls', nargs='*', required=False) - args = parser.parse_args(extra_args) - self._incl_dirs = args.includes - - with open(tmp_file, 'w') as f: - f.write('global ' + self._prefix + file_name + '\n') - f.write('global ' + self._prefix + file_name + 'Size' + '\n') - f.write('SECTION .rodata ALIGN=16\n') - f.write(self._prefix + file_name + ':\nincbin "' + in_file + '"\n') - f.write('align 4, db 0\n') - f.write(self._prefix + file_name + 'Size:\ndd ' + str(file_size) + '\n') - - if self._fmt.startswith('elf'): - f.write('size ' + self._prefix + file_name + ' ' + str(file_size) + '\n') - f.write('size ' + self._prefix + file_name + 'Size 4\n') - - return self.do_run(binary, tmp_file) - - def do_run(self, binary, path): - def plt(): - for x in self._platform: - yield '-D' - yield x - - def incls(): - for x in self._incl_dirs: - yield '-I' - yield x - - cmd = [binary, '-f', self._fmt] + list(plt()) + ['-D', '_' + self._type + '_', '-D_YASM_'] + self._flags + list(incls()) + ['-o', common.get(self.output, 0), path] - self.call(cmd) - - -class RODataCXX(iw.CustomCommand): - def __init__(self, path, unit): - self._path = path - self._base = os.path.basename(common.stripext(self._path)) - - def descr(self): - return 'RD', self._path, 'light-green' - - def input(self): - return common.make_tuples([self._path]) - - def main_out(self): - return common.tobuilddir(common.stripext(self._path)) + '.cpp' - - def output(self): - return common.make_tuples([self.main_out()]) - - def run(self, extra_args, binary): - with open(self.resolve_path(self.main_out()), 'w') as f: - f.write('static_assert(sizeof(unsigned int) == 4, "ups, something gone wrong");\n\n') - f.write('extern "C" {\n') - f.write(' extern const unsigned char ' + self._base + '[] = {\n') - - cnt = 0 - - with open(self.resolve_path(self._path), 'r') as input: - for ch in input.read(): - f.write('0x%02x, ' % ord(ch)) - - cnt += 1 - - if cnt % 50 == 1: - f.write('\n') - - f.write(' };\n') - f.write(' extern const unsigned int ' + self._base + 'Size = sizeof(' + self._base + ');\n') - f.write('}\n') - - -def ro_data(path, unit): - if unit.enabled('ARCH_AARCH64') or unit.enabled('ARCH_ARM') or unit.enabled('ARCH_PPC64LE'): - return RODataCXX(path, unit) - - return ROData(path, unit) - - -def init(): - iw.addrule('rodata', ro_data) 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/rodata2cpp.py b/build/scripts/rodata2cpp.py new file mode 100644 index 00000000000..be67d3af53a --- /dev/null +++ b/build/scripts/rodata2cpp.py @@ -0,0 +1,34 @@ +import argparse + + +def main(): + parser = argparse.ArgumentParser(description='Convert rodata into C++ source with embedded file content') + parser.add_argument('symbol', help='symbol name exported from generated file') + parser.add_argument('rodata', type=argparse.FileType('rb'), help='input .rodata file path') + parser.add_argument('cpp', type=argparse.FileType('w', encoding='UTF-8'), help='destination .cpp file path') + + args = parser.parse_args() + args.cpp.write('static_assert(sizeof(unsigned int) == 4, "ups, something gone wrong");\n\n') + args.cpp.write('extern "C" {\n') + args.cpp.write(' extern const unsigned char ' + args.symbol + '[] = {\n') + + cnt = 0 + + for ch in args.rodata.read(): + args.cpp.write('0x%02x, ' % ch) + + cnt += 1 + + if cnt % 50 == 1: + args.cpp.write('\n') + + args.cpp.write(' };\n') + args.cpp.write(' extern const unsigned int ' + args.symbol + 'Size = sizeof(' + args.symbol + ');\n') + args.cpp.write('}\n') + + args.rodata.close() + args.cpp.close() + + +if __name__ == '__main__': + main() diff --git a/build/ya.conf.json b/build/ya.conf.json index 9a4ac26b4d9..5b2fddd3336 100644 --- a/build/ya.conf.json +++ b/build/ya.conf.json @@ -7318,7 +7318,7 @@ "infractl": { "formula": { "sandbox_id": [ - 1252683800 + 1253648884 ], "match": "infractl" }, diff --git a/build/ymake.core.conf b/build/ymake.core.conf index 36bfc5be1e9..0b44f77deda 100644 --- a/build/ymake.core.conf +++ b/build/ymake.core.conf @@ -5559,6 +5559,27 @@ macro _SRC(EXT, SRC, SRCFLAGS...) { # Generic macro definition for _SRC (just a placeholder, it does nothing) } +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"} + .PEERDIR=$YMAKE_PYTHON3_PEER +} + # 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} @@ -7224,8 +7245,13 @@ 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=${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} ${input:SRC} ${kv;hide:"p AS"} ${kv;hide:"pc light-green"} + .CMD=$_SRC_yasm_helper(${input:SRC}, $SRCFLAGS, PREINCLUDES $PREINCLUDES) } ### @usage: ASM_PREINCLUDE(AsmFiles...) diff --git a/library/cpp/unicode/punycode/CMakeLists.txt b/library/cpp/unicode/punycode/CMakeLists.txt index 00906afe58b..0f1d26ebc11 100644 --- a/library/cpp/unicode/punycode/CMakeLists.txt +++ b/library/cpp/unicode/punycode/CMakeLists.txt @@ -6,13 +6,14 @@ # original buildsystem will not be accepted. -find_package(libidn REQUIRED) +find_package(IDN REQUIRED) add_library(cpp-unicode-punycode) target_link_libraries(cpp-unicode-punycode PUBLIC contrib-libs-cxxsupp yutil - libidn::libidn + IDN::IDN + $CONAN_OPTS_SEM ) target_sources(cpp-unicode-punycode PRIVATE ${CMAKE_SOURCE_DIR}/library/cpp/unicode/punycode/punycode.cpp diff --git a/library/cpp/uri/CMakeLists.txt b/library/cpp/uri/CMakeLists.txt index 41ac6fb5b17..c5a6a6259d5 100644 --- a/library/cpp/uri/CMakeLists.txt +++ b/library/cpp/uri/CMakeLists.txt @@ -6,13 +6,14 @@ # original buildsystem will not be accepted. -find_package(libidn REQUIRED) +find_package(IDN REQUIRED) add_library(library-cpp-uri) target_link_libraries(library-cpp-uri PUBLIC contrib-libs-cxxsupp yutil - libidn::libidn + IDN::IDN + $CONAN_OPTS_SEM library-cpp-charset ) target_sources(library-cpp-uri PRIVATE |