| Build the APK with buck2, from pins rather than from a second checkout a71ef8f nandi 19d ago | 1 | # 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. |
| 6 | def 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 | ) |