summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt13
-rwxr-xr-xcheck.py15
-rw-r--r--src/support/command-line.cpp2
3 files changed, 22 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index afd700c41..8fc8e15ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,17 +15,16 @@ option(BYN_ENABLE_ASSERTIONS "Enable assertions" ON)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
find_package(Git QUIET REQUIRED)
execute_process(COMMAND
- "${GIT_EXECUTABLE}" --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git describe --tags
+ "${GIT_EXECUTABLE}" --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git describe --tags --match version_*
RESULT_VARIABLE
- GIT_HASH_RESULT
+ GIT_VERSION_RESULT
OUTPUT_VARIABLE
- GIT_HASH
+ GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(${GIT_HASH_RESULT})
- message(WARNING "Error running git describe to determine version")
- set(CMAKE_PROJECT_VERSION "(unable to determine version)")
+ if(${GIT_VERSION_RESULT})
+ message(FATAL_ERROR "Error running git describe to determine version")
else()
- set(CMAKE_PROJECT_VERSION "${GIT_HASH}")
+ set(CMAKE_PROJECT_VERSION "${CMAKE_PROJECT_VERSION} (${GIT_VERSION})")
endif()
endif()
diff --git a/check.py b/check.py
index f4d6bed7e..6703a9c8f 100755
--- a/check.py
+++ b/check.py
@@ -35,6 +35,16 @@ if shared.options.interpreter:
assert os.path.exists(shared.options.interpreter), 'interpreter not found'
+def get_changelog_version():
+ with open(os.path.join(shared.options.binaryen_root, 'CHANGELOG.md')) as f:
+ lines = f.readlines()
+ lines = [l for l in lines if len(l.split()) == 1]
+ lines = [l for l in lines if l.startswith('v')]
+ version = lines[0][1:]
+ print("Parsed CHANGELOG.md version: %s" % version)
+ return int(version)
+
+
def run_help_tests():
print('[ checking --help is useful... ]\n')
@@ -56,6 +66,7 @@ def run_help_tests():
assert len(out.split('\n')) > 8, 'Expected some help, got:\n%s' % out
print('[ checking --version ... ]\n')
+ changelog_version = get_changelog_version()
for e in executables:
print('.. %s --version' % e)
out, err = subprocess.Popen([e, '--version'],
@@ -66,6 +77,10 @@ def run_help_tests():
assert len(err) == 0, 'Expected no stderr, got:\n%s' % err
assert os.path.basename(e).replace('.exe', '') in out, 'Expected version to contain program name, got:\n%s' % out
assert len(out.strip().splitlines()) == 1, 'Expected only version info, got:\n%s' % out
+ parts = out.split()
+ assert parts[1] == 'version'
+ version = int(parts[2])
+ assert version == changelog_version
def run_wasm_opt_tests():
diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp
index e6cd352bb..e4dff8aad 100644
--- a/src/support/command-line.cpp
+++ b/src/support/command-line.cpp
@@ -58,7 +58,7 @@ Options::Options(const std::string& command, const std::string& description)
"Output version information and exit",
Arguments::Zero,
[command](Options*, const std::string&) {
- std::cout << command << " " << CMAKE_PROJECT_VERSION << "\n";
+ std::cout << command << " version " << CMAKE_PROJECT_VERSION << "\n";
exit(0);
});
add("--help",