diff options
author | René Meusel <[email protected]> | 2020-03-10 15:15:45 +0100 |
---|---|---|
committer | René Meusel <[email protected]> | 2020-03-10 15:39:26 +0100 |
commit | f23d942c4834c756821d49d3b0d93885317e3f3b (patch) | |
tree | 0fa86e639e0173854d6ce625d4138fac87617b08 | |
parent | a5674df8142c87a523fc4973de555f876e9f9ff7 (diff) |
read build_config.json from --build-dir
-rw-r--r-- | src/build-data/makefile.in | 7 | ||||
-rw-r--r-- | src/scripts/check.py | 39 |
2 files changed, 24 insertions, 22 deletions
diff --git a/src/build-data/makefile.in b/src/build-data/makefile.in index 5b3a3a148..0d678345f 100644 --- a/src/build-data/makefile.in +++ b/src/build-data/makefile.in @@ -60,12 +60,7 @@ install: %{install_targets} $(PYTHON_EXE) $(SCRIPTS_DIR)/install.py --prefix="%{prefix}" --build-dir="%{build_dir}" --bindir=%{bindir} --libdir=%{libdir} --docdir=%{docdir} --includedir=%{includedir} check: tests -%{if build_shared_lib} - $(PYTHON_EXE) $(SCRIPTS_DIR)/check.py --test-exe="%{test_exe}" --shared-lib="%{shared_lib_name}" -%{endif} -%{unless build_shared_lib} - $(PYTHON_EXE) $(SCRIPTS_DIR)/check.py --test-exe="%{test_exe}" -%{endif} + $(PYTHON_EXE) $(SCRIPTS_DIR)/check.py --build-dir="%{build_dir}" # Object Files LIBOBJS = %{join lib_objs} diff --git a/src/scripts/check.py b/src/scripts/check.py index 702541a2c..b27c92672 100644 --- a/src/scripts/check.py +++ b/src/scripts/check.py @@ -8,12 +8,13 @@ Implements the "make check" target Botan is released under the Simplified BSD License (see license.txt) """ -import os -import sys -import optparse -import subprocess +import json import logging +import optparse # pylint: disable=deprecated-module +import os import platform +import subprocess +import sys def is_macos(): return platform.system() == "Darwin" @@ -37,8 +38,8 @@ def run_and_check(cmd_line, env=None, cwd=None): sys.exit(1) -def get_environment(shared_lib): - if not shared_lib: +def make_environment(build_shared_lib): + if not build_shared_lib: return None env = os.environ.copy() @@ -53,10 +54,8 @@ def get_environment(shared_lib): def parse_options(args): parser = optparse.OptionParser() - parser.add_option('--test-exe', default='botan-test', metavar='BINARY', - help='specify the botan-test binary name (default %default)') - parser.add_option('--shared-lib', default=None, metavar='SHARED_LIB', - help='use shared library of botan (default %default)') + parser.add_option('--build-dir', default='build', metavar='DIR', + help='specify the botan build directory (default %default)') (options, args) = parser.parse_args(args) @@ -66,21 +65,29 @@ def parse_options(args): return options +def read_config(config): + try: + with open(config) as f: + return json.load(f) + except OSError: + raise Exception('Failed to load build config %s - is build dir correct?' % (config)) + + def main(args=None): if args is None: args = sys.argv options = parse_options(args) - test_exe = options.test_exe - shared_lib = options.shared_lib + + cfg = read_config(os.path.join(options.build_dir, 'build_config.json')) + + test_exe = cfg.get('test_exe') + build_shared_lib = cfg.get('build_shared_lib') if not os.path.isfile(test_exe) or not os.access(test_exe, os.X_OK): raise Exception("Test binary not built") - if shared_lib and not os.path.isfile(shared_lib): - raise Exception("Shared library %s not found" % shared_lib) - - run_and_check([ test_exe ], get_environment(shared_lib)) + run_and_check([ test_exe ], make_environment(build_shared_lib)) return 0 |