Added field CTarget::unit_dir

This commit is contained in:
Андреев Григорий 2024-07-19 16:02:16 +03:00
parent 5ee754cf3d
commit ce6a9e2e4c

View File

@ -3,7 +3,6 @@
/* This file is standalone from libregexis024 project (but it is related to it as it's dependency) */ /* This file is standalone from libregexis024 project (but it is related to it as it's dependency) */
#include <algorithm> #include <algorithm>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -925,7 +924,9 @@ struct CTarget {
std::vector<std::string> additional_compilation_flags; std::vector<std::string> additional_compilation_flags;
std::vector<std::string> additional_linkage_flags; std::vector<std::string> additional_linkage_flags;
/* .c and .cpp source files relative to the special src directory*/ /* Prefix for all cpp files in `units` array */
std::string units_dir;
/* .c and .cpp source files relative to the special src/${units_dir} directory*/
std::vector<std::string> units; std::vector<std::string> units;
std::string include_pr; std::string include_pr;
@ -981,8 +982,8 @@ void check_pkg_conf_rel_install_path(const path_t& P) {
ASSERT_pl(does_str_end_in(P.parts.back(), ".pc")); ASSERT_pl(does_str_end_in(P.parts.back(), ".pc"));
} }
/* Argument `name` is relative to project_src_dir, return value is relative_to $IR/$TARGET_NAME/obj */ /* Argument `name` is just a name in `units` array, return value is relative to $IR/$TARGET_NAME/obj */
path_t c_unit_name_to_obj_filename(const std::string& PtoC) { path_t c_unit_name_to_obj_filename(const std::string& units_dir, const std::string& PtoC) {
path_t P(PtoC); path_t P(PtoC);
assert(!P.parts.empty()); assert(!P.parts.empty());
std::string& filename = P.parts.back(); std::string& filename = P.parts.back();
@ -998,6 +999,10 @@ path_t c_unit_name_to_obj_filename(const std::string& PtoC) {
return P; return P;
} }
path_t c_unit_name_to_source_filename(const std::string& units_dir, const std::string& PtoC){
return path_t(units_dir) / PtoC;
}
void load_ctargets_on_building_and_installing( void load_ctargets_on_building_and_installing(
const std::vector<ExternalLibraryTarget>& ext_lib_targs, const std::vector<ExternalLibraryTarget>& ext_lib_targs,
const std::vector<CTarget>& proj_targs, const std::vector<CTarget>& proj_targs,
@ -1053,10 +1058,10 @@ void load_ctargets_on_building_and_installing(
size_t mk_personal_targ_dir_bu_id = add_bbu(new MkdirBuildUnit(path_t(proj_compiled_dir_path) / tg.name)); size_t mk_personal_targ_dir_bu_id = add_bbu(new MkdirBuildUnit(path_t(proj_compiled_dir_path) / tg.name));
std::vector<size_t> all_comp_units_bu_ids; std::vector<size_t> all_comp_units_bu_ids;
auto BU_to_SOURCE_FILEPATH = [&](const std::string& bu) -> path_t { auto BU_to_SOURCE_FILEPATH = [&](const std::string& bu) -> path_t {
return path_t(proj_src_dir_path) / bu; return path_t(proj_src_dir_path) / c_unit_name_to_source_filename(tg.units_dir, bu);
}; };
auto BU_to_OBJ_FILEPATH = [&](const std::string& bu) -> path_t { auto BU_to_OBJ_FILEPATH = [&](const std::string& bu) -> path_t {
return path_t(proj_compiled_dir_path) / tg.name / "obj" / c_unit_name_to_obj_filename(bu); return path_t(proj_compiled_dir_path) / tg.name / "obj" / c_unit_name_to_obj_filename(tg.units_dir, bu);
}; };
auto generate_cu_BUs = [&](const std::vector<std::string>& ctg_type_intrinsic_comp_args) { auto generate_cu_BUs = [&](const std::vector<std::string>& ctg_type_intrinsic_comp_args) {
const std::string comp_cmd = "g++"; // todo: think of some other way around const std::string comp_cmd = "g++"; // todo: think of some other way around