updated build system
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-09-08 09:16:10 -05:00
parent de74dbcbac
commit ba21676c2b
4 changed files with 125 additions and 116 deletions

View File

@@ -306,6 +306,99 @@ auto use_getpwuid(uid_t uid, passwd_callback_t callback) -> result {
.function_name = std::string{function_name},
};
}
#if defined(__APPLE__)
#if defined(PROJECT_ENABLE_PUGIXML)
auto generate_launchd_plist(const plist_cfg &cfg, bool overwrite_existing)
-> bool {
auto file = utils::path::combine(cfg.plist_path, {cfg.label + ".plist"});
if (utils::file::file{file}.exists() && not overwrite_existing) {
return true;
}
pugi::xml_document doc;
auto decl = doc.append_child(pugi::node_declaration);
decl.append_attribute("version") = "1.0";
decl.append_attribute("encoding") = "UTF-8";
auto plist = doc.append_child("plist");
plist.append_attribute("version") = "1.0";
auto dict = plist.append_child("dict");
dict.append_child("key").text().set("Label");
dict.append_child("string").text().set(cfg.label.c_str());
dict.append_child("key").text().set("ProgramArguments");
auto array = dict.append_child("array");
for (const auto &arg : cfg.args) {
array.append_child("string").text().set(arg.c_str());
}
dict.append_child("key").text().set("EnvironmentVariables");
pugi::xml_node env_dict = dict.append_child("dict");
if (not utils::get_environment_variable("PROJECT_TEST_CONFIG_DIR").empty()) {
env_dict.append_child("key").text().set("PROJECT_TEST_CONFIG_DIR");
env_dict.append_child("string").text().set(
utils::get_environment_variable("PROJECT_TEST_CONFIG_DIR"));
}
if (not utils::get_environment_variable("PROJECT_TEST_INPUT_DIR").empty()) {
env_dict.append_child("key").text().set("PROJECT_TEST_INPUT_DIR");
env_dict.append_child("string").text().set(
utils::get_environment_variable("PROJECT_TEST_INPUT_DIR"));
}
dict.append_child("key").text().set("WorkingDirectory");
dict.append_child("string").text().set(cfg.working_dir.c_str());
dict.append_child("key").text().set("KeepAlive");
dict.append_child(cfg.keep_alive ? "true" : "false");
dict.append_child("key").text().set("RunAtLoad");
dict.append_child(cfg.run_at_load ? "true" : "false");
dict.append_child("key").text().set("StandardOutPath");
dict.append_child("string").text().set(cfg.stdout_log.c_str());
dict.append_child("key").text().set("StandardErrorPath");
dict.append_child("string").text().set(cfg.stderr_log.c_str());
return doc.save_file(file.c_str(), " ",
pugi::format_indent | pugi::format_write_bom);
}
#endif // defined(PROJECT_ENABLE_PUGIXML)
auto launchctl_command(std::string_view label, launchctl_type type) -> int {
switch (type) {
case launchctl_type::bootout:
return system(
fmt::format("launchctl bootout gui/{} '{}' 1>/dev/null 2>&1", getuid(),
utils::path::combine("~",
{
"/Library/LaunchAgents",
fmt::format("{}.plist", label),
}))
.c_str());
case launchctl_type::bootstrap:
return system(
fmt::format("launchctl bootstrap gui/{} '{}' 1>/dev/null 2>&1",
getuid(),
utils::path::combine("~",
{
"/Library/LaunchAgents",
fmt::format("{}.plist", label),
}))
.c_str());
case launchctl_type::kickstart:
return system(
fmt::format("launchctl kickstart gui/{}/{}", getuid(), label).c_str());
}
return -1;
}
#endif // defined(__APPLE__)
} // namespace repertory::utils
#endif // !defined(_WIN32)