Xcode project generation with bazel (#1108)

Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
mwilsnd
2023-05-08 17:37:05 -04:00
committed by GitHub
parent bd91b2362a
commit d716636d83
18 changed files with 160 additions and 22 deletions

View File

@@ -1 +1 @@
6.0.0-pre.20220630.1
6.1.1

View File

@@ -4,9 +4,14 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_apple",
sha256 = "a95d9007570cb5c6180b7e380bad2a854734209cc02390eed208efb922843c8a",
strip_prefix = "rules_apple-76752fe84ff0dc5d793033015647c78efbf41309",
url = "https://github.com/bazelbuild/rules_apple/archive/76752fe84ff0dc5d793033015647c78efbf41309.tar.gz",
sha256 = "9e26307516c4d5f2ad4aee90ac01eb8cd31f9b8d6ea93619fc64b3cbc81b0944",
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.2.0/rules_apple.2.2.0.tar.gz",
)
http_archive(
name = "rules_xcodeproj",
sha256 = "54cee524abd72db950482ded168dd44397369077b734d4cf4b06f734e10a3e80",
url = "https://github.com/MobileNativeFoundation/rules_xcodeproj/releases/download/1.5.1/release.tar.gz",
)
load(
@@ -36,3 +41,10 @@ load(
)
apple_support_dependencies()
load(
"@rules_xcodeproj//xcodeproj:repositories.bzl",
"xcodeproj_rules_dependencies",
)
xcodeproj_rules_dependencies()

View File

@@ -1,7 +1,12 @@
load("@build_bazel_rules_apple//apple:apple.bzl", "apple_static_xcframework", "apple_xcframework")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_framework")
load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS", "WARNING_FLAGS")
load(
"@rules_xcodeproj//xcodeproj:defs.bzl",
"top_level_target",
"xcodeproj",
)
# This list of public headers is from what Mapbox vendors with their dynamic framework
# If we forget one the build will fail, and if we add too many there will be a warning
@@ -93,7 +98,7 @@ apple_static_xcframework(
],
"device": ["arm64"],
},
minimum_os_versions = {"ios": "9.0"},
minimum_os_versions = {"ios": "12.0"},
public_hdrs = _PUBLIC_HEADERS,
umbrella_header = "platform/ios/src/Mapbox.h",
visibility = ["//visibility:public"],
@@ -116,7 +121,7 @@ apple_xcframework(
],
"device": ["arm64"],
},
minimum_os_versions = {"ios": "9.0"},
minimum_os_versions = {"ios": "12.0"},
public_hdrs = _PUBLIC_HEADERS,
umbrella_header = "platform/ios/src/Mapbox.h",
visibility = ["//visibility:public"],
@@ -131,7 +136,7 @@ ios_framework(
families = ["iphone"],
infoplists = ["build/Info.plist"],
linkopts = ["-all_load"],
minimum_os_version = "9.0",
minimum_os_version = "12.0",
deps = ["sdk"],
)
@@ -149,10 +154,12 @@ objc_library(
"Security",
"WebKit",
],
visibility = ["//visibility:public"],
deps = [
"objc-sdk",
"objcpp-sdk",
],
hdrs = _PUBLIC_HEADERS
)
# sdk for the dynamic target. Lacking the resources bundle since for dynamic
@@ -169,6 +176,7 @@ objc_library(
"Security",
"WebKit",
],
visibility = ["//visibility:public"],
deps = [
"objc-sdk",
"objcpp-sdk",
@@ -358,3 +366,89 @@ objc_library(
"//platform/darwin:darwin-objcpp",
],
)
objc_library(
name = "iosapp",
srcs = [
"platform/ios/app/MBXAppDelegate.m",
"platform/ios/app/MBXState.m",
"platform/ios/app/MBXCustomLocationViewController.m",
"platform/ios/app/MBXSnapshotsViewController.m",
"platform/ios/app/MBXFrameTimeGraphView.m",
"platform/ios/app/main.m",
"platform/ios/app/MBXCustomCalloutView.m",
"platform/ios/app/MBXViewController.m",
"platform/ios/app/MBXUserLocationAnnotationView.m",
"platform/ios/app/MBXAnnotationView.m",
"platform/ios/app/MBXOfflinePacksTableViewController.m",
"platform/ios/app/MBXEmbeddedMapViewController.m",
"platform/ios/app/MBXOrnamentsViewController.m",
"platform/ios/app/MBXStateManager.m",
"platform/darwin/app/LimeGreenStyleLayer.m",
"platform/darwin/app/LimeGreenStyleLayer.h"
],
hdrs = [
"platform/ios/app/MBXAppDelegate.h",
"platform/ios/app/MBXState.h",
"platform/ios/app/MBXCustomLocationViewController.h",
"platform/ios/app/MBXSnapshotsViewController.h",
"platform/ios/app/MBXFrameTimeGraphView.h",
"platform/ios/app/MBXCustomCalloutView.h",
"platform/ios/app/MBXViewController.h",
"platform/ios/app/MBXUserLocationAnnotationView.h",
"platform/ios/app/MBXAnnotationView.h",
"platform/ios/app/MBXOfflinePacksTableViewController.h",
"platform/ios/app/MBXEmbeddedMapViewController.h",
"platform/ios/app/MBXOrnamentsViewController.h",
"platform/ios/app/MBXStateManager.h",
"platform/ios/app/MLNMapView_Experimental.h"
],
includes = [
"platform/darwin/app"
],
deps = [
"sdk"
],
sdk_frameworks = [
"GLKit" # needed for LimeGreenStyleLayer
]
)
ios_application(
name = "App",
bundle_id = "com.maplibre.app",
families = ["iphone", "ipad"],
infoplists = ["platform/ios/app/Info.plist"],
minimum_os_version = "12.0",
visibility = ["//visibility:public"],
deps = [
"iosapp",
],
resources = [
"platform/ios/app/numeric_filter_style.json",
"platform/ios/app/missing_icon.json",
"platform/ios/app/points.geojson",
"platform/ios/app/polyline.geojson",
"platform/ios/app/Settings.bundle",
"platform/ios/app/Main.storyboard",
"platform/ios/app/threestates.geojson",
"platform/ios/app/LaunchScreen.storyboard",
"platform/ios/app/simple_route.json",
"platform/ios/app/fill_filter_style.json",
"platform/ios/app/Assets.xcassets",
"platform/darwin/test/amsterdam.geojson"
] + glob([
"platform/ios/app/*.lproj/**"
])
)
xcodeproj(
name = "xcodeproj",
project_name = "MapLibre",
tags = ["manual"],
top_level_targets = [
top_level_target("App", target_environments = ["simulator"]),
],
minimum_xcode_version = "14"
)

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import "Mapbox.h"
@interface LimeGreenStyleLayer : MLNOpenGLStyleLayer

View File

@@ -1,5 +1,5 @@
#import "LimeGreenStyleLayer.h"
@import GLKit;
#import <GLKit/GLKit.h>
@implementation LimeGreenStyleLayer {
GLuint _program;

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
@interface MBXAnnotationView : MLNAnnotationView
@end

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
#import "MBXAppDelegate.h"
#import "MBXViewController.h"

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
/**
* Basic custom callout view to demonstrate how to

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
#import "MBXCustomLocationViewController.h"

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
#import "MBXEmbeddedMapViewController.h"

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
#import "MBXOfflinePacksTableViewController.h"

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
#import "MBXOrnamentsViewController.h"

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
#import "MBXSnapshotsViewController.h"

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
NS_ASSUME_NONNULL_BEGIN

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
@interface MBXUserLocationAnnotationView : MLNUserLocationAnnotationView

View File

@@ -1,4 +1,4 @@
@import Mapbox;
#import "Mapbox.h"
#import "MBXViewController.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import "Mapbox.h"
@interface MLNMapView (Experimental)

View File

@@ -0,0 +1,32 @@
#!/bin/bash
set -euo pipefail
pushd ../../../../../
echo "------ Determining Maplibre version and hash ------"
sem_version=0.0.0
hash=$(git log | head -1 | awk '{ print $2 }' | cut -c 1-10) && true
# 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"
if [ ! -d platform/ios/build ]; then
mkdir platform/ios/build
fi
cp platform/ios/platform/ios/framework/Info-static.plist "$temp_info_static_plist"
cp platform/ios/platform/ios/framework/Info.plist "$temp_info_plist"
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"
echo "------ Building Maplibre version: $sem_version hash: $hash ------"
bazel run //platform/ios:xcodeproj
popd