forked from Jonathan-Mckenzie/xcode-rust-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (61 loc) · 2.03 KB
/
Copy pathMakefile
File metadata and controls
71 lines (61 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
SHELL := /bin/bash
PROJECT := swiftyapp/swiftyapp.xcodeproj
SCHEME := swiftyapp
BUILD_SCRIPT := ./build.sh
RUST_CRATE_DIR := rustylib
DERIVED_DATA ?= .build/xcode
CONFIGURATION ?= Debug
APP_NAME := swiftyapp.app
INSTALL_DIR ?= $(HOME)/Applications
SYMROOT := $(abspath $(DERIVED_DATA))
OBJROOT := $(SYMROOT)/Intermediates.noindex
HOST_ARCH := $(shell uname -m)
SIMULATOR_ARCH := $(if $(filter arm64,$(HOST_ARCH)),arm64,x86_64)
IOS_DESTINATION ?= generic/platform=iOS Simulator
CATALYST_DESTINATION ?= generic/platform=macOS,variant=Mac Catalyst
CATALYST_APP_PATH := $(SYMROOT)/$(CONFIGURATION)-maccatalyst/$(APP_NAME)
.DEFAULT_GOAL := help
.PHONY: help rust resolve app catalyst install clean
help:
@printf '%s\n' \
'make rust - build the Rust library, bindings, and XCFramework' \
'make resolve - resolve local Swift package dependencies' \
'make app - build the iOS app for a generic simulator destination' \
'make catalyst - build the app for Mac Catalyst' \
'make install - install the Mac Catalyst app into ~/Applications' \
'make clean - clean Rust and Xcode build artifacts'
rust:
$(BUILD_SCRIPT)
resolve:
xcodebuild -resolvePackageDependencies -project "$(PROJECT)" -scheme "$(SCHEME)"
app: rust resolve
xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration "$(CONFIGURATION)" \
-derivedDataPath "$(DERIVED_DATA)" \
SYMROOT="$(SYMROOT)" \
OBJROOT="$(OBJROOT)" \
-destination "$(IOS_DESTINATION)" \
ARCHS="$(SIMULATOR_ARCH)" \
ONLY_ACTIVE_ARCH=YES \
build
catalyst: rust resolve
xcodebuild \
-project "$(PROJECT)" \
-scheme "$(SCHEME)" \
-configuration "$(CONFIGURATION)" \
-derivedDataPath "$(DERIVED_DATA)" \
SYMROOT="$(SYMROOT)" \
OBJROOT="$(OBJROOT)" \
-destination "$(CATALYST_DESTINATION)" \
ARCHS="$(HOST_ARCH)" \
ONLY_ACTIVE_ARCH=YES \
build
install: catalyst
mkdir -p "$(INSTALL_DIR)"
rm -rf "$(INSTALL_DIR)/$(APP_NAME)"
cp -R "$(CATALYST_APP_PATH)" "$(INSTALL_DIR)/$(APP_NAME)"
clean:
cd "$(RUST_CRATE_DIR)" && cargo clean
rm -rf "$(DERIVED_DATA)"