blob: 1cb03afa453811cbc19b5f9bba09437e06e4a741 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include <library/cpp/resource/registry.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/split.h>
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"
<< "extern \"C\" const unsigned int " << size << ";\n"
<< "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;
}
TFixedBufferFileOutput out(argv[1]);
argv = argv + 2;
out << "#include <library/cpp/resource/registry.h>\n\n";
while (*argv) {
TVector<TString> items = StringSplitter(TString(*(argv))).Split('=').Limit(2).ToList<TString>();
GenOne(items[0], items[1], out);
argv++;
}
}
|