Update build script to build our deps Run the bootstrap builds in their respective directorydefault_compile_flags
@@ -102,6 +102,17 @@ vector<string> toolchain::definition_args(std::string_view s) const noexcept { | |||
vector<string> toolchain::create_compile_command(const compile_file_spec& spec) const noexcept { | |||
vector<string> flags; | |||
language lang = spec.lang; | |||
if (lang == language::automatic) { | |||
if (spec.source_path.extension() == ".c" || spec.source_path.extension() == ".C") { | |||
lang = language::c; | |||
} else { | |||
lang = language::cxx; | |||
} | |||
} | |||
auto& cmd_template = lang == language::c ? _c_compile : _cxx_compile; | |||
for (auto&& inc_dir : spec.include_dirs) { | |||
auto inc_args = include_args(inc_dir); | |||
extend(flags, inc_args); | |||
@@ -117,7 +128,7 @@ vector<string> toolchain::create_compile_command(const compile_file_spec& spec) | |||
} | |||
vector<string> command; | |||
for (auto arg : _cxx_compile) { | |||
for (auto arg : cmd_template) { | |||
if (arg == "<FLAGS>") { | |||
extend(command, flags); | |||
} else { |
@@ -60,6 +60,7 @@ def _build_bootstrap_phase(ph: str, bts_dir: Path, | |||
f'--cxx={args.cxx}', | |||
], | |||
env=env, | |||
cwd=bts_dir, | |||
) | |||
@@ -92,7 +93,6 @@ def main(argv: Sequence[str]) -> int: | |||
exe = _run_boot_phase(phase, args) | |||
print(f'A bootstrapped DDS executable has been generated: {exe}') | |||
return 0 | |||
@@ -10,6 +10,11 @@ import sys | |||
import shutil | |||
import tempfile | |||
from dds_ci import paths | |||
from self_build import self_build | |||
from self_deps_get import self_deps_get | |||
from self_deps_build import self_deps_build | |||
ROOT = Path(__file__).parent.parent.absolute() | |||
BUILD_DIR = ROOT / '_build' | |||
@@ -25,13 +30,17 @@ def _generate_toolchain(cxx: str): | |||
comp_id = 'MSVC' | |||
flags += '/experimental:preprocessor ' | |||
link_flags += 'rpcrt4.lib ' | |||
else: | |||
flags += '-fconcepts' | |||
flags += ' -DSPDLOG_COMPILED_LIB' | |||
content = f''' | |||
Compiler-ID: {comp_id} | |||
C++-Compiler: {cxx} | |||
C++-Version: C++17 | |||
Debug: True | |||
Flags: {flags} | |||
Link-Flags: {link_flags}''' | |||
Link-Flags: {link_flags} | |||
''' | |||
print('Using generated toolchain file: ' + content) | |||
f.write(content.encode('utf-8')) | |||
f.close() | |||
@@ -47,25 +56,21 @@ def main(argv: Sequence[str]) -> int: | |||
dds_bootstrap_env_key = 'DDS_BOOTSTRAP_PREV_EXE' | |||
if dds_bootstrap_env_key not in os.environ: | |||
raise RuntimeError( | |||
'A previous-phase bootstrapped executable must be available via $DDS_BOOTSTRAP_PREV_EXE' | |||
) | |||
dds_exe = os.environ[dds_bootstrap_env_key] | |||
raise RuntimeError('A previous-phase bootstrapped executable ' | |||
'must be available via $DDS_BOOTSTRAP_PREV_EXE') | |||
print(f'Using previously built DDS executable: {dds_exe}') | |||
dds_exe = Path(os.environ[dds_bootstrap_env_key]) | |||
if BUILD_DIR.exists(): | |||
shutil.rmtree(BUILD_DIR) | |||
print(f'Using previously built DDS executable: {dds_exe}') | |||
self_deps_get(dds_exe, paths.SELF_TEST_REPO_DIR) | |||
with _generate_toolchain(args.cxx) as tc_fpath: | |||
subprocess.check_call([ | |||
dds_exe, | |||
'build', | |||
'-A', | |||
f'-T{tc_fpath}', | |||
f'-p{ROOT}', | |||
f'--out={BUILD_DIR}', | |||
]) | |||
self_deps_build(dds_exe, tc_fpath, paths.SELF_TEST_REPO_DIR, | |||
ROOT / 'remote.dds') | |||
self_build(dds_exe, toolchain=tc_fpath, dds_flags=['--apps']) | |||
return 0 | |||
@@ -1,7 +1,7 @@ | |||
#!/usr/bin/env python3 | |||
import argparse | |||
from pathlib import Path | |||
from typing import List, NamedTuple | |||
from typing import List, NamedTuple, Iterable | |||
import shutil | |||
import subprocess | |||
import sys | |||
@@ -11,7 +11,11 @@ from dds_ci import cli, proc | |||
ROOT = Path(__file__).parent.parent.absolute() | |||
def self_build(exe: Path, *, toolchain: str, lmi_path: Path = None): | |||
def self_build(exe: Path, | |||
*, | |||
toolchain: str, | |||
lmi_path: Path = None, | |||
dds_flags: Iterable[str] = ()): | |||
# Copy the exe to another location, as windows refuses to let a binary be | |||
# replaced while it is executing | |||
new_exe = ROOT / '_dds.bootstrap-test.exe' | |||
@@ -20,7 +24,7 @@ def self_build(exe: Path, *, toolchain: str, lmi_path: Path = None): | |||
proc.check_run( | |||
new_exe, | |||
'build', | |||
'--full', | |||
dds_flags, | |||
('--toolchain', toolchain), | |||
('-I', lmi_path) if lmi_path else (), | |||
) | |||
@@ -33,7 +37,7 @@ def main(argv: List[str]) -> int: | |||
cli.add_tc_arg(parser) | |||
cli.add_dds_exe_arg(parser) | |||
args = parser.parse_args(argv) | |||
self_build(Path(args.exe), args.toolchain) | |||
self_build(Path(args.exe), toolchain=args.toolchain, dds_flags=['--full']) | |||
return 0 | |||