|
|
|
|
|
|
|
|
str)); |
|
|
str)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
|
|
fs::path generate_lml(const library_plan& lib, path_ref libdir, const build_env& env) { |
|
|
|
|
|
auto fname = lib.name() + ".lml"; |
|
|
|
|
|
auto lml_path = libdir / fname; |
|
|
|
|
|
|
|
|
|
|
|
std::vector<lm::pair> kvs; |
|
|
|
|
|
kvs.emplace_back("Type", "Library"); |
|
|
|
|
|
kvs.emplace_back("Name", lib.name()); |
|
|
|
|
|
if (lib.create_archive()) { |
|
|
|
|
|
kvs.emplace_back("Path", |
|
|
|
|
|
fs::relative(lib.create_archive()->calc_archive_file_path(env), |
|
|
|
|
|
lml_path.parent_path()) |
|
|
|
|
|
.string()); |
|
|
|
|
|
} |
|
|
|
|
|
auto pub_inc_dir = lib.source_root() / "include"; |
|
|
|
|
|
auto src_dir = lib.source_root() / "src"; |
|
|
|
|
|
if (!fs::exists(pub_inc_dir)) { |
|
|
|
|
|
pub_inc_dir = src_dir; |
|
|
|
|
|
} |
|
|
|
|
|
kvs.emplace_back("Include-Path", pub_inc_dir.string()); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Uses, Preprocessor-Define, and Special-Uses |
|
|
|
|
|
|
|
|
|
|
|
fs::create_directories(lml_path.parent_path()); |
|
|
|
|
|
lm::write_pairs(lml_path, kvs); |
|
|
|
|
|
return lml_path; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fs::path generate_lmp(const package_plan& pkg, path_ref basedir, const build_env& env) { |
|
|
|
|
|
auto fname = pkg.name() + ".lmp"; |
|
|
|
|
|
auto lmp_path = basedir / fname; |
|
|
|
|
|
|
|
|
|
|
|
std::vector<lm::pair> kvs; |
|
|
|
|
|
kvs.emplace_back("Type", "Package"); |
|
|
|
|
|
kvs.emplace_back("Name", pkg.name()); |
|
|
|
|
|
kvs.emplace_back("Namespace", pkg.namespace_()); |
|
|
|
|
|
|
|
|
|
|
|
for (auto&& lib : pkg.libraries()) { |
|
|
|
|
|
auto lml = generate_lml(lib, basedir / pkg.name(), env); |
|
|
|
|
|
kvs.emplace_back("Library", fs::relative(lml, lmp_path.parent_path()).string()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: `Requires` for transitive package imports |
|
|
|
|
|
|
|
|
|
|
|
fs::create_directories(lmp_path.parent_path()); |
|
|
|
|
|
lm::write_pairs(lmp_path, kvs); |
|
|
|
|
|
return lmp_path; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} // namespace |
|
|
|
|
|
|
|
|
|
|
|
void dds::write_libman_index(path_ref out_filepath, const build_plan& plan, const build_env& env) { |
|
|
|
|
|
fs::create_directories(out_filepath.parent_path()); |
|
|
|
|
|
auto lm_items_dir = out_filepath.parent_path() / "_libman"; |
|
|
|
|
|
std::vector<lm::pair> kvs; |
|
|
|
|
|
kvs.emplace_back("Type", "Index"); |
|
|
|
|
|
for (const package_plan& pkg : plan.packages()) { |
|
|
|
|
|
auto pkg_lmp = generate_lmp(pkg, lm_items_dir, env); |
|
|
|
|
|
kvs.emplace_back("Package", |
|
|
|
|
|
fmt::format("{}; {}", |
|
|
|
|
|
pkg.name(), |
|
|
|
|
|
fs::relative(pkg_lmp, out_filepath.parent_path()).string())); |
|
|
|
|
|
} |
|
|
|
|
|
lm::write_pairs(out_filepath, kvs); |
|
|
|
|
|
} |
|
|
|