diff options
-rw-r--r-- | ctor.cc | 118 | ||||
m--------- | libctor | 0 |
2 files changed, 35 insertions, 83 deletions
@@ -1,5 +1,5 @@ // -*- c++ -*- -#include <libctor.h> +#include <ctor.h> #include <filesystem> #include <iostream> @@ -12,65 +12,12 @@ int execute(const std::string& command, namespace { -class PathRAII -{ -public: - PathRAII(const std::filesystem::path& path) - { - pwd = std::filesystem::current_path(); - std::filesystem::current_path(path); - } - - ~PathRAII() - { - std::filesystem::current_path(pwd); - } - -private: - std::filesystem::path pwd; -}; - -std::vector<Source> eval_mocs(const std::string& path, - const std::vector<std::pair<std::string, std::string>>& moc_list) -{ - std::vector<Source> sources; - for(const auto& moc : moc_list) - { - std::filesystem::path input(moc.first); - std::filesystem::path output(moc.second); - - std::filesystem::path fspath(path); - - if(!std::filesystem::exists(fspath / input)) - { - std::cerr << "Missing moc input file: " << input.string() << '\n'; - exit(1); - } - - if(!std::filesystem::exists(path / output) || - std::filesystem::last_write_time(path / input) > - std::filesystem::last_write_time(path / output)) - { - PathRAII p(path); - auto ret = execute("/usr/bin/moc", {"-o", output.string(), input.string()}); - if(ret != 0) - { - std::cerr << "moc generation failed\n"; - exit(ret); - } - } - sources.push_back((path / output).string()); - } - - return sources; -} - -BuildConfigurations myConfigs() +ctor::build_configurations myConfigs(const ctor::settings& settings) { // - // Qookie-cast client + // Qookie main application // - BuildConfiguration qookie = + ctor::build_configuration qookie = { .target = "qookie", // output filename .sources = { @@ -78,9 +25,13 @@ BuildConfigurations myConfigs() "src/database.cc", "src/database_gourmet.cc", "src/database_krecipes.cc", + "src/database_qookie.cc", "src/mainwindow.cc", "src/viewer.cc", "src/client.cc", + settings.builddir + "/moc_mainwindow.cc", + settings.builddir + "/moc_viewer.cc", + settings.builddir + "/moc_client.cc", }, .flags = { .cxxflags = { @@ -92,26 +43,37 @@ BuildConfigurations myConfigs() }, .externals = { "qt", "sqlite" }, }; - std::vector<Source> qookie_mocs = - eval_mocs("src", - { - { "mainwindow.h", "moc_mainwindow.cc"}, - { "viewer.h", "moc_viewer.cc"}, - { "client.h", "moc_client.cc"}, - }); - for(const auto& moc : qookie_mocs) - { - qookie.sources.push_back(moc); - } + + // + // Moc generation for all configurations + // + ctor::build_configuration mocs = + { + .sources = { + { "src/mainwindow.h", "moc_mainwindow.cc"}, + { "src/viewer.h", "moc_viewer.cc"}, + { "src/client.h", "moc_client.cc"}, + { "src/qookie-cast-client.h", "moc_qookie-cast-client.cc"}, + }, + .function = [](const std::string& input, + const std::string& output, + const ctor::build_configuration& config, + const ctor::settings& settings) + { + return execute("/usr/bin/moc", {"-I../src", "-o", output, input}, + settings.verbose > 0); + } + }; // // Qookie-cast client // - BuildConfiguration qookie_cast_client = + ctor::build_configuration qookie_cast_client = { .target = "qookie-cast-client", // output filename .sources = { "src/qookie-cast-client.cc", + settings.builddir + "/moc_qookie-cast-client.cc", }, .flags = { .cxxflags = { @@ -124,26 +86,16 @@ BuildConfigurations myConfigs() .externals = {"qt"}, }; - std::vector<Source> qookie_cast_client_mocs = - eval_mocs("src", - { - { "qookie-cast-client.h", "moc_qookie-cast-client.cc"}, - }); - for(const auto& moc : qookie_cast_client_mocs) - { - qookie_cast_client.sources.push_back(moc); - } - - return {qookie, qookie_cast_client}; + return { qookie, mocs, qookie_cast_client }; } -ExternalConfigurations ctorExtConfigs() +ctor::external_configurations ctorExtConfigs(const ctor::settings& settings) { return { { .name = "qt", - .external = ExternalManual{ + .external = ctor::external_manual{ .flags = { .cxxflags = { "-I/usr/include/qt5", @@ -159,7 +111,7 @@ ExternalConfigurations ctorExtConfigs() }, { .name = "sqlite", - .external = ExternalManual{ + .external = ctor::external_manual{ .flags = { .ldflags = { "-lsqlite3", diff --git a/libctor b/libctor -Subproject fb88dc797f1f5f420416521d4b3088bf6b8450a +Subproject 321f25af1ba33d8409cd294b4f50d0d3e79cf3b |