Simplify bazel xcode scripts (#1639)

This commit is contained in:
mwilsnd
2023-09-18 08:03:48 -04:00
committed by GitHub
parent 25c1f3c7a6
commit fb496dcc7c
12 changed files with 51 additions and 202 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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"