summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/version.hpp20
-rw-r--r--src/main.cpp7
-rw-r--r--src/version.cpp29
3 files changed, 56 insertions, 0 deletions
diff --git a/src/include/version.hpp b/src/include/version.hpp
new file mode 100644
index 00000000..2270a592
--- /dev/null
+++ b/src/include/version.hpp
@@ -0,0 +1,20 @@
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * version.hpp
+ * - Compiler version number
+ */
+#pragma once
+
+#include <string>
+
+extern unsigned int giVersion_Major;
+extern unsigned int giVersion_Minor;
+extern unsigned int giVersion_Patch;
+extern const char* gsVersion_GitHash;
+extern const char* gsVersion_GitShortHash;
+extern const char* gsVersion_BuildTime;
+extern bool gbVersion_GitDirty;
+
+extern ::std::string Version_GetString();
diff --git a/src/main.cpp b/src/main.cpp
index 8f2740fc..0e37f4a3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -9,6 +9,7 @@
#include <iomanip>
#include <string>
#include <set>
+#include <version.hpp>
#include <string_view.hpp>
#include "parse/lex.hpp"
#include "parse/parseerror.hpp"
@@ -944,6 +945,12 @@ ProgramParams::ProgramParams(int argc, char *argv[])
this->show_help();
exit(0);
}
+ else if( strcmp(arg, "--version" ) == 0 ) {
+ ::std::cout << "MRustC " << Version_GetString() << ::std::endl;
+ ::std::cout << "- Build time: " << gsVersion_BuildTime << ::std::endl;
+ ::std::cout << "- Commit: " << gsVersion_GitHash << (gbVersion_GitDirty ? " (dirty tree)" : "") << ::std::endl;
+ exit(0);
+ }
// --out-dir <dir> >> Set the output directory for automatically-named files
else if( strcmp(arg, "--out-dir") == 0) {
if (i == argc - 1) {
diff --git a/src/version.cpp b/src/version.cpp
new file mode 100644
index 00000000..d6307618
--- /dev/null
+++ b/src/version.cpp
@@ -0,0 +1,29 @@
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * version.cpp
+ * - Compiler version number
+ */
+#include <version.hpp>
+#include <sstream>
+
+#define VERSION_MAJOR 0
+#define VERSION_MINOR 8
+#define VERSION_PATCH 0
+
+unsigned int giVersion_Major = VERSION_MAJOR;
+unsigned int giVersion_Minor = VERSION_MINOR;
+unsigned int giVersion_Patch = VERSION_PATCH;
+bool gbVersion_GitDirty = VERSION_GIT_ISDIRTY;
+const char* gsVersion_GitHash = VERSION_GIT_FULLHASH;
+const char* gsVersion_GitShortHash = VERSION_GIT_SHORTHASH;
+const char* gsVersion_BuildTime = VERSION_BUILDTIME;
+
+
+::std::string Version_GetString()
+{
+ ::std::stringstream ss;
+ ss << "v" << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_PATCH << " " << VERSION_GIT_BRANCH << ":" << VERSION_GIT_SHORTHASH;
+ return ss.str();
+}