Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release build scripts for Metal support #50

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ include(${PROJECT_SOURCE_DIR}/vendor/benchmark.cmake)
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set_target_properties(mbgl-vendor-benchmark PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_DEPLOYMENT_TARGET}")
set_target_properties(mbgl-vendor-benchmark PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
set_target_properties(mbgl-vendor-benchmark PROPERTIES XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode)
set_target_properties(mbgl-vendor-benchmark PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)

set_target_properties(mbgl-benchmark PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_DEPLOYMENT_TARGET}")
set_target_properties(mbgl-benchmark PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
set_target_properties(mbgl-benchmark PROPERTIES XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode)
set_target_properties(mbgl-benchmark PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)
endif()

Expand Down
1 change: 0 additions & 1 deletion platform/ios/ios.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ set_target_properties(mbgl-core PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[vari
macro(initialize_ios_target target)
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_DEPLOYMENT_TARGET}")
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode)
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)
endmacro()

Expand Down
1 change: 0 additions & 1 deletion platform/ios/platform/darwin/darwin.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ OTHER_CPLUSPLUSFLAGS = $(inherited) -fvisibility=hidden -fcxx-modules
OTHER_SWIFT_FLAGS = -warnings-as-errors

// User defined
BITCODE_GENERATION_MODE = bitcode
CURRENT_COMMIT_HASH = deadbeef
CURRENT_SEMANTIC_VERSION = 0.0.0
CURRENT_SHORT_VERSION = 0.0
Expand Down
1 change: 0 additions & 1 deletion platform/ios/platform/ios/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set(USE_GLES2 ON)
macro(initialize_ios_target target)
set_xcode_property(${target} IPHONEOS_DEPLOYMENT_TARGET "9.0")
set_xcode_property(${target} ENABLE_BITCODE "YES")
set_xcode_property(${target} BITCODE_GENERATION_MODE bitcode)
set_xcode_property(${target} ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)

target_compile_options(${target}
Expand Down
285 changes: 19 additions & 266 deletions platform/ios/platform/ios/ios.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
BuildableName = "Mapbox GL.app"
BuildableName = "MapLibre GL.app"
BlueprintName = "iosapp"
ReferencedContainer = "container:ios.xcodeproj">
</BuildableReference>
Expand All @@ -31,7 +31,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
BuildableName = "Mapbox GL.app"
BuildableName = "MapLibre GL.app"
BlueprintName = "iosapp"
ReferencedContainer = "container:ios.xcodeproj">
</BuildableReference>
Expand All @@ -54,7 +54,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
BuildableName = "Mapbox GL.app"
BuildableName = "MapLibre GL.app"
BlueprintName = "iosapp"
ReferencedContainer = "container:ios.xcodeproj">
</BuildableReference>
Expand All @@ -78,7 +78,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DA1DC9491CB6C1C2006E619F"
BuildableName = "Mapbox GL.app"
BuildableName = "MapLibre GL.app"
BlueprintName = "iosapp"
ReferencedContainer = "container:ios.xcodeproj">
</BuildableReference>
Expand Down
11 changes: 11 additions & 0 deletions platform/ios/platform/ios/scripts/deploy-swift-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ make xcframework
step "Zipping xcframeworks…"
MAPBOX_ZIP_FILE="Mapbox-${PUBLISH_VERSION}.zip"
(cd ${BINARY_DIRECTORY} && rm -f ${MAPBOX_ZIP_FILE} && zip -yr ${MAPBOX_ZIP_FILE} Mapbox.xcframework)
METAL_ANGLE_ZIP_FILE="MetalANGLE-${PUBLISH_VERSION}.zip"
(cd ${BINARY_DIRECTORY} && rm -f ${METAL_ANGLE_ZIP_FILE} && zip -yr ${METAL_ANGLE_ZIP_FILE} MetalANGLE.xcframework)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version numbers of the binaries are as below, but I think this script pulls the {PUBLISH_VERSION} from the git tags. If we cannot tag the MetalANGLE, then we may be able to use the binaries version as it is on disk.

image


if [[ ${S3_DISTRIBUTION} == true ]]; then
step "Uploading ${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE} to s3"
uploadToS3 "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" false
MAPBOX_ZIP_FILE_URL=$EXT_TARGET_S3_URL

step "Uploading ${BINARY_DIRECTORY}/${METAL_ANGLE_ZIP_FILE} to s3"
uploadToS3 "${BINARY_DIRECTORY}/${METAL_ANGLE_ZIP_FILE}" false
METAL_ANGLE_ZIP_FILE_URL=$EXT_TARGET_S3_URL
fi

step "Create GitHub release…"
Expand All @@ -130,6 +136,10 @@ step "Uploading ${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE} to github release [${VERS
uploadToGithub "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" "${VERSION_TAG}"
MAPBOX_ZIP_FILE_URL=$EXT_TARGET_GITHUB_URL

step "Uploading ${BINARY_DIRECTORY}/${METAL_ANGLE_ZIP_FILE} to github releases"
uploadToGithub "${BINARY_DIRECTORY}/${METAL_ANGLE_ZIP_FILE}" "${VERSION_TAG}"
METAL_ANGLE_ZIP_FILE_URL=$EXT_TARGET_GITHUB_URL

step "Creating Swift package…"

rm -f Package.swift
Expand All @@ -150,6 +160,7 @@ setTarget() {
}

setTarget "MAPBOX" "${BINARY_DIRECTORY}/${MAPBOX_ZIP_FILE}" "${MAPBOX_ZIP_FILE_URL}"
setTarget "METAL_ANGLE" "${BINARY_DIRECTORY}/${METAL_ANGLE_ZIP_FILE}" "${METAL_ANGLE_ZIP_FILE_URL}"

step "Publishing Swift package…"

Expand Down
11 changes: 9 additions & 2 deletions platform/ios/platform/ios/scripts/swift_package_template.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ let package = Package(
products: [
.library(
name: "Mapbox",
targets: ["Mapbox"])
targets: ["Mapbox"]),
.library(
name: "MetalANGLE",
targets: ["MetalANGLE"])
],
dependencies: [
],
targets: [
.binaryTarget(
name: "Mapbox",
url: "MAPBOX_PACKAGE_URL",
checksum: "MAPBOX_PACKAGE_CHECKSUM")
checksum: "MAPBOX_PACKAGE_CHECKSUM"),
.binaryTarget(
name: "MetalANGLE",
url: "METAL_ANGLE_PACKAGE_URL",
checksum: "METAL_ANGLE_PACKAGE_CHECKSUM")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reviewers (assume Petr already knows this)

Please see notes at maplibre/maplibre-gl-native-distribution#5 on how to test locally built *.xcframeworks with SPM.

]
)
19 changes: 15 additions & 4 deletions platform/ios/platform/ios/scripts/xcpackage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ LOG_PATH=build/xcodebuild-$(date +"%Y-%m-%d_%H%M%S").log

BUILD_DOCS=${BUILD_DOCS:-true}
SYMBOLS=${SYMBOLS:-YES}

BUILDTYPE=${BUILDTYPE:-Debug}
if [[ ${SYMBOLS} == YES && ${BUILDTYPE} == Release ]]; then
BUILDTYPE='RelWithDebInfo'
fi

FORMAT=${FORMAT:-dynamic}
if [[ ${FORMAT} != "dynamic" ]]; then
Expand Down Expand Up @@ -51,6 +47,11 @@ PROJ_VERSION=$(git rev-list --count HEAD)
SEM_VERSION=$( git describe --tags --match=ios-v*.*.* --abbrev=0 | sed 's/^ios-v//' )
SHORT_VERSION=${SEM_VERSION%-*}

echo "Version=${SHORT_VERSION}"

step "Fetching MetalANGLE dependencies"
platform/ios/vendor/metalangle/ios/xcode/fetchDependencies.sh

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

SCHEME='dynamic'
Expand Down Expand Up @@ -127,6 +128,16 @@ echo "Creating ${NAME}.xcframework with args: $BUILD_ARGS"
xcodebuild -create-xcframework $BUILD_ARGS
echo "${NAME}.xcframework created"

# MetalANGLE
METAL_ANGLE_NAME="MetalANGLE"
BUILD_ARGS=""
BUILD_ARGS="$BUILD_ARGS -output ${BINOUT}/${METAL_ANGLE_NAME}.xcframework"
addFramework "${BINOUT}/${NAME}-iphoneos.xcarchive" ${METAL_ANGLE_NAME} ${INCLUDE_DEBUG_SYMBOLS}
addFramework "${BINOUT}/${NAME}-iphonesimulator.xcarchive" ${METAL_ANGLE_NAME} ${INCLUDE_DEBUG_SYMBOLS}
echo "Creating ${METAL_ANGLE_NAME}.xcframework with args: $BUILD_ARGS"
xcodebuild -create-xcframework $BUILD_ARGS
echo "${METAL_ANGLE_NAME}.xcframework created"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great!

step "Copying library resources…"
cp -pv LICENSE.md ${OUTPUT}
sed -n -e '/^## /,$p' platform/ios/CHANGELOG.md > "${OUTPUT}/CHANGELOG.md"
Expand Down
1 change: 0 additions & 1 deletion render-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ add_library(
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set_target_properties(mbgl-render-test PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_DEPLOYMENT_TARGET}")
set_target_properties(mbgl-render-test PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
set_target_properties(mbgl-render-test PROPERTIES XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode)
set_target_properties(mbgl-render-test PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)
endif()

Expand Down
2 changes: 0 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,10 @@ include(${PROJECT_SOURCE_DIR}/vendor/googletest.cmake)
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set_target_properties(mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_DEPLOYMENT_TARGET}")
set_target_properties(mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
set_target_properties(mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode)
set_target_properties(mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)

set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_DEPLOYMENT_TARGET}")
set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode)
set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$<CONFIG:Debug>:YES>)
endif()

Expand Down