Repository navigation
Expand file tree
/
Copy pathtest-mobile-dune-build.sh
More file actions
executable file
·76 lines (64 loc) · 2.36 KB
/
Copy pathtest-mobile-dune-build.sh
File metadata and controls
executable file
·76 lines (64 loc) · 2.36 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
72
73
74
75
76
#!/usr/bin/env bash
set -euo pipefail
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
workspace="$repo_root/dune-workspace.mobile"
builder="$repo_root/scripts/build-mobile-ocaml.sh"
core_dune="$repo_root/shared/native/dune"
dune_project="$repo_root/dune-project"
lockfile="$repo_root/logseq.opam.locked"
legacy_builder="$repo_root/scripts/build-mobile-ocaml-deps.sh"
legacy_mldoc_patch="$repo_root/scripts/patches/mldoc-wrapped.patch"
[[ -f $workspace ]] || {
echo "error: mobile Dune workspace is missing" >&2
exit 1
}
[[ -x $builder ]] || {
echo "error: mobile OCaml builder is missing or not executable" >&2
exit 1
}
[[ ! -e $repo_root/Vendor/mldoc ]] || {
echo "error: mldoc must come from the pinned Dune dependency, not a submodule" >&2
exit 1
}
[[ ! -e $legacy_builder && ! -e $legacy_mldoc_patch ]] || {
echo "error: legacy manual mobile dependency build files must be removed" >&2
exit 1
}
grep -Fq '(switch 5.5.0)' "$workspace"
grep -Fq '(host mobile_host)' "$workspace"
for context in ios_simulator ios_device android_arm64 android_x86_64; do
grep -Fq "(name $context)" "$workspace"
done
if grep -Fq "(name macos_arm64)" "$workspace"; then
echo "error: desktop macOS Dune context must be removed" >&2
exit 1
fi
grep -Fq '"$dune" build' "$builder"
grep -Fq 'target="_build/$context/shared/native/logseq_mobile_entry.exe.o"' "$builder"
grep -Fq '(modes object)' "$core_dune"
if grep -Eq '\(modes[^)]*(exe|shared_object)' "$core_dune"; then
echo "error: mobile OCaml must only build the host-linked object" >&2
exit 1
fi
if grep -Eq 'ocamlopt|\.cmx|output-complete-obj|yojson|melange|mldoc|datascript|curl|git|patch|find|sed|awk' "$builder"; then
echo "error: mobile OCaml builder contains dependency or linker internals" >&2
exit 1
fi
if grep -Fq 'OPAM_SWITCH_PREFIX' "$core_dune"; then
echo "error: mobile Dune rules depend on a local opam installation path" >&2
exit 1
fi
if grep -Fq '(depends' "$dune_project"; then
echo "error: OCaml dependencies must be declared only in logseq.opam" >&2
exit 1
fi
if [[ -f $lockfile ]] && grep -Fq 'file:///' "$lockfile"; then
echo "error: mobile dependency lock contains a local file URL" >&2
exit 1
fi
line_count=$(wc -l <"$builder")
((line_count <= 40)) || {
echo "error: mobile OCaml builder is too large: $line_count lines" >&2
exit 1
}
echo "ok - mobile OCaml build is a thin Dune wrapper"