diff options
| author | Anton Samokhvalov <[email protected]> | 2022-02-10 16:45:15 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:15 +0300 |
| commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
| tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /build/plugins/rodata.py | |
| parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
Restoring authorship annotation for Anton Samokhvalov <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'build/plugins/rodata.py')
| -rw-r--r-- | build/plugins/rodata.py | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/build/plugins/rodata.py b/build/plugins/rodata.py index 3ecb0f9a839..98defaff654 100644 --- a/build/plugins/rodata.py +++ b/build/plugins/rodata.py @@ -1,15 +1,15 @@ import argparse -import os - -import _common as common -import _import_wrapper as iw - - +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: @@ -118,51 +118,51 @@ class ROData(iw.CustomCommand): 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): +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): + + 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): + 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) - - + return RODataCXX(path, unit) + + return ROData(path, unit) + + def init(): iw.addrule('rodata', ro_data) |
