Simplify bazel xcode scripts (#1639)
This commit is contained in:
4
.github/workflows/ios-ci.yml
vendored
4
.github/workflows/ios-ci.yml
vendored
@@ -95,10 +95,6 @@ jobs:
|
||||
|
||||
- name: npm install
|
||||
run: npm ci --ignore-scripts
|
||||
|
||||
- name: Generate app plists
|
||||
working-directory: ./
|
||||
run: bash platform/ios/scripts/bazel-generate-plists.sh
|
||||
|
||||
- run: cp bazel/example_config.bzl bazel/config.bzl
|
||||
|
||||
|
||||
@@ -123,9 +123,7 @@ objc_library(
|
||||
"//platform/ios:ios_sdk_hdrs",
|
||||
] + select({
|
||||
"//:metal_renderer": [],
|
||||
"//conditions:default": [
|
||||
"//platform/darwin:darwin_objc_opengl_hdrs",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
data = ["//platform/ios:resources"],
|
||||
module_name = "MapLibre",
|
||||
@@ -242,8 +240,6 @@ sh_binary(
|
||||
] + select({
|
||||
"//:metal_renderer": [],
|
||||
"//conditions:default": [
|
||||
"//platform/darwin:darwin_private_opengl_hdrs",
|
||||
"//platform/darwin:darwin_objc_opengl_hdrs",
|
||||
"//platform/darwin:darwin_objcpp_opengl_srcs",
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -3,9 +3,7 @@ load(
|
||||
"bazel/files.bzl",
|
||||
"MLN_DARWIN_OBJCPP_HEADERS",
|
||||
"MLN_DARWIN_OBJC_HEADERS",
|
||||
"MLN_DARWIN_OBJC_OPENGL_HEADERS",
|
||||
"MLN_DARWIN_PRIVATE_HEADERS",
|
||||
"MLN_DARWIN_PRIVATE_OPENGL_HEADERS",
|
||||
"MLN_DARWIN_PUBLIC_OBJCPP_SOURCE",
|
||||
"MLN_DARWIN_PUBLIC_OBJCPP_OPENGL_SOURCE",
|
||||
"MLN_DARWIN_PUBLIC_OBJC_SOURCE",
|
||||
@@ -24,22 +22,12 @@ filegroup(
|
||||
srcs = MLN_DARWIN_PRIVATE_HEADERS,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
filegroup(
|
||||
name = "darwin_private_opengl_hdrs",
|
||||
srcs = MLN_DARWIN_PRIVATE_OPENGL_HEADERS,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "darwin_objc_hdrs",
|
||||
srcs = MLN_DARWIN_OBJC_HEADERS,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
filegroup(
|
||||
name = "darwin_objc_opengl_hdrs",
|
||||
srcs = MLN_DARWIN_OBJC_OPENGL_HEADERS,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "darwin_objcpp_hdrs",
|
||||
@@ -342,8 +330,6 @@ exports_files(
|
||||
MLN_DARWIN_PUBLIC_OBJCPP_SOURCE +
|
||||
MLN_DARWIN_PUBLIC_OBJCPP_OPENGL_SOURCE +
|
||||
MLN_DARWIN_PRIVATE_HEADERS +
|
||||
MLN_DARWIN_PRIVATE_OPENGL_HEADERS +
|
||||
MLN_DARWIN_OBJC_HEADERS +
|
||||
MLN_DARWIN_OBJC_OPENGL_HEADERS +
|
||||
MLN_DARWIN_OBJCPP_HEADERS,
|
||||
)
|
||||
|
||||
@@ -100,8 +100,6 @@ MLN_DARWIN_OBJC_HEADERS = [
|
||||
"src/NSPredicate+MLNAdditions.h",
|
||||
"src/NSValue+MLNAdditions.h",
|
||||
]
|
||||
MLN_DARWIN_OBJC_OPENGL_HEADERS = [
|
||||
]
|
||||
|
||||
MLN_DARWIN_OBJCPP_HEADERS = [
|
||||
"src/MLNConversion.h",
|
||||
@@ -156,8 +154,6 @@ MLN_DARWIN_PRIVATE_HEADERS = [
|
||||
"src/NSExpression+MLNPrivateAdditions.h",
|
||||
"src/NSPredicate+MLNPrivateAdditions.h",
|
||||
]
|
||||
MLN_DARWIN_PRIVATE_OPENGL_HEADERS = [
|
||||
]
|
||||
|
||||
MLN_DARWIN_PUBLIC_OBJCPP_SOURCE = [
|
||||
"src/MLNAttributionInfo.mm",
|
||||
|
||||
@@ -63,9 +63,27 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
info_plist(
|
||||
name = "info_plist",
|
||||
out = "Info.plist",
|
||||
base_info_plist = "framework/Info.plist",
|
||||
)
|
||||
|
||||
info_plist(
|
||||
name = "info_static_plist",
|
||||
out = "Info-static.plist",
|
||||
base_info_plist = "framework/Info-static.plist",
|
||||
)
|
||||
|
||||
info_plist(
|
||||
name = "info_app_plist",
|
||||
out = "Info-app.plist",
|
||||
base_info_plist = "app/Info.plist",
|
||||
)
|
||||
|
||||
apple_static_xcframework(
|
||||
name = "Mapbox.static",
|
||||
bundle_name = "Mapbox",
|
||||
name = "MapLibre.static",
|
||||
bundle_name = "MapLibre",
|
||||
ios = {
|
||||
"simulator": [
|
||||
"x86_64",
|
||||
@@ -81,28 +99,13 @@ apple_static_xcframework(
|
||||
"//platform/darwin:darwin_objcpp_hdrs",
|
||||
] + select({
|
||||
"//:metal_renderer": [],
|
||||
"//conditions:default": [
|
||||
"//platform/darwin:darwin_objc_opengl_hdrs",
|
||||
"//platform/darwin:darwin_objcpp_opengl_hdrs"
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
umbrella_header = "src/Mapbox.h",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//platform:ios-sdk"],
|
||||
)
|
||||
|
||||
info_plist(
|
||||
name = "info_plist",
|
||||
out = "Info.plist",
|
||||
base_info_plist = "framework/Info.plist",
|
||||
)
|
||||
|
||||
info_plist(
|
||||
name = "info_static_plist",
|
||||
out = "Info-static.plist",
|
||||
base_info_plist = "framework/Info-static.plist",
|
||||
)
|
||||
|
||||
apple_xcframework(
|
||||
name = "MapLibre.dynamic",
|
||||
bundle_id = "com.maplibre.mapbox",
|
||||
@@ -127,10 +130,7 @@ apple_xcframework(
|
||||
"//platform/darwin:darwin_objcpp_hdrs",
|
||||
] + select({
|
||||
"//:metal_renderer": [],
|
||||
"//conditions:default": [
|
||||
"//platform/darwin:darwin_objc_opengl_hdrs",
|
||||
"//platform/darwin:darwin_objcpp_opengl_hdrs"
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
umbrella_header = "src/Mapbox.h",
|
||||
visibility = ["//visibility:public"],
|
||||
@@ -183,7 +183,7 @@ ios_application(
|
||||
"iphone",
|
||||
"ipad",
|
||||
],
|
||||
infoplists = ["build/Info-app.plist"],
|
||||
infoplists = ["info_app_plist"],
|
||||
minimum_os_version = "12.0",
|
||||
provisioning_profile = "xcode_profile",
|
||||
resources = _IOS_APPLICATION_RESOURCES,
|
||||
@@ -220,7 +220,7 @@ ios_application(
|
||||
"iphone",
|
||||
"ipad",
|
||||
],
|
||||
infoplists = ["build/Info-benchmark.plist"],
|
||||
infoplists = ["//platform/ios/benchmark:info_benchmark_plist"],
|
||||
minimum_os_version = "12.0",
|
||||
provisioning_profile = "xcode_profile",
|
||||
resources = ["//platform/ios/benchmark:bundle_resources"],
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# Find your team ID inside a .mobileprovision file or in your keychain (Apple development: your@email -> Get Info -> Organizational Unit)
|
||||
APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID = "TC45MCF93C"
|
||||
APPLE_MOBILE_PROVISIONING_PROFILE_NAME = "iOS Team Provisioning Profile: *"
|
||||
BUNDLE_ID_PREFIX = "com.firstnamelastname"
|
||||
@@ -6,3 +7,8 @@ BUNDLE_ID_PREFIX = "com.firstnamelastname"
|
||||
# not finding a provisioning profile when building.
|
||||
# https://github.com/MobileNativeFoundation/rules_xcodeproj/blob/main/docs/bazel.md#xcodeproj-build_mode
|
||||
BUILD_MODE = "bazel"
|
||||
|
||||
# Enter your API key for MapTiler here, if you have one.
|
||||
API_KEY = "0000000000"
|
||||
# Semantic version number to include in plist files.
|
||||
SEM_VER = "0.0.0"
|
||||
@@ -1,3 +1,5 @@
|
||||
load("//platform/ios/bazel:config.bzl", "API_KEY", "SEM_VER")
|
||||
|
||||
def info_plist(name, base_info_plist, out, **kwargs):
|
||||
native.genrule(
|
||||
name = name,
|
||||
@@ -8,13 +10,14 @@ def info_plist(name, base_info_plist, out, **kwargs):
|
||||
outs = [
|
||||
out,
|
||||
],
|
||||
cmd = """
|
||||
cmd = ("""
|
||||
cp $(location {}) $@
|
||||
plutil -replace MLNCommitHash -string $$(cat $(location //:git_hash)) $@
|
||||
|
||||
# TODO: move to file
|
||||
sem_version=0.0.0
|
||||
sem_version=\"""" + SEM_VER + """\"
|
||||
token=\"""" + API_KEY + """\"
|
||||
plutil -replace MLNSemanticVersionString -string $$sem_version $@
|
||||
""".format(base_info_plist),
|
||||
plutil -replace MLNApiKey -string $$token $@
|
||||
""").format(base_info_plist),
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
load("//platform/ios/bazel:macros.bzl", "info_plist")
|
||||
|
||||
filegroup(
|
||||
name = "ios_benchmark_srcs",
|
||||
srcs = [
|
||||
@@ -31,6 +33,11 @@ filegroup(
|
||||
visibility = ["//platform/ios:__pkg__"],
|
||||
)
|
||||
|
||||
exports_files([
|
||||
"Info.plist",
|
||||
])
|
||||
info_plist(
|
||||
name = "info_benchmark_plist",
|
||||
out = "Info-benchmark.plist",
|
||||
base_info_plist = "Info.plist",
|
||||
visibility = ["//platform/ios:__pkg__"],
|
||||
)
|
||||
|
||||
exports_files(["Info.plist"])
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
echo "Generating plist files..."
|
||||
|
||||
sem_version="0.0.0"
|
||||
hash=""
|
||||
teamid="0000000000" # Provisioning profile team ID, required for targeting physical devices
|
||||
bundleidprefix="org.maplibre.app" # bundle id prefix
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--sem-ver)
|
||||
shift
|
||||
sem_version="$1"
|
||||
shift
|
||||
;;
|
||||
--hash)
|
||||
shift
|
||||
hash="$1"
|
||||
shift
|
||||
;;
|
||||
--token)
|
||||
shift
|
||||
token="$1"
|
||||
shift
|
||||
;;
|
||||
--team-id)
|
||||
shift
|
||||
teamid="$1"
|
||||
shift
|
||||
;;
|
||||
--bundleidprefix)
|
||||
shift
|
||||
bundleidprefix="$1"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Move and configure the info plists with the semantic version and hash.
|
||||
temp_info_static_plist="platform/ios/build/Info-static.plist"
|
||||
temp_info_plist="platform/ios/build/Info.plist"
|
||||
# Move and configure the app plist
|
||||
temp_app_info_plist="platform/ios/build/Info-app.plist"
|
||||
# Move and configure the BenchmarkApp plist
|
||||
temp_benchmark_info_plist="platform/ios/build/Info-benchmark.plist"
|
||||
|
||||
if [ ! -d platform/ios/build ]; then
|
||||
mkdir platform/ios/build
|
||||
fi
|
||||
|
||||
cp platform/ios/framework/Info-static.plist "$temp_info_static_plist"
|
||||
cp platform/ios/framework/Info.plist "$temp_info_plist"
|
||||
cp platform/ios/app/Info.plist "$temp_app_info_plist"
|
||||
cp platform/ios/benchmark/Info.plist "$temp_benchmark_info_plist"
|
||||
|
||||
# Replace semver and hash
|
||||
plutil -replace MLNSemanticVersionString -string "$sem_version" "$temp_info_static_plist"
|
||||
plutil -replace MLNCommitHash -string "$hash" "$temp_info_static_plist"
|
||||
plutil -replace MLNSemanticVersionString -string "$sem_version" "$temp_info_plist"
|
||||
plutil -replace MLNCommitHash -string "$hash" "$temp_info_plist"
|
||||
|
||||
# Insert API Key
|
||||
echo "Inserting MapLibre API key..."
|
||||
if [ "$token" ]; then
|
||||
plutil -replace MLNApiKey -string $token "$temp_app_info_plist"
|
||||
plutil -replace MLNApiKey -string $token "$temp_benchmark_info_plist"
|
||||
echo "API key insertion successful"
|
||||
else
|
||||
echo "Warning: Missing API key."
|
||||
fi
|
||||
|
||||
# Generate the team ID for Xcode device provisioning
|
||||
echo "Updating bazel/config.bzl..."
|
||||
cat > platform/ios/bazel/config.bzl <<EOF
|
||||
APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID = "$teamid"
|
||||
APPLE_MOBILE_PROVISIONING_PROFILE_NAME = "iOS Team Provisioning Profile: *"
|
||||
BUNDLE_ID_PREFIX = "$bundleidprefix"
|
||||
BUILD_MODE = "bazel"
|
||||
EOF
|
||||
@@ -11,12 +11,6 @@ release_type="release"
|
||||
# Renderer flavor
|
||||
flavor="legacy"
|
||||
|
||||
echo "------ Determining Maplibre version and hash ------"
|
||||
sem_version=$(git describe --tags --match=ios-v*.*.* --abbrev=0 | sed 's/^ios-v//')
|
||||
hash=$(git log | head -1 | awk '{ print $2 }' | cut -c 1-10) && true
|
||||
|
||||
args=("--sem-ver" "$sem_version" "--hash" "$hash")
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--static)
|
||||
@@ -39,16 +33,6 @@ while [[ $# -gt 0 ]]; do
|
||||
build_type="link"
|
||||
shift
|
||||
;;
|
||||
--teamid)
|
||||
shift
|
||||
args+=("--team-id" "$1")
|
||||
shift
|
||||
;;
|
||||
--bundleidprefix)
|
||||
shift
|
||||
args+=("--bundleidprefix" "$1")
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
echo "Build the maplibre xcframework using the bazel build files. You must install Baselisk to build using this method."
|
||||
echo "Usage: .bazel-package.sh --static|--dynamic --release|--debug"
|
||||
@@ -69,7 +53,7 @@ done
|
||||
|
||||
echo "------ Build type: $build_type Release type: $release_type ------"
|
||||
|
||||
target="Mapbox.$build_type"
|
||||
target="MapLibre.$build_type"
|
||||
|
||||
compilation_mode="opt"
|
||||
if [ "$release_type" = "debug" ]; then
|
||||
@@ -80,9 +64,7 @@ if [ ! -d platform/ios/build ]; then
|
||||
mkdir platform/ios/build
|
||||
fi
|
||||
|
||||
bash "platform/ios/scripts/bazel-generate-plists.sh" "${args[@]}"
|
||||
|
||||
echo "------ Building Maplibre version: $sem_version hash: $hash ------"
|
||||
echo "------ Building Maplibre ------"
|
||||
|
||||
# Build
|
||||
ncpu=$(sysctl -n hw.ncpu)
|
||||
|
||||
@@ -2,20 +2,8 @@
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
echo "------ Determining Maplibre version and hash ------"
|
||||
sem_version=0.0.0
|
||||
hash=$(git log | head -1 | awk '{ print $2 }' | cut -c 1-10) && true
|
||||
|
||||
echo "------ Configuring project ------"
|
||||
|
||||
# Build parameters
|
||||
token_file=~/.maplibre
|
||||
token_file2=~/maplibre
|
||||
token="$(cat $token_file 2>/dev/null || cat $token_file2 2>/dev/null || echo $MLN_API_KEY)"
|
||||
flavor="legacy" # Renderer build flavor: legacy, drawable, split
|
||||
|
||||
args=("--sem-ver" "$sem_version" "--hash" "$hash")
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--flavor)
|
||||
@@ -23,21 +11,6 @@ while [[ $# -gt 0 ]]; do
|
||||
flavor="$1"
|
||||
shift
|
||||
;;
|
||||
--teamid)
|
||||
shift
|
||||
args+=("--team-id" "$1")
|
||||
shift
|
||||
;;
|
||||
--bundleidprefix)
|
||||
shift
|
||||
args+=("--bundleidprefix" "$1")
|
||||
shift
|
||||
;;
|
||||
--apikey)
|
||||
shift
|
||||
token="$1"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
@@ -45,15 +18,6 @@ while [[ $# -gt 0 ]]; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -z "$token" ]; then
|
||||
args+=("--token" "$token")
|
||||
fi
|
||||
|
||||
bash "platform/ios/scripts/bazel-generate-plists.sh" "${args[@]}"
|
||||
|
||||
echo "------ Building Maplibre version: $sem_version hash: $hash ------"
|
||||
|
||||
# Generate the Xcode project
|
||||
# Example invocation: ./bazel-xcodeproj.sh flavor split teamid 1234567890
|
||||
# Find your team ID inside a .mobileprovision file or in your keychain (Apple development: your@email -> Get Info -> Organizational Unit)
|
||||
# Example invocation: bazel-xcodeproj.sh flavor split
|
||||
bazel run //platform/ios:xcodeproj --@rules_xcodeproj//xcodeproj:extra_common_flags="--//:renderer=$flavor --//:maplibre_platform=ios"
|
||||
|
||||
@@ -68,7 +68,6 @@ ios_unit_test(
|
||||
"//platform/darwin:shared_tests_swift_srcs",
|
||||
"//platform/darwin:darwin_objc_hdrs",
|
||||
"//platform/darwin:darwin_objcpp_hdrs",
|
||||
"//platform/darwin:darwin_objc_opengl_hdrs",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user