summaryrefslogtreecommitdiff
path: root/include/version.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/version.cpp')
-rw-r--r--include/version.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/include/version.cpp b/include/version.cpp
index 69568c2df..76a4d3c40 100644
--- a/include/version.cpp
+++ b/include/version.cpp
@@ -42,7 +42,7 @@ static std::string get_git_hash(const std::string &git_dir)
}
fd.close();
- return "g" + filebuf.substr(0, 7);
+ return filebuf.substr(0, 7);
}
static bool read_version_sh(const std::string &version_sh, std::map<std::string, std::string> &versions)
@@ -105,8 +105,9 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
return false;
}
- fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl;
- fd << build << std::endl;
+ fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl
+ << "#pragma once" << std::endl
+ << build << std::endl;
if (!git_version.empty())
fd << "#define VERSION_GIT \"" << git_version << "\"" << std::endl;
fd.close();
@@ -144,9 +145,10 @@ static bool write_version_h(const std::string &versionh, const std::map<std::str
if (!fd.is_open())
return false;
- for (std::map<std::string, std::string>::const_iterator it = versions.begin(); it != versions.end(); ++it)
+ fd << "#pragma once" << std::endl;
+ for (const auto &[key, value] : versions)
{
- fd << "#define " << it->first << " " << it->second << std::endl;
+ fd << "#define " << key << " " << value << std::endl;
}
fd.close();
@@ -170,19 +172,19 @@ int main(int argc, char *argv[])
std::map<std::string, std::string> versions, old_versions;
if (!read_version_sh(version_sh, versions))
- return -1;
+ return EXIT_FAILURE;
std::string git_version = get_git_hash(git_dir);
if (!write_build_h(buildh, git_version))
- return -1;
+ return EXIT_FAILURE;
read_version_h(versionh, old_versions);
if (versions == old_versions)
- return 0;
+ return EXIT_SUCCESS;
if (!write_version_h(versionh, versions))
- return -1;
+ return EXIT_FAILURE;
- return 0;
+ return EXIT_SUCCESS;
}