diff --git a/bootstrap.py b/bootstrap.py index 719c5f9..cf7a71e 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -27,7 +27,7 @@ def get_files(root, pattern): yield os.path.join(dir, f) def object_file(fn): - return os.path.join('obj', re.sub(r'\.c\+\+', '.o', fn)) + return os.path.join('obj', re.sub(r'\.c\+\+$', '.o', fn)) # --- arguments @@ -114,6 +114,24 @@ def object_file(fn): ninja.build('dist', 'phony', inputs = tar) +# --- examples + +example_files = list(get_files('examples', '*.c++')) +examples = [] +for fn in example_files: + ninja.build(object_file(fn), 'cxx', + inputs = fn) + name = re.sub(r'\.c\+\+$', '', os.path.basename(fn)) + example = os.path.join('bin', 'examples', name) + ninja.build(example, 'link', + inputs = [object_file(fn), libnonius]) + ninja.build(name, 'phony', + inputs = example) + examples += [name] + +ninja.build('examples', 'phony', + inputs = examples) + # --- default targets ninja.default('lib')