mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 09:46:00 +01:00
internal: improve version query and define HYPRLAND_VERSION (#8034)
This commit is contained in:
parent
178a300eea
commit
7564b26b7d
6 changed files with 25 additions and 39 deletions
|
@ -71,6 +71,8 @@ else()
|
||||||
message(STATUS "Configuring Hyprland in Release with CMake")
|
message(STATUS "Configuring Hyprland in Release with CMake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_compile_definitions(HYPRLAND_VERSION="${HYPRLAND_VERSION}")
|
||||||
|
|
||||||
include_directories(. "src/" "protocols/")
|
include_directories(. "src/" "protocols/")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 26)
|
set(CMAKE_CXX_STANDARD 26)
|
||||||
|
|
|
@ -440,8 +440,7 @@ bool CPluginManager::updateHeaders(bool force) {
|
||||||
|
|
||||||
// let us give a bit of leg-room for shallowing
|
// let us give a bit of leg-room for shallowing
|
||||||
// due to timezones, etc.
|
// due to timezones, etc.
|
||||||
const std::string SHALLOW_DATE =
|
const std::string SHALLOW_DATE = trim(HLVER.date).empty() ? "" : execAndGet("LC_TIME=\"en_US.UTF-8\" date --date='" + HLVER.date + " - 1 weeks' '+%a %b %d %H:%M:%S %Y'");
|
||||||
trim(HLVER.date).empty() ? "" : execAndGet("LC_TIME=\"en_US.UTF-8\" date --date='" + HLVER.date + " - 1 weeks' '+\%a \%b \%d \%H:\%M:\%S \%Y'");
|
|
||||||
|
|
||||||
if (m_bVerbose && bShallow)
|
if (m_bVerbose && bShallow)
|
||||||
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "will shallow since: " + SHALLOW_DATE);
|
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "will shallow since: " + SHALLOW_DATE);
|
||||||
|
|
|
@ -21,6 +21,7 @@ add_project_arguments(
|
||||||
'-Wno-missing-field-initializers',
|
'-Wno-missing-field-initializers',
|
||||||
'-Wno-narrowing',
|
'-Wno-narrowing',
|
||||||
'-Wno-pointer-arith', datarootdir,
|
'-Wno-pointer-arith', datarootdir,
|
||||||
|
'-DHYPRLAND_VERSION="' + meson.project_version() + '"',
|
||||||
],
|
],
|
||||||
language: 'cpp',
|
language: 'cpp',
|
||||||
)
|
)
|
||||||
|
|
|
@ -853,26 +853,33 @@ std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||||
std::replace(commitMsg.begin(), commitMsg.end(), '#', ' ');
|
std::replace(commitMsg.begin(), commitMsg.end(), '#', ' ');
|
||||||
|
|
||||||
if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
||||||
std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + " " + GIT_DIRTY + " (" + commitMsg +
|
std::string result = std::format("Hyprland {} built from branch {} at commit {} {} ({}).\n"
|
||||||
").\nDate: " + GIT_COMMIT_DATE + "\nTag: " + GIT_TAG + ", commits: " + GIT_COMMITS + std::string{"\nbuilt against aquamarine "} + AQUAMARINE_VERSION + "\n" +
|
"Date: {}\n"
|
||||||
"\n\nflags: (if any)\n";
|
"Tag: {}, commits: {}\n"
|
||||||
|
"built against aquamarine {}\n\n\n",
|
||||||
|
HYPRLAND_VERSION, GIT_BRANCH, GIT_COMMIT_HASH, GIT_DIRTY, commitMsg, GIT_COMMIT_DATE, GIT_TAG, GIT_COMMITS, AQUAMARINE_VERSION);
|
||||||
|
|
||||||
|
#if (!defined(LEGACY_RENDERER) && !defined(ISDEBUG) && !defined(NO_XWAYLAND))
|
||||||
|
result += "no flags were set\n";
|
||||||
|
#else
|
||||||
|
result += "flags set:\n";
|
||||||
#ifdef LEGACY_RENDERER
|
#ifdef LEGACY_RENDERER
|
||||||
result += "legacyrenderer\n";
|
result += "legacyrenderer\n";
|
||||||
#endif
|
#endif
|
||||||
#ifndef ISDEBUG
|
#ifdef ISDEBUG
|
||||||
result += "debug\n";
|
result += "debug\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_XWAYLAND
|
#ifdef NO_XWAYLAND
|
||||||
result += "no xwayland\n";
|
result += "no xwayland\n";
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
std::string result = std::format(
|
std::string result = std::format(
|
||||||
R"#({{
|
R"#({{
|
||||||
"branch": "{}",
|
"branch": "{}",
|
||||||
"commit": "{}",
|
"commit": "{}",
|
||||||
|
"version": "{}",
|
||||||
"dirty": {},
|
"dirty": {},
|
||||||
"commit_message": "{}",
|
"commit_message": "{}",
|
||||||
"commit_date": "{}",
|
"commit_date": "{}",
|
||||||
|
@ -880,13 +887,13 @@ std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||||
"commits": "{}",
|
"commits": "{}",
|
||||||
"buildAquamarine": "{}",
|
"buildAquamarine": "{}",
|
||||||
"flags": [)#",
|
"flags": [)#",
|
||||||
GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_COMMIT_DATE, GIT_TAG, GIT_COMMITS,
|
GIT_BRANCH, GIT_COMMIT_HASH, HYPRLAND_VERSION, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_COMMIT_DATE, GIT_TAG,
|
||||||
AQUAMARINE_VERSION);
|
GIT_COMMITS, AQUAMARINE_VERSION);
|
||||||
|
|
||||||
#ifdef LEGACY_RENDERER
|
#ifdef LEGACY_RENDERER
|
||||||
result += "\"legacyrenderer\",";
|
result += "\"legacyrenderer\",";
|
||||||
#endif
|
#endif
|
||||||
#ifndef ISDEBUG
|
#ifdef ISDEBUG
|
||||||
result += "\"debug\",";
|
result += "\"debug\",";
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_XWAYLAND
|
#ifdef NO_XWAYLAND
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
// exposed for main.cpp
|
// exposed for main.cpp
|
||||||
std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request);
|
std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request);
|
||||||
|
std::string versionRequest(eHyprCtlOutputFormat format, std::string request);
|
||||||
|
|
||||||
class CHyprCtl {
|
class CHyprCtl {
|
||||||
public:
|
public:
|
||||||
|
|
34
src/main.cpp
34
src/main.cpp
|
@ -23,6 +23,7 @@ void help() {
|
||||||
std::cout << " --config FILE -c FILE - Specify config file to use\n";
|
std::cout << " --config FILE -c FILE - Specify config file to use\n";
|
||||||
std::cout << " --socket NAME - Sets the Wayland socket name (for Wayland socket handover)\n";
|
std::cout << " --socket NAME - Sets the Wayland socket name (for Wayland socket handover)\n";
|
||||||
std::cout << " --wayland-fd FD - Sets the Wayland socket fd (for Wayland socket handover)\n";
|
std::cout << " --wayland-fd FD - Sets the Wayland socket fd (for Wayland socket handover)\n";
|
||||||
|
std::cout << " --systeminfo - Prints system infos\n";
|
||||||
std::cout << " --i-am-really-stupid - Omits root user privileges check (why would you do that?)\n";
|
std::cout << " --i-am-really-stupid - Omits root user privileges check (why would you do that?)\n";
|
||||||
std::cout << " --version -v - Print this binary's version\n";
|
std::cout << " --version -v - Print this binary's version\n";
|
||||||
}
|
}
|
||||||
|
@ -33,9 +34,9 @@ int main(int argc, char** argv) {
|
||||||
throwError("XDG_RUNTIME_DIR is not set!");
|
throwError("XDG_RUNTIME_DIR is not set!");
|
||||||
|
|
||||||
// export HYPRLAND_CMD
|
// export HYPRLAND_CMD
|
||||||
std::string cmd = "";
|
std::string cmd = argv[0];
|
||||||
for (auto i = 0; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
cmd += std::string(i == 0 ? "" : " ") + argv[i];
|
cmd += std::string(" ") + argv[i];
|
||||||
|
|
||||||
setenv("HYPRLAND_CMD", cmd.c_str(), 1);
|
setenv("HYPRLAND_CMD", cmd.c_str(), 1);
|
||||||
setenv("XDG_BACKEND", "wayland", 1);
|
setenv("XDG_BACKEND", "wayland", 1);
|
||||||
|
@ -116,32 +117,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else if (it->compare("-v") == 0 || it->compare("--version") == 0) {
|
} else if (it->compare("-v") == 0 || it->compare("--version") == 0) {
|
||||||
auto result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH;
|
std::cout << versionRequest(eHyprCtlOutputFormat::FORMAT_NORMAL, "") << std::endl;
|
||||||
auto dirty = std::string(GIT_DIRTY);
|
|
||||||
if (!dirty.empty())
|
|
||||||
result += " " + dirty;
|
|
||||||
|
|
||||||
auto commitMsg = trim(GIT_COMMIT_MESSAGE);
|
|
||||||
std::replace(commitMsg.begin(), commitMsg.end(), '#', ' ');
|
|
||||||
result += " (" + commitMsg + ").";
|
|
||||||
|
|
||||||
result += "\nDate: " + std::string(GIT_COMMIT_DATE);
|
|
||||||
result += "\nTag: " + std::string(GIT_TAG) + ", commits: " + std::string(GIT_COMMITS);
|
|
||||||
result += "\nbuilt against aquamarine " + std::string(AQUAMARINE_VERSION);
|
|
||||||
|
|
||||||
result += "\n\nflags: (if any)\n";
|
|
||||||
|
|
||||||
#ifdef LEGACY_RENDERER
|
|
||||||
result += "legacyrenderer\n";
|
|
||||||
#endif
|
|
||||||
#ifndef ISDEBUG
|
|
||||||
result += "debug\n";
|
|
||||||
#endif
|
|
||||||
#ifdef NO_XWAYLAND
|
|
||||||
result += "no xwayland\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::cout << result;
|
|
||||||
return 0;
|
return 0;
|
||||||
} else if (it->compare("--systeminfo") == 0) {
|
} else if (it->compare("--systeminfo") == 0) {
|
||||||
const auto SYSINFO = systemInfoRequest(eHyprCtlOutputFormat::FORMAT_NORMAL, "");
|
const auto SYSINFO = systemInfoRequest(eHyprCtlOutputFormat::FORMAT_NORMAL, "");
|
||||||
|
|
Loading…
Reference in a new issue