Skip to content

Commit

Permalink
Search output directory for include files (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
milasudril committed Mar 9, 2022
1 parent d2c6ee7 commit bfdc6f7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
4 changes: 3 additions & 1 deletion maikeconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
},
"recipe": "recipes/cxx_compiler.py"
},
"config": {},
"config": {
"generated_includes":[".\\.gen\\.hpp$"]
},
"loader": "cxx_src_loader"
},
"cxx_test": {
Expand Down
12 changes: 8 additions & 4 deletions recipes/cxx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,23 @@
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)

def format_iquote(src_dir, list):
def format_iquote(src_dir, target_dir, list):
ret = []
for item in list:
if src_dir == '.':
ret.append('-iquote%s'%(item))
ret.append('-iquote%s/%s'%(target_dir,item))
else:
ret.append('-iquote%s/%s'%(src_dir, item))
ret.append('-iquote%s/%s/%s'%(src_dir, target_dir,item))
return ret

def collect_cflags(src_dir, compiler_flags, dependencies):
def collect_cflags(src_dir, target_dir, src_file_dir, compiler_flags, dependencies):
tmp = []
tmp.extend(compiler_flags['cflags'])
tmp.extend(format_iquote(src_dir, compiler_flags['iquote']))
iquote = [src_file_dir]
iquote.extend(compiler_flags['iquote'])
tmp.extend(format_iquote(src_dir, target_dir, iquote))
for item in dependencies:
if item['origin'] == 'pkg-config':
tmp.extend(pkg_config.get_cflags(item['ref']))
Expand Down Expand Up @@ -56,7 +60,7 @@ def compile(build_args):
args = []
compiler_cfg = build_args['compiler_cfg']
args.append(compiler_cfg['backend'])
args.extend(collect_cflags(build_args['build_info']['source_dir'], compiler_cfg, build_args['dependencies']))
args.extend(collect_cflags(build_args['build_info']['source_dir'], build_args['build_info']['target_dir'], os.path.dirname(build_args['source_file']), compiler_cfg, build_args['dependencies']))
if 'std_revision' in compiler_cfg:
if 'selected' in compiler_cfg['std_revision']:
args.append('-std=%s'%compiler_cfg['std_revision']['selected'])
Expand Down
13 changes: 13 additions & 0 deletions test_files/gen_foo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3

#@ {"targets":[{"name":"foo.gen.hpp"}, {"name":"bar.gen.hpp"}]}

import sys
import json

if __name__ == '__main__':
if sys.argv[1] == 'compile':
args = json.loads(sys.argv[2])
for target in args['targets']:
with open(target, 'wb') as f:
pass
4 changes: 4 additions & 0 deletions test_files/include_gen_files.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//@ {"target":{"name":"include_gen_files.o"}}

#include "./foo.gen.hpp"
#include "test_files/bar.gen.hpp"

0 comments on commit bfdc6f7

Please sign in to comment.