| using namespace dds; | using namespace dds; | ||||
| library_plan library_plan::create(const library& root, const sroot_build_params& params) { | |||||
| library_plan library_plan::create(const library& lib, const library_build_params& params) { | |||||
| std::vector<compile_file_plan> compile_files; | std::vector<compile_file_plan> compile_files; | ||||
| std::vector<create_archive_plan> create_archives; | std::vector<create_archive_plan> create_archives; | ||||
| std::vector<create_exe_plan> link_executables; | std::vector<create_exe_plan> link_executables; | ||||
| std::vector<source_file> test_sources; | std::vector<source_file> test_sources; | ||||
| std::vector<source_file> lib_sources; | std::vector<source_file> lib_sources; | ||||
| auto src_dir = root.src_dir(); | |||||
| auto src_dir = lib.src_dir(); | |||||
| if (src_dir.exists()) { | if (src_dir.exists()) { | ||||
| auto all_sources = src_dir.sources(); | auto all_sources = src_dir.sources(); | ||||
| auto to_compile = all_sources | ranges::views::filter([&](const source_file& sf) { | auto to_compile = all_sources | ranges::views::filter([&](const source_file& sf) { | ||||
| for (const auto& sfile : to_compile) { | for (const auto& sfile : to_compile) { | ||||
| compile_file_plan cf_plan; | compile_file_plan cf_plan; | ||||
| cf_plan.source = sfile; | cf_plan.source = sfile; | ||||
| cf_plan.qualifier = params.main_name; | |||||
| cf_plan.qualifier = lib.name(); | |||||
| cf_plan.rules = params.compile_rules; | cf_plan.rules = params.compile_rules; | ||||
| compile_files.push_back(std::move(cf_plan)); | compile_files.push_back(std::move(cf_plan)); | ||||
| if (sfile.kind == source_kind::test) { | if (sfile.kind == source_kind::test) { | ||||
| ar_plan.in_sources = lib_sources // | ar_plan.in_sources = lib_sources // | ||||
| | ranges::views::transform([](auto&& sf) { return sf.path; }) // | | ranges::views::transform([](auto&& sf) { return sf.path; }) // | ||||
| | ranges::to_vector; | | ranges::to_vector; | ||||
| ar_plan.name = params.main_name; | |||||
| ar_plan.name = lib.name(); | |||||
| ar_plan.out_dir = params.out_subdir; | ar_plan.out_dir = params.out_subdir; | ||||
| create_archives.push_back(std::move(ar_plan)); | create_archives.push_back(std::move(ar_plan)); | ||||
| } | } |
| #include <dds/build/compile.hpp> | #include <dds/build/compile.hpp> | ||||
| #include <dds/build/params.hpp> | #include <dds/build/params.hpp> | ||||
| #include <dds/build/sroot.hpp> | |||||
| #include <dds/library.hpp> | #include <dds/library.hpp> | ||||
| #include <dds/toolchain.hpp> | #include <dds/toolchain.hpp> | ||||
| std::vector<create_exe_plan> link_executables; | std::vector<create_exe_plan> link_executables; | ||||
| fs::path out_subdir; | fs::path out_subdir; | ||||
| static library_plan create(const library& lib, const sroot_build_params& params); | |||||
| static library_plan create(const library& lib, const library_build_params& params); | |||||
| }; | }; | ||||
| struct build_plan { | struct build_plan { | ||||
| std::vector<library_plan> create_libraries; | std::vector<library_plan> create_libraries; | ||||
| // static build_plan generate(const build_params& params); | // static build_plan generate(const build_params& params); | ||||
| void add_library(const library& lib, const sroot_build_params& params) { | |||||
| void add_library(const library& lib, const library_build_params& params) { | |||||
| create_libraries.push_back(library_plan::create(lib, params)); | create_libraries.push_back(library_plan::create(lib, params)); | ||||
| } | } | ||||
| #include "./sroot.hpp" | |||||
| using namespace dds; |
| #pragma once | |||||
| #include <dds/build/compile.hpp> | |||||
| #include <dds/build/source_dir.hpp> | |||||
| #include <dds/util/fs.hpp> | |||||
| #include <vector> | |||||
| namespace dds { | |||||
| struct sroot_build_params { | |||||
| std::string main_name; | |||||
| fs::path out_subdir; | |||||
| bool build_tests = false; | |||||
| bool build_apps = false; | |||||
| std::vector<fs::path> rt_link_libraries; | |||||
| shared_compile_file_rules compile_rules; | |||||
| }; | |||||
| } // namespace dds |
| #include "./deps.hpp" | #include "./deps.hpp" | ||||
| #include <dds/build/sroot.hpp> | |||||
| #include <dds/repo/repo.hpp> | #include <dds/repo/repo.hpp> | ||||
| #include <dds/sdist.hpp> | #include <dds/sdist.hpp> | ||||
| #include <dds/util/string.hpp> | #include <dds/util/string.hpp> | ||||
| auto lib = dds::library::from_directory(sd.path); | auto lib = dds::library::from_directory(sd.path); | ||||
| shared_compile_file_rules comp_rules = lib.base_compile_rules(); | shared_compile_file_rules comp_rules = lib.base_compile_rules(); | ||||
| add_dep_includes(comp_rules, sd.manifest, sd_idx); | add_dep_includes(comp_rules, sd.manifest, sd_idx); | ||||
| sroot_build_params params; | |||||
| params.main_name = sd.manifest.name; | |||||
| library_build_params params; | |||||
| params.compile_rules = comp_rules; | params.compile_rules = comp_rules; | ||||
| plan.add_library(lib, params); | plan.add_library(lib, params); | ||||
| } | } |
| #pragma once | #pragma once | ||||
| #include <dds/library_manifest.hpp> | |||||
| #include <dds/build/source_dir.hpp> | |||||
| #include <dds/build/compile.hpp> | #include <dds/build/compile.hpp> | ||||
| #include <dds/build/source_dir.hpp> | |||||
| #include <dds/library_manifest.hpp> | |||||
| #include <dds/source.hpp> | #include <dds/source.hpp> | ||||
| #include <optional> | #include <optional> | ||||
| fs::path public_include_dir() const noexcept; | fs::path public_include_dir() const noexcept; | ||||
| fs::path private_include_dir() const noexcept; | fs::path private_include_dir() const noexcept; | ||||
| const source_list& all_sources() const noexcept { return _sources; } | |||||
| const source_list& all_sources() const noexcept { return _sources; } | |||||
| shared_compile_file_rules base_compile_rules() const noexcept; | shared_compile_file_rules base_compile_rules() const noexcept; | ||||
| }; | }; | ||||
| struct library_build_params { | |||||
| fs::path out_subdir; | |||||
| bool build_tests = false; | |||||
| bool build_apps = false; | |||||
| std::vector<fs::path> rt_link_libraries; | |||||
| shared_compile_file_rules compile_rules; | |||||
| }; | |||||
| } // namespace dds | } // namespace dds |