| @@ -121,7 +121,7 @@ library_plan prepare_library(state& st, | |||
| } | |||
| } | |||
| } | |||
| return library_plan::create(lib, std::move(lp)); | |||
| return library_plan::create(lib, std::move(lp), pkg_man.namespace_ + "/" + lib.manifest().name); | |||
| } | |||
| package_plan prepare_one(state& st, const sdist_target& sd) { | |||
| @@ -40,17 +40,19 @@ void create_archive_plan::archive(const build_env& env) const { | |||
| fs::create_directories(ar.out_path.parent_path()); | |||
| // Do it! | |||
| spdlog::info("[{}] Archive: {}", _name, out_relpath); | |||
| spdlog::info("[{}] Archive: {}", _qual_name, out_relpath); | |||
| auto&& [dur_ms, ar_res] = timed<std::chrono::milliseconds>([&] { return run_proc(ar_cmd); }); | |||
| spdlog::info("[{}] Archive: {} - {:n}ms", _name, out_relpath, dur_ms.count()); | |||
| spdlog::info("[{}] Archive: {} - {:n}ms", _qual_name, out_relpath, dur_ms.count()); | |||
| // Check, log, and throw | |||
| if (!ar_res.okay()) { | |||
| spdlog::error("Creating static library archive [{}] failed for '{}'", out_relpath, _name); | |||
| spdlog::error("Creating static library archive [{}] failed for '{}'", | |||
| out_relpath, | |||
| _qual_name); | |||
| spdlog::error("Subcommand FAILED: {}\n{}", quote_command(ar_cmd), ar_res.output); | |||
| throw_external_error< | |||
| errc::archive_failure>("Creating static library archive [{}] failed for '{}'", | |||
| out_relpath, | |||
| _name); | |||
| _qual_name); | |||
| } | |||
| } | |||
| @@ -18,6 +18,8 @@ namespace dds { | |||
| class create_archive_plan { | |||
| /// The name of the archive. Not the filename, but the base name thereof | |||
| std::string _name; | |||
| /// The qualified name of the library, as it would appear in a libman-usage | |||
| std::string _qual_name; | |||
| /// The subdirectory in which the archive should be generated. | |||
| fs::path _subdir; | |||
| /// The plans for compiling the constituent source files of this library | |||
| @@ -32,8 +34,12 @@ public: | |||
| * @param cfs The file compilation plans that will be collected together to | |||
| * form the static library. | |||
| */ | |||
| create_archive_plan(std::string_view name, path_ref subdir, std::vector<compile_file_plan> cfs) | |||
| create_archive_plan(std::string_view name, | |||
| std::string_view full_name, | |||
| path_ref subdir, | |||
| std::vector<compile_file_plan> cfs) | |||
| : _name(name) | |||
| , _qual_name(full_name) | |||
| , _subdir(subdir) | |||
| , _compile_files(std::move(cfs)) {} | |||
| @@ -46,7 +46,7 @@ void link_executable_plan::link(build_env_ref env, const library_plan& lib) cons | |||
| const auto link_command = env.toolchain.create_link_executable_command(spec); | |||
| fs::create_directories(spec.output.parent_path()); | |||
| auto msg = fmt::format("[{}] Link: {:30}", | |||
| lib.name(), | |||
| lib.qualified_name(), | |||
| fs::relative(spec.output, env.output_root).string()); | |||
| spdlog::info(msg); | |||
| auto [dur_ms, proc_res] | |||
| @@ -10,14 +10,18 @@ | |||
| using namespace dds; | |||
| library_plan library_plan::create(const library& lib, const library_build_params& params) { | |||
| library_plan library_plan::create(const library& lib, | |||
| const library_build_params& params, | |||
| std::optional<std::string_view> full_name) { | |||
| // Source files are kept in three groups: | |||
| std::vector<source_file> app_sources; | |||
| std::vector<source_file> test_sources; | |||
| std::vector<source_file> lib_sources; | |||
| // Collect the source for this library. This will look for any compilable sources in the `src/` | |||
| // subdirectory of the library. | |||
| auto qual_name = std::string(full_name.value_or(lib.manifest().name)); | |||
| // Collect the source for this library. This will look for any compilable sources in the | |||
| // `src/` subdirectory of the library. | |||
| auto src_dir = lib.src_dir(); | |||
| if (src_dir.exists()) { | |||
| // Sort each source file between the three source arrays, depending on | |||
| @@ -45,10 +49,7 @@ library_plan library_plan::create(const library& lib, const library_build_params | |||
| auto lib_compile_files = // | |||
| lib_sources // | |||
| | ranges::views::transform([&](const source_file& sf) { | |||
| return compile_file_plan(compile_rules, | |||
| sf, | |||
| lib.manifest().name, | |||
| params.out_subdir / "obj"); | |||
| return compile_file_plan(compile_rules, sf, qual_name, params.out_subdir / "obj"); | |||
| }) | |||
| | ranges::to_vector; | |||
| @@ -57,6 +58,7 @@ library_plan library_plan::create(const library& lib, const library_build_params | |||
| std::optional<create_archive_plan> create_archive; | |||
| if (!lib_compile_files.empty()) { | |||
| create_archive.emplace(lib.manifest().name, | |||
| qual_name, | |||
| params.out_subdir, | |||
| std::move(lib_compile_files)); | |||
| } | |||
| @@ -96,7 +98,7 @@ library_plan library_plan::create(const library& lib, const library_build_params | |||
| exe_links, | |||
| compile_file_plan(rules, | |||
| source, | |||
| lib.manifest().name, | |||
| qual_name, | |||
| params.out_subdir / "obj"), | |||
| subdir, | |||
| source.path.stem().stem().string()}; | |||
| @@ -104,5 +106,5 @@ library_plan library_plan::create(const library& lib, const library_build_params | |||
| } | |||
| // Done! | |||
| return library_plan{lib, std::move(create_archive), std::move(link_executables)}; | |||
| return library_plan{lib, qual_name, std::move(create_archive), std::move(link_executables)}; | |||
| } | |||
| @@ -54,6 +54,8 @@ struct library_build_params { | |||
| class library_plan { | |||
| /// The underlying library object | |||
| library _lib; | |||
| /// The qualified name of the library | |||
| std::string _qual_name; | |||
| /// The `create_archive_plan` for this library, if applicable | |||
| std::optional<create_archive_plan> _create_archive; | |||
| /// The executables that should be linked as part of this library's build | |||
| @@ -67,9 +69,11 @@ public: | |||
| * @param exes The `link_executable_plan` objects for this library. | |||
| */ | |||
| library_plan(library lib, | |||
| std::string_view full_name, | |||
| std::optional<create_archive_plan> ar, | |||
| std::vector<link_executable_plan> exes) | |||
| : _lib(std::move(lib)) | |||
| , _qual_name(full_name) | |||
| , _create_archive(std::move(ar)) | |||
| , _link_exes(std::move(exes)) {} | |||
| @@ -81,6 +85,10 @@ public: | |||
| * Get the name of the library | |||
| */ | |||
| auto& name() const noexcept { return _lib.manifest().name; } | |||
| /** | |||
| * Get the qualified name of the library, as if for a libman usage requirement | |||
| */ | |||
| auto& qualified_name() const noexcept { return _qual_name; } | |||
| /** | |||
| * The directory that defines the source root of the library. | |||
| */ | |||
| @@ -109,11 +117,15 @@ public: | |||
| * @param lib The `library` object from which we will inherit several properties. | |||
| * @param params Parameters controlling the build of the library. i.e. if we create tests, | |||
| * enable warnings, etc. | |||
| * @param full_name Optionally, provide the fully-qualified name of the library that is being | |||
| * built | |||
| * | |||
| * The `lib` parameter defines the usage requirements of this library, and they are looked up in | |||
| * the `ureqs` map. If there are any missing requirements, an exception will be thrown. | |||
| */ | |||
| static library_plan create(const library& lib, const library_build_params& params); | |||
| static library_plan create(const library& lib, | |||
| const library_build_params& params, | |||
| std::optional<std::string_view> full_name); | |||
| }; | |||
| } // namespace dds | |||