diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-18 15:49:59 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-18 15:49:59 +0300 |
commit | b4cb34dfb2619f594d82e512fd9ff7fc97400133 (patch) | |
tree | 6a64ab25a145265287789bceed3f59e953561206 /tools/rescompiler | |
parent | 5e837a820d5be0671fa4096a1cc1e378453e5132 (diff) | |
download | ydb-b4cb34dfb2619f594d82e512fd9ff7fc97400133.tar.gz |
intermediate changes
ref:1a0585d83f27cb6fb5b9c4f68a08177e10faf3b3
Diffstat (limited to 'tools/rescompiler')
-rw-r--r-- | tools/rescompiler/bin/CMakeLists.txt | 17 | ||||
-rw-r--r-- | tools/rescompiler/bin/ya.make | 19 | ||||
-rw-r--r-- | tools/rescompiler/main.cpp | 56 | ||||
-rw-r--r-- | tools/rescompiler/ya.make | 13 |
4 files changed, 105 insertions, 0 deletions
diff --git a/tools/rescompiler/bin/CMakeLists.txt b/tools/rescompiler/bin/CMakeLists.txt new file mode 100644 index 0000000000..6861bd59f6 --- /dev/null +++ b/tools/rescompiler/bin/CMakeLists.txt @@ -0,0 +1,17 @@ +add_executable(rescompiler) +target_link_libraries(rescompiler PUBLIC + contrib-libs-cxxsupp + yutil + library-cpp-cpuid_check + library-cpp-resource +) +target_sources(rescompiler PRIVATE + ${CMAKE_SOURCE_DIR}/tools/rescompiler/main.cpp +) +target_link_flags(rescompiler + PUBLIC + -lpthread + -lrt + -ldl +) +vcs_info(rescompiler) diff --git a/tools/rescompiler/bin/ya.make b/tools/rescompiler/bin/ya.make new file mode 100644 index 0000000000..42557c85f6 --- /dev/null +++ b/tools/rescompiler/bin/ya.make @@ -0,0 +1,19 @@ +OWNER(pg g:ymake) + +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/main.cpp b/tools/rescompiler/main.cpp new file mode 100644 index 0000000000..b5f50cea2d --- /dev/null +++ b/tools/rescompiler/main.cpp @@ -0,0 +1,56 @@ +#include <library/cpp/resource/registry.h> + +#include <util/stream/output.h> +#include <util/stream/file.h> +#include <util/digest/city.h> +#include <util/string/cast.h> +#include <util/string/hex.h> +#include <util/string/vector.h> +#include <util/string/split.h> + +using namespace NResource; + +static inline void GenOne(const TString& data, const TString& key, IOutputStream& out) { + const TString name = "name" + ToString(CityHash64(key.data(), key.size())); + + out << "static const unsigned char " << name << "[] = {"; + + const TString c = Compress(data); + char buf[16]; + + for (size_t i = 0; i < c.size(); ++i) { + if ((i % 10) == 0) { + out << "\n "; + } + + const char ch = c[i]; + + out << "0x" << TStringBuf(buf, HexEncode(&ch, 1, buf)) << ", "; + } + + out << "\n};\n\nstatic const NResource::TRegHelper REG_" << name << "(\"" << key << "\", TStringBuf((const char*)" << name << ", sizeof(" << name << ")));\n"; +} + +int main(int argc, char** argv) { + if ((argc < 4) || (argc % 2)) { + Cerr << "usage: " << argv[0] << " outfile [infile path]+ [- key=value]+" << Endl; + + return 1; + } + + TFixedBufferFileOutput out(argv[1]); + + argv = argv + 2; + + out << "#include <library/cpp/resource/registry.h>\n\n"; + + while (*argv) { + if ("-"sv == *argv) { + TVector<TString> items = StringSplitter(TString(*(argv + 1))).Split('=').Limit(2).ToList<TString>(); + GenOne(TString(items[1]), TString(items[0]), out); + } else { + GenOne(TUnbufferedFileInput(*argv).ReadAll(), *(argv + 1), out); + } + argv += 2; + } +} diff --git a/tools/rescompiler/ya.make b/tools/rescompiler/ya.make new file mode 100644 index 0000000000..808608eded --- /dev/null +++ b/tools/rescompiler/ya.make @@ -0,0 +1,13 @@ +OWNER(pg g:ymake) + +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 +) |