diff options
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cmake/core-files.cmake | 3 | ||||
-rw-r--r-- | cmake/core.cmake | 21 | ||||
-rw-r--r-- | cmake/mbgl.cmake | 2 | ||||
-rw-r--r-- | cmake/test.cmake | 1 | ||||
-rw-r--r-- | platform/android/config.cmake | 1 | ||||
-rw-r--r-- | platform/darwin/src/http_file_source.mm | 5 | ||||
-rwxr-xr-x | scripts/build-version.js | 81 | ||||
-rw-r--r-- | src/mbgl/util/version.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/util/version.hpp | 9 | ||||
-rw-r--r-- | src/mbgl/util/version_info.cpp | 14 |
12 files changed, 34 insertions, 126 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a48d544538..48c62007ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,18 @@ if(IS_CI_BUILD) add_compile_options(-DCI_BUILD=1) endif() +if(EXISTS ${CMAKE_SOURCE_DIR}/.git/HEAD) + exec_program( + "git" + ${CMAKE_SOURCE_DIR} + ARGS "rev-parse --short=8 HEAD" + OUTPUT_VARIABLE MBGL_VERSION_REV ) +else() + set(MBGL_VERSION_REV 00000000) +endif() + +set_source_files_properties(src/mbgl/util/version.cpp PROPERTIES COMPILE_DEFINITIONS MBGL_VERSION_REV="${MBGL_VERSION_REV}") + mason_use(geometry VERSION 0.9.0 HEADER_ONLY) mason_use(variant VERSION 1.1.4 HEADER_ONLY) mason_use(unique_resource VERSION dev HEADER_ONLY) @@ -194,7 +194,6 @@ compdb: $(BUILD_DEPS) $(TEST_DEPS) $(MACOS_COMPDB_PATH)/Makefile clang-tools: compdb if test -z $(CLANG_TIDY); then .mason/mason install clang-tidy 3.9.1; fi if test -z $(CLANG_FORMAT); then .mason/mason install clang-format 3.9.1; fi - $(MAKE) -C $(MACOS_COMPDB_PATH) mbgl-headers .PHONY: tidy tidy: clang-tools @@ -366,7 +365,6 @@ compdb: $(LINUX_BUILD) clang-tools: compdb if test -z $(CLANG_TIDY); then .mason/mason install clang-tidy 3.9.1; fi if test -z $(CLANG_FORMAT); then .mason/mason install clang-format 3.9.1; fi - $(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-headers .PHONY: tidy tidy: clang-tools diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index a481249d61..47e486571f 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -519,7 +519,8 @@ set(MBGL_CORE_FILES src/mbgl/util/url.cpp src/mbgl/util/url.hpp src/mbgl/util/utf.hpp - src/mbgl/util/version_info.cpp + src/mbgl/util/version.cpp + src/mbgl/util/version.hpp src/mbgl/util/work_queue.cpp src/mbgl/util/work_queue.hpp src/mbgl/util/work_request.cpp diff --git a/cmake/core.cmake b/cmake/core.cmake index f893e1571e..59de7708b6 100644 --- a/cmake/core.cmake +++ b/cmake/core.cmake @@ -1,27 +1,7 @@ -set(MBGL_VERSION_DEPS package.json) -if(EXISTS ${CMAKE_SOURCE_DIR}/.git/HEAD) - set(MBGL_VERSION_DEPS ${MBGL_VERSION_DEPS} .git/HEAD) -endif() - -add_custom_command( - OUTPUT ${MBGL_GENERATED}/include/mbgl/util/version.hpp - DEPENDS ${MBGL_VERSION_DEPS} - COMMAND ${NodeJS_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/build-version.js ${MBGL_GENERATED} - VERBATIM -) - -add_custom_target(mbgl-headers DEPENDS - ${MBGL_GENERATED}/include/mbgl/util/version.hpp -) - add_library(mbgl-core STATIC ${MBGL_CORE_FILES} ) -add_dependencies(mbgl-core - mbgl-headers -) - target_compile_options(mbgl-core PRIVATE -fPIC PRIVATE -fvisibility-inlines-hidden @@ -30,7 +10,6 @@ target_compile_options(mbgl-core target_include_directories(mbgl-core PUBLIC include PUBLIC src # TODO: make private - PRIVATE ${MBGL_GENERATED}/include ) target_add_mason_package(mbgl-core PUBLIC geometry) diff --git a/cmake/mbgl.cmake b/cmake/mbgl.cmake index 4002257bb4..ca0487ef34 100644 --- a/cmake/mbgl.cmake +++ b/cmake/mbgl.cmake @@ -10,8 +10,6 @@ if (NOT MASON_PLATFORM) set(MASON_PLATFORM "${MBGL_PLATFORM}") endif() -set(MBGL_GENERATED ${CMAKE_BINARY_DIR}/generated/${CMAKE_CFG_INTDIR}) - if(NOT EXISTS ${CMAKE_SOURCE_DIR}/node_modules/node-cmake/FindNodeJS.cmake) message(FATAL_ERROR "Can't find node-cmake") endif() diff --git a/cmake/test.cmake b/cmake/test.cmake index fc7a22874c..2a83a633c0 100644 --- a/cmake/test.cmake +++ b/cmake/test.cmake @@ -14,7 +14,6 @@ target_include_directories(mbgl-test PRIVATE test/include PRIVATE test/src PRIVATE platform/default - PRIVATE ${MBGL_GENERATED}/include ) target_link_libraries(mbgl-test diff --git a/platform/android/config.cmake b/platform/android/config.cmake index 7d554dc786..9d8858ac0d 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -237,7 +237,6 @@ target_include_directories(mbgl-test PRIVATE test/include PRIVATE test/src PRIVATE platform/default - PRIVATE ${MBGL_GENERATED}/include ) target_link_libraries(mbgl-test diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm index f4b2f8af01..649cebb47f 100644 --- a/platform/darwin/src/http_file_source.mm +++ b/platform/darwin/src/http_file_source.mm @@ -4,7 +4,6 @@ #include <mbgl/util/http_header.hpp> #include <mbgl/util/async_task.hpp> - #include <mbgl/util/version.hpp> #import <Foundation/Foundation.h> @@ -133,8 +132,8 @@ NSString *HTTPFileSource::Impl::getUserAgent() const { // Avoid %s here because it inserts hidden bidirectional markers on macOS when the system // language is set to a right-to-left language. - [userAgentComponents addObject:[NSString stringWithFormat:@"MapboxGL/%@ (%@)", - CFSTR(MBGL_VERSION_STRING), CFSTR(MBGL_VERSION_REV)]]; + [userAgentComponents addObject:[NSString stringWithFormat:@"MapboxGL/0.0.0 (%@)", + @(mbgl::version::revision)]]; NSString *systemName = @"Darwin"; #if TARGET_OS_IPHONE diff --git a/scripts/build-version.js b/scripts/build-version.js deleted file mode 100755 index eb8a00f72c..0000000000 --- a/scripts/build-version.js +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env node - -var path = require('path'); -var fs = require('fs'); -var util = require('util'); -var mkdirp = require('mkdirp'); -var execSync = require('child_process').execSync; - -const DEFAULT_TAG = [0, 0, 0]; -const DEFAULT_REV = 'unknown'; - -function is_git_repo() { - try { - execSync('git rev-parse', { stdio: ['ignore', 'ignore', 'ignore'] }); - return true; - } catch(err) { - return false; - } -} - - -function parse_tag(raw_tag) { - return raw_tag.replace(/[^0-9.]/g, '').split('.').map(parseFloat).slice(0, 3); -} - -function parse_rev(raw_rev) { - return raw_rev.substr(0, 8); -} - -var output_dir = process.argv[2]; - -if (!output_dir) { - console.warn('No output directory given.'); - console.warn('Usage: %s [output dir]', path.basename(process.argv[1])); - process.exit(1); -} - -if (is_git_repo()) { - var raw_tag = execSync('git describe --tags --always --abbrev=0').toString().trim(); - var raw_rev = execSync('git rev-parse HEAD').toString().trim(); - - // When they're identical, the "git describe" can't find a tag and reports the rev instead. - if (raw_tag == raw_rev) { - var tag = DEFAULT_TAG - var rev = parse_rev(raw_rev) - } else { - var tag = parse_tag(raw_tag) - var rev = parse_rev(raw_rev) - } -} else { - var tag = DEFAULT_TAG; - var rev = DEFAULT_REV; -} - -console.log('Tag: %d.%d.%d', tag[0], tag[1], tag[2]); -console.log('Rev: %s', rev); - -var header = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n' + - '#pragma once\n' + - '\n' + - '#define MBGL_VERSION 0x' + (tag[0] << 16 | tag[1] << 8 | tag[2]).toString(16) + '\n' + - '#define MBGL_VERSION_STRING "' + tag[0] + '.' + tag[1] + '.' + tag[2] + '"\n' + - '#define MBGL_VERSION_MAJOR ' + tag[0] + '\n' + - '#define MBGL_VERSION_MINOR ' + tag[1] + '\n' + - '#define MBGL_VERSION_PATCH ' + tag[2] + '\n' + - '#define MBGL_VERSION_REV "' + rev + '"\n' + - '\n' + - 'namespace mbgl {\n' + - 'namespace version {\n' + - '\n' + - 'extern const int major, minor, patch;\n' + - 'extern const char *revision;\n' + - 'extern const char *string;\n' + - 'extern const unsigned int number;\n' + - '\n' + - '} // namespace version\n' + - '} // namespace mbgl\n'; - -var header_path = path.join(output_dir, 'include/mbgl/util/version.hpp') -mkdirp.sync(path.dirname(header_path)); -fs.writeFileSync(header_path, header); diff --git a/src/mbgl/util/version.cpp b/src/mbgl/util/version.cpp new file mode 100644 index 0000000000..fcb31f0b71 --- /dev/null +++ b/src/mbgl/util/version.cpp @@ -0,0 +1,9 @@ +#include <mbgl/util/version.hpp> + +namespace mbgl { +namespace version { + +const char* revision = MBGL_VERSION_REV; + +} // namespace version +} // namespace mbgl diff --git a/src/mbgl/util/version.hpp b/src/mbgl/util/version.hpp new file mode 100644 index 0000000000..e652016485 --- /dev/null +++ b/src/mbgl/util/version.hpp @@ -0,0 +1,9 @@ +#pragma once + +namespace mbgl { +namespace version { + +extern const char* revision; + +} // namespace version +} // namespace mbgl diff --git a/src/mbgl/util/version_info.cpp b/src/mbgl/util/version_info.cpp deleted file mode 100644 index f0fb139bca..0000000000 --- a/src/mbgl/util/version_info.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include <mbgl/util/version.hpp> - -namespace mbgl { -namespace version { - -const int major = MBGL_VERSION_MAJOR; -const int minor = MBGL_VERSION_MINOR; -const int patch = MBGL_VERSION_PATCH; -const char *revision = MBGL_VERSION_REV; -const char *string = MBGL_VERSION_STRING; -const unsigned int number = MBGL_VERSION; - -} // namespace version -} // namespace mbgl |