瀏覽代碼

Fix language detection (based on file extension)

Update build script to build our deps

Run the bootstrap builds in their respective directory
default_compile_flags
vector-of-bool 5 年之前
父節點
當前提交
63b206fd7b
共有 4 個文件被更改,包括 40 次插入20 次删除
  1. +12
    -1
      src/dds/toolchain/toolchain.cpp
  2. +1
    -1
      tools/bootstrap.py
  3. +19
    -14
      tools/build.py
  4. +8
    -4
      tools/self_build.py

+ 12
- 1
src/dds/toolchain/toolchain.cpp 查看文件

vector<string> toolchain::create_compile_command(const compile_file_spec& spec) const noexcept { vector<string> toolchain::create_compile_command(const compile_file_spec& spec) const noexcept {
vector<string> flags; 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) { for (auto&& inc_dir : spec.include_dirs) {
auto inc_args = include_args(inc_dir); auto inc_args = include_args(inc_dir);
extend(flags, inc_args); extend(flags, inc_args);
} }


vector<string> command; vector<string> command;
for (auto arg : _cxx_compile) {
for (auto arg : cmd_template) {
if (arg == "<FLAGS>") { if (arg == "<FLAGS>") {
extend(command, flags); extend(command, flags);
} else { } else {

+ 1
- 1
tools/bootstrap.py 查看文件

f'--cxx={args.cxx}', f'--cxx={args.cxx}',
], ],
env=env, env=env,
cwd=bts_dir,
) )




exe = _run_boot_phase(phase, args) exe = _run_boot_phase(phase, args)


print(f'A bootstrapped DDS executable has been generated: {exe}') print(f'A bootstrapped DDS executable has been generated: {exe}')

return 0 return 0





+ 19
- 14
tools/build.py 查看文件

import shutil import shutil
import tempfile 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() ROOT = Path(__file__).parent.parent.absolute()
BUILD_DIR = ROOT / '_build' BUILD_DIR = ROOT / '_build'


comp_id = 'MSVC' comp_id = 'MSVC'
flags += '/experimental:preprocessor ' flags += '/experimental:preprocessor '
link_flags += 'rpcrt4.lib ' link_flags += 'rpcrt4.lib '
else:
flags += '-fconcepts'
flags += ' -DSPDLOG_COMPILED_LIB'
content = f''' content = f'''
Compiler-ID: {comp_id} Compiler-ID: {comp_id}
C++-Compiler: {cxx} C++-Compiler: {cxx}
C++-Version: C++17 C++-Version: C++17
Debug: True Debug: True
Flags: {flags} Flags: {flags}
Link-Flags: {link_flags}'''
Link-Flags: {link_flags}
'''
print('Using generated toolchain file: ' + content) print('Using generated toolchain file: ' + content)
f.write(content.encode('utf-8')) f.write(content.encode('utf-8'))
f.close() f.close()


dds_bootstrap_env_key = 'DDS_BOOTSTRAP_PREV_EXE' dds_bootstrap_env_key = 'DDS_BOOTSTRAP_PREV_EXE'
if dds_bootstrap_env_key not in os.environ: 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(): if BUILD_DIR.exists():
shutil.rmtree(BUILD_DIR) 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: 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 return 0



+ 8
- 4
tools/self_build.py 查看文件

#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse import argparse
from pathlib import Path from pathlib import Path
from typing import List, NamedTuple
from typing import List, NamedTuple, Iterable
import shutil import shutil
import subprocess import subprocess
import sys import sys
ROOT = Path(__file__).parent.parent.absolute() 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 # Copy the exe to another location, as windows refuses to let a binary be
# replaced while it is executing # replaced while it is executing
new_exe = ROOT / '_dds.bootstrap-test.exe' new_exe = ROOT / '_dds.bootstrap-test.exe'
proc.check_run( proc.check_run(
new_exe, new_exe,
'build', 'build',
'--full',
dds_flags,
('--toolchain', toolchain), ('--toolchain', toolchain),
('-I', lmi_path) if lmi_path else (), ('-I', lmi_path) if lmi_path else (),
) )
cli.add_tc_arg(parser) cli.add_tc_arg(parser)
cli.add_dds_exe_arg(parser) cli.add_dds_exe_arg(parser)
args = parser.parse_args(argv) 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 return 0





Loading…
取消
儲存