1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-27 05:29:10 +03:00

Show license information in the --help message

This commit is contained in:
Rui Ueyama 2022-11-13 16:45:42 +08:00
parent 2b7b45c8d1
commit 1f67ccfa20
2 changed files with 13 additions and 2 deletions

View File

@ -1,2 +1,3 @@
#define MOLD_VERSION "@mold_VERSION@"
#define MOLD_LIBDIR "@CMAKE_INSTALL_FULL_LIBDIR@"
#cmakedefine01 MOLD_HAS_COMMERCIAL_LICENSE

14
main.cc
View File

@ -27,10 +27,20 @@ namespace macho {
int main(int argc, char **argv);
}
static bool has_commercial_license() {
if (MOLD_HAS_COMMERCIAL_LICENSE)
return true;
char *env = getenv("MOLD_HAS_COMMERCIAL_LICENSE");
return env && env[0];
}
static std::string get_mold_version() {
std::string ver = "mold " MOLD_VERSION;
ver += has_commercial_license() ? " commercial edition" : " free edition";
if (mold_git_hash.empty())
return "mold " MOLD_VERSION " (compatible with GNU ld)";
return "mold " MOLD_VERSION " (" + mold_git_hash + "; compatible with GNU ld)";
return ver + " (compatible with GNU ld)";
return ver + " (" + mold_git_hash + "; compatible with GNU ld)";
}
void cleanup() {