diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-10-28 13:13:57 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-11-01 10:20:55 +0200 |
commit | 4eb685d94e89a2aef61047225c1834a89de01de2 (patch) | |
tree | 99a6cab3b8766e23aecacc1cb91b00bfcf99700f /rcc | |
parent | Drop libc++ default (diff) | |
download | rcc-4eb685d94e89a2aef61047225c1834a89de01de2.tar.xz |
Simplify rccv0.1.0
- drop qrc parsing and zstd compression
Diffstat (limited to 'rcc')
-rwxr-xr-x | rcc | 54 |
1 files changed, 17 insertions, 37 deletions
@@ -4,48 +4,28 @@ import argparse import sys import rcc_format -def none(filelist, args): - rcc_format.write_header(args.output, args.namespace) - - for f in filelist: - with open(f.path, 'rb') as contents: - rcc_format.write_item(args.output, f.variable, contents.read()) - - rcc_format.write_entries(args.output, filelist) - print("constexpr auto compression = embed::None;", file=args.output) - - rcc_format.write_footer(args.output, args.namespace) - if __name__ == "__main__": parser = argparse.ArgumentParser( - description='Resource Compiler for C++', - epilog='For a full list of compression options, check {mode} --help.', + description='Simple Resource Compiler for C++20', + epilog='For more information check --help.', ) - mode = parser.add_subparsers(help='compression mode') - - none_mode = mode.add_parser('-') - none_mode.set_defaults(func=none) - - zstd_mode = mode.add_parser('Zstd', - description='use Zstd compression', - epilog='A dictionary is recommended if compressing many small files. size(source)/size(dictionary) should be >= 10' + mode = parser.add_subparsers(help='mode') + + dump_mode = mode.add_parser('dump', + formatter_class=argparse.RawDescriptionHelpFormatter, + description='Create a hexdump of [input](s) to [output]', + epilog='''The header file will also contain: + entries - an array of tuples of (input basename, span of data); + get - a get convience function that will return the span of a supplied basename +All of these are constexpr.''', ) - zstd_mode.add_argument('--binary', type=str, default='zstd', help='zstd binary name') - zstd_mode.add_argument('--train', type=argparse.FileType('wb'), help='train dictionary and exit') - zstd_mode.add_argument('-d', '--dict', type=argparse.FileType('rb'), help='use dictionary, recommended for many similar small files') - zstd_mode.add_argument('--dsize', type=int, default=512, help='dictionary size, used for training') - zstd_mode.add_argument('-l', '--level', type=int, default=19, help='compression level') - zstd_mode.set_defaults(func=rcc_format.zstd) - - gen_mode = mode.add_parser('generate', description='Generate .xrc file from inputs') - gen_mode.add_argument('-a', '--alias', type=str, help='set alias') - gen_mode.set_defaults(func=rcc_format.generate) - - parser.add_argument('input', type=argparse.FileType('rt'), help='input file (.xrc)') - parser.add_argument('-o', '--output', type=argparse.FileType('wt'), default=sys.stdout, help='output header file') - parser.add_argument('-n', '--namespace', type=str, default='resources', help='namespace') + dump_mode.set_defaults(func=rcc_format.dump) + + parser.add_argument('-o', '--output', type=argparse.FileType('wt'), default=sys.stdout, help='output header file (default: stdout)') + parser.add_argument('-n', '--namespace', type=str, default='resources', help='namespace (default: resources)') + parser.add_argument('input', type=argparse.FileType('rb'), nargs='+', help='input file(s)') args=parser.parse_args() - args.func(rcc_format.filelist(args.input), args) + args.func(args.input, args) |