Repository navigation
Expand file tree
/
Copy pathextract-app-intents.sh
More file actions
executable file
·63 lines (63 loc) · 2.64 KB
/
Copy pathextract-app-intents.sh
File metadata and controls
executable file
·63 lines (63 loc) · 2.64 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
#!/usr/bin/env bash
set -euo pipefail
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
module=$1
sdk=$2
triple=$3
deployment_target=$4
output=$5
swift_build_dir=$6
swift_scratch_dir=$7
shift 7
work=$(mktemp -d /tmp/logseq-app-intents.XXXXXX)
trap 'rm -rf "$work"' EXIT
sources=("$@")
printf '%s\n' "${sources[@]}" > "$work/sources"
if [[ -n ${LOGSEQ_APP_INTENTS_VALUES_PATH:-} ]]; then
# Swift uses the requested path for whole-module builds and writes one
# sidecar next to each object file for incremental builds.
const_values=("$LOGSEQ_APP_INTENTS_VALUES_PATH")
if [[ ! -s $LOGSEQ_APP_INTENTS_VALUES_PATH ]]; then
const_values=()
for source in "${sources[@]}"; do
const_values+=("$swift_build_dir/$module.build/${source##*/}.swiftconstvalues")
done
fi
for file in "${const_values[@]}"; do
[[ -s $file ]] || { echo "Missing Swift App Intents constants: $file" >&2; exit 1; }
done
else
module_cache="$repo_root/apple/.build/app-intents-module-cache"
mkdir -p "$module_cache"
# Supply the Clang modules normally configured by SwiftPM.
compiler_options=(
-I "$swift_build_dir/Modules"
-Xcc "-fmodule-map-file=$swift_build_dir/LogseqCoreABI.build/module.modulemap"
-I "$repo_root/apple/Sources/LogseqCoreABI/include"
)
if [[ ${LOGSEQ_ENABLE_SENTRY:-0} == 1 ]]; then
sentry_headers="$swift_scratch_dir/checkouts/sentry-cocoa/Sources/Sentry"
compiler_options+=(
-Xcc "-fmodule-map-file=$swift_build_dir/SentryHeaders.build/module.modulemap"
-I "$sentry_headers/Public"
-I "$sentry_headers/include"
)
fi
const_values=("$work/values.swiftconstvalues")
started=$SECONDS
xcrun swiftc -frontend -typecheck -parse-as-library -sdk "$sdk" -target "$triple" \
-module-cache-path "$module_cache" \
-module-name "$module" -const-gather-protocols-file "$repo_root/scripts/app-intents-protocols.json" \
-emit-const-values-path "${const_values[0]}" "${compiler_options[@]}" "${sources[@]}"
echo "[ios-build] App Intents typecheck and constants: $((SECONDS - started))s" >&2
fi
printf '%s\n' "${const_values[@]}" > "$work/values"
started=$SECONDS
xcrun appintentsmetadataprocessor --output "$output" \
--toolchain-dir "$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain" \
--module-name "$module" --sdk-root "$sdk" \
--xcode-version "$(xcodebuild -version | awk '/Build version/ {print $3}')" \
--platform-family iOS --deployment-target "$deployment_target" --target-triple "$triple" \
--source-file-list "$work/sources" --swift-const-vals-list "$work/values"
[[ -s "$output/Metadata.appintents/extract.actionsdata" ]]
echo "[ios-build] App Intents metadata: $((SECONDS - started))s" >&2