summaryrefslogtreecommitdiff
path: root/justfile
blob: e2946156ed39b2e8743b867f005c8622c28e49aa (plain) (blame)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import? 'xcode.just'
import? 'environment.just'

target := 'Sora'
identifier := "me.fuwn." + target
derived_data := "/Users/${USER}/Library/Developer/Xcode/DerivedData"
location := "/Users/${USER}/Applications"

alias fmt := format
alias b := build
alias gen := generate
alias loc := localize
alias t := test
alias to := test_only
alias v := verify

fetch:
   curl https://raw.githubusercontent.com/Fuwn/justfiles/refs/heads/main/xcode.just > xcode.just

format:
	just _format {{target}}

build destination="platform=macOS" configuration="Release":
  command -v xcbeautify >/dev/null 2>&1 \
    && xcodebuild -project Sora.xcodeproj -configuration {{configuration}} -scheme {{target}} -destination '{{destination}}' build | xcbeautify \
    || just _build {{target}}

build_ios configuration="Release":
  just build "platform=iOS,arch=arm64,name={{device_name}}" "{{configuration}}"

build_ios_simulator configuration="Release":
  just build "platform=iOS Simulator,name=iPhone 17 Pro" "{{configuration}}"

localize destination="platform=macOS" configuration="Debug":
  xcodebuild -project Sora.xcodeproj -configuration {{configuration}} -scheme {{target}} -destination '{{destination}}' CODE_SIGNING_ALLOWED=NO build

_test destination="platform=iOS Simulator,name=iPhone 17 Pro" scheme="SoraTests" configuration="Debug" *xcodebuild_args:
  simulator_name="$(printf '%s\n' '{{destination}}' | sed -n "s/.*name=\\([^,']*\\).*/\\1/p")"; \
  if [ -n "${simulator_name}" ]; then \
    xcrun simctl boot "${simulator_name}" >/dev/null 2>&1 || true; \
    xcrun simctl bootstatus "${simulator_name}" -b; \
  fi
  xcodebuild -project Sora.xcodeproj -configuration {{configuration}} -scheme {{scheme}} -destination '{{destination}}' {{xcodebuild_args}} test

test destination="platform=iOS Simulator,name=iPhone 17 Pro" scheme="SoraTests" configuration="Debug":
  just _test "{{destination}}" "{{scheme}}" "{{configuration}}"

test_only filter destination="platform=iOS Simulator,name=iPhone 17 Pro" scheme="SoraTests" configuration="Debug":
  just _test "{{destination}}" "{{scheme}}" "{{configuration}}" "-only-testing:{{filter}}"

verify configuration="Debug":
  just format
  just lint
  just localize "platform=macOS" "{{configuration}}"
  just test "platform=iOS Simulator,name=iPhone 17 Pro" "SoraTests" "{{configuration}}"

test_ios_simulator scheme="SoraTests":
  xcodebuild -project Sora.xcodeproj -scheme {{scheme}} -destination 'platform=iOS Simulator,name=iPhone 17 Pro' test

run:
	just _open {{target}}

install derived_data=derived_data location=location:
  app_path="$(find {{derived_data}} -maxdepth 6 -path '*/Build/Products/Release/{{target}}.app' -print | xargs ls -td 2>/dev/null | head -n 1)"; [ -n "${app_path}" ] || { echo "No built app found for {{target}}" >&2; exit 1; }; \
  cp -r "${app_path}" {{location}}

generate:
  command -v xcodegen >/dev/null 2>&1 \
    && DEVELOPMENT_TEAM='{{development_team}}' xcodegen generate \
    || DEVELOPMENT_TEAM='{{development_team}}' mint run xcodegen@synced_folder generate

install_ios derived_data=derived_data configuration="Release":
  app_path="$(find {{derived_data}} -maxdepth 6 -path '*/Build/Products/{{configuration}}-iphoneos/{{target}}.app' -print | xargs ls -td 2>/dev/null | head -n 1)"; [ -n "${app_path}" ] || { echo "No iOS app found for {{target}} ({{configuration}})" >&2; exit 1; }; \
  xcrun devicectl device install app --device {{device_identifier}} "${app_path}"

run_ios flags="":
  xcrun devicectl device process launch {{flags}} --device {{device_identifier}} {{identifier}}

ios_log:
  just ios --console "Debug"

ios flags="" configuration="Release":
  just build_ios "{{configuration}}"
  just install_ios "{{derived_data}}" "{{configuration}}"
  just run_ios {{flags}}

macos:
  just build
  just run

commit:
  git add . && git commit -am "feat: Development commit"