nandi/frqpublic Fork 0
6c745dfdacf9ce4b652034872fbebd67d16a66e5
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.

Pin the media plane, now that there is a release to pin 03d5a6b · on 6c745dfdacf9ce4b652034872fbebd67d16a66e5 · nandi · 18d ago
defs.bzl · 86 lines · 3.6 KBPython Blame HistoryRaw
 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
# Where libvidya comes from, which is a question with two answers.
#
# A BUCK file cannot branch — `if` outside a `def` is not this dialect — and
# this is not a `select` either: it does not vary by configuration but by
# whether a checkout is sitting next to this one. So it lives in a macro.
def libvidya(name):
    """The Android libvidya: a sibling checkout's, or the pinned release's.

    Either way the library's bytes are an input to what reads them, which is
    the part that matters — an action that shelled out to build it would have
    nothing to invalidate on and would serve the same stale object forever.
    """
    if native.read_root_config("frq", "libvidya", "pinned") == "checkout":
        # Staged by the `buck` recipe out of the sibling jolt-native, so that
        # anyone working on both repos at once builds what they are editing.
        native.export_file(
            name = name,
            src = "prebuilt/arm64-v8a/libvidya.so",
            mode = "reference",
        )
    else:
        # The release, fetched by digest. This is what makes an APK buildable
        # with no jolt-native checkout and no NDK anywhere on the machine.
        native.genrule(
            name = name,
            out = "libvidya.so",
            cmd = "cp $(location toolchains//dist:libvidya-android)/libvidya.so \"$OUT\"",
        )

def libjoltmoq(name):
    """The Android libjoltmoq: a sibling checkout's, or the pinned release's.

    The same two answers as libvidya, and necessarily the same one — the two
    objects are built together, libjoltapp links both, and pairing one release's
    media plane with another's UI is a combination nothing has tested. Both
    macros read the same config key, so they cannot disagree.
    """
    if native.read_root_config("frq", "libvidya", "pinned") == "checkout":
        native.export_file(
            name = name,
            src = "prebuilt/arm64-v8a/libjoltmoq.so",
            mode = "reference",
        )
    else:
        native.genrule(
            name = name,
            out = "libjoltmoq.so",
            cmd = "cp $(location toolchains//dist:libjoltmoq-android)/libjoltmoq.so \"$OUT\"",
        )

def glue(c_name, include_name):
    """jolt_main.c and the ABI's headers, from wherever libvidya came from.

    Targets rather than paths, and that is the point: naming a checkout's file
    by absolute path leaves buck with nothing to notice when it changes, so
    editing the glue rebuilt nothing and the APK kept the old object. It has to
    be an input.
    """
    if native.read_root_config("frq", "libvidya", "pinned") == "checkout":
        # Staged by the `buck` recipe, because a cell cannot reach outside its
        # own root.
        native.export_file(
            name = c_name,
            src = "prebuilt/glue/android/jolt_main.c",
            mode = "reference",
        )
        # A genrule rather than a filegroup: a filegroup keeps each file at
        # its own path inside the output, so `-I` would have to name the
        # staging directory again. This hands back a directory of headers.
        native.genrule(
            name = include_name,
            out = "include",
            srcs = native.glob(["prebuilt/glue/include/*.h"]),
            cmd = "mkdir -p \"$OUT\" && cp $SRCS \"$OUT\"/",
        )
    else:
        native.genrule(
            name = c_name,
            out = "jolt_main.c",
            cmd = "cp $(location toolchains//dist:android-glue)/android/jolt_main.c \"$OUT\"",
        )
        native.genrule(
            name = include_name,
            out = "include",
            cmd = "cp -r $(location toolchains//dist:android-glue)/include \"$OUT\"",
        )