aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorheretic <heretic@yandex-team.ru>2022-02-10 16:45:46 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:46 +0300
commit81eddc8c0b55990194e112b02d127b87d54164a9 (patch)
tree9142afc54d335ea52910662635b898e79e192e49 /tools
parent397cbe258b9e064f49c4ca575279f02f39fef76e (diff)
downloadydb-81eddc8c0b55990194e112b02d127b87d54164a9.tar.gz
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'tools')
-rw-r--r--tools/rescompressor/main.cpp168
-rw-r--r--tools/rescompressor/ya.make6
-rw-r--r--tools/rorescompiler/main.cpp52
-rw-r--r--tools/rorescompiler/ya.make6
-rw-r--r--tools/ya.make4
5 files changed, 118 insertions, 118 deletions
diff --git a/tools/rescompressor/main.cpp b/tools/rescompressor/main.cpp
index e038cdab7fe..9aba1002c5d 100644
--- a/tools/rescompressor/main.cpp
+++ b/tools/rescompressor/main.cpp
@@ -1,46 +1,46 @@
#include <library/cpp/resource/registry.h>
-#include <util/stream/file.h>
-#include <util/folder/path.h>
-
-using namespace NResource;
-
-class TAsmWriter {
-private:
- IOutputStream& AsmOut;
- TString AsmPrefix;
-
-public:
- TAsmWriter(IOutputStream& out, const TString& prefix) : AsmOut(out), AsmPrefix(prefix)
- {
- }
-
- void Write(TStringBuf filename, const TString& data, bool raw) {
- TString constname(Basename(filename));
- if (constname.rfind('.') != TStringBuf::npos) {
- constname = constname.substr(0, constname.rfind('.'));
- }
- WriteHeader(constname);
- if (raw) {
- WriteRaw(constname, data);
- } else {
- WriteIncBin(constname, filename, data);
- }
+#include <util/stream/file.h>
+#include <util/folder/path.h>
+
+using namespace NResource;
+
+class TAsmWriter {
+private:
+ IOutputStream& AsmOut;
+ TString AsmPrefix;
+
+public:
+ TAsmWriter(IOutputStream& out, const TString& prefix) : AsmOut(out), AsmPrefix(prefix)
+ {
+ }
+
+ void Write(TStringBuf filename, const TString& data, bool raw) {
+ TString constname(Basename(filename));
+ if (constname.rfind('.') != TStringBuf::npos) {
+ constname = constname.substr(0, constname.rfind('.'));
+ }
+ WriteHeader(constname);
+ if (raw) {
+ WriteRaw(constname, data);
+ } else {
+ WriteIncBin(constname, filename, data);
+ }
WriteFooter(constname);
WriteSymbolSize(constname);
- }
-
-private:
- void WriteHeader(const TStringBuf& constname) {
- AsmOut << "global " << AsmPrefix << constname << "\n";
- AsmOut << "global " << AsmPrefix << constname << "Size\n";
- AsmOut << "SECTION .rodata\n";
- }
-
+ }
+
+private:
+ void WriteHeader(const TStringBuf& constname) {
+ AsmOut << "global " << AsmPrefix << constname << "\n";
+ AsmOut << "global " << AsmPrefix << constname << "Size\n";
+ AsmOut << "SECTION .rodata\n";
+ }
+
void WriteFooter(TStringBuf constname) {
AsmOut << AsmPrefix << constname << "Size:\n";
AsmOut << "dd " << AsmPrefix << constname << ".end - " << AsmPrefix << constname << "\n";
- }
-
+ }
+
void WriteSymbolSize(TStringBuf constname) {
AsmOut << "%ifidn __OUTPUT_FORMAT__,elf64\n";
AsmOut << "size " << AsmPrefix << constname << " " << AsmPrefix << constname << ".end - " << AsmPrefix << constname << "\n";
@@ -48,34 +48,34 @@ private:
AsmOut << "%endif\n";
}
- void WriteIncBin(TStringBuf constname, TStringBuf filename, const TString& data) {
- AsmOut << AsmPrefix << constname << ":\nincbin \"" << Basename(filename) << "\"\n";
+ void WriteIncBin(TStringBuf constname, TStringBuf filename, const TString& data) {
+ AsmOut << AsmPrefix << constname << ":\nincbin \"" << Basename(filename) << "\"\n";
AsmOut << ".end:\n";
TFixedBufferFileOutput out(filename.data());
- out << data;
- }
-
- void WriteRaw(TStringBuf constname, const TString& data) {
- AsmOut << AsmPrefix << constname << ":\ndb ";
+ out << data;
+ }
+
+ void WriteRaw(TStringBuf constname, const TString& data) {
+ AsmOut << AsmPrefix << constname << ":\ndb ";
for (size_t i = 0; i < data.size() - 1; i++) {
- unsigned char c = static_cast<unsigned char>(data[i]);
- AsmOut << IntToString<10, unsigned char>(c) << ",";
- }
+ unsigned char c = static_cast<unsigned char>(data[i]);
+ AsmOut << IntToString<10, unsigned char>(c) << ",";
+ }
AsmOut << IntToString<10, unsigned char>(static_cast<unsigned char>(data[data.size() - 1])) << "\n";
AsmOut << ".end:\n";
- }
-
- TString Basename(TStringBuf origin) {
- TString result(origin);
- if (result.rfind('/') != TString::npos) {
- result = result.substr(result.rfind('/') + 1);
- } else if (result.rfind('\\') != TString::npos) {
- result = result.substr(result.rfind('\\') + 1);
- }
- return result;
- }
-};
-
+ }
+
+ TString Basename(TStringBuf origin) {
+ TString result(origin);
+ if (result.rfind('/') != TString::npos) {
+ result = result.substr(result.rfind('/') + 1);
+ } else if (result.rfind('\\') != TString::npos) {
+ result = result.substr(result.rfind('\\') + 1);
+ }
+ return result;
+ }
+};
+
static TString CompressPath(const TVector<TStringBuf>& replacements, TStringBuf in) {
for (auto r : replacements) {
TStringBuf from, to;
@@ -88,37 +88,37 @@ static TString CompressPath(const TVector<TStringBuf>& replacements, TStringBuf
return Compress(in);
}
-int main(int argc, char** argv) {
+int main(int argc, char** argv) {
int ind = 0;
- if (argc < 4) {
+ if (argc < 4) {
Cerr << "usage: " << argv[ind] << "asm_output --prefix? [-? origin_resource ro_resource]+" << Endl;
- return 1;
- }
-
+ return 1;
+ }
+
TVector<TStringBuf> replacements;
ind++;
TFixedBufferFileOutput asmout(argv[ind]);
ind++;
- TString prefix;
+ TString prefix;
if (TStringBuf(argv[ind]) == "--prefix") {
- prefix = "_";
+ prefix = "_";
ind++;
- }
- else {
- prefix = "";
- }
-
+ }
+ else {
+ prefix = "";
+ }
+
while (TStringBuf(argv[ind]).StartsWith("--replace=")) {
replacements.push_back(TStringBuf(argv[ind]).SubStr(TStringBuf("--replace=").Size()));
ind++;
}
- TAsmWriter aw(asmout, prefix);
- bool raw;
+ TAsmWriter aw(asmout, prefix);
+ bool raw;
bool error = false;
while (ind < argc) {
- TString compressed;
+ TString compressed;
if ("-"sv == argv[ind]) {
ind++;
if (ind >= argc) {
@@ -126,14 +126,14 @@ int main(int argc, char** argv) {
break;
}
compressed = CompressPath(replacements, TStringBuf(argv[ind]));
- raw = true;
- }
- else {
+ raw = true;
+ }
+ else {
TUnbufferedFileInput inp(argv[ind]);
- TString data = inp.ReadAll();
+ TString data = inp.ReadAll();
compressed = Compress(TStringBuf(data.data(), data.size()));
- raw = false;
- }
+ raw = false;
+ }
ind++;
if (ind >= argc) {
error = true;
@@ -141,10 +141,10 @@ int main(int argc, char** argv) {
}
aw.Write(argv[ind], compressed, raw);
ind++;
- }
+ }
if (error) {
Cerr << "Incorrect number of parameters at argument " << ind - 1 << argv[ind-1] << Endl;
return 1;
}
- return 0;
-}
+ return 0;
+}
diff --git a/tools/rescompressor/ya.make b/tools/rescompressor/ya.make
index 8f76a7f315a..4c118c0bc6e 100644
--- a/tools/rescompressor/ya.make
+++ b/tools/rescompressor/ya.make
@@ -1,13 +1,13 @@
OWNER(heretic g:ymake)
-
+
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/main.cpp b/tools/rorescompiler/main.cpp
index 8eb756cac1d..7ca5346e4c8 100644
--- a/tools/rorescompiler/main.cpp
+++ b/tools/rorescompiler/main.cpp
@@ -1,15 +1,15 @@
#include <library/cpp/resource/registry.h>
-
-#include <util/digest/city.h>
-#include <util/stream/output.h>
-#include <util/stream/file.h>
+
+#include <util/digest/city.h>
+#include <util/stream/output.h>
+#include <util/stream/file.h>
#include <util/string/escape.h>
-#include <util/string/vector.h>
+#include <util/string/vector.h>
#include <util/string/split.h>
-
-using namespace NResource;
-
-void GenOne(const TString& raw, const TString& key, IOutputStream& out) {
+
+using namespace NResource;
+
+void GenOne(const TString& raw, const TString& key, IOutputStream& out) {
TString size = raw + "Size";
TString name = ToString(CityHash64(key.data(), key.size()));
out << "extern \"C\" const char " << raw << "[];\n"
@@ -17,23 +17,23 @@ void GenOne(const TString& raw, const TString& key, IOutputStream& out) {
<< "static const NResource::TRegHelper REG_name" << name
<< "(\"" << EscapeC(key) << "\", TStringBuf(" << raw << ", " << size << "));\n"
<< "\n";
-};
-
-int main(int argc, char** argv) {
- if (argc < 3) {
- Cerr << "usage: " << argv[0] << " outfile [key=value]+" << Endl;
-
- return 1;
- }
-
+};
+
+int main(int argc, char** argv) {
+ if (argc < 3) {
+ Cerr << "usage: " << argv[0] << " outfile [key=value]+" << Endl;
+
+ return 1;
+ }
+
TFixedBufferFileOutput out(argv[1]);
-
- argv = argv + 2;
+
+ argv = argv + 2;
out << "#include <library/cpp/resource/registry.h>\n\n";
-
- while (*argv) {
+
+ while (*argv) {
TVector<TString> items = StringSplitter(TString(*(argv))).Split('=').Limit(2).ToList<TString>();
- GenOne(items[0], items[1], out);
- argv++;
- }
-}
+ GenOne(items[0], items[1], out);
+ argv++;
+ }
+}
diff --git a/tools/rorescompiler/ya.make b/tools/rorescompiler/ya.make
index 55640d731af..7e372666f9b 100644
--- a/tools/rorescompiler/ya.make
+++ b/tools/rorescompiler/ya.make
@@ -1,13 +1,13 @@
OWNER(heretic g:ymake)
-
+
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/tools/ya.make b/tools/ya.make
index 1f91da00488..51a6b8b4263 100644
--- a/tools/ya.make
+++ b/tools/ya.make
@@ -130,8 +130,8 @@ RECURSE(
remorphc
remorphparser
rescompiler
- rescompressor
- rorescompiler
+ rescompressor
+ rorescompiler
sandboxctl
sanitizer
segutils