Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[build] merge iOS and macOS projects
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Aug 18, 2016
1 parent 26bdcad commit c13e287
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 169 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(mbgl LANGUAGES CXX C)

if(NOT MBGL_PROJECT_NAME)
set(MBGL_PROJECT_NAME mbgl)
endif()

project(${MBGL_PROJECT_NAME} LANGUAGES CXX C)

include(cmake/mbgl.cmake)

Expand Down
75 changes: 33 additions & 42 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ 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_PROJ_PATH = $(MACOS_OUTPUT_PATH)/mbgl-macos.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)
Expand All @@ -83,66 +83,62 @@ MACOS_XCSCHEMES += platform/macos/scripts/node.xcscheme

$(MACOS_PROJ_PATH): $(BUILD_DEPS) $(MACOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings $(MACOS_XCSCHEMES)
mkdir -p $(MACOS_OUTPUT_PATH)
(cd $(MACOS_OUTPUT_PATH) && cmake -G Xcode ../..)
(cd $(MACOS_OUTPUT_PATH) && cmake -G Xcode -DMBGL_PROJECT_NAME=mbgl-macos ../..)

@# Create Xcode schemes so that we can use xcodebuild from the command line. CMake doesn't
@# create these automatically.
SCHEME_NAME=mbgl-test SCHEME_TYPE=executable platform/macos/scripts/create_scheme.sh
SCHEME_NAME=mbgl-render SCHEME_TYPE=executable platform/macos/scripts/create_scheme.sh
SCHEME_NAME=mbgl-offline SCHEME_TYPE=executable platform/macos/scripts/create_scheme.sh
SCHEME_NAME=mbgl-glfw SCHEME_TYPE=executable platform/macos/scripts/create_scheme.sh
SCHEME_NAME=mbgl-core SCHEME_TYPE=library BUILDABLE_NAME=libmbgl-core.a BLUEPRINT_NAME=mbgl-core platform/macos/scripts/create_scheme.sh
SCHEME_NAME=mbgl-node SCHEME_TYPE=library BUILDABLE_NAME=mbgl-node.node BLUEPRINT_NAME=mbgl-node platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="macOS unit tests" SCHEME_TYPE=executable BLUEPRINT_NAME=mbgl-test BUILDABLE_NAME=mbgl-test platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="macOS render" SCHEME_TYPE=executable BLUEPRINT_NAME=mbgl-render BUILDABLE_NAME=mbgl-render platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="macOS offline" SCHEME_TYPE=executable BLUEPRINT_NAME=mbgl-offline BUILDABLE_NAME=mbgl-offline platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="macOS GLFW app" SCHEME_TYPE=executable BLUEPRINT_NAME=mbgl-glfw BUILDABLE_NAME=mbgl-glfw platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="macOS core library" SCHEME_TYPE=library BLUEPRINT_NAME=mbgl-core BUILDABLE_NAME=libmbgl-core.a BLUEPRINT_NAME=mbgl-core platform/macos/scripts/create_scheme.sh

@# Create schemes for running node tests. These have all of the environment variables set to
@# launch in the correct location.
SCHEME_NAME="node tests" SCHEME_TYPE=node BUILDABLE_NAME=mbgl-node.node BLUEPRINT_NAME=mbgl-node NODE_ARGUMENT="`npm bin tape`/tape platform/node/test/js/**/*.test.js" platform/macos/scripts/create_scheme.sh
SCHEME_NAME="node render tests" SCHEME_TYPE=node BUILDABLE_NAME=mbgl-node.node BLUEPRINT_NAME=mbgl-node NODE_ARGUMENT="platform/node/test/render.test.js" platform/macos/scripts/create_scheme.sh
SCHEME_NAME="node query tests" SCHEME_TYPE=node BUILDABLE_NAME=mbgl-node.node BLUEPRINT_NAME=mbgl-node NODE_ARGUMENT="platform/node/test/query.test.js" platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="node module" SCHEME_TYPE=library BLUEPRINT_NAME=mbgl-node BUILDABLE_NAME=mbgl-node.node BLUEPRINT_NAME=mbgl-node platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="node tests" SCHEME_TYPE=node BUILDABLE_NAME=mbgl-node.node BLUEPRINT_NAME=mbgl-node NODE_ARGUMENT="`npm bin tape`/tape platform/node/test/js/**/*.test.js" platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="node render tests" SCHEME_TYPE=node BUILDABLE_NAME=mbgl-node.node BLUEPRINT_NAME=mbgl-node NODE_ARGUMENT="platform/node/test/render.test.js" platform/macos/scripts/create_scheme.sh
XCODEPROJ=$(MACOS_PROJ_PATH) SCHEME_NAME="node query tests" SCHEME_TYPE=node BUILDABLE_NAME=mbgl-node.node BLUEPRINT_NAME=mbgl-node NODE_ARGUMENT="platform/node/test/query.test.js" platform/macos/scripts/create_scheme.sh

$(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)
open $(MACOS_WORK_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'macOS CI' build $(XCPRETTY)

.PHONY: test
test: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-test' build $(XCPRETTY)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'macOS unit tests' 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)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'macOS CI' test $(XCPRETTY)

.PHONY: glfw-app
glfw-app: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-glfw' build $(XCPRETTY)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'macOS GLFW app' 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)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'macOS render' build $(XCPRETTY)

.PHONY: offline
offline: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-offline' build $(XCPRETTY)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'macOS offline' build $(XCPRETTY)

.PHONY: node
node: $(MACOS_PROJ_PATH)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'mbgl-node' build $(XCPRETTY)
set -o pipefail && $(MACOS_XCODEBUILD) -scheme 'node module' build $(XCPRETTY)

.PHONY: xpackage
xpackage: $(MACOS_PROJ_PATH)
Expand Down Expand Up @@ -185,53 +181,42 @@ tidy: clang-tools
check: clang-tools
scripts/clang-tools.sh $(MACOS_COMPDB_PATH) --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_PROJ_PATH = $(IOS_OUTPUT_PATH)/mbgl-ios.xcodeproj

IOS_XCODEBUILD_SIM = xcodebuild \
ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES \
-derivedDataPath $(IOS_OUTPUT_PATH) \
-configuration $(BUILDTYPE) -sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' \
-workspace $(IOS_WORK_PATH)
-workspace $(MACOS_WORK_PATH)

$(IOS_PROJ_PATH): $(IOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings $(BUILD_DEPS)
$(IOS_PROJ_PATH): $(BUILD_DEPS) $(MACOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings $(MACOS_XCSCHEMES)
mkdir -p $(IOS_OUTPUT_PATH)
(cd $(IOS_OUTPUT_PATH) && cmake -G Xcode ../.. \
-DMBGL_PROJECT_NAME=mbgl-ios \
-DCMAKE_TOOLCHAIN_FILE=../../platform/ios/toolchain.cmake \
-DMBGL_PLATFORM=ios)

$(IOS_USER_DATA_PATH)/WorkspaceSettings.xcsettings: platform/ios/WorkspaceSettings.xcsettings
mkdir -p "$(IOS_USER_DATA_PATH)"
cp platform/ios/WorkspaceSettings.xcsettings "$@"
XCODEPROJ=$(IOS_PROJ_PATH) SCHEME_NAME="iOS core library" SCHEME_TYPE=library BLUEPRINT_NAME=mbgl-core BUILDABLE_NAME=libmbgl-core.a BLUEPRINT_NAME=mbgl-core platform/macos/scripts/create_scheme.sh

.PHONY: ios
ios: $(IOS_PROJ_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'CI' build $(XCPRETTY)

.PHONY: iproj
iproj: $(IOS_PROJ_PATH)
open $(IOS_WORK_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'iOS CI' build $(XCPRETTY)

.PHONY: ios-test
ios-test: $(IOS_PROJ_PATH)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'CI' test $(XCPRETTY)
set -o pipefail && $(IOS_XCODEBUILD_SIM) -scheme 'iOS CI' test $(XCPRETTY)

.PHONY: ipackage
ipackage: $(IOS_PROJ_PATH)
FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=$(SYMBOLS) \
./platform/ios/scripts/package.sh

.PHONY: ipackage-strip
ipackage-strip: $(IOS_PROJ_PATH)
ipackage-strip§: $(IOS_PROJ_PATH)
FORMAT=$(FORMAT) BUILD_DEVICE=$(BUILD_DEVICE) SYMBOLS=NO \
./platform/ios/scripts/package.sh

Expand All @@ -256,6 +241,11 @@ idocument:

style-code-darwin:
node platform/darwin/scripts/generate-style-code.js

.PHONY: xproj
xproj: $(MACOS_PROJ_PATH) $(IOS_PROJ_PATH)
open $(MACOS_WORK_PATH)

endif

#### Linux targets #####################################################
Expand Down Expand Up @@ -357,10 +347,11 @@ $(QT_BUILD): $(BUILD_DEPS)

ifeq ($(HOST_PLATFORM), macos)

MACOS_QT_PROJ_PATH = $(QT_ROOT_PATH)/xcode/mbgl.xcodeproj
MACOS_QT_PROJ_PATH = $(QT_ROOT_PATH)/xcode/mbgl-qt.xcodeproj
$(MACOS_QT_PROJ_PATH): $(BUILD_DEPS)
mkdir -p $(QT_ROOT_PATH)/xcode
(cd $(QT_ROOT_PATH)/xcode && cmake -G Xcode ../../.. \
-DMBGL_PROJECT_NAME=mbgl-qt \
-DMBGL_PLATFORM=qt \
-DMASON_PLATFORM=$(BUILD_PLATFORM) \
-DMASON_PLATFORM_VERSION=$(BUILD_PLATFORM_VERSION) \
Expand Down
22 changes: 0 additions & 22 deletions platform/ios/WorkspaceSettings.xcsettings

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4E8A9455A3A23B7FD2A8FC52"
BuildableName = "All"
BlueprintName = "All"
ReferencedContainer = "container:../../build/ios/platform/ios/platform.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
Expand Down
16 changes: 0 additions & 16 deletions platform/ios/ios.xcworkspace/contents.xcworkspacedata

This file was deleted.

37 changes: 0 additions & 37 deletions platform/ios/ios.xcworkspace/xcshareddata/ios.xcscmblueprint

This file was deleted.

This file was deleted.

13 changes: 7 additions & 6 deletions platform/ios/scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ SHORT_VERSION=${SEM_VERSION%-*}

step "Building targets (build ${PROJ_VERSION}, version ${SEM_VERSION})…"

SCHEME='dynamic'
SCHEME='iOS dynamic'
if [[ ${BUILD_DYNAMIC} == true && ${BUILD_STATIC} == true ]]; then
SCHEME+='+static'
elif [[ ${BUILD_STATIC} == true ]]; then
SCHEME='static'
SCHEME='iOS static'
fi
SCHEME+=' framework'

xcodebuild \
GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \
Expand All @@ -86,8 +87,8 @@ xcodebuild \
CURRENT_COMMIT_HASH=${HASH} \
ONLY_ACTIVE_ARCH=NO \
-derivedDataPath ${DERIVED_DATA} \
-workspace ./platform/ios/ios.xcworkspace \
-scheme ${SCHEME} \
-workspace ./platform/macos/macos.xcworkspace \
-scheme '${SCHEME}' \
-configuration ${BUILDTYPE} \
-sdk iphonesimulator \
-jobs ${JOBS} | xcpretty
Expand All @@ -101,8 +102,8 @@ if [[ ${BUILD_FOR_DEVICE} == true ]]; then
CURRENT_COMMIT_HASH=${HASH} \
ONLY_ACTIVE_ARCH=NO \
-derivedDataPath ${DERIVED_DATA} \
-workspace ./platform/ios/ios.xcworkspace \
-scheme ${SCHEME} \
-workspace ./platform/macos/macos.xcworkspace \
-scheme '${SCHEME}' \
-configuration ${BUILDTYPE} \
-sdk iphoneos \
-jobs ${JOBS} | xcpretty
Expand Down
2 changes: 1 addition & 1 deletion platform/macos/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Mapbox macOS SDK and the macosapp demo application run on macOS 10.10.0 and

1. [Install core dependencies](../../INSTALL.md).
1. Run `make xproj`.
1. Switch to the “dynamic” or “macosapp” scheme. The former builds just the Cocoa framework, while the latter also builds a Cocoa demo application based on it.
1. Switch to the “dynamic (macos project)” or “macOS app” scheme. The former builds just the Cocoa framework, while the latter also builds a Cocoa demo application based on it.

## Contributing

Expand Down
14 changes: 13 additions & 1 deletion platform/macos/macos.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>
Loading

0 comments on commit c13e287

Please sign in to comment.