|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fs::path compile_file(fs::path src_path, |
|
|
|
|
|
const build_params& params, |
|
|
|
|
|
const toolchain& tc, |
|
|
|
|
|
const library_manifest& man) { |
|
|
|
|
|
|
|
|
fs::path compile_file(fs::path src_path, const build_params& params, const library_manifest& man) { |
|
|
auto obj_dir = params.out_root / "obj"; |
|
|
auto obj_dir = params.out_root / "obj"; |
|
|
auto obj_relpath = fs::relative(src_path, params.root); |
|
|
auto obj_relpath = fs::relative(src_path, params.root); |
|
|
obj_relpath.replace_filename(obj_relpath.filename().string() + ".o"); |
|
|
|
|
|
|
|
|
obj_relpath.replace_filename(obj_relpath.filename().string() |
|
|
|
|
|
+ params.toolchain.object_suffix()); |
|
|
auto obj_path = obj_dir / obj_relpath; |
|
|
auto obj_path = obj_dir / obj_relpath; |
|
|
fs::create_directories(obj_path.parent_path()); |
|
|
fs::create_directories(obj_path.parent_path()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spec.definitions.push_back(def); |
|
|
spec.definitions.push_back(def); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
auto cmd = tc.create_compile_command(spec); |
|
|
|
|
|
|
|
|
auto cmd = params.toolchain.create_compile_command(spec); |
|
|
auto compile_res = run_proc(cmd); |
|
|
auto compile_res = run_proc(cmd); |
|
|
if (!compile_res.okay()) { |
|
|
if (!compile_res.okay()) { |
|
|
spdlog::error("Compilation failed: {}", spec.source_path.string()); |
|
|
spdlog::error("Compilation failed: {}", spec.source_path.string()); |
|
|
|
|
|
|
|
|
lm_write_pairs(export_root / "lib.lml", lm_pairs); |
|
|
lm_write_pairs(export_root / "lib.lml", lm_pairs); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::vector<fs::path> compile_sources(source_list sources, |
|
|
|
|
|
const build_params& params, |
|
|
|
|
|
const toolchain& tc, |
|
|
|
|
|
const library_manifest& man) { |
|
|
|
|
|
|
|
|
std::vector<fs::path> |
|
|
|
|
|
compile_sources(source_list sources, const build_params& params, const library_manifest& man) { |
|
|
// We don't bother with a nice thread pool, as the overhead of compiling |
|
|
// We don't bother with a nice thread pool, as the overhead of compiling |
|
|
// source files dwarfs the cost of interlocking. |
|
|
// source files dwarfs the cost of interlocking. |
|
|
std::mutex mut; |
|
|
std::mutex mut; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
lk.unlock(); |
|
|
lk.unlock(); |
|
|
try { |
|
|
try { |
|
|
auto obj_path = compile_file(source.path, params, tc, man); |
|
|
|
|
|
|
|
|
auto obj_path = compile_file(source.path, params, man); |
|
|
lk.lock(); |
|
|
lk.lock(); |
|
|
objects.emplace_back(std::move(obj_path)); |
|
|
objects.emplace_back(std::move(obj_path)); |
|
|
} catch (...) { |
|
|
} catch (...) { |
|
|
|
|
|
|
|
|
} // namespace |
|
|
} // namespace |
|
|
|
|
|
|
|
|
void dds::build(const build_params& params, const library_manifest& man) { |
|
|
void dds::build(const build_params& params, const library_manifest& man) { |
|
|
auto tc = toolchain::load_from_file(params.toolchain_file); |
|
|
|
|
|
|
|
|
|
|
|
auto include_dir = params.root / "include"; |
|
|
auto include_dir = params.root / "include"; |
|
|
auto src_dir = params.root / "src"; |
|
|
auto src_dir = params.root / "src"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
archive_spec arc; |
|
|
archive_spec arc; |
|
|
arc.input_files = compile_sources(sources, params, tc, man); |
|
|
|
|
|
|
|
|
arc.input_files = compile_sources(sources, params, man); |
|
|
|
|
|
|
|
|
arc.out_path = params.out_root / ("lib" + params.export_name + tc.archive_suffix()); |
|
|
|
|
|
|
|
|
arc.out_path |
|
|
|
|
|
= params.out_root / ("lib" + params.export_name + params.toolchain.archive_suffix()); |
|
|
|
|
|
|
|
|
spdlog::info("Create archive {}", arc.out_path.string()); |
|
|
spdlog::info("Create archive {}", arc.out_path.string()); |
|
|
auto ar_cmd = tc.create_archive_command(arc); |
|
|
|
|
|
|
|
|
auto ar_cmd = params.toolchain.create_archive_command(arc); |
|
|
if (fs::exists(arc.out_path)) { |
|
|
if (fs::exists(arc.out_path)) { |
|
|
fs::remove(arc.out_path); |
|
|
fs::remove(arc.out_path); |
|
|
} |
|
|
} |