aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-03-30 14:08:41 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-03-30 14:17:00 +0300
commitf9ea03470e3a0bbe67ccb0a531dcf0e39aec1e90 (patch)
treea2079e6810e083ed437d2c0f1b9b1fe0bba27776
parentDrop dependency on serge-sans-paille/frozen (diff)
downloadrcc-f9ea03470e3a0bbe67ccb0a531dcf0e39aec1e90.tar.xz
Move scripts/rcc to top level
- add rcc generator for use when importing as subproject
-rw-r--r--.gitignore2
-rw-r--r--meson.build30
-rwxr-xr-xrcc (renamed from scripts/rcc)15
-rw-r--r--rcc_format/__init__.py2
-rwxr-xr-xrcc_format/gen-resources.sh (renamed from scripts/gen-resources.sh)0
-rw-r--r--rcc_format/util.py (renamed from scripts/rcc_format.py)0
-rw-r--r--rcc_format/zstd.py (renamed from scripts/zstd.py)2
7 files changed, 29 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ce8c7f3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+__pycache__
+build
diff --git a/meson.build b/meson.build
index d49e251..5c7cd65 100644
--- a/meson.build
+++ b/meson.build
@@ -1,10 +1,13 @@
project('libembed', ['cpp'],
+ version: '0.1',
default_options: ['cpp_std=c++2a', 'warning_level=3'],
)
+if not meson.is_subproject()
# libstdc++ lacks std::span at the moment
add_project_arguments(['-stdlib=libc++'], language: 'cpp')
add_project_link_arguments(['-stdlib=libc++'], language : 'cpp')
+endif
libzstd = dependency('libzstd')
@@ -12,40 +15,41 @@ libembed_sourceset = import('sourceset').source_set()
libembed_sourceset.add(when: libzstd, if_true: [ libzstd, files('lib/zstd.cpp') ] )
libembed_conf = libembed_sourceset.apply(configuration_data())
-libembed = library('embed',
- libembed_conf.sources(),
- dependencies: libembed_conf.dependencies(),
- include_directories: '3rd-party/frozen/include/'
+libembed = library('embed', libembed_conf.sources(),
+ dependencies: libembed_conf.dependencies()
)
-dep_embed = declare_dependency(
+libembed_dep = declare_dependency(
link_with: libembed,
- include_directories: include_directories('lib/', '3rd-party/frozen/include')
+ include_directories: include_directories('lib/')
)
prog_python = import('python').find_installation('python3')
-resources_h = custom_target('resources.h',
- output: 'resources.h',
- input: 'scripts/rcc',
- command: [prog_python, '@INPUT@', '--namespace=staticdata', '--output=@OUTPUT@', '-', files('test/resources.xrc')],
+rcc = generator(prog_python,
+ output: '@BASENAME@.h',
+ arguments: [ meson.current_source_dir()/'rcc', '--output=@OUTPUT@', '@EXTRA_ARGS@', '@INPUT@' ]
)
+if not meson.is_subproject()
+resources_h = rcc.process(files('test/resources.xrc'), extra_args: [ '--namespace=staticdata', '-' ])
+
zstd_dictionary = custom_target('zstd_dictionary',
output: 'zstd_dict',
- input: 'scripts/rcc',
+ input: 'rcc',
command: [ prog_python, '@INPUT@', 'Zstd', '--train=@OUTPUT@', files('test/resources.xrc') ]
)
zstd_resources_h = custom_target('zstd_resources.h',
output: 'zstd_resources.h',
- input: [ 'scripts/rcc', zstd_dictionary ],
+ input: [ 'rcc', zstd_dictionary ],
command: [prog_python, '@INPUT0@', '--namespace=zstd_data', '--output=@OUTPUT@', 'Zstd', '--dict=@INPUT1@', files('test/resources.xrc')],
)
test('libembed',
executable('embed',
sources: [ 'test/main.cpp', resources_h, zstd_resources_h ],
- dependencies: [ dep_embed ]
+ dependencies: [ libembed_dep ]
)
)
+endif # meson.is_subproject()
diff --git a/scripts/rcc b/rcc
index 479b609..00d453f 100755
--- a/scripts/rcc
+++ b/rcc
@@ -2,20 +2,19 @@
import argparse
import sys
-from zstd import zstd
-from rcc_format import *
+import rcc_format
def none(filelist, args):
- write_header(args.output, args.namespace)
+ rcc_format.write_header(args.output, args.namespace)
for f in filelist:
with open(f.path, 'rb') as contents:
- write_item(args.output, f.variable, contents.read())
+ rcc_format.write_item(args.output, f.variable, contents.read())
- write_entries(args.output, filelist)
+ rcc_format.write_entries(args.output, filelist)
print("constexpr auto compression = embed::None;", file=args.output)
- write_footer(args.output, args.namespace)
+ rcc_format.write_footer(args.output, args.namespace)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
@@ -37,7 +36,7 @@ if __name__ == "__main__":
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=zstd)
+ zstd_mode.set_defaults(func=rcc_format.zstd)
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')
@@ -45,5 +44,5 @@ if __name__ == "__main__":
args=parser.parse_args()
- args.func(filelist(args.input), args)
+ args.func(rcc_format.filelist(args.input), args)
diff --git a/rcc_format/__init__.py b/rcc_format/__init__.py
new file mode 100644
index 0000000..133bcc1
--- /dev/null
+++ b/rcc_format/__init__.py
@@ -0,0 +1,2 @@
+from rcc_format.util import *
+from rcc_format.zstd import zstd
diff --git a/scripts/gen-resources.sh b/rcc_format/gen-resources.sh
index a1db9fd..a1db9fd 100755
--- a/scripts/gen-resources.sh
+++ b/rcc_format/gen-resources.sh
diff --git a/scripts/rcc_format.py b/rcc_format/util.py
index 7fcfe34..7fcfe34 100644
--- a/scripts/rcc_format.py
+++ b/rcc_format/util.py
diff --git a/scripts/zstd.py b/rcc_format/zstd.py
index 2cfa149..34eeb64 100644
--- a/scripts/zstd.py
+++ b/rcc_format/zstd.py
@@ -1,5 +1,5 @@
import subprocess
-from rcc_format import *
+from rcc_format.util import *
def zstd(filelist, args):
if args.train is not None: