2024-07-27 11:27:52 +00:00
|
|
|
#include "regexis024_build_system.h"
|
2024-08-16 19:10:04 +00:00
|
|
|
#include <utility>
|
2024-07-27 11:27:52 +00:00
|
|
|
|
2024-08-16 19:10:04 +00:00
|
|
|
std::string make_uppercase(const std::string &source) {
|
|
|
|
std::string result(source);
|
|
|
|
for (size_t i = 0; i < source.size(); i++) {
|
|
|
|
char ch = source[i];
|
|
|
|
if ('a' <= ch && ch <= 'z')
|
|
|
|
result[i] = (char)(ch - 'a' + 'A');
|
2024-07-27 11:27:52 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-08-16 19:10:04 +00:00
|
|
|
ExternalLibraryTarget formExternalLibraryTargetWithNonNativeName(const std::string& name) {
|
|
|
|
std::string ev_name = "BSCRIPT_DEP_" + make_uppercase(name);
|
|
|
|
const char* ev = getenv(ev_name.c_str());
|
|
|
|
ASSERT(ev, "No environmaent variable " + ev_name);
|
|
|
|
return {name, parse_passed_forward_str(ev)};
|
2024-07-27 11:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct CAWebChat {
|
|
|
|
/* Building runlevel */
|
|
|
|
BuildUnitsArray runlevel_1;
|
|
|
|
/* Installation runlevel */
|
|
|
|
BuildUnitsArray runlevel_2;
|
|
|
|
|
|
|
|
std::string build_type;
|
2024-08-11 21:12:30 +00:00
|
|
|
bool build_tests = false;
|
2024-07-27 11:27:52 +00:00
|
|
|
|
|
|
|
std::vector<std::string> warning_flags = {"-Wall", "-Wno-unused-variable", "-Werror=return-type","-pedantic",
|
|
|
|
"-Wno-unused-but-set-variable", "-Wno-reorder"};
|
2024-08-19 16:25:21 +00:00
|
|
|
std::vector<std::string> version_flags = {"--std", "c++17", "-D", "_POSIX_C_SOURCE=200809L"};
|
2024-07-27 11:27:52 +00:00
|
|
|
std::vector<std::string> debug_defines_release = {"_GLIBCXX_DEBUG"};
|
|
|
|
std::vector<std::string> debug_defines_debug = {"_GLIBCXX_DEBUG", "DEBUG_ALLOW_LOUD"};
|
|
|
|
std::vector<std::string> opt_flags_release = {"-g", "-O2"};
|
|
|
|
std::vector<std::string> opt_flags_debug = {"-g", "-ggdb", "-O0"};
|
|
|
|
|
|
|
|
std::vector<std::string> getSomeRadFlags() const {
|
|
|
|
std::vector<std::string> my_flag_collection;
|
|
|
|
gxx_add_cli_options(my_flag_collection, warning_flags);
|
|
|
|
gxx_add_cli_options(my_flag_collection, version_flags);
|
|
|
|
if (build_type == "release") {
|
|
|
|
gxx_add_cli_defines(my_flag_collection, debug_defines_release);
|
|
|
|
gxx_add_cli_options(my_flag_collection, opt_flags_release);
|
|
|
|
} else if (build_type == "debug") {
|
|
|
|
gxx_add_cli_defines(my_flag_collection, debug_defines_debug);
|
|
|
|
gxx_add_cli_options(my_flag_collection, opt_flags_debug);
|
|
|
|
}
|
|
|
|
return my_flag_collection;
|
|
|
|
}
|
|
|
|
|
2024-08-11 21:12:30 +00:00
|
|
|
CAWebChat(const std::string& _build_type, bool _build_tests, const NormalCBuildSystemCommandMeaning& cmd)
|
|
|
|
: build_type(_build_type), build_tests(_build_tests)
|
2024-07-27 11:27:52 +00:00
|
|
|
{
|
|
|
|
ASSERT(build_type == "release" || build_type == "debug", "Unknown build type");
|
|
|
|
|
|
|
|
std::vector<ExternalLibraryTarget> ext_targets = {
|
2024-08-16 19:10:04 +00:00
|
|
|
formExternalLibraryTargetWithNonNativeName("libjsonincpp"),
|
|
|
|
formExternalLibraryTargetWithNonNativeName("sqlite3"),
|
|
|
|
formExternalLibraryTargetWithNonNativeName("libregexis024"),
|
2024-07-27 11:27:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<CTarget> my_targets;
|
|
|
|
|
2024-08-05 00:37:56 +00:00
|
|
|
{ CTarget T{"engine_engine_number_9", "shared_library"};
|
2024-07-27 11:27:52 +00:00
|
|
|
T.additional_compilation_flags = getSomeRadFlags();
|
|
|
|
T.proj_deps = {};
|
2024-08-05 00:37:56 +00:00
|
|
|
T.external_deps = {
|
|
|
|
CTargetDependenceOnExternalLibrary{"libjsonincpp", {true, true}},
|
|
|
|
CTargetDependenceOnExternalLibrary{"libregexis024", {true, true}}
|
|
|
|
};
|
2024-07-27 11:27:52 +00:00
|
|
|
T.units = {
|
|
|
|
"baza.cpp",
|
|
|
|
"thread_synchronization.cpp",
|
|
|
|
"os_utils.cpp",
|
|
|
|
"http_structures/client_request_parse.cpp",
|
|
|
|
"http_structures/response_gen.cpp",
|
|
|
|
"connecting_assets/static_asset_manager.cpp",
|
|
|
|
"running_mainloop.cpp",
|
2024-08-06 08:53:33 +00:00
|
|
|
"form_data_structure/urlencoded_query.cpp",
|
2024-08-19 16:25:21 +00:00
|
|
|
"socket_address.cpp",
|
2024-07-27 11:27:52 +00:00
|
|
|
};
|
|
|
|
for (std::string& u: T.units)
|
|
|
|
u = "http_server/engine_engine_number_9/" + u;
|
|
|
|
T.include_pr = "http_server";
|
|
|
|
T.include_ir = "";
|
|
|
|
T.exported_headers = {
|
|
|
|
"baza.h",
|
|
|
|
"baza_throw.h",
|
|
|
|
"thread_synchronization.h",
|
|
|
|
"os_utils.h",
|
|
|
|
"connecting_assets/static_asset_manager.h",
|
|
|
|
"http_structures/client_request.h",
|
|
|
|
"http_structures/response_gen.h",
|
|
|
|
"running_mainloop.h",
|
2024-08-06 08:53:33 +00:00
|
|
|
"form_data_structure/urlencoded_query.h",
|
2024-08-19 16:25:21 +00:00
|
|
|
"socket_address.h",
|
|
|
|
"admin_control.h",
|
2024-07-27 11:27:52 +00:00
|
|
|
};
|
|
|
|
for (std::string& u: T.exported_headers)
|
|
|
|
u = "engine_engine_number_9/" + u;
|
|
|
|
|
|
|
|
T.installation_dir = "";
|
|
|
|
my_targets.push_back(T);
|
|
|
|
}
|
2024-08-10 20:56:07 +00:00
|
|
|
{ CTarget T{"new_york_transit_line", "shared_library"};
|
|
|
|
T.additional_compilation_flags = getSomeRadFlags();
|
|
|
|
T.external_deps = {
|
|
|
|
CTargetDependenceOnExternalLibrary{"libjsonincpp", {true, true}},
|
|
|
|
};
|
|
|
|
T.units = {
|
|
|
|
"alotalot.cpp",
|
|
|
|
"html_case.cpp",
|
|
|
|
"parser.cpp",
|
|
|
|
"rendering.cpp",
|
|
|
|
"templater.cpp",
|
|
|
|
};
|
|
|
|
for (std::string& u: T.units)
|
|
|
|
u = "http_server/new_york_transit_line/" + u;
|
|
|
|
T.include_pr = "http_server";
|
|
|
|
T.exported_headers = {
|
|
|
|
"templater.h",
|
|
|
|
"html_case.h",
|
|
|
|
};
|
|
|
|
for (std::string& u: T.exported_headers)
|
|
|
|
u = "new_york_transit_line/" + u;
|
|
|
|
my_targets.push_back(T);
|
|
|
|
}
|
2024-08-05 00:37:56 +00:00
|
|
|
{ CTarget T{"iu9-ca-web-chat", "executable"};
|
2024-07-27 11:27:52 +00:00
|
|
|
T.additional_compilation_flags = getSomeRadFlags();
|
2024-08-10 20:56:07 +00:00
|
|
|
T.proj_deps = {
|
|
|
|
CTargetDependenceOnProjectsLibrary{"engine_engine_number_9"},
|
|
|
|
CTargetDependenceOnProjectsLibrary{"new_york_transit_line"},
|
|
|
|
};
|
|
|
|
T.external_deps = {
|
|
|
|
CTargetDependenceOnExternalLibrary{"sqlite3"}
|
|
|
|
};
|
2024-08-15 10:39:42 +00:00
|
|
|
T.units = {
|
|
|
|
"main.cpp",
|
|
|
|
"initialize.cpp",
|
|
|
|
"run.cpp",
|
2024-08-15 21:06:35 +00:00
|
|
|
"str_fields_check.cpp",
|
|
|
|
"find_db.cpp",
|
2024-08-15 10:39:42 +00:00
|
|
|
};
|
2024-07-27 11:27:52 +00:00
|
|
|
for (std::string& u: T.units)
|
|
|
|
u = "web_chat/" + u;
|
|
|
|
T.include_pr = "web_chat";
|
|
|
|
T.installation_dir = "";
|
|
|
|
my_targets.push_back(T);
|
|
|
|
}
|
|
|
|
regular_ctargets_to_2bus_conversion(ext_targets, my_targets, runlevel_1, runlevel_2,
|
|
|
|
cmd.project_root, cmd.installation_root);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
try {
|
|
|
|
ASSERT_pl(argc > 0);
|
|
|
|
std::vector<std::string> args(argc - 1);
|
|
|
|
for (int i = 0; i + 1 < argc; i++) {
|
|
|
|
args[i] = argv[i + 1];
|
|
|
|
}
|
|
|
|
NormalCBuildSystemCommandMeaning cmd;
|
|
|
|
regular_bs_cli_cmd_interpret(args, cmd);
|
2024-08-17 13:09:29 +00:00
|
|
|
const char* BS_SCRIPT_TYPE = getenv("BSCRIPT_TYPE");
|
|
|
|
const char* BS_SCRIPT_TESTS = getenv("BSCRIPT_TESTS");
|
2024-08-11 21:12:30 +00:00
|
|
|
CAWebChat bs(BS_SCRIPT_TYPE ? BS_SCRIPT_TYPE : "release", (bool)BS_SCRIPT_TESTS, cmd);
|
2024-07-27 11:27:52 +00:00
|
|
|
if (cmd.need_to_build)
|
|
|
|
complete_tasks_of_build_units(bs.runlevel_1);
|
|
|
|
umask(~0755);
|
|
|
|
if (cmd.need_to_install)
|
|
|
|
complete_tasks_of_build_units(bs.runlevel_2);
|
|
|
|
} catch (const buildSystemFailure& e) {
|
|
|
|
printf("Build system failure\n""%s\n", e.toString().c_str());
|
|
|
|
}
|
2024-08-05 00:37:56 +00:00
|
|
|
}
|