Files
MapLibreParticleLab/Makefile
2020-01-21 17:52:17 +03:00

490 lines
14 KiB
Makefile

export BUILDTYPE ?= Debug
export IS_LOCAL_DEVELOPMENT ?= true
export TARGET_BRANCH ?= master
CMAKE ?= cmake
ifeq ($(BUILDTYPE), Release)
else ifeq ($(BUILDTYPE), RelWithDebInfo)
else ifeq ($(BUILDTYPE), Sanitize)
else ifeq ($(BUILDTYPE), Debug)
else
$(error BUILDTYPE must be Debug, Sanitize, Release or RelWithDebInfo)
endif
buildtype := $(shell echo "$(BUILDTYPE)" | tr "[A-Z]" "[a-z]")
ifeq ($(shell uname -s), Darwin)
HOST_PLATFORM = macos
HOST_PLATFORM_VERSION = $(shell uname -m)
export NINJA = platform/macos/ninja
export JOBS ?= $(shell sysctl -n hw.ncpu)
else ifeq ($(shell uname -s), Linux)
HOST_PLATFORM = linux
HOST_PLATFORM_VERSION = $(shell uname -m)
export NINJA = platform/linux/ninja
export JOBS ?= $(shell grep --count processor /proc/cpuinfo)
else
$(error Cannot determine host platform)
endif
ifeq ($(MASON_PLATFORM),)
BUILD_PLATFORM = $(HOST_PLATFORM)
else
BUILD_PLATFORM = $(MASON_PLATFORM)
endif
ifeq ($(MASON_PLATFORM_VERSION),)
BUILD_PLATFORM_VERSION = $(HOST_PLATFORM_VERSION)
else
BUILD_PLATFORM_VERSION = $(MASON_PLATFORM_VERSION)
endif
ifeq ($(MASON_PLATFORM),macos)
MASON_PLATFORM=osx
endif
ifeq ($(V), 1)
export XCPRETTY
NINJA_ARGS ?= -v
else
export XCPRETTY ?= | tee '$(shell pwd)/build/xcodebuild-$(shell date +"%Y-%m-%d_%H%M%S").log' | xcpretty
NINJA_ARGS ?=
endif
.PHONY: default
default: test
BUILD_DEPS += Makefile
BUILD_DEPS += CMakeLists.txt
BUILD_DOCS ?= true
#### macOS targets ##############################################################
ifeq ($(HOST_PLATFORM), macos)
export PATH := $(shell pwd)/platform/macos:$(PATH)
MACOS_OUTPUT_PATH = build/macos
MACOS_PROJ_PATH = $(MACOS_OUTPUT_PATH)/mbgl.xcodeproj
MACOS_WORK_PATH = platform/macos/macos.xcworkspace
MACOS_USER_DATA_PATH = $(MACOS_WORK_PATH)/xcuserdata/$(USER).xcuserdatad
MACOS_COMPDB_PATH = $(MACOS_OUTPUT_PATH)/compdb/$(BUILDTYPE)
MACOS_XCODEBUILD = xcodebuild \
-derivedDataPath $(MACOS_OUTPUT_PATH) \
-configuration $(BUILDTYPE) \
-workspace $(MACOS_WORK_PATH) \
-jobs $(JOBS)
ifneq ($(CI),)
MACOS_XCODEBUILD += -xcconfig platform/darwin/ci.xcconfig
endif
$(MACOS_PROJ_PATH): $(BUILD_DEPS) $(MACOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings
mkdir -p $(MACOS_OUTPUT_PATH)
(cd $(MACOS_OUTPUT_PATH) && $(CMAKE) -G Xcode ../.. \
-DWITH_EGL=${WITH_EGL})
$(MACOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings: platform/macos/WorkspaceSettings.xcsettings
mkdir -p "$(MACOS_USER_DATA_PATH)"
cp platform/macos/WorkspaceSettings.xcsettings "$@"
.PHONY: macos
macos: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'CI' build $(XCPRETTY)
.PHONY: xproj
xproj: $(MACOS_PROJ_PATH)
xed $(MACOS_WORK_PATH)
.PHONY: test
test: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-test' build $(XCPRETTY)
.PHONY: benchmark
benchmark: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-benchmark' build $(XCPRETTY)
.PHONY: run-test
run-test: run-test-*
run-test-%: test
ulimit -c unlimited && ($(MACOS_OUTPUT_PATH)/$(BUILDTYPE)/mbgl-test --gtest_catch_exceptions=0 --gtest_filter=$* & pid=$$! && wait $$pid \
|| (lldb -c /cores/core.$$pid --batch --one-line 'thread backtrace all' --one-line 'quit' && exit 1))
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'CI' test $(XCPRETTY)
.PHONY: run-benchmark
run-benchmark: run-benchmark-.
run-benchmark-%: benchmark
$(MACOS_OUTPUT_PATH)/$(BUILDTYPE)/mbgl-benchmark --benchmark_filter=$* ${BENCHMARK_ARGS}
.PHONY: node-benchmark
node-benchmark: node
.PHONY: run-node-benchmark
run-node-benchmark: node-benchmark
node platform/node/test/benchmark.js
.PHONY: glfw-app
glfw-app: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-glfw' build $(XCPRETTY)
.PHONY: run-glfw-app
run-glfw-app: glfw-app
"$(MACOS_OUTPUT_PATH)/$(BUILDTYPE)/mbgl-glfw"
.PHONY: render
render: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-render' build $(XCPRETTY)
.PHONY: offline
offline: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-offline' build $(XCPRETTY)
.PHONY: node
node: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-node (Active ABI)' build $(XCPRETTY)
.PHONY: node-all
node-all: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-node (All ABIs)' build $(XCPRETTY)
.PHONY: macos-test
macos-test: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'CI' test $(XCPRETTY)
.PHONY: macos-lint
macos-lint:
find platform/macos -type f -name '*.plist' | xargs plutil -lint
.PHONY: xpackage
xpackage: $(MACOS_PROJ_PATH)
SYMBOLS=$(SYMBOLS) ./platform/macos/scripts/package.sh
.PHONY: xdeploy
xdeploy:
caffeinate -i ./platform/macos/scripts/deploy-packages.sh
.PHONY: xdocument
#xdocument:
# OUTPUT=$(OUTPUT) ./platform/macos/scripts/document.sh
.PHONY: genstrings
genstrings:
genstrings -u -o platform/macos/sdk/Base.lproj platform/darwin/src/*.{m,mm}
genstrings -u -o platform/macos/sdk/Base.lproj platform/macos/src/*.{m,mm}
genstrings -u -o platform/ios/resources/Base.lproj platform/ios/src/*.{m,mm}
-find platform/ios/resources platform/macos/sdk -path '*/Base.lproj/*.strings' -exec \
textutil -convert txt -extension strings -inputencoding UTF-16 -encoding UTF-8 {} \;
mv platform/macos/sdk/Base.lproj/Foundation.strings platform/darwin/resources/Base.lproj/
$(MACOS_COMPDB_PATH)/Makefile:
mkdir -p $(MACOS_COMPDB_PATH)
(cd $(MACOS_COMPDB_PATH) && $(CMAKE) ../../../.. \
-DCMAKE_BUILD_TYPE=$(BUILDTYPE) \
-DWITH_EGL=${WITH_EGL})
.PHONY:
compdb: $(BUILD_DEPS) $(TEST_DEPS) $(MACOS_COMPDB_PATH)/Makefile
@$(MAKE) -C $(MACOS_COMPDB_PATH) cmake_check_build_system
.PHONY: tidy
tidy: compdb
scripts/clang-tools.sh $(MACOS_COMPDB_PATH) $(TARGET_BRANCH)
.PHONY: check
check: compdb
scripts/clang-tools.sh $(MACOS_COMPDB_PATH) $(TARGET_BRANCH) --diff
endif
#### iOS targets ##############################################################
ifeq ($(HOST_PLATFORM), macos)
IOS_OUTPUT_PATH = build/ios
IOS_PROJ_PATH = $(IOS_OUTPUT_PATH)/mbgl.xcodeproj
IOS_WORK_PATH = platform/ios/ios.xcworkspace
IOS_USER_DATA_PATH = $(IOS_WORK_PATH)/xcuserdata/$(USER).xcuserdatad
IOS_XCODEBUILD_SIM = xcodebuild \
ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES \
-derivedDataPath $(IOS_OUTPUT_PATH) \
-configuration $(BUILDTYPE) -sdk iphonesimulator \
-workspace $(IOS_WORK_PATH) \
-jobs $(JOBS)
ifneq ($(MORE_SIMULATORS),)
IOS_LATEST = true
IOS_11 = true
IOS_10 = true
IOS_9 = true
endif
ifdef IOS_LATEST
IOS_XCODEBUILD_SIM += \
-destination 'platform=iOS Simulator,OS=latest,name=iPhone 8' \
-destination 'platform=iOS Simulator,OS=latest,name=iPhone Xs Max' \
-destination 'platform=iOS Simulator,OS=latest,name=iPhone Xr' \
-destination 'platform=iOS Simulator,OS=latest,name=iPad Pro (11-inch)'
endif
ifdef IOS_11
IOS_XCODEBUILD_SIM += \
-destination 'platform=iOS Simulator,OS=11.4,name=iPhone 7' \
-destination 'platform=iOS Simulator,OS=11.4,name=iPhone X' \
-destination 'platform=iOS Simulator,OS=11.4,name=iPad (5th generation)'
endif
ifdef IOS_10
IOS_XCODEBUILD_SIM += \
-destination 'platform=iOS Simulator,OS=10.3.1,name=iPhone SE' \
-destination 'platform=iOS Simulator,OS=10.3.1,name=iPhone 7 Plus' \
-destination 'platform=iOS Simulator,OS=10.3.1,name=iPad Pro (9.7-inch)'
endif
ifdef IOS_9
IOS_XCODEBUILD_SIM += \
-destination 'platform=iOS Simulator,OS=9.3,name=iPhone 6s Plus' \
-destination 'platform=iOS Simulator,OS=9.3,name=iPhone 6s' \
-destination 'platform=iOS Simulator,OS=9.3,name=iPad Air 2'
endif
# If IOS_XCODEBUILD_SIM does not contain a simulator destination, add the default.
ifeq (, $(findstring destination, $(IOS_XCODEBUILD_SIM)))
IOS_XCODEBUILD_SIM += \
-destination 'platform=iOS Simulator,OS=latest,name=iPhone 8'
else
IOS_XCODEBUILD_SIM += -parallel-testing-enabled YES
endif
ifneq ($(ONLY_TESTING),)
IOS_XCODEBUILD_SIM += -only-testing:$(ONLY_TESTING)
endif
ifneq ($(SKIP_TESTING),)
IOS_XCODEBUILD_SIM += -skip-testing:$(SKIP_TESTING)
endif
ifneq ($(CI),)
IOS_XCODEBUILD_SIM += -xcconfig platform/darwin/ci.xcconfig
endif
$(IOS_PROJ_PATH): $(IOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings $(BUILD_DEPS)
mkdir -p $(IOS_OUTPUT_PATH)
(cd $(IOS_OUTPUT_PATH) && $(CMAKE) -G Xcode ../.. \
-DCMAKE_TOOLCHAIN_FILE=../../platform/ios/toolchain.cmake \
-DMBGL_PLATFORM=ios \
-DMASON_PLATFORM=ios)
$(IOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings: platform/ios/WorkspaceSettings.xcsettings
mkdir -p "$(IOS_USER_DATA_PATH)"
cp platform/ios/WorkspaceSettings.xcsettings "$@"
.PHONY: ios
ios: $(IOS_PROJ_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'CI' build $(XCPRETTY)
.PHONY: iproj
iproj: $(IOS_PROJ_PATH)
xed $(IOS_WORK_PATH)
.PHONY: ios-lint
ios-lint: ios-pod-lint
find platform/ios/framework -type f -name '*.plist' | xargs plutil -lint
find platform/ios/app -type f -name '*.plist' | xargs plutil -lint
.PHONY: ios-pod-lint
ios-pod-lint:
./platform/ios/scripts/lint-podspecs.js
.PHONY: ios-test
ios-test: $(IOS_PROJ_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'CI' test $(XCPRETTY)
.PHONY: ios-integration-test
ios-integration-test: $(IOS_PROJ_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'Integration Test Harness' test $(XCPRETTY)
.PHONY: ios-sanitize
ios-sanitize: $(IOS_PROJ_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'CI' -enableThreadSanitizer YES -enableUndefinedBehaviorSanitizer YES test $(XCPRETTY)
.PHONY: ios-sanitize-address
ios-sanitize-address: $(IOS_PROJ_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'CI' -enableAddressSanitizer YES test $(XCPRETTY)
.PHONY: ios-static-analyzer
ios-static-analyzer: $(IOS_PROJ_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) analyze -scheme 'CI' test $(XCPRETTY)
.PHONY: ios-install-simulators
ios-install-simulators:
xcversion simulators --install="iOS 11.4" || true
xcversion simulators --install="iOS 10.3.1" || true
xcversion simulators --install="iOS 9.3" || true
.PHONY: ios-check-events-symbols
ios-check-events-symbols:
./platform/ios/scripts/check-events-symbols.sh
.PHONY: ipackage
ipackage: ipackage*
ipackage%:
@echo make ipackage is deprecated — use make iframework.
.PHONY: iframework
iframework: $(IOS_PROJ_PATH)
FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) BUILD_DOCS=$(BUILD_DOCS) \
./platform/ios/scripts/package.sh
.PHONY: ideploy
ideploy:
caffeinate -i ./platform/ios/scripts/deploy-packages.sh
.PHONY: idocument
#idocument:
# OUTPUT=$(OUTPUT) ./platform/ios/scripts/document.sh
.PHONY: darwin-style-code
darwin-style-code:
node platform/darwin/scripts/generate-style-code.js
node platform/darwin/scripts/update-examples.js
style-code: darwin-style-code
.PHONY: darwin-update-examples
darwin-update-examples:
node platform/darwin/scripts/update-examples.js
.PHONY: darwin-check-public-symbols
darwin-check-public-symbols:
node platform/darwin/scripts/check-public-symbols.js macOS iOS
endif
#### Linux targets #####################################################
ifeq ($(HOST_PLATFORM), linux)
export PATH := $(shell pwd)/platform/linux:$(PATH)
export LINUX_OUTPUT_PATH = build/linux-$(shell uname -m)/$(BUILDTYPE)
LINUX_BUILD = $(LINUX_OUTPUT_PATH)/build.ninja
$(LINUX_BUILD): $(BUILD_DEPS)
mkdir -p $(LINUX_OUTPUT_PATH)
(cd $(LINUX_OUTPUT_PATH) && $(CMAKE) -G Ninja ../../.. \
-DCMAKE_BUILD_TYPE=$(BUILDTYPE) \
-DWITH_COVERAGE=${WITH_COVERAGE} \
-DWITH_OSMESA=${WITH_OSMESA} \
-DWITH_EGL=${WITH_EGL})
.PHONY: linux
linux: glfw-app render offline
.PHONY: linux-core
linux-core: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-core mbgl-loop-uv mbgl-filesource
.PHONY: test
test: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-test
.PHONY: benchmark
benchmark: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-benchmark
GDB ?= gdb \
-batch -return-child-result \
-ex 'set print thread-events off' \
-ex 'set disable-randomization off' \
-ex 'run' \
-ex 'thread apply all bt' --args
.PHONY: run-test
run-test: run-test-*
run-test-%: test
$(GDB) $(LINUX_OUTPUT_PATH)/mbgl-test --gtest_catch_exceptions=0 --gtest_filter=$*
.PHONY: run-benchmark
run-benchmark: run-benchmark-.
run-benchmark-%: benchmark
$(LINUX_OUTPUT_PATH)/mbgl-benchmark --benchmark_filter=$*
.PHONY: render
render: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-render
.PHONY: offline
offline: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-offline
.PHONY: glfw-app
glfw-app: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-glfw
.PHONY: run-glfw-app
run-glfw-app: glfw-app
cd $(LINUX_OUTPUT_PATH) && ./mbgl-glfw
.PHONY: node
node: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-node.active
.PHONY: node-all
node-all: $(LINUX_BUILD)
$(NINJA) $(NINJA_ARGS) -j$(JOBS) -C $(LINUX_OUTPUT_PATH) mbgl-node.all
.PHONY: compdb
compdb: $(LINUX_BUILD)
# Ninja generator already outputs the file at the right location
.PHONY: tidy
tidy: compdb
scripts/clang-tools.sh $(LINUX_OUTPUT_PATH) $(TARGET_BRANCH)
.PHONY: check
check: compdb
scripts/clang-tools.sh $(LINUX_OUTPUT_PATH) $(TARGET_BRANCH) --diff
endif
#### Node targets ##############################################################
.PHONY: test-node
test-node: node
npm test
npm run test-memory
#### Miscellaneous targets #####################################################
.PHONY: style-code
style-code:
node scripts/generate-style-code.js
node scripts/generate-shaders.js
.PHONY: codestyle
codestyle:
scripts/codestyle.sh
.PHONY: clean
clean:
-rm -rf ./build \
./lib/*.node \
./platform/android/gradle/configuration.gradle \
./platform/android/MapboxGLAndroidSDK/build \
./platform/android/MapboxGLAndroidSDK/.externalNativeBuild \
./platform/android/MapboxGLAndroidSDKTestApp/build \
./platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen \
./platform/android/MapboxGLAndroidSDK/src/main/assets \
./platform/android/MapboxGLAndroidSDKTestApp/src/main/assets/integration
.PHONY: distclean
distclean: clean
-rm -rf ./mason_packages
-rm -rf ./node_modules