Skip to content

Commit 65c91a0

Browse files
author
Vano
committed
Scons global paths fix
1 parent ebe6553 commit 65c91a0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

cppscript.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ class CppScriptBuilder():
1515
def __init__(self, *args, **kwargs):
1616
self.builder = Builder(action=generate_header_scons, emitter=generate_header_emitter, *args, **kwargs)
1717

18-
def __call__(self, scons_env, source, call_args, *args, **kwargs):
18+
def __call__(self, scons_env, source, call_args, cwd = os.getcwd(), *args, **kwargs):
1919
env, *other = call_args
2020
cppscript_src = os.path.join(os.path.dirname(__file__), 'src')
2121
# Convert scons variables to cppscript's env
2222
scons_env['cppscript_env'] = {
2323
'header_name' : env['header_name'],
24-
'header_dir' : env['header_dir'],
25-
'gen_dir' : env['gen_dir'],
24+
'header_dir' : resolve_path(str(env['header_dir']), cwd),
25+
'gen_dir' : resolve_path(str(env['gen_dir']), cwd),
2626
'compile_defs' : {f'{i[0]}={i[1]}' if type(i) is tuple else str(i) for i in env.get('compile_defs', [])},
27-
'include_paths' : {cppscript_src, env['header_dir']}.union({str(path) for path in env.get('include_paths', [])}),
27+
'include_paths' : {resolve_path(i, cwd) for i in {cppscript_src, str(env['header_dir'])}.union({str(path) for path in env.get('include_paths', [])})},
2828
'auto_methods' : env['auto_methods']
2929
}
3030

3131
# Append needed directories
32-
scons_env.Append(CPPPATH=[cppscript_src, env['header_dir']])
32+
scons_env.Append(CPPPATH=[cppscript_src, resolve_path(env['header_dir'], cwd)])
3333
return self.builder(scons_env, source=source, *other, *args, **kwargs)
3434

3535

@@ -70,6 +70,11 @@ def GlobRecursive(path, pattern, **kwargs):
7070
class CppScriptException(Exception):
7171
pass
7272

73+
74+
def resolve_path(path, cwd):
75+
return path if os.path.isabs(path) else os.path.abspath(os.path.join(cwd, path))
76+
77+
7378
def filename_to_gen_filename(name, env):
7479
return os.path.join(env['gen_dir'], os.path.relpath(name.replace('.hpp', '.gen.cpp'), env['header_dir']))
7580

0 commit comments

Comments
 (0)