nandi/frqpublic Fork 0
43ada0baeebdb0aaa22e7659498a9422d3642725
Commits
Clone
git clone https://git.rickub.com/nandi/frq.git
git clone ssh://git@rickub.com/nandi/frq.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

defs.bzl · 87 lines · 3.7 KBPython Blame HistoryRaw
Build the APK with buck2, from pins rather than from a second checkout a71ef8f nandi 19d ago1# Where libvidya comes from, which is a question with two answers.
2#
3# A BUCK file cannot branch — `if` outside a `def` is not this dialect — and
4# this is not a `select` either: it does not vary by configuration but by
5# whether a checkout is sitting next to this one. So it lives in a macro.
6def libvidya(name):
7 """The Android libvidya: a sibling checkout's, or the pinned release's.
8
9 Either way the library's bytes are an input to what reads them, which is
10 the part that matters — an action that shelled out to build it would have
11 nothing to invalidate on and would serve the same stale object forever.
12 """
13 if native.read_root_config("frq", "libvidya", "pinned") == "checkout":
14 # Staged by the `buck` recipe out of the sibling jolt-native, so that
15 # anyone working on both repos at once builds what they are editing.
16 native.export_file(
17 name = name,
18 src = "prebuilt/arm64-v8a/libvidya.so",
19 mode = "reference",
20 )
21 else:
22 # The release, fetched by digest. This is what makes an APK buildable
23 # with no jolt-native checkout and no NDK anywhere on the machine.
24 native.genrule(
25 name = name,
26 out = "libvidya.so",
27 cmd = "cp $(location toolchains//dist:libvidya-android)/libvidya.so \"$OUT\"",
28 )
Make the worktree its own buck root, and the glue an input ae207b8 nandi 18d ago29
Carry the media plane, and the class that opens the camera 43ada0b nandi 18d ago30def libjoltmoq(name):
31 """The Android libjoltmoq, or nothing.
32
33 The media plane crosses to the phone now, but only out of a sibling
34 jolt-native checkout: the pinned v0.1.1 release predates it and carries no
35 such object. Returns True when the APK should package it.
36
37 The two halves cannot disagree, and do not: the pinned glue is the same
38 v0.1.1 and never mentions joltmoq either, so a pinned APK is consistently
39 without a media plane rather than half-wired. Delete the branch — and make
40 the caller unconditional — once jolt-native cuts a release carrying
41 libjoltmoq.so and scripts/libjoltmoq-android.dotslash pins it.
42 """
43 if native.read_root_config("frq", "libvidya", "pinned") != "checkout":
44 return False
45 native.export_file(
46 name = name,
47 src = "prebuilt/arm64-v8a/libjoltmoq.so",
48 mode = "reference",
49 )
50 return True
51
Make the worktree its own buck root, and the glue an input ae207b8 nandi 18d ago52def glue(c_name, include_name):
53 """jolt_main.c and the ABI's headers, from wherever libvidya came from.
54
55 Targets rather than paths, and that is the point: naming a checkout's file
56 by absolute path leaves buck with nothing to notice when it changes, so
57 editing the glue rebuilt nothing and the APK kept the old object. It has to
58 be an input.
59 """
60 if native.read_root_config("frq", "libvidya", "pinned") == "checkout":
61 # Staged by the `buck` recipe, because a cell cannot reach outside its
62 # own root.
63 native.export_file(
64 name = c_name,
65 src = "prebuilt/glue/android/jolt_main.c",
66 mode = "reference",
67 )
68 # A genrule rather than a filegroup: a filegroup keeps each file at
69 # its own path inside the output, so `-I` would have to name the
70 # staging directory again. This hands back a directory of headers.
71 native.genrule(
72 name = include_name,
73 out = "include",
74 srcs = native.glob(["prebuilt/glue/include/*.h"]),
75 cmd = "mkdir -p \"$OUT\" && cp $SRCS \"$OUT\"/",
76 )
77 else:
78 native.genrule(
79 name = c_name,
80 out = "jolt_main.c",
81 cmd = "cp $(location toolchains//dist:android-glue)/android/jolt_main.c \"$OUT\"",
82 )
83 native.genrule(
84 name = include_name,
85 out = "include",
86 cmd = "cp -r $(location toolchains//dist:android-glue)/include \"$OUT\"",
87 )