Quellcode durchsuchen

Emit a libman index for build-deps

default_compile_flags
vector-of-bool vor 5 Jahren
Ursprung
Commit
c481b92f94
4 geänderte Dateien mit 58 neuen und 0 gelöschten Zeilen
  1. +1
    -0
      src/dds.main.cpp
  2. +47
    -0
      src/dds/build/builder.cpp
  3. +1
    -0
      src/dds/build/params.hpp
  4. +9
    -0
      tests/deps/build-deps/test_build_deps.py

+ 1
- 0
src/dds.main.cpp Datei anzeigen

@@ -611,6 +611,7 @@ struct cli_build_deps {
params.out_root = out_path.Get();
params.toolchain = tc.get_toolchain();
params.parallel_jobs = n_jobs.Get();
params.emit_lmi = lmi_path.Get();

dds::builder bd;
dds::sdist_build_params sdist_params;

+ 47
- 0
src/dds/build/builder.cpp Datei anzeigen

@@ -145,6 +145,49 @@ prepare_ureqs(const build_plan& plan, const toolchain& toolchain, path_ref out_r
return ureqs;
}

void write_lml(build_env_ref env, const library_plan& lib, path_ref lml_path) {
fs::create_directories(lml_path.parent_path());
auto out = open(lml_path, std::ios::binary | std::ios::out);
out << "Type: Library\n"
<< "Name: " << lib.name() << '\n'
<< "Include-Path: " << lib.library_().public_include_dir().generic_string() << '\n';
for (auto&& use : lib.uses()) {
out << "Uses: " << use.namespace_ << "/" << use.name << '\n';
}
for (auto&& link : lib.links()) {
out << "Links: " << link.namespace_ << "/" << link.name << '\n';
}
if (auto&& arc = lib.create_archive()) {
out << "Path: "
<< (env.output_root / arc->calc_archive_file_path(env.toolchain)).generic_string()
<< '\n';
}
}

void write_lmp(build_env_ref env, const package_plan& pkg, path_ref lmp_path) {
fs::create_directories(lmp_path.parent_path());
auto out = open(lmp_path, std::ios::binary | std::ios::out);
out << "Type: Package\n"
<< "Name: " << pkg.name() << '\n'
<< "Namespace: " << pkg.namespace_() << '\n';
for (const auto& lib : pkg.libraries()) {
auto lml_path = lmp_path.parent_path() / pkg.namespace_() / (lib.name() + ".lml");
write_lml(env, lib, lml_path);
out << "Library: " << lml_path.generic_string() << '\n';
}
}

void write_lmi(build_env_ref env, const build_plan& plan, path_ref base_dir, path_ref lmi_path) {
fs::create_directories(lmi_path.parent_path());
auto out = open(lmi_path, std::ios::binary | std::ios::out);
out << "Type: Index\n";
for (const auto& pkg : plan.packages()) {
auto lmp_path = base_dir / "_libman" / (pkg.name() + ".lmp");
write_lmp(env, pkg, lmp_path);
out << "Package: " << pkg.name() << "; " << lmp_path.generic_string() << '\n';
}
}

} // namespace

void builder::build(const build_params& params) const {
@@ -193,4 +236,8 @@ void builder::build(const build_params& params) const {
if (!test_failures.empty()) {
throw compile_failure("Test failures during the build!");
}

if (params.emit_lmi) {
write_lmi(env, plan, params.out_root, *params.emit_lmi);
}
}

+ 1
- 0
src/dds/build/params.hpp Datei anzeigen

@@ -11,6 +11,7 @@ namespace dds {
struct build_params {
fs::path out_root;
std::optional<fs::path> existing_lm_index;
std::optional<fs::path> emit_lmi;
dds::toolchain toolchain;
bool generate_compdb = true;
int parallel_jobs = 0;

+ 9
- 0
tests/deps/build-deps/test_build_deps.py Datei anzeigen

@@ -6,6 +6,9 @@ def test_build_deps_from_file(dds: DDS):
dds.catalog_import(dds.source_root / 'catalog.json')
dds.build_deps(['-d', 'deps.dds'])
assert (dds.deps_build_dir / 'neo-sqlite3@0.1.0').is_dir()
assert (dds.scratch_dir / 'INDEX.lmi').is_file()
assert (dds.deps_build_dir / '_libman/neo-sqlite3.lmp').is_file()
assert (dds.deps_build_dir / '_libman/neo/sqlite3.lml').is_file()


def test_build_deps_from_cmd(dds: DDS):
@@ -13,6 +16,9 @@ def test_build_deps_from_cmd(dds: DDS):
dds.catalog_import(dds.source_root / 'catalog.json')
dds.build_deps(['neo-sqlite3 =0.1.0'])
assert (dds.deps_build_dir / 'neo-sqlite3@0.1.0').is_dir()
assert (dds.scratch_dir / 'INDEX.lmi').is_file()
assert (dds.deps_build_dir / '_libman/neo-sqlite3.lmp').is_file()
assert (dds.deps_build_dir / '_libman/neo/sqlite3.lml').is_file()


def test_multiple_deps(dds: DDS):
@@ -20,3 +26,6 @@ def test_multiple_deps(dds: DDS):
dds.catalog_import(dds.source_root / 'catalog.json')
dds.build_deps(['neo-sqlite3 ^0.1.0', 'neo-sqlite3 ~0.2.0'])
assert (dds.deps_build_dir / 'neo-sqlite3@0.2.2').is_dir()
assert (dds.scratch_dir / 'INDEX.lmi').is_file()
assert (dds.deps_build_dir / '_libman/neo-sqlite3.lmp').is_file()
assert (dds.deps_build_dir / '_libman/neo/sqlite3.lml').is_file()

Laden…
Abbrechen
Speichern