diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-02-08 13:26:23 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-02-08 19:07:16 +0100 |
commit | bb931505c5f11c21a31cdd7be6fe036ca44e729d (patch) | |
tree | e0310f3a4965dbe364639efb610d96eeca49ee19 | |
parent | f5b86c0f11bc921647d1f677b62a14527bfb50c3 (diff) | |
download | qtlocation-mapboxgl-bb931505c5f11c21a31cdd7be6fe036ca44e729d.tar.gz |
[build] Remove Mason submodule in favor of CMake mason
-rw-r--r-- | .gitmodules | 5 | ||||
m--------- | .mason | 0 | ||||
-rw-r--r-- | .travis.yml | 6 | ||||
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | Makefile | 85 | ||||
-rw-r--r-- | cmake/mason.cmake | 212 | ||||
-rw-r--r-- | cmake/mbgl.cmake | 8 | ||||
-rw-r--r-- | platform/android/config.cmake | 11 | ||||
-rwxr-xr-x | platform/android/scripts/debug.sh | 24 | ||||
-rwxr-xr-x | platform/android/scripts/toolchain.sh | 23 | ||||
-rw-r--r-- | platform/linux/config.cmake | 6 | ||||
-rwxr-xr-x | platform/linux/scripts/coveralls.sh | 5 | ||||
-rw-r--r-- | platform/macos/config.cmake | 4 | ||||
-rw-r--r-- | platform/qt/config.cmake | 2 | ||||
-rwxr-xr-x | scripts/clang-tools.sh | 6 | ||||
-rwxr-xr-x | scripts/mason.sh | 3 | ||||
-rwxr-xr-x | scripts/travis_setup.sh | 14 | ||||
-rwxr-xr-x | scripts/valgrind.sh | 6 |
18 files changed, 294 insertions, 134 deletions
diff --git a/.gitmodules b/.gitmodules index fbdee10efc..72cbe56da7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,11 +1,6 @@ -[submodule ".mason"] - path = .mason - url = https://github.com/mapbox/mason.git - [submodule "platform/ios/vendor/SMCalloutView"] path = platform/ios/vendor/SMCalloutView url = https://github.com/nfarina/calloutview.git - [submodule "platform/ios/uitest/KIF"] path = platform/ios/uitest/KIF url = https://github.com/kif-framework/KIF.git diff --git a/.mason b/.mason deleted file mode 160000 -Subproject 3c5372c645fded4b122d879f499a7ab355b2daf diff --git a/.travis.yml b/.travis.yml index a328c7d43c..30c3fa6be6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -96,8 +96,7 @@ matrix: - nvm install 4 - nvm use 4 - make node - - mason install apitrace 6a30de1 - - $(mason prefix apitrace 6a30de1)/bin/apitrace trace --api=egl -v make test-node + - $(scripts/mason.sh PREFIX apitrace VERSION 6a30de1)/bin/apitrace trace --api=egl -v make test-node after_script: - ccache --show-stats - ./platform/node/scripts/after_script.sh ${TRAVIS_JOB_NUMBER} @@ -123,8 +122,7 @@ matrix: - nvm install 4 - nvm use 4 - make node - - mason install apitrace 6a30de1 - - $(mason prefix apitrace 6a30de1)/bin/apitrace trace --api=egl -v make test-node + - $(scripts/mason.sh PREFIX apitrace VERSION 6a30de1)/bin/apitrace trace --api=egl -v make test-node after_script: - ccache --show-stats - ./platform/node/scripts/after_script.sh ${TRAVIS_JOB_NUMBER} diff --git a/CMakeLists.txt b/CMakeLists.txt index 48c62007ee..6ca19d3e41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(mbgl LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 14) include(cmake/mbgl.cmake) -include(.mason/mason.cmake) +include(cmake/mason.cmake) option(WITH_CXX11ABI "Use cxx11abi mason packages" OFF) option(WITH_COVERAGE "Enable coverage reports" OFF) @@ -41,12 +41,12 @@ set_source_files_properties(src/mbgl/util/version.cpp PROPERTIES COMPILE_DEFINIT 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) +mason_use(unique_resource VERSION cba309e HEADER_ONLY) mason_use(rapidjson VERSION 1.1.0 HEADER_ONLY) mason_use(boost VERSION 1.62.0 HEADER_ONLY) mason_use(geojsonvt VERSION 6.1.3 HEADER_ONLY) -mason_use(supercluster VERSION 0.2.0 HEADER_ONLY) -mason_use(kdbush VERSION 0.1.1 HEADER_ONLY) +mason_use(supercluster VERSION 0.2.0-1 HEADER_ONLY) +mason_use(kdbush VERSION 0.1.1-1 HEADER_ONLY) mason_use(earcut VERSION 0.12.1 HEADER_ONLY) mason_use(protozero VERSION 1.4.2 HEADER_ONLY) mason_use(pixelmatch VERSION 0.10.0 HEADER_ONLY) @@ -32,6 +32,10 @@ else BUILD_PLATFORM_VERSION = $(MASON_PLATFORM_VERSION) endif +ifeq ($(MASON_PLATFORM),macos) + MASON_PLATFORM=osx +endif + ifeq ($(V), 1) export XCPRETTY NINJA_ARGS ?= -v @@ -43,18 +47,10 @@ endif .PHONY: default default: test -ifneq (,$(wildcard .git/.)) -.mason/mason: - git submodule update --init -else -.mason/mason: ; -endif - .NOTPARALLEL: node_modules node_modules: package.json npm install --ignore-scripts # Install dependencies but don't run our own install script. -BUILD_DEPS += .mason/mason BUILD_DEPS += Makefile BUILD_DEPS += node_modules BUILD_DEPS += CMakeLists.txt @@ -190,17 +186,12 @@ $(MACOS_COMPDB_PATH)/Makefile: compdb: $(BUILD_DEPS) $(TEST_DEPS) $(MACOS_COMPDB_PATH)/Makefile @$(MAKE) -C $(MACOS_COMPDB_PATH) cmake_check_build_system -.PHONY: clang-tools -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 - .PHONY: tidy -tidy: clang-tools +tidy: compdb scripts/clang-tools.sh $(MACOS_COMPDB_PATH) .PHONY: check -check: clang-tools +check: compdb scripts/clang-tools.sh $(MACOS_COMPDB_PATH) --diff endif @@ -225,7 +216,9 @@ $(IOS_PROJ_PATH): $(IOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings $(BUILD_DEP mkdir -p $(IOS_OUTPUT_PATH) (cd $(IOS_OUTPUT_PATH) && cmake -G Xcode ../.. \ -DCMAKE_TOOLCHAIN_FILE=../../platform/ios/toolchain.cmake \ - -DMBGL_PLATFORM=ios) + -DMBGL_PLATFORM=ios \ + -DMASON_PLATFORM=ios \ + -DMASON_PLATFORM_VERSION=8.0) $(IOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings: platform/ios/WorkspaceSettings.xcsettings mkdir -p "$(IOS_USER_DATA_PATH)" @@ -361,17 +354,12 @@ node: $(LINUX_BUILD) compdb: $(LINUX_BUILD) # Ninja generator already outputs the file at the right location -.PHONY: clang-tools -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 - .PHONY: tidy -tidy: clang-tools +tidy: compdb scripts/clang-tools.sh $(LINUX_OUTPUT_PATH) .PHONY: check -check: clang-tools +check: compdb scripts/clang-tools.sh $(LINUX_OUTPUT_PATH) --diff endif @@ -397,8 +385,8 @@ $(QT_BUILD): $(BUILD_DEPS) -DCMAKE_BUILD_TYPE=$(BUILDTYPE) \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DMBGL_PLATFORM=qt \ - -DMASON_PLATFORM=$(BUILD_PLATFORM) \ - -DMASON_PLATFORM_VERSION=$(BUILD_PLATFORM_VERSION) \ + -DMASON_PLATFORM=$(MASON_PLATFORM) \ + -DMASON_PLATFORM_VERSION=$(MASON_PLATFORM_VERSION) \ -DWITH_QT_DECODERS=${WITH_QT_DECODERS} \ -DWITH_QT_I18N=${WITH_QT_I18N} \ -DWITH_QT_4=${WITH_QT_4} \ @@ -413,8 +401,8 @@ $(MACOS_QT_PROJ_PATH): $(BUILD_DEPS) mkdir -p $(QT_ROOT_PATH)/xcode (cd $(QT_ROOT_PATH)/xcode && cmake -G Xcode ../../.. \ -DMBGL_PLATFORM=qt \ - -DMASON_PLATFORM=$(BUILD_PLATFORM) \ - -DMASON_PLATFORM_VERSION=$(BUILD_PLATFORM_VERSION) \ + -DMASON_PLATFORM=$(MASON_PLATFORM) \ + -DMASON_PLATFORM_VERSION=$(MASON_PLATFORM_VERSION) \ -DWITH_QT_DECODERS=${WITH_QT_DECODERS} \ -DWITH_QT_I18N=${WITH_QT_I18N} \ -DWITH_QT_4=${WITH_QT_4} \ @@ -480,11 +468,10 @@ test-node: node #### Android targets ########################################################### -MBGL_ANDROID_ENV = platform/android/scripts/toolchain.sh -MBGL_ANDROID_ABIS = arm-v5 arm-v7 arm-v8 x86 x86-64 mips +MBGL_ANDROID_ABIS = arm-v5-9 arm-v7-9 arm-v8-21 x86-9 x86-64-21 mips-9 MBGL_ANDROID_LOCAL_WORK_DIR = /data/local/tmp/core-tests -MBGL_ANDROID_LIBDIR = lib$(if $(filter arm-v8 x86-64,$1),64) -MBGL_ANDROID_DALVIKVM = dalvikvm$(if $(filter arm-v8 x86-64,$1),64,32) +MBGL_ANDROID_LIBDIR = lib$(if $(filter arm-v8-21 x86-64-21,$1),64) +MBGL_ANDROID_DALVIKVM = dalvikvm$(if $(filter arm-v8-21 x86-64-21,$1),64,32) MBGL_ANDROID_APK_SUFFIX = $(if $(filter Release,$(BUILDTYPE)),release-unsigned,debug) MBGL_ANDROID_CORE_TEST_DIR = build/android-$1/$(BUILDTYPE)/core-tests @@ -495,25 +482,24 @@ style-code: android-style-code define ANDROID_RULES -build/android-$1/$(BUILDTYPE): $(BUILD_DEPS) - mkdir -p build/android-$1/$(BUILDTYPE) - -build/android-$1/$(BUILDTYPE)/toolchain.cmake: platform/android/scripts/toolchain.sh build/android-$1/$(BUILDTYPE) - $(MBGL_ANDROID_ENV) $1 > build/android-$1/$(BUILDTYPE)/toolchain.cmake - -build/android-$1/$(BUILDTYPE)/Makefile: build/android-$1/$(BUILDTYPE)/toolchain.cmake platform/android/config.cmake +build/android-$1/$(BUILDTYPE)/build.ninja: $(BUILD_DEPS) platform/android/config.cmake + @mkdir -p build/android-$1/$(BUILDTYPE) + export MASON_XC_ROOT=`scripts/mason.sh PREFIX android-ndk VERSION $1-r13b` && \ cd build/android-$1/$(BUILDTYPE) && cmake ../../.. -G Ninja \ - -DCMAKE_TOOLCHAIN_FILE=build/android-$1/$(BUILDTYPE)/toolchain.cmake \ + -DMASON_XC_ROOT="$$$${MASON_XC_ROOT}" \ + -DCMAKE_TOOLCHAIN_FILE="$$$${MASON_XC_ROOT}/toolchain.cmake" \ -DCMAKE_BUILD_TYPE=$(BUILDTYPE) \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DMBGL_PLATFORM=android + -DMBGL_PLATFORM=android \ + -DMASON_PLATFORM=android \ + -DMASON_PLATFORM_VERSION=$1 .PHONY: android-test-lib-$1 -android-test-lib-$1: build/android-$1/$(BUILDTYPE)/Makefile +android-test-lib-$1: build/android-$1/$(BUILDTYPE)/build.ninja $(NINJA) $(NINJA_ARGS) -j$(JOBS) -C build/android-$1/$(BUILDTYPE) mbgl-test .PHONY: android-lib-$1 -android-lib-$1: build/android-$1/$(BUILDTYPE)/Makefile +android-lib-$1: build/android-$1/$(BUILDTYPE)/build.ninja $(NINJA) $(NINJA_ARGS) -j$(JOBS) -C build/android-$1/$(BUILDTYPE) mapbox-gl example-custom-layer .PHONY: android-$1 @@ -570,11 +556,20 @@ endef $(foreach abi,$(MBGL_ANDROID_ABIS),$(eval $(call ANDROID_RULES,$(abi)))) +# Backwards compatibility +%-arm-v5: %-arm-v5-9 ; +%-arm-v7: %-arm-v7-9 ; +%-arm-v8: %-arm-v8-21 ; +%-mips: %-mips-9 ; +%-mips-64: %-mips-64-21 ; +%-x86: %-x86-9 ; +%-x86-64: %-x86-64-21 ; + .PHONY: android -android: android-arm-v7 +android: android-arm-v7-9 .PHONY: run-android -run-android: run-android-arm-v7 +run-android: run-android-arm-v7-9 .PHONY: run-android-unit-test run-android-unit-test: @@ -616,7 +611,7 @@ test-code-android: .PHONY: android-ndk-stack android-ndk-stack: - adb logcat | ndk-stack -sym build/android-arm-v7/Debug + adb logcat | ndk-stack -sym build/android-arm-v7-9/Debug .PHONY: android-checkstyle android-checkstyle: diff --git a/cmake/mason.cmake b/cmake/mason.cmake new file mode 100644 index 0000000000..4e4e46b619 --- /dev/null +++ b/cmake/mason.cmake @@ -0,0 +1,212 @@ +# Mason CMake + +include(CMakeParseArguments) + +function(mason_detect_platform) + # Determine platform + if(NOT MASON_PLATFORM) + # we call uname -s manually here since + # CMAKE_HOST_SYSTEM_NAME will not be defined before the project() call + execute_process( + COMMAND uname -s + OUTPUT_VARIABLE UNAME + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (UNAME STREQUAL "Darwin") + set(MASON_PLATFORM "osx" PARENT_SCOPE) + else() + set(MASON_PLATFORM "linux" PARENT_SCOPE) + endif() + endif() + + # Determine platform version string + if(NOT MASON_PLATFORM_VERSION) + execute_process( + COMMAND uname -m + OUTPUT_VARIABLE MASON_PLATFORM_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(MASON_PLATFORM_VERSION "${MASON_PLATFORM_VERSION}" PARENT_SCOPE) + endif() +endfunction() + +function(mason_use _PACKAGE) + if(NOT _PACKAGE) + message(FATAL_ERROR "[Mason] No package name given") + endif() + + cmake_parse_arguments("" "HEADER_ONLY" "VERSION" "" ${ARGN}) + + if(_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "[Mason] mason_use() called with unrecognized arguments: ${_UNPARSED_ARGUMENTS}") + endif() + + if(NOT _VERSION) + message(FATAL_ERROR "[Mason] Specifying a version is required") + endif() + + if(MASON_PACKAGE_${_PACKAGE}_INVOCATION STREQUAL "${MASON_INVOCATION}") + # Check that the previous invocation of mason_use didn't select another version of this package + if(NOT MASON_PACKAGE_${_PACKAGE}_VERSION STREQUAL ${_VERSION}) + message(FATAL_ERROR "[Mason] Already using ${_PACKAGE} ${MASON_PACKAGE_${_PACKAGE}_VERSION}. Cannot select version ${_VERSION}.") + endif() + else() + if(_HEADER_ONLY) + set(_PLATFORM_ID "headers") + else() + set(_PLATFORM_ID "${MASON_PLATFORM}-${MASON_PLATFORM_VERSION}") + endif() + + set(_SLUG "${_PLATFORM_ID}/${_PACKAGE}/${_VERSION}") + set(_INSTALL_PATH "${MASON_PACKAGE_DIR}/${_SLUG}") + file(RELATIVE_PATH _INSTALL_PATH_RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${_INSTALL_PATH}") + + if(NOT EXISTS "${_INSTALL_PATH}") + set(_CACHE_PATH "${MASON_PACKAGE_DIR}/.binaries/${_SLUG}.tar.gz") + if (NOT EXISTS "${_CACHE_PATH}") + # Download the package + set(_URL "${MASON_REPOSITORY}/${_SLUG}.tar.gz") + message("[Mason] Downloading package ${_URL}...") + + set(_FAILED) + set(_ERROR) + # Note: some CMake versions are compiled without SSL support + get_filename_component(_CACHE_DIR "${_CACHE_PATH}" DIRECTORY) + file(MAKE_DIRECTORY "${_CACHE_DIR}") + execute_process( + COMMAND curl --retry 3 -s -f -S -L "${_URL}" -o "${_CACHE_PATH}.tmp" + RESULT_VARIABLE _FAILED + ERROR_VARIABLE _ERROR) + if(_FAILED) + message(FATAL_ERROR "[Mason] Failed to download ${_URL}: ${_ERROR}") + else() + # We downloaded to a temporary file to prevent half-finished downloads + file(RENAME "${_CACHE_PATH}.tmp" "${_CACHE_PATH}") + endif() + endif() + + # Unpack the package + message("[Mason] Unpacking package to ${_INSTALL_PATH_RELATIVE}...") + file(MAKE_DIRECTORY "${_INSTALL_PATH}") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf "${_CACHE_PATH}" + WORKING_DIRECTORY "${_INSTALL_PATH}") + endif() + + # Error out if there is no config file. + if(NOT EXISTS "${_INSTALL_PATH}/mason.ini") + message(FATAL_ERROR "[Mason] Could not find mason.ini for package ${_PACKAGE} ${_VERSION}") + endif() + + set(MASON_PACKAGE_${_PACKAGE}_PREFIX "${_INSTALL_PATH}" CACHE STRING "${_PACKAGE} ${_INSTALL_PATH}" FORCE) + mark_as_advanced(MASON_PACKAGE_${_PACKAGE}_PREFIX) + + # Load the configuration from the ini file + file(STRINGS "${_INSTALL_PATH}/mason.ini" _CONFIG_FILE) + foreach(_LINE IN LISTS _CONFIG_FILE) + string(REGEX MATCH "^([a-z_]+) *= *" _KEY "${_LINE}") + if (_KEY) + string(LENGTH "${_KEY}" _KEY_LENGTH) + string(SUBSTRING "${_LINE}" ${_KEY_LENGTH} -1 _VALUE) + string(REGEX REPLACE ";.*$" "" _VALUE "${_VALUE}") # Trim trailing commas + string(REPLACE "{prefix}" "${_INSTALL_PATH}" _VALUE "${_VALUE}") + string(STRIP "${_VALUE}" _VALUE) + string(REPLACE "=" "" _KEY "${_KEY}") + string(STRIP "${_KEY}" _KEY) + string(TOUPPER "${_KEY}" _KEY) + if(_KEY STREQUAL "INCLUDE_DIRS" OR _KEY STREQUAL "STATIC_LIBS" ) + separate_arguments(_VALUE) + endif() + set(MASON_PACKAGE_${_PACKAGE}_${_KEY} "${_VALUE}" CACHE STRING "${_PACKAGE} ${_KEY}" FORCE) + mark_as_advanced(MASON_PACKAGE_${_PACKAGE}_${_KEY}) + endif() + endforeach() + + # Compare version in the package to catch errors early on + if(NOT _VERSION STREQUAL MASON_PACKAGE_${_PACKAGE}_VERSION) + message(FATAL_ERROR "[Mason] Package at ${_INSTALL_PATH_RELATIVE} has version '${MASON_PACKAGE_${_PACKAGE}_VERSION}', but required '${_VERSION}'") + endif() + + if(NOT _PACKAGE STREQUAL MASON_PACKAGE_${_PACKAGE}_NAME) + message(FATAL_ERROR "[Mason] Package at ${_INSTALL_PATH_RELATIVE} has name '${MASON_PACKAGE_${_PACKAGE}_NAME}', but required '${_NAME}'") + endif() + + if(NOT _HEADER_ONLY) + if(NOT MASON_PLATFORM STREQUAL MASON_PACKAGE_${_PACKAGE}_PLATFORM) + message(FATAL_ERROR "[Mason] Package at ${_INSTALL_PATH_RELATIVE} has platform '${MASON_PACKAGE_${_PACKAGE}_PLATFORM}', but required '${MASON_PLATFORM}'") + endif() + + if(NOT MASON_PLATFORM_VERSION STREQUAL MASON_PACKAGE_${_PACKAGE}_PLATFORM_VERSION) + message(FATAL_ERROR "[Mason] Package at ${_INSTALL_PATH_RELATIVE} has platform version '${MASON_PACKAGE_${_PACKAGE}_PLATFORM_VERSION}', but required '${MASON_PLATFORM_VERSION}'") + endif() + endif() + + # Concatenate the static libs and libraries + set(_LIBRARIES) + list(APPEND _LIBRARIES ${MASON_PACKAGE_${_PACKAGE}_STATIC_LIBS} ${MASON_PACKAGE_${_PACKAGE}_LDFLAGS}) + set(MASON_PACKAGE_${_PACKAGE}_LIBRARIES "${_LIBRARIES}" CACHE STRING "${_PACKAGE} _LIBRARIES" FORCE) + mark_as_advanced(MASON_PACKAGE_${_PACKAGE}_LIBRARIES) + + if(NOT _HEADER_ONLY) + string(REGEX MATCHALL "(^| +)-L *([^ ]+)" MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS "${MASON_PACKAGE_${_PACKAGE}_LDFLAGS}") + string(REGEX REPLACE "(^| +)-L *" "\\1" MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS "${MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS}") + set(MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS "${MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS}" CACHE STRING "${_PACKAGE} ${MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS}" FORCE) + mark_as_advanced(MASON_PACKAGE_${_PACKAGE}_LIBRARY_DIRS) + endif() + + # Store invocation ID to prevent different versions of the same package in one invocation + set(MASON_PACKAGE_${_PACKAGE}_INVOCATION "${MASON_INVOCATION}" CACHE INTERNAL "${_PACKAGE} invocation ID" FORCE) + endif() +endfunction() + +macro(target_add_mason_package _TARGET _VISIBILITY _PACKAGE) + if (NOT MASON_PACKAGE_${_PACKAGE}_INVOCATION) + message(FATAL_ERROR "[Mason] Package ${_PACKAGE} has not been initialized yet") + endif() + + target_include_directories(${_TARGET} ${_VISIBILITY} "${MASON_PACKAGE_${_PACKAGE}_INCLUDE_DIRS}") + target_compile_definitions(${_TARGET} ${_VISIBILITY} "${MASON_PACKAGE_${_PACKAGE}_DEFINITIONS}") + target_compile_options(${_TARGET} ${_VISIBILITY} "${MASON_PACKAGE_${_PACKAGE}_OPTIONS}") + target_link_libraries(${_TARGET} ${_VISIBILITY} "${MASON_PACKAGE_${_PACKAGE}_LIBRARIES}") +endmacro() + +# Setup + +string(RANDOM LENGTH 16 MASON_INVOCATION) + +# Read environment variables if CMake is run in command mode +if (CMAKE_ARGC) + set(MASON_PLATFORM "$ENV{MASON_PLATFORM}") + set(MASON_PLATFORM_VERSION "$ENV{MASON_PLATFORM_VERSION}") + set(MASON_PACKAGE_DIR "$ENV{MASON_PACKAGE_DIR}") + set(MASON_REPOSITORY "$ENV{MASON_REPOSITORY}") +endif() + +# Directory where Mason packages are located; typically ends with mason_packages +if (NOT MASON_PACKAGE_DIR) + set(MASON_PACKAGE_DIR "${CMAKE_SOURCE_DIR}/mason_packages") +endif() + +# URL prefix of where packages are located. +if (NOT MASON_REPOSITORY) + set(MASON_REPOSITORY "https://mason-binaries.s3.amazonaws.com") +endif() + +mason_detect_platform() + +# Execute commands if CMake is run in command mode +if (CMAKE_ARGC) + # Collect remaining arguments for passing to mason_use + set(_MASON_ARGS) + foreach(I RANGE 4 ${CMAKE_ARGC}) + list(APPEND _MASON_ARGS "${CMAKE_ARGV${I}}") + endforeach() + + # Install the package + mason_use(${_MASON_ARGS}) + + # Optionally print variables + if(DEFINED MASON_PACKAGE_${CMAKE_ARGV4}_${CMAKE_ARGV3}) + # CMake can't write to stdout with message() + execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${MASON_PACKAGE_${CMAKE_ARGV4}_${CMAKE_ARGV3}}") + endif() +endif() diff --git a/cmake/mbgl.cmake b/cmake/mbgl.cmake index ca0487ef34..813e4ba071 100644 --- a/cmake/mbgl.cmake +++ b/cmake/mbgl.cmake @@ -6,10 +6,6 @@ if (NOT MBGL_PLATFORM) endif() endif() -if (NOT MASON_PLATFORM) - set(MASON_PLATFORM "${MBGL_PLATFORM}") -endif() - if(NOT EXISTS ${CMAKE_SOURCE_DIR}/node_modules/node-cmake/FindNodeJS.cmake) message(FATAL_ERROR "Can't find node-cmake") endif() @@ -54,7 +50,7 @@ endfunction() # Run submodule update message(STATUS "Updating submodules...") execute_process( - COMMAND git submodule update --init .mason mapbox-gl-js + COMMAND git submodule update --init mapbox-gl-js WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") if(NOT EXISTS "${CMAKE_SOURCE_DIR}/mapbox-gl-js/node_modules") @@ -68,7 +64,7 @@ endif() # Add target for running submodule update during builds add_custom_target( update-submodules ALL - COMMAND git submodule update --init .mason mapbox-gl-js + COMMAND git submodule update --init mapbox-gl-js WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMENT "Updating submodules..." ) diff --git a/platform/android/config.cmake b/platform/android/config.cmake index 9d8858ac0d..cfd6a3cdb5 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -2,9 +2,6 @@ add_definitions(-DMBGL_USE_GLES2=1) include(cmake/test-files.cmake) -#Include to use build specific variables -include(${CMAKE_CURRENT_BINARY_DIR}/toolchain.cmake) - # Build thin archives. set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>") @@ -18,17 +15,17 @@ if ((ANDROID_ABI STREQUAL "armeabi") OR (ANDROID_ABI STREQUAL "armeabi-v7a") OR set(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=gold -Wl,--icf=safe ${CMAKE_SHARED_LINKER_FLAGS}") endif() -mason_use(jni.hpp VERSION 2.0.0 HEADER_ONLY) +mason_use(jni.hpp VERSION 2.0.0-1 HEADER_ONLY) mason_use(libzip VERSION 1.1.3) mason_use(nunicode VERSION 1.7.1) mason_use(sqlite VERSION 3.14.2) -mason_use(gtest VERSION 1.7.0) +mason_use(gtest VERSION 1.8.0) mason_use(icu VERSION 58.1) set(ANDROID_SDK_PROJECT_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDK) -set(ANDROID_JNI_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/jniLibs/${ANDROID_JNIDIR}) +set(ANDROID_JNI_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/jniLibs/${ANDROID_ABI}) set(ANDROID_ASSETS_TARGET_DIR ${ANDROID_SDK_PROJECT_DIR}/src/main/assets) -set(ANDROID_TEST_APP_JNI_TARGET_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDKTestApp/src/main/jniLibs/${ANDROID_JNIDIR}) +set(ANDROID_TEST_APP_JNI_TARGET_DIR ${CMAKE_SOURCE_DIR}/platform/android/MapboxGLAndroidSDKTestApp/src/main/jniLibs/${ANDROID_ABI}) ## mbgl core ## diff --git a/platform/android/scripts/debug.sh b/platform/android/scripts/debug.sh index efed96969a..c3390b4ce1 100755 --- a/platform/android/scripts/debug.sh +++ b/platform/android/scripts/debug.sh @@ -5,13 +5,12 @@ set -o pipefail # Automation of https://github.com/mapbox/mapbox-gl-native/wiki/Android-debugging-with-remote-GDB -export MASON_DIR="`pwd`/.mason" -export PATH="${MASON_DIR}:${PATH}" - -export MASON_ANDROID_ABI=x86 export MASON_ANDROID_ARCH=x86 export MASON_ANDROID_PLATFORM=9 -export MASON_NDK_PACKAGE_VERSION=${MASON_ANDROID_ARCH}-${MASON_ANDROID_PLATFORM}-r12b +export MASON_ANDROID_NDK_VERSION=r13b + +export MASON_XC_ROOT=`scripts/mason.sh PREFIX android-ndk VERSION ${MASON_ANDROID_ARCH}-${MASON_ANDROID_PLATFORM}-${MASON_ANDROID_NDK_VERSION}` +source ${MASON_XC_ROOT}/toolchain.sh if [[ $1 == '--prepare' ]]; then mkdir -p ~/.android/debugging/{vendor,system}_lib @@ -21,16 +20,16 @@ if [[ $1 == '--prepare' ]]; then adb pull /system/bin/app_process32 ~/.android/debugging adb pull /system/bin/linker ~/.android/debugging - if [[ ${MASON_ANDROID_ABI} == 'x86_64' || ${MASON_ANDROID_ABI} == 'mips64' ]]; then + if [[ ${MASON_ANDROID_ARCH} == 'arm-v8' || ${MASON_ANDROID_ARCH} == 'x86-64' || ${MASON_ANDROID_ARCH} == 'mips-64' ]]; then adb pull /system/bin/app_process64 ~/.android/debugging adb pull /system/bin/linker64 ~/.android/debugging fi - cp `mason prefix android-ndk ${MASON_NDK_PACKAGE_VERSION}`/prebuilt/android-${MASON_ANDROID_ABI}/gdbserver/gdbserver \ - platform/android/MapboxGLAndroidSDK/src/main/jniLibs/${MASON_ANDROID_ABI}/gdbserver.so + cp ${MASON_XC_ROOT}/prebuilt/gdbserver/gdbserver \ + platform/android/MapboxGLAndroidSDK/src/main/jniLibs/${ANDROID_ABI}/gdbserver.so fi -adb install -rtdg platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug.apk +adb install -r -t -d -g platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug.apk adb shell am start -n "com.mapbox.mapboxsdk.testapp/com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity" \ -a android.intent.action.MAIN -c android.intent.category.LAUNCHER @@ -38,9 +37,6 @@ adb forward tcp:5039 tcp:5039 adb shell run-as com.mapbox.mapboxsdk.testapp '/data/data/com.mapbox.mapboxsdk.testapp/lib/gdbserver.so \ --attach :5039 `pgrep com.mapbox.mapboxsdk.testapp`' & -export MASON_PLATFORM=android -export PATH=`mason env PATH` -`mason env MASON_ANDROID_TOOLCHAIN`-gdb \ +${MASON_XC_ROOT}/bin/gdb \ -ex "target remote :5039" \ - -ex "set solib-search-path ~/.android/debugging:~/.android/debugging/system_lib:~/.android/debugging/vendor_lib:~/.android/debugging/vendor_lib/egl:./build/android-${MASON_ANDROID_ABI}/Debug/lib.target/" - + -ex "set solib-search-path ~/.android/debugging:~/.android/debugging/system_lib:~/.android/debugging/vendor_lib:~/.android/debugging/vendor_lib/egl:./build/android-${MASON_ANDROID_ARCH}-${MASON_ANDROID_PLATFORM}/Debug/lib.target/" diff --git a/platform/android/scripts/toolchain.sh b/platform/android/scripts/toolchain.sh deleted file mode 100755 index a64818dd20..0000000000 --- a/platform/android/scripts/toolchain.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -export MASON_PLATFORM=android -export MASON_ANDROID_ABI=${1:-arm-v7} -export PATH="`pwd`/.mason:${PATH}" -export MASON_DIR="`pwd`/.mason" - -export PATH=`mason env PATH` - -echo "set(CMAKE_SYSTEM_NAME Android)" -echo "set(CMAKE_SYSTEM_VERSION 1)" -echo "set(CMAKE_CXX_COMPILER \"`which $(mason env CXX)`\")" -echo "set(CMAKE_C_COMPILER \"`which $(mason env CC)`\")" -echo "set(ANDROID_JNIDIR \"`mason env JNIDIR`\")" -echo "set(ANDROID_ABI \"\${ANDROID_JNIDIR}\")" -echo "set(CMAKE_EXE_LINKER_FLAGS \"`mason env LDFLAGS` \${CMAKE_EXE_LINKER_FLAGS}\")" -echo "set(CMAKE_SHARED_LINKER_FLAGS \"`mason env LDFLAGS` \${CMAKE_SHARED_LINKER_FLAGS}\")" -echo "set(CMAKE_CXX_FLAGS \"`mason env CXXFLAGS` \${CMAKE_CXX_FLAGS}\")" -echo "set(CMAKE_C_FLAGS \"`mason env CPPFLAGS` \${CMAKE_C_FLAGS}\")" -echo "set(STRIP_COMMAND \"`which $(mason env STRIP)`\")" diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake index ac1a195822..7f32622596 100644 --- a/platform/linux/config.cmake +++ b/platform/linux/config.cmake @@ -1,5 +1,5 @@ mason_use(glfw VERSION 3.2.1) -mason_use(mesa VERSION 13.0.3) +mason_use(mesa VERSION 13.0.4) mason_use(boost_libprogram_options VERSION 1.62.0${MASON_CXXABI_SUFFIX}) mason_use(sqlite VERSION 3.14.2) mason_use(libuv VERSION 1.9.1) @@ -7,8 +7,8 @@ mason_use(nunicode VERSION 1.7.1) mason_use(libpng VERSION 1.6.25) mason_use(libjpeg-turbo VERSION 1.5.0) mason_use(webp VERSION 0.5.1) -mason_use(gtest VERSION 1.7.0${MASON_CXXABI_SUFFIX}) -mason_use(benchmark VERSION 1.0.0) +mason_use(gtest VERSION 1.8.0) +mason_use(benchmark VERSION 1.0.0-1) mason_use(icu VERSION 58.1) include(cmake/loop-uv.cmake) diff --git a/platform/linux/scripts/coveralls.sh b/platform/linux/scripts/coveralls.sh index 8d5903de6c..b8ab73a24e 100755 --- a/platform/linux/scripts/coveralls.sh +++ b/platform/linux/scripts/coveralls.sh @@ -3,12 +3,9 @@ set -e set -o pipefail -mapbox_time "install_lcov" \ -mason install lcov 1.12 - # Collect coverage data and save it into coverage.info mapbox_time "lcov_capture" \ -`mason prefix lcov 1.12`/usr/bin/lcov \ +`scripts/mason.sh PREFIX lcov VERSION 1.12`/usr/bin/lcov \ --quiet \ --capture \ --no-external \ diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake index c8927cec3b..46357d7d73 100644 --- a/platform/macos/config.cmake +++ b/platform/macos/config.cmake @@ -2,8 +2,8 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10) mason_use(glfw VERSION 3.2.1) mason_use(boost_libprogram_options VERSION 1.62.0) -mason_use(gtest VERSION 1.7.0${MASON_CXXABI_SUFFIX}) -mason_use(benchmark VERSION 1.0.0) +mason_use(gtest VERSION 1.8.0) +mason_use(benchmark VERSION 1.0.0-1) mason_use(icu VERSION 58.1) include(cmake/loop-darwin.cmake) diff --git a/platform/qt/config.cmake b/platform/qt/config.cmake index 50e374174b..fe5c45b479 100644 --- a/platform/qt/config.cmake +++ b/platform/qt/config.cmake @@ -1,7 +1,7 @@ include(platform/qt/qt.cmake) mason_use(sqlite VERSION 3.14.2) -mason_use(gtest VERSION 1.7.0${MASON_CXXABI_SUFFIX}) +mason_use(gtest VERSION 1.8.0) if(NOT WITH_QT_DECODERS) mason_use(libjpeg-turbo VERSION 1.5.0) diff --git a/scripts/clang-tools.sh b/scripts/clang-tools.sh index ae3a5fa0e7..2a330a5ee4 100755 --- a/scripts/clang-tools.sh +++ b/scripts/clang-tools.sh @@ -3,10 +3,8 @@ set -e set -o pipefail -export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" - -CLANG_TIDY=${CLANG_TIDY:-$(mason prefix clang-tidy 3.9.1)/bin/clang-tidy} -CLANG_FORMAT=${CLANG_FORMAT:-$(mason prefix clang-format 3.9.1)/bin/clang-format} +CLANG_TIDY=${CLANG_TIDY:-$(scripts/mason.sh PREFIX clang-tidy VERSION 3.9.1)/bin/clang-tidy} +CLANG_FORMAT=${CLANG_FORMAT:-$(scripts/mason.sh PREFIX clang-format VERSION 3.9.1)/bin/clang-format} command -v ${CLANG_TIDY} >/dev/null 2>&1 || { echo "Can't find ${CLANG_TIDY} in PATH." diff --git a/scripts/mason.sh b/scripts/mason.sh new file mode 100755 index 0000000000..696ad26adb --- /dev/null +++ b/scripts/mason.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cmake -P cmake/mason.cmake "$@" diff --git a/scripts/travis_setup.sh b/scripts/travis_setup.sh index cdf36be363..20688ab4ec 100755 --- a/scripts/travis_setup.sh +++ b/scripts/travis_setup.sh @@ -29,12 +29,6 @@ if [ -x $(which ${CXX}) ]; then ${CXX} --version fi -# Ensure mason is on the PATH -export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason" - -mapbox_time "checkout_mason" \ -git submodule update --init .mason - # Touch package.json so that we are definitely going to run an npm update action mapbox_time "touch_package_json" \ touch package.json @@ -58,9 +52,11 @@ export -f mapbox_start_xvfb function mapbox_export_mesa_library_path { # Install and set up to load a more recent version of mesa mapbox_time "install_mesa" \ - mason install mesa 13.0.3 - export LD_LIBRARY_PATH="`mason prefix mesa 13.0.3`/lib:${LD_LIBRARY_PATH:-}" - export LIBGL_DRIVERS_PATH="`mason prefix mesa 13.0.3`/lib/dri" + scripts/mason.sh install mesa VERSION 13.0.4 + + MESA_PREFIX=`scripts/mason.sh PREFIX mesa VERSION 13.0.4` + export LD_LIBRARY_PATH="${MESA_PREFIX}/lib:${LD_LIBRARY_PATH:-}" + export LIBGL_DRIVERS_PATH="${MESA_PREFIX}/lib/dri" } export -f mapbox_export_mesa_library_path diff --git a/scripts/valgrind.sh b/scripts/valgrind.sh index c717fc2cb8..4eeb9c9785 100755 --- a/scripts/valgrind.sh +++ b/scripts/valgrind.sh @@ -3,7 +3,7 @@ set -e set -o pipefail -.mason/mason install valgrind 3.12.0 +VALGRIND_PREFIX=$(scripts/mason.sh PREFIX valgrind VERSION 3.12.0) PARAMS="\ --leak-check=full \ @@ -13,6 +13,6 @@ PARAMS="\ --gen-suppressions=all \ --suppressions=scripts/valgrind.sup" -export VALGRIND_LIB=$(.mason/mason prefix valgrind 3.12.0)/lib/valgrind +export VALGRIND_LIB=${VALGRIND_PREFIX}/lib/valgrind -$(.mason/mason prefix valgrind 3.12.0)/bin/valgrind $PARAMS $@ +${VALGRIND_PREFIX}/bin/valgrind $PARAMS $@ |