def Pch(pch, *, flags=(), order_only_inputs=(), implicit_outputs=(), **kwargs): #pylint:disable=invalid-name,missing-docstring pch = pch.env.base_dir / pch.outputs[0] if hasattr(pch, 'outputs') else Path(pch) cxx = Target((E.source_path / pch,), ((E.build_path / pch).with_suffix('.cxx'),), 'make_pch_cxx') compiled_pch = (E.build_path / pch).with_suffix('.pch') flags = chain(flags, (Variable('PCH', E.source_path / pch), Variable('PCH_SOURCE', cxx), Variable('COMPILED_PCH', compiled_pch), Variable('PDB', pdb(E)))) # return Target((), (cxx.outputs[0].with_suffix('.obj'),), 'pch', flags=flags, order_only_inputs=chain(order_only_inputs, (cxx,)), implicit_outputs=chain(implicit_outputs, (compiled_pch,)), **kwargs) return Target((), (cxx.outputs[0].with_suffix('.obj'),), 'pch', flags=flags, order_only_inputs=chain(order_only_inputs, (cxx,)), implicit_outputs=implicit_outputs, **kwargs)
def Cxx(cxx, pch=None, *, implicit_inputs=(), flags=(), output_flags=(), quick_build_alias='{source}:{flavour}', **kwargs): #pylint:disable=invalid-name,missing-docstring if pch: pch_cxx, pch_obj = pch.order_only_inputs[0], pch.outputs[0] flags = chain(flags, (CxxFlag('/Yu', pch_cxx), CxxFlag('/FI', pch_cxx))) output_flags = chain(output_flags, (Variable('PCH_OBJ', pch_obj),)) implicit_inputs = chain(implicit_inputs, (pch_cxx, pch_obj)) flags = chain(flags, (Variable('PDB', pdb(E)),)) cxx = cxx.outputs[0] if hasattr(cxx, 'outputs') else E.source_path / cxx result = Target((cxx,), ((E.build_path / cxx).with_suffix('.obj'),), 'cxx', implicit_inputs=implicit_inputs, flags=flags, output_flags=output_flags, **kwargs) if quick_build_alias is not None: Alias(quick_build_alias.format(source=E.get_source_path() / cxx, flavour='{flavour}'), (result,)) return result
def Cxx(cxx, *, pch=None, implicit_inputs=(), flags=(), quick_build_alias='{source}:{flavour}', **kwargs): #pylint: disable=invalid-name,missing-docstring if pch: flags = chain(flags, (CxxFlag('-include ', pch.inputs[0]), )) implicit_inputs = chain(implicit_inputs, pch.outputs) cxx = cxx.outputs[0] if hasattr(cxx, 'outputs') else E.source_path / cxx result = Target((cxx, ), ((E.build_path / cxx).with_suffix('.o'), ), 'cxx', implicit_inputs=implicit_inputs, flags=flags, **kwargs) if quick_build_alias is not None: Alias( quick_build_alias.format(source=E.source_path / cxx, flavour='{flavour}'), (result, )) return result
def apply_to_env(cls): #pylint: disable=missing-docstring from genjutsu import Alias, E, Inject, Target, Variable, resolve_escape_join Inject( lambda env, flavour: f'include {resolve_escape_join(_RESOURCE_DIR / "msbuild.ninja_inc", env=env, flavour=flavour)}', key=(cls, 0)) if E.ninja_file: Inject( lambda env, flavour: f'build {resolve_escape_join(env.build_path / "msbuild_cookie", env=env, flavour=flavour)} : msbuild_cookie {" ".join(set(resolve_escape_join(default, env=env, flavour=flavour) for default in env.all_defaults) or (flavour.name,))}', key=(cls, 1)) Inject( lambda env, flavour: f'build {flavour.name}_msbuild_cookie : phony {resolve_escape_join(env.build_path / "msbuild_cookie", env=env, flavour=flavour)}', key=(cls, 2)) Alias('msbuild', [ Target(inputs=(E.prj_file, ), implicit_inputs=(E.ninja_file, ), outputs=vcxproj_files(E.ninja_file.parent), rule='msbuild_vcxproj', flags=(Variable(var, (environ.get(var, ''), )) for var in ('GENJUTSU_RESOURCE_PATH', 'GENJUTSU_TOOLSETS'))) ])
def LinkerTarget(*args, libs=(), implicit_inputs=(), flags=(), **kwargs): #pylint: disable=invalid-name,missing-docstring flags = chain(flags, *((LibDir(lib.outputs[0].parent), Lib(lib.outputs[0].stem[3:])) for lib in libs)) return Target(*args, implicit_inputs=chain(libs, implicit_inputs), flags=flags, **kwargs)
def Pch(pch, **kwargs): #pylint: disable=invalid-name,missing-docstring return Target((E.source_path / pch, ), ((E.build_path / pch).with_suffix('.pch'), ), 'pch', **kwargs)
def add_rules(globals_): globals_['Copy'] = lambda from_, to=None, **kwargs: Target( (E.source_path / from_, ), (E.build_path / (to or from_), ), 'copy', **kwargs)