diff --git a/regexis024_build_system.h b/regexis024_build_system.h index 061ae05..67e094d 100644 --- a/regexis024_build_system.h +++ b/regexis024_build_system.h @@ -681,11 +681,9 @@ std::string prettyprint_outofboundness(size_t ind, size_t sz) { /* circular_dependency_result is filled in case of circular dependency */ void topsort(std::vector& result, std::vector& circular_dependency_result, - const std::vector& entry_points, const std::vector>& depgraph) + const std::vector>& depgraph) { size_t N = depgraph.size(); - for (size_t e: entry_points) - ASSERT(e < N, "bad entry point to tosorted task list " + prettyprint_outofboundness(e, N)); for (size_t i = 0; i < N; i++) for (size_t ch: depgraph[i]) ASSERT(ch < N, "bad dependency point to tosorted task list " + prettyprint_outofboundness(ch, N)); @@ -701,7 +699,7 @@ void topsort(std::vector& result, std::vector& circular_dependen size_t i = 0; explicit topsortDfsFrame(size_t v): v(v){} }; - for (size_t st: entry_points) { + for (size_t st = 0; st < N; st++) { if (status[st] == 2) continue; std::vector callStack = {topsortDfsFrame(st)}; @@ -842,35 +840,32 @@ std::string prettyprint_cyclic_dependency(const std::vector& lines) return res; } -struct BuildUnitsArray { - std::vector> tasks; - std::vector entry_points; -}; +typedef std::vector> BuildUnitsArray; void complete_tasks_of_build_units (const BuildUnitsArray& arr) { - size_t N = arr.tasks.size(); + size_t N = arr.size(); std::vector execution_order; std::vector cyc_dep_problem; std::vector> depgraph(N); for (size_t i = 0; i < N; i++) - depgraph[i] = arr.tasks[i]->bu_dependencies; - topsort(execution_order, cyc_dep_problem, arr.entry_points, depgraph); + depgraph[i] = arr[i]->bu_dependencies; + topsort(execution_order, cyc_dep_problem, depgraph); if (!cyc_dep_problem.empty()) { std::vector bad_units(cyc_dep_problem.size()); for (size_t i = 0; i < cyc_dep_problem.size(); i++) { - bad_units[i] = prettyprint_build_unit(*arr.tasks[cyc_dep_problem[i]]) + " "; + bad_units[i] = prettyprint_build_unit(*arr[cyc_dep_problem[i]]) + " "; } THROW("Cyclic dependency of build units was found:\n" + prettyprint_cyclic_dependency(bad_units)); } ASSERT(execution_order.size() == N, std::to_string(N - execution_order.size()) + " build units are unreachable in dependency tree"); for (size_t I: execution_order) { - printf("Executing %s\n", prettyprint_build_unit(*arr.tasks[I]).c_str()); - for (auto& rqd: arr.tasks[I]->all_fs_dependencies) + printf("Executing %s\n", prettyprint_build_unit(*arr[I]).c_str()); + for (auto& rqd: arr[I]->all_fs_dependencies) checkFsEntity(rqd); - arr.tasks[I]->execute(); - for (auto& rqr: arr.tasks[I]->all_fs_results) + arr[I]->execute(); + for (auto& rqr: arr[I]->all_fs_results) checkFsEntity(rqr); } } @@ -940,8 +935,6 @@ struct CTarget { std::string description; std::string version = "0.1"; - bool entry_point = true; - CTarget(const std::string& name, const std::string& type): name(name), type(type){} }; @@ -1015,8 +1008,6 @@ void load_ctargets_on_building_and_installing( const std::string& install_bin_dir_path, const std::string& install_pkgconfig_dir_path) { - ret_at_build.tasks.clear(); - ret_at_build.entry_points.clear(); std::map ext_libs_map; for (auto& e: ext_lib_targs) { check_target_name(e.name); @@ -1038,12 +1029,12 @@ void load_ctargets_on_building_and_installing( }; std::map before; auto add_bbu = [&](BuildUnit* obj) -> size_t { - ret_at_build.tasks.emplace_back(obj); - return ret_at_build.tasks.size() - 1; + ret_at_build.emplace_back(obj); + return ret_at_build.size() - 1; }; auto add_ibu = [&](BuildUnit* obj) -> size_t { - ret_at_install.tasks.emplace_back(obj); - return ret_at_install.tasks.size() - 1; + ret_at_install.emplace_back(obj); + return ret_at_install.size() - 1; }; for (auto& tg: proj_targs) { check_target_name(tg.name); @@ -1203,7 +1194,7 @@ void load_ctargets_on_building_and_installing( "-l:" + tg.name + ".so" }); /* Determining how to create pkg-config file at installation stage */ - if (!tg.pc_output_path.empty() && tg.entry_point) { + if (!tg.pc_output_path.empty()) { check_pkg_conf_rel_install_path(tg.pc_output_path); // todo: ESCAPE THESE VALUES size_t pkg_conf_install_ibu = add_ibu(new FileWriteBuildUnit( @@ -1213,7 +1204,7 @@ void load_ctargets_on_building_and_installing( "Version: " + tg.version + "\n" + "Cflags: " + join_string_arr(s.emitted_compilation_flags_PASSED_FORWARD, " ") + "\n" + "Libs: " + join_string_arr(s.emitted_linkage_flags_PASSED_FORWARD, " ") + "\n")); - ret_at_install.tasks[blank_ibu_for_tg_FINAL]->bu_dependencies.push_back(pkg_conf_install_ibu); + ret_at_install[blank_ibu_for_tg_FINAL]->bu_dependencies.push_back(pkg_conf_install_ibu); } /* s.end_BU... fields allow us to establish dependency relations between BUs of ctargets with such relation */ s.end_BBU_id = targ_FINAL_bbu_id; @@ -1221,10 +1212,6 @@ void load_ctargets_on_building_and_installing( } else { THROW("Unknown C-target type " + tg.type); } - if (tg.entry_point) { - ret_at_build.entry_points.push_back(targ_FINAL_bbu_id); - ret_at_install.entry_points.push_back(blank_ibu_for_tg_FINAL); - } } } @@ -1308,20 +1295,15 @@ std::string text_formatting_break_spaces(const std::string& text) { } void draw_bu_arr_in_dot(const BuildUnitsArray& taskSet, std::string& output) { - size_t N = taskSet.tasks.size(); - std::vector turningRed(N, false); - for (size_t eid: taskSet.entry_points) { - ASSERT_pl(eid < N && !turningRed[eid]); - turningRed[eid] = true; - } + size_t N = taskSet.size(); output += "digraph BUs { \n" "graph [rankdir=LR]" "node [fontcolor = black color = black fillcolor = white margin = \"0.2,0.2\"" " shape=rect ]\n"; for (size_t i = 0; i < N; i++) { - const BuildUnit& bu = *(taskSet.tasks[i]); - output += std::string("N_") + std::to_string(i) + " [ color = " + (turningRed[i] ? "red" : "black") - + " label = " + escape_with_doublequoting("[" + std::to_string(i) + "] " + prettyprint_build_unit(bu)) + const BuildUnit& bu = *(taskSet[i]); + output += std::string("N_") + std::to_string(i) + " [ label = " + + escape_with_doublequoting("[" + std::to_string(i) + "] " + prettyprint_build_unit(bu)) + "]\n"; for (size_t j: bu.bu_dependencies) { output += "N_" + std::to_string(i) + " -> N_" + std::to_string(j) + "\n";