@@ -23,6 +23,14 @@ IOS_SCRIPTS := $(IOS_DIR)/scripts
2323IOS_FW_DIR := $(IOS_DIR ) /Frameworks
2424IOS_GENERATED := $(IOS_DIR ) /GeneratedRust
2525IOS_SOURCES := $(IOS_DIR ) /Sources
26+ IOS_RUN_ARTIFACTS_DIR ?= $(ROOT ) /artifacts/ios-device-run
27+ IOS_DEVICE_PROFILE ?= 1
28+ IOS_DEVICE_PROFILE_TEMPLATE ?= Time Profiler
29+ IOS_DEVICE_PROFILE_TIME_LIMIT ?=
30+ IOS_SIM_RUN_ARTIFACTS_DIR ?= $(ROOT ) /artifacts/ios-sim-run
31+ IOS_SIM_PROFILE ?= 1
32+ IOS_SIM_PROFILE_TEMPLATE ?= Time Profiler
33+ IOS_SIM_PROFILE_TIME_LIMIT ?=
2634ANDROID_DIR := $(ROOT ) /apps/android
2735ANDROID_JNI := $(ANDROID_DIR ) /core/bridge/src/main/jniLibs
2836GENERATED_DIR := $(RUST_DIR ) /generated
@@ -42,6 +50,19 @@ ANDROID_EMULATOR_ABIS ?= $(if $(filter arm64 aarch64,$(HOST_ARCH)),arm64-v8a,x86
4250# Source local env (credentials, SDK paths) if present — must precede ?= auto-detect
4351-include .env
4452
53+ AWS_SHARED_CREDENTIALS_FILE ?= $(HOME ) /.aws/credentials
54+
55+ define aws_profile_credential
56+ $(strip $(shell PROFILE='$(AWS_PROFILE ) ' CREDS_FILE='$(AWS_SHARED_CREDENTIALS_FILE ) ' KEY='$(1 ) ' /bin/bash -lc '\
57+ if [ -n "$$PROFILE" ] && [ -f "$$CREDS_FILE" ]; then \
58+ awk -F" * = * " -v profile="$$PROFILE" -v key="$$KEY" '\''
59+ $$0 == "[" profile "]" { in_profile = 1; next } \
60+ /^\[/ { in_profile = 0 } \
61+ in_profile && $$1 == key { print $$2; exit }\
62+ '\'' "$$CREDS_FILE"; \
63+ fi') )
64+ endef
65+
4566# Auto-detect Android SDK/NDK/JDK paths (macOS defaults, overridable via env or .env)
4667ANDROID_SDK_ROOT ?= $(or $(ANDROID_HOME ) ,$(wildcard $(HOME ) /Library/Android/sdk) )
4768ANDROID_NDK_HOME ?= $(shell ls -d $(ANDROID_SDK_ROOT ) /ndk/* / 2>/dev/null | sort -V | tail -1 | sed 's:/* $$::')
@@ -61,14 +82,30 @@ export JAVA_HOME
6182
6283SCCACHE := $(shell command -v sccache 2>/dev/null)
6384ifneq ($(SCCACHE ) ,)
85+ ifeq ($(strip $(AWS_ACCESS_KEY_ID)),)
86+ AWS_ACCESS_KEY_ID := $(call aws_profile_credential,aws_access_key_id)
87+ endif
88+ ifeq ($(strip $(AWS_SECRET_ACCESS_KEY)),)
89+ AWS_SECRET_ACCESS_KEY := $(call aws_profile_credential,aws_secret_access_key)
90+ endif
91+ ifeq ($(strip $(AWS_SESSION_TOKEN)),)
92+ AWS_SESSION_TOKEN := $(call aws_profile_credential,aws_session_token)
93+ endif
6494 export RUSTC_WRAPPER := $(SCCACHE )
6595 ifdef SCCACHE_BUCKET
6696 export SCCACHE_BUCKET
6797 export SCCACHE_ENDPOINT
6898 export SCCACHE_REGION
6999 export SCCACHE_S3_KEY_PREFIX
70- export AWS_ACCESS_KEY_ID
71- export AWS_SECRET_ACCESS_KEY
100+ ifneq ($(strip $(AWS_ACCESS_KEY_ID)),)
101+ export AWS_ACCESS_KEY_ID
102+ endif
103+ ifneq ($(strip $(AWS_SECRET_ACCESS_KEY)),)
104+ export AWS_SECRET_ACCESS_KEY
105+ endif
106+ ifneq ($(strip $(AWS_SESSION_TOKEN)),)
107+ export AWS_SESSION_TOKEN
108+ endif
72109 $(info [cache] Using sccache : $(SCCACHE ) → s3://$(SCCACHE_BUCKET ) )
73110 else
74111 $(info [cache] Using sccache : $(SCCACHE ) (local only))
@@ -89,8 +126,7 @@ BOUNDARY_SOURCES := \
89126 $(RUST_DIR ) /codex-mobile-client/Cargo.toml \
90127 $(RUST_DIR ) /codex-mobile-client/src/lib.rs \
91128 $(RUST_DIR ) /codex-mobile-client/src/conversation_uniffi.rs \
92- $(RUST_DIR ) /codex-mobile-client/src/discovery_uniffi.rs \
93- $(RUST_DIR ) /codex-mobile-client/src/mobile_client_impl.rs
129+ $(RUST_DIR ) /codex-mobile-client/src/discovery_uniffi.rs
94130
95131BOUNDARY_SOURCES += $(shell find $(RUST_DIR ) /codex-mobile-client/src -type f -name '* .rs' 2>/dev/null)
96132
@@ -140,24 +176,22 @@ ios-sim-fast: ios-build-sim-fast
140176ios-device : ios-build-device
141177ios-device-fast : ios-build-device-fast
142178ios-sim-run : ios-sim-fast
143- @echo " ==> Installing and launching on booted simulator..."
144- @APP_PATH=$$(/bin/ls -dt $(HOME ) /Library/Developer/Xcode/DerivedData/Litter-*/Build/Products/Debug-iphonesimulator/Litter.app 2>/dev/null | head -1 ) && \
145- if [ -z " $$ APP_PATH" ]; then echo " ERROR: Litter.app not found in DerivedData" ; exit 1; fi && \
146- xcrun simctl install booted " $$ APP_PATH" && \
147- xcrun simctl launch booted com.sigkitten.litter
179+ @echo " ==> Installing and launching on booted simulator with saved logs/profile..."
180+ @cd $(ROOT ) && \
181+ IOS_SIM_PROFILE=' $(IOS_SIM_PROFILE)' \
182+ IOS_SIM_PROFILE_TEMPLATE=' $(IOS_SIM_PROFILE_TEMPLATE)' \
183+ IOS_SIM_PROFILE_TIME_LIMIT=' $(IOS_SIM_PROFILE_TIME_LIMIT)' \
184+ IOS_SIM_RUN_ARTIFACTS_DIR=' $(IOS_SIM_RUN_ARTIFACTS_DIR)' \
185+ $(IOS_SCRIPTS ) /run-sim.sh
148186
149187ios-device-run : ios-device-fast
150- @echo " ==> Installing and launching on connected device..."
151- @set -o pipefail && \
152- APP_PATH=$$(/bin/ls -dt $(HOME ) /Library/Developer/Xcode/DerivedData/Litter-*/Build/Products/Debug-iphoneos/Litter.app 2>/dev/null | head -1 ) && \
153- if [ -z " $$ APP_PATH" ]; then echo " ERROR: Litter.app not found in DerivedData" ; exit 1; fi && \
154- DEVICE_ID=$$(xcrun devicectl list devices 2>/dev/null | grep -E 'available|connected' | grep -v 'Simulator' | grep -oE '[0-9A-F]{8}-([0-9A-F]{4}- ) {3}[0-9A-F]{12}' | head -1) && \
155- if [ -z " $$ DEVICE_ID" ]; then echo " ERROR: no connected device found" ; exit 1; fi && \
156- echo " ==> Installing on device $$ DEVICE_ID..." && \
157- xcrun devicectl device install app --device " $$ DEVICE_ID" " $$ APP_PATH" && \
158- echo " ==> Launching with attached console and timestamps (Ctrl+C stops the app)..." && \
159- xcrun devicectl device process launch --device " $$ DEVICE_ID" --terminate-existing --console com.sigkitten.litter 2>&1 | \
160- perl -MPOSIX=strftime -ne ' BEGIN { $$| = 1 } print strftime("[%Y-%m-%d %H:%M:%S] ", localtime), $$_'
188+ @echo " ==> Installing and launching on connected device with saved logs/profile..."
189+ @cd $(ROOT ) && \
190+ IOS_DEVICE_PROFILE=' $(IOS_DEVICE_PROFILE)' \
191+ IOS_DEVICE_PROFILE_TEMPLATE=' $(IOS_DEVICE_PROFILE_TEMPLATE)' \
192+ IOS_DEVICE_PROFILE_TIME_LIMIT=' $(IOS_DEVICE_PROFILE_TIME_LIMIT)' \
193+ IOS_RUN_ARTIFACTS_DIR=' $(IOS_RUN_ARTIFACTS_DIR)' \
194+ $(IOS_SCRIPTS ) /run-device.sh
161195
162196ios-run : ios
163197 @open $(IOS_DIR ) /Litter.xcodeproj
@@ -251,10 +285,10 @@ help:
251285 @printf ' %s\n' \
252286 ' make ios full iOS package lane + simulator build' \
253287 ' make ios-sim-fast fast simulator lane using raw staticlib outputs' \
254- ' make ios-sim-run fast sim build + install + launch on booted simulator' \
288+ ' make ios-sim-run fast sim build + install + launch on booted simulator; saves console log and Time Profiler trace under artifacts/ios-sim-run (override IOS_SIM_PROFILE=0, IOS_SIM_PROFILE_TEMPLATE, IOS_SIM_PROFILE_TIME_LIMIT=30s to cap capture) ' \
255289 ' make ios-device full iOS package lane + device build' \
256290 ' make ios-device-fast fast device lane using raw staticlib outputs' \
257- ' make ios-device-run fast device build + install + launch with attached console on connected device' \
291+ ' make ios-device-run fast device build + install + launch on connected device; saves console log and Time Profiler trace for the whole run under artifacts/ios- device-run (override IOS_DEVICE_PROFILE=0, IOS_DEVICE_PROFILE_TEMPLATE, IOS_DEVICE_PROFILE_TIME_LIMIT=30s to cap capture) ' \
258292 ' make rust-ios-package full Rust iOS package lane (bindings + xcframework)' \
259293 ' make rust-ios-sim-fast fast Rust iOS simulator lane (raw staticlib only)' \
260294 ' make rust-ios-device-fast fast Rust iOS device lane (raw staticlib only)' \
0 commit comments