1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
8 arches
= ['i386', 'x86-64']
12 for fn
in sys
.argv
[2:]:
13 dir, name
= fn
.split('/')[-2:]
14 name
= name
.rstrip('.txt')
15 golden
= goldens
.setdefault(name
, [None] * len(arches
))
16 idx
= arches
.index(dir)
17 golden
[idx
] = open(fn
).read()
19 with
open(sys
.argv
[1], 'w') as f
:
20 f
.write("""// Generated by sandbox/linux/bpf_dsl/golden/generate.py
22 #ifndef SANDBOX_LINUX_BPF_DSL_GOLDEN_GOLDEN_FILES_H_
23 #define SANDBOX_LINUX_BPF_DSL_GOLDEN_GOLDEN_FILES_H_
30 const char* i386_dump;
31 const char* x86_64_dump;
36 for name
, datas
in sorted(goldens
.items()):
37 f
.write("const Golden k%s = {\n" % name
)
40 f
.write(" nullptr,\n")
42 f
.write(" \"%s\",\n" % data
.replace("\n", "\\n\\\n"))
47 } // namespace bpf_dsl
48 } // namespace sandbox
50 #endif // SANDBOX_LINUX_BPF_DSL_GOLDEN_GOLDEN_FILES_H_