stim 1.20.2 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -8
- package/dist/acquire-artifact-Co2k4f7O.mjs +171 -0
- package/dist/act-DsuqEkiM.mjs +2801 -0
- package/dist/activity-CMLmzp7o.mjs +1397 -0
- package/dist/{agent-device-usage-output-Dzgv6lgR.mjs → agent-device-usage-output-DUFaTMdd.mjs} +23 -67
- package/dist/{android-DCKZrNvV.mjs → android-ByRMUoiJ.mjs} +157 -93
- package/dist/{android-Mz_Inn3w.mjs → android-C7sVmyI9.mjs} +299 -116
- package/dist/{android-Dlzxshgp.mjs → android-DGkNqa_c.mjs} +5 -5
- package/dist/{android-HqP1_vB_.mjs → android-DR5lZ2Az.mjs} +2 -2
- package/dist/android-cas-compiler.mjs +2 -2
- package/dist/{android-cas-Bl-cLJBk.mjs → android-cas-ngferVq2.mjs} +7 -6
- package/dist/android-project-BCAAmMwz.mjs +12 -0
- package/dist/android-project-DVWyCbWU.d.mts +391 -0
- package/dist/api.d.mts +810 -64
- package/dist/api.mjs +782 -1
- package/dist/{artifact-HSwkIWEQ.mjs → artifact-8EY8SAPw.mjs} +240 -213
- package/dist/{artifact-D3czlUvT.mjs → artifact-DJPy518Y.mjs} +203 -164
- package/dist/artifact-platform-CXcmX_j3.mjs +27 -0
- package/dist/{browser-web-CA-F1GQo.mjs → browser-web-Bcv99PBM.mjs} +194 -64
- package/dist/budget-Cvwn54qV.mjs +9285 -0
- package/dist/{build-DYDbfkk5.mjs → build-CabC3G23.mjs} +153 -98
- package/dist/build-cache-Dv7RN200.mjs +602 -0
- package/dist/build-plan-DUC8Ka9y.mjs +248 -0
- package/dist/{cache-manifest-XH-fvDUj.mjs → cache-manifest-DSeQjt-Q.mjs} +2 -2
- package/dist/cache-manifest.mjs +1 -1
- package/dist/{ccache-zdKiYQ3E.mjs → ccache-Btwc36-I.mjs} +10 -9
- package/dist/{cdp-Dq_ypAlJ.mjs → cdp-3fwICjzi.mjs} +18 -5
- package/dist/{chrome-BnzZMqsR.mjs → chrome-Bbw689-6.mjs} +7 -4
- package/dist/{cli-CLP3diBm.mjs → cli-CHZa9Lvk.mjs} +20 -20
- package/dist/cli.mjs +1 -1
- package/dist/client-OyRoEuSr.mjs +1577 -0
- package/dist/collector-run.d.mts +4 -40
- package/dist/collector-run.mjs +9 -8
- package/dist/{command-output-BTy8hZ0F.mjs → command-output-gwpm28fu.mjs} +1 -1
- package/dist/config-DlrsduwG.mjs +955 -0
- package/dist/{created-devices-Dzd5C2LF.mjs → created-devices-x9rN6bhs.mjs} +14 -4
- package/dist/{dependency-state-DG0p31-y.mjs → dependency-state-1I9KZT1Y.mjs} +20 -5
- package/dist/{detached-entry-B9C_zeQC.mjs → detached-entry-BwNEtIrP.mjs} +1 -1
- package/dist/{dev-client-DAWVIGBu.mjs → dev-client-BSDR5h3F.mjs} +2 -2
- package/dist/{device-BECOiufl.mjs → device-B-L3Fbxy.mjs} +91 -34
- package/dist/device-DklWZLqb.mjs +1068 -0
- package/dist/{device-capacity-CBUAcRyQ.mjs → device-capacity-DK5_EwRS.mjs} +42 -13
- package/dist/device-host-worker.mjs +76 -79
- package/dist/{device-ios-COSi6oS1.mjs → device-ios-DoB6KFCO.mjs} +77 -51
- package/dist/{device-lease-run-Cw2M4z51.mjs → device-lease-run-xJPQ_QQG.mjs} +14 -26
- package/dist/{device-pool-Bf-pOhSw.mjs → device-pool-BMkdsefq.mjs} +5 -5
- package/dist/{doctor-kfMBnUw6.mjs → doctor-Bo7BXLux.mjs} +271 -320
- package/dist/{doctor-CB8oZKCk.mjs → doctor-D5_EzwfA.mjs} +186 -91
- package/dist/doctor-fingerprint-DZLoYFVb.mjs +16 -0
- package/dist/doctor-fingerprint.mjs +19 -0
- package/dist/doctor-thjWAV0z.mjs +2 -0
- package/dist/{doctor-watchman-BRyV2adA.mjs → doctor-watchman-N2wDotwQ.mjs} +40 -21
- package/dist/{eas-build-JyfqyHfC.mjs → eas-build-CwknaQYj.mjs} +53 -20
- package/dist/{build-plan-B7SZsc2N.mjs → eas-fallback-CSgAulr5.mjs} +41 -214
- package/dist/{watchman-CPQFZLXY.mjs → eas-session-ledger-DlY_serQ.mjs} +230 -11
- package/dist/{error-diagnostics-BR677IDM.mjs → error-diagnostics-DBWO2rxE.mjs} +172 -82
- package/dist/exec-DEoAhcze.mjs +858 -0
- package/dist/exec-DnYc4HGH.d.mts +78 -0
- package/dist/{gc-qWOMdnER.mjs → gc-CXxN-4SE.mjs} +1091 -1029
- package/dist/gc-DnNDQyaP.mjs +3 -0
- package/dist/{guide-G9cAbVAc.mjs → guide-Br0LEfKy.mjs} +1165 -297
- package/dist/{hosted-android-C3MHGld1.mjs → hosted-android-B-9f-jkd.mjs} +10 -8
- package/dist/{hosted-client-ZEKpS9vw.mjs → hosted-client-DZAPrcro.mjs} +34 -19
- package/dist/{hosted-ios-l-o3iM9J.mjs → hosted-ios-CsCS21hn.mjs} +1 -1
- package/dist/{hosted-logs-EzQM7-3Z.mjs → hosted-logs-FIRx9X2f.mjs} +77 -43
- package/dist/{hosted-macos-BACVAVqE.mjs → hosted-macos-_awYSpfv.mjs} +35 -22
- package/dist/{hosted-native-A4s1QPXe.mjs → hosted-native-BdzE668-.mjs} +49 -27
- package/dist/idle-C4cZ757K.d.mts +24 -0
- package/dist/{idle-shutdown-DtxhPTKe.mjs → idle-shutdown-DDg3SdvY.mjs} +11 -10
- package/dist/ios-CDvlmUs7.d.mts +24 -0
- package/dist/{ios-BwVCF7oA.mjs → ios-Ds1clbIt.mjs} +8 -8
- package/dist/{ios-device-D7pi2Sca.mjs → ios-device--h_-8ENa.mjs} +51 -26
- package/dist/{ios-device-B5veSDDQ.mjs → ios-device-BXZ0c7Kb.mjs} +1 -1
- package/dist/{ios-RkW4pnQf.mjs → ios-hcBpnEGk.mjs} +200 -93
- package/dist/{ios-Ce7bc7br.mjs → ios-pm4nL6By.mjs} +160 -108
- package/dist/{ios-project-K9hY_Jab.mjs → ios-project-CZhKODF3.mjs} +13 -13
- package/dist/ios-signing-BtAffm0A.mjs +489 -0
- package/dist/{ios-state-CBLe1xYw.mjs → ios-state-Dtw5K2aI.mjs} +1 -1
- package/dist/{ios-nOLJGVdy.mjs → ios-xtlRHaeB.mjs} +1 -1
- package/dist/{js-swap-Bb3nsS07.mjs → js-swap-Bwhh4S7V.mjs} +30 -25
- package/dist/{launch-C3qJ6Agb.mjs → launch-BjxemNpK.mjs} +85 -543
- package/dist/{launch-F4sOqAhB.mjs → launch-CCzXlc8r.mjs} +91 -90
- package/dist/logs-BfwwadsZ.mjs +479 -0
- package/dist/logs-jTS_lHSo.mjs +248 -0
- package/dist/{macos-D7uDvO-z.mjs → macos-DVlSSyUg.mjs} +1 -1
- package/dist/macos-NfV2D7dO.mjs +694 -0
- package/dist/macos-run.mjs +1 -1
- package/dist/maintenance-run.mjs +123 -248
- package/dist/{metro-DnCEjCxs.mjs → metro-DiXtA3Ty.mjs} +107 -30
- package/dist/metro-gateway-CKZqKqx7.mjs +209 -0
- package/dist/{named-ports-4WopRPg-.mjs → named-ports-DkEzOfzO.mjs} +42 -90
- package/dist/native-android-CqgnOgsT.mjs +645 -0
- package/dist/native-gradle-artifact-inputs-DHFnmrVf.mjs +270 -0
- package/dist/native-gradle-inputs-Dnh84Zbd.mjs +211 -0
- package/dist/native-inputs-TRTTTRxt.mjs +91 -0
- package/dist/native-run-NwUuxbkg.mjs +276 -0
- package/dist/{native-runtime-k8dTIrbK.mjs → native-runtime-B7KIafpM.mjs} +11 -9
- package/dist/native-source-Y0yLhFyQ.mjs +133 -0
- package/dist/{native-xcode-inputs-CykopJdM.mjs → native-xcode-inputs-D_VOfFL7.mjs} +26 -18
- package/dist/{native-xcode-ios-Bbf30Gm0.mjs → native-xcode-ios-BYDOHWLN.mjs} +104 -60
- package/dist/{ndjson-GOnbyvso.mjs → ndjson-CgE_o3Dl.mjs} +3 -3
- package/dist/offload-worker.d.mts +59 -41
- package/dist/offload-worker.mjs +478 -115
- package/dist/operation-exec-BW0em61G.mjs +171 -0
- package/dist/{ownership-DCtw_2IA.mjs → ownership-C5fo5Edb.mjs} +3 -3
- package/dist/{page-DRHy329N.mjs → page-DBL2PiUU.mjs} +12 -5
- package/dist/paths-BsJMoPP2.mjs +12 -0
- package/dist/paths-DQtTgsBf.mjs +42 -0
- package/dist/{placement-log-MOfPVgaM.mjs → placement-log-BnGgJRRZ.mjs} +5 -5
- package/dist/{plan-placement-V0TdzYXp.mjs → plan-placement-DIsMtN-d.mjs} +15 -11
- package/dist/{ports-DdSUicVo.mjs → ports-Cy1RkmuQ.mjs} +3 -3
- package/dist/prebuild-D4JoEAEs.mjs +484 -0
- package/dist/{project-_phNIJfs.mjs → project-wM_XFTvE.mjs} +65 -37
- package/dist/{pull-request-CQ8sPbZa.mjs → pull-request-W1IuLXDt.mjs} +102 -20
- package/dist/pull-request-eODyIqZF.d.mts +124 -0
- package/dist/pull-requests.d.mts +2 -120
- package/dist/pull-requests.mjs +2 -2
- package/dist/{react-native-android-CM1XRDwv.mjs → react-native-android-6OZ7MSM7.mjs} +121 -72
- package/dist/{gradle-DSrXb6lG.mjs → react-native-build-Dvd8hC21.mjs} +292 -15
- package/dist/react-native-doctor-DsoSF1Y9.mjs +234 -0
- package/dist/{react-native-ios-Dhq_eiYQ.mjs → react-native-ios-4u1Rn-GR.mjs} +71 -39
- package/dist/{recordings-D0d5aQt0.mjs → recordings-CQmfzAh7.mjs} +12 -9
- package/dist/registration-BcRgF6Ox.mjs +51 -0
- package/dist/{reload-C8JhxjSh.mjs → reload-BzkYabB-.mjs} +94 -47
- package/dist/reload-D7AVlb8N.mjs +2 -0
- package/dist/{remote-BiR6aYjy.mjs → remote-DjGDmlTZ.mjs} +26 -18
- package/dist/result-D2Ykz_iD.mjs +435 -0
- package/dist/{run-BtPgpKks.mjs → run-DidHghD1.mjs} +5 -5
- package/dist/selection-DSMbWEX2.mjs +620 -0
- package/dist/{server-bare-R2m_gsH8.mjs → server-bare-CafzuyFB.mjs} +3 -4
- package/dist/{server-command-CTtCkmcQ.mjs → server-command-C6QjeupS.mjs} +14 -7
- package/dist/{server-expo-DsguMGUF.mjs → server-expo-CrjB29pq.mjs} +54 -11
- package/dist/server-expo-D58c9L0M.mjs +2 -0
- package/dist/{settings-B717odTD.mjs → settings-C7O8A6ZI.mjs} +309 -119
- package/dist/settings-DpR-1Wnn.mjs +114 -0
- package/dist/settings-write-CzD60rOD.mjs +360 -0
- package/dist/settings.schema.json +176 -16
- package/dist/{simslim-CCr3rE-A.mjs → simslim-BNckWpXi.mjs} +14 -12
- package/dist/{slot-launch-DPt0m9Nd.mjs → slot-launch-CbfmNgM6.mjs} +15 -20
- package/dist/{spawn-entry-Dcb7sDUz.mjs → spawn-entry-jw19m8Nl.mjs} +0 -1
- package/dist/stage-Bps5oius.mjs +200 -0
- package/dist/{start-TXeMmmO2.mjs → start-Br-oxqMD.mjs} +1 -1
- package/dist/start-EojN4WFz.mjs +1364 -0
- package/dist/{state-D1Icyjlu.mjs → state--smjFSTL.mjs} +55 -13
- package/dist/{state-CG_OFoaA.mjs → state-08I3hw3_.mjs} +3 -2
- package/dist/{stats-BoY5sEPU.mjs → stats-D3GerlFW.mjs} +7 -13
- package/dist/stats-report-BzaPrRm6.mjs +16 -0
- package/dist/{status-BTA7kKiQ.mjs → status-BRROykC8.mjs} +7 -5
- package/dist/status-EvrK72L2.mjs +2 -0
- package/dist/{status-WgFbkRzj.mjs → status-WBDajew2.mjs} +554 -452
- package/dist/{status-watch-C23ILtf9.mjs → status-watch-Bg_u-pwR.mjs} +222 -25
- package/dist/status-worker.d.mts +1 -0
- package/dist/status-worker.mjs +19 -0
- package/dist/stim-desktop-D5OGpYZM.mjs +112 -0
- package/dist/{stop-DR6VoDIk.mjs → stop-DTZ9uTw3.mjs} +2 -2
- package/dist/{stop-DPEhunlw.mjs → stop-Dky10AEJ.mjs} +33 -23
- package/dist/{stop-BNmBMi1F.mjs → stop-Mv6W9FAk.mjs} +137 -98
- package/dist/supervisor-run.d.mts +8 -17
- package/dist/supervisor-run.mjs +56 -28
- package/dist/{support-CwjbFs9H.mjs → support-CNioewsd.mjs} +14 -14
- package/dist/{support-DMTqj3Hm.mjs → support-yUiOjnVY.mjs} +20 -13
- package/dist/swiftpm-artifact-inputs-DFcGsXDP.mjs +153 -0
- package/dist/swiftpm-macos-BIak-Rxv.mjs +532 -0
- package/dist/toolchain-BY8X8HXx.mjs +2 -0
- package/dist/toolchain-DpJMHq0n.mjs +876 -0
- package/dist/{trigger-CigAYjeL.mjs → trigger-Cbyc41d_.mjs} +21 -6
- package/dist/trigger-yb_nFzPF.mjs +2 -0
- package/dist/{warm-progress-BuY-Fvfn.mjs → warm-progress-CA3TgT3-.mjs} +263 -156
- package/dist/web-CZ07gd77.mjs +2 -0
- package/dist/{web-BDBMxDpx.mjs → web-DKx6yoFA.mjs} +20 -14
- package/dist/web-run.mjs +13 -12
- package/dist/windows-report.d.mts +1 -0
- package/dist/windows-report.mjs +18 -0
- package/dist/windows-report.ps1 +43 -0
- package/dist/{workspace-state-DJt_MMvf.mjs → workspace-state-U08dEzhG.mjs} +62 -58
- package/dist/{workspaces-C36s2jb9.mjs → workspaces-CpANmBlq.mjs} +1723 -1286
- package/dist/{worktree-CgvJYJ-Q.mjs → worktree-CHecZ4Oq.mjs} +1097 -547
- package/dist/worktree-ZqZVjD9K.mjs +2 -0
- package/dist/xcode-BXn9-xYx.mjs +896 -0
- package/package.json +7 -5
- package/shim/android-audio/Main.java +24 -0
- package/shim/android-audio/README.md +17 -0
- package/shim/android-audio.jar +0 -0
- package/shim/android-optimizations.gradle +7 -5
- package/dist/activity-BSV745Kz.mjs +0 -629
- package/dist/api-qvOzWyfO.mjs +0 -154
- package/dist/api-run.mjs +0 -294
- package/dist/app-install-BIKtMfPq.mjs +0 -896
- package/dist/artifact-lifecycle-DzPpBYvK.mjs +0 -30
- package/dist/budget-f7516Zk0.mjs +0 -4106
- package/dist/build-facts-DcLv2HSd.d.mts +0 -111
- package/dist/cancellation-C_22VQTH.mjs +0 -24
- package/dist/client-qQAaXSUs.mjs +0 -1771
- package/dist/config-BYDxlMY3.mjs +0 -562
- package/dist/device-DuiPJQSn.mjs +0 -290
- package/dist/device-lease-BX1sJQ2E.mjs +0 -1224
- package/dist/device-remote-xRT0Vmo9.mjs +0 -1272
- package/dist/eas-session-ledger-Cm0Gwq2F.mjs +0 -207
- package/dist/exec-DqKo9GKJ.mjs +0 -268
- package/dist/git-DDfFzkMm.mjs +0 -45
- package/dist/launch-verify-B6Q8hZP-.mjs +0 -428
- package/dist/logs-BGrEUaEs.mjs +0 -383
- package/dist/macos-Ch5VJmcS.mjs +0 -584
- package/dist/metro-gateway-CX9Xlkq2.mjs +0 -103
- package/dist/miss-reason-mKzZ4VvN.mjs +0 -238
- package/dist/native-android-D5qc3-_v.mjs +0 -226
- package/dist/native-gradle-inputs-BsLRrl7u.mjs +0 -349
- package/dist/ndjson-Du3j0AQ9.d.mts +0 -17
- package/dist/plan-C4TjdPsR.mjs +0 -260
- package/dist/prebuild-DYbucPXy.mjs +0 -212
- package/dist/preview-78a9kR_-.mjs +0 -1011
- package/dist/react-native-build-CtCccJtb.mjs +0 -239
- package/dist/react-native-doctor-CfRnFfjs.mjs +0 -78
- package/dist/remote-cache-OyOyVIS3.mjs +0 -526
- package/dist/result-CaJg5Iat.mjs +0 -186
- package/dist/server-expo-Bigriskl.mjs +0 -2
- package/dist/settings-BORNaaCO.mjs +0 -402
- package/dist/settings-vk3mJGSm.d.mts +0 -13
- package/dist/spawn-claims-DVS5RkMS.mjs +0 -72
- package/dist/stage-KNTQopqv.mjs +0 -157
- package/dist/start-BWqzODpb.mjs +0 -1116
- package/dist/stim-desktop-BzBN2Em2.mjs +0 -63
- package/dist/swiftpm-macos-DRNVJWlb.mjs +0 -119
- package/dist/tailnet-Dh-qiYzG.mjs +0 -265
- package/dist/toolchain-BFkAcstd.mjs +0 -2
- package/dist/toolchain-DxSsNssu.mjs +0 -1657
- package/dist/trigger-9_USgmxz.mjs +0 -2
- package/dist/web-Dq-i3wzJ.mjs +0 -2
- package/dist/worktree-DpLdCHga.mjs +0 -2
- package/dist/{api-run.d.mts → doctor-fingerprint.d.mts} +0 -0
- package/dist/{errors-DzkMYh8Q.mjs → errors-ccaPc4ox.mjs} +2 -2
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
import { t as getExecutor } from "./exec-DEoAhcze.mjs";
|
|
2
|
+
import { d as workspaceDir, i as sharedBuildCache } from "./paths-DQtTgsBf.mjs";
|
|
3
|
+
import { H as deviceSlotPlatforms, p as getProject, q as validateDeviceSlot } from "./config-DlrsduwG.mjs";
|
|
4
|
+
import { tt as settingValueAt } from "./settings-C7O8A6ZI.mjs";
|
|
5
|
+
import { r as register } from "./cache-manifest-DSeQjt-Q.mjs";
|
|
6
|
+
import { Y as statsProjectKey } from "./budget-Cvwn54qV.mjs";
|
|
7
|
+
import { d as runCancellationSignal } from "./native-run-NwUuxbkg.mjs";
|
|
8
|
+
import { h as resolveBuild, o as entryDir, t as artifactIn } from "./build-cache-Dv7RN200.mjs";
|
|
9
|
+
import { B as ownedAvdDeviceProfile, E as findBuildTool, I as listInstalledSystemImages, K as ownedAvdSystemImage, V as ownedAvdDirectory, X as pickDefaultSystemImage, l as androidSystemImageAbi, o as androidHome } from "./android-C7sVmyI9.mjs";
|
|
10
|
+
import { o as resolveCcache } from "./ccache-Btwc36-I.mjs";
|
|
11
|
+
import { r as androidToolchainAsync } from "./toolchain-DpJMHq0n.mjs";
|
|
12
|
+
import { a as nativeGradleTransfer, t as gradleOffloadInputs } from "./native-gradle-inputs-Dnh84Zbd.mjs";
|
|
13
|
+
import { d as buildGradle, l as androidSdkRefusal } from "./react-native-build-Dvd8hC21.mjs";
|
|
14
|
+
import { l as skippedMissReason, o as explainBuildMiss } from "./prebuild-D4JoEAEs.mjs";
|
|
15
|
+
import { c as resolveAndroidRunPlan } from "./result-D2Ykz_iD.mjs";
|
|
16
|
+
import { n as androidProcessRuntime } from "./launch-CCzXlc8r.mjs";
|
|
17
|
+
import { n as planFlagRefusal, r as planPayload } from "./build-plan-DUC8Ka9y.mjs";
|
|
18
|
+
import { a as nativeGradleWorkerArtifactIdentity, n as gradleArtifactInputs, r as nativeGradleArtifactSnapshot, t as NATIVE_GRADLE_CACHE_LIMIT } from "./native-gradle-artifact-inputs-DHFnmrVf.mjs";
|
|
19
|
+
import { createHash } from "node:crypto";
|
|
20
|
+
import { createReadStream, createWriteStream, existsSync, readFileSync, statSync } from "node:fs";
|
|
21
|
+
import { tmpdir } from "node:os";
|
|
22
|
+
import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
23
|
+
import { storeArtifactAsync } from "@stim-cli/core";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
import { mkdtemp, open, readFile, realpath, rm, stat, writeFile } from "node:fs/promises";
|
|
26
|
+
import { pipeline } from "node:stream/promises";
|
|
27
|
+
import { Readable } from "node:stream";
|
|
28
|
+
//#region src/integrations/native-android-cache.ts
|
|
29
|
+
const RECEIPT$1 = "native-android.json";
|
|
30
|
+
async function digest(path, signal) {
|
|
31
|
+
const hash = createHash("sha256");
|
|
32
|
+
for await (const chunk of createReadStream(path, { signal })) hash.update(chunk);
|
|
33
|
+
return hash.digest("hex");
|
|
34
|
+
}
|
|
35
|
+
async function inspectApk(path, sdk, abi, operation, signal) {
|
|
36
|
+
signal?.throwIfAborted();
|
|
37
|
+
if (!(await stat(path)).isFile()) throw new Error("The native APK is not a regular file.");
|
|
38
|
+
const signer = findBuildTool(["apksigner"], { home: sdk });
|
|
39
|
+
const aapt = findBuildTool(["aapt"], { home: sdk });
|
|
40
|
+
if (!signer || !aapt) throw new Error("Android SDK apksigner and aapt are required to verify a cached native APK.");
|
|
41
|
+
const before = await digest(path, signal);
|
|
42
|
+
const options = {
|
|
43
|
+
timeoutMs: 3e4,
|
|
44
|
+
signal,
|
|
45
|
+
declareFor: operation
|
|
46
|
+
};
|
|
47
|
+
const executor = getExecutor();
|
|
48
|
+
const signers = [...(await executor.runFileAsync(signer.path, [
|
|
49
|
+
"verify",
|
|
50
|
+
"--print-certs",
|
|
51
|
+
path
|
|
52
|
+
], options)).matchAll(/^(?:Signer #\d+|V\d+(?:\.\d+)? Signer:) certificate SHA-256 digest: ([a-f\d]{64})\s*$/gim)].flatMap((match) => match[1] ? [match[1].toLowerCase()] : []).toSorted();
|
|
53
|
+
if (!signers.length) throw new Error("The native APK has no verified signing certificate.");
|
|
54
|
+
const badging = await executor.runFileAsync(aapt.path, [
|
|
55
|
+
"dump",
|
|
56
|
+
"badging",
|
|
57
|
+
path
|
|
58
|
+
], options);
|
|
59
|
+
const line = badging.split(/\r?\n/).find((value) => value.startsWith("package:"));
|
|
60
|
+
const androidPackage = line?.match(/^package: name='([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)+)'/)?.[1];
|
|
61
|
+
if (!line || !androidPackage || /\bsplit=/.test(line)) throw new Error("The native APK is not a standalone Android package.");
|
|
62
|
+
const native = badging.split(/\r?\n/).find((value) => value.startsWith("native-code:"));
|
|
63
|
+
const abis = native ? [...native.matchAll(/'([^']+)'/g)].flatMap((match) => match[1] ? [match[1]] : []).toSorted() : [];
|
|
64
|
+
if (abi && native && !abis.includes(abi)) throw new Error("The native APK does not contain the target ABI.");
|
|
65
|
+
const sha256 = await digest(path, signal);
|
|
66
|
+
if (sha256 !== before) throw new Error("The native APK changed during verification.");
|
|
67
|
+
return {
|
|
68
|
+
androidPackage,
|
|
69
|
+
signers,
|
|
70
|
+
abis,
|
|
71
|
+
sha256
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function verifiedNativeApk(key, path, sdk, abi, operation, signal) {
|
|
75
|
+
try {
|
|
76
|
+
const receipt = JSON.parse(await readFile(join(dirname(path), RECEIPT$1), {
|
|
77
|
+
encoding: "utf8",
|
|
78
|
+
signal
|
|
79
|
+
}));
|
|
80
|
+
if (receipt.schema !== 1 || receipt.key !== key || receipt.sha256 !== await digest(path, signal)) return null;
|
|
81
|
+
const actual = await inspectApk(path, sdk, abi, operation, signal);
|
|
82
|
+
if (actual.sha256 !== receipt.sha256 || actual.androidPackage !== receipt.androidPackage || JSON.stringify(actual.signers) !== JSON.stringify(receipt.signers) || JSON.stringify(actual.abis) !== JSON.stringify(receipt.abis)) return null;
|
|
83
|
+
return actual;
|
|
84
|
+
} catch {
|
|
85
|
+
signal?.throwIfAborted();
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function materializeNativeApk(key, path, sdk, abi, operation, signal = runCancellationSignal(operation) ?? operation?.signal ?? getExecutor().reportSignal?.()) {
|
|
90
|
+
const actual = await verifiedNativeApk(key, path, sdk, abi, operation, signal);
|
|
91
|
+
return actual ? {
|
|
92
|
+
apkPath: path,
|
|
93
|
+
directory: null,
|
|
94
|
+
androidPackage: actual.androidPackage
|
|
95
|
+
} : null;
|
|
96
|
+
}
|
|
97
|
+
function nativeAndroidCache(sdk, abi, androidPackage, operation) {
|
|
98
|
+
return {
|
|
99
|
+
resolve: ({ key }) => resolveBuild("android", key),
|
|
100
|
+
async store({ key, sourcePath, overwrite, signal }) {
|
|
101
|
+
const expectedPackage = androidPackage();
|
|
102
|
+
const actual = expectedPackage === null ? await verifiedNativeApk(key, sourcePath, sdk, abi, operation, signal) : await inspectApk(sourcePath, sdk, abi, operation, signal);
|
|
103
|
+
if (!actual) throw new Error("The native APK has no matching verified cache receipt.");
|
|
104
|
+
if (expectedPackage !== null && actual.androidPackage !== expectedPackage) throw new Error("The APK package does not match the Gradle model.");
|
|
105
|
+
register({
|
|
106
|
+
dir: sharedBuildCache(),
|
|
107
|
+
name: "Build cache",
|
|
108
|
+
prune: "entries",
|
|
109
|
+
entriesDepth: 2,
|
|
110
|
+
note: "built .app/.apk keyed on the native fingerprint"
|
|
111
|
+
});
|
|
112
|
+
return storeArtifactAsync(entryDir("android", key), sourcePath, {
|
|
113
|
+
signal,
|
|
114
|
+
overwrite,
|
|
115
|
+
runFile: (file, args) => getExecutor().runFileAsync(file, args, {
|
|
116
|
+
timeoutMs: 12e4,
|
|
117
|
+
signal,
|
|
118
|
+
declareFor: operation
|
|
119
|
+
}),
|
|
120
|
+
async writeMetadata(staging) {
|
|
121
|
+
if (await digest(join(staging, basename(sourcePath)), signal) !== actual.sha256) throw new Error("The native APK changed while it was copied.");
|
|
122
|
+
await writeFile(join(staging, RECEIPT$1), JSON.stringify({
|
|
123
|
+
schema: 1,
|
|
124
|
+
key,
|
|
125
|
+
...actual
|
|
126
|
+
}), { signal });
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
async function plannedNativeApk(key, sdk, abi, operation) {
|
|
133
|
+
const path = artifactIn(entryDir("android", key));
|
|
134
|
+
return path !== null && await materializeNativeApk(key, path, sdk, abi, operation) !== null;
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/integrations/native-android-file-cache.ts
|
|
138
|
+
const MAGIC = Buffer.from("STIMAPK1\n");
|
|
139
|
+
const HEADER_BYTES = MAGIC.length + 4;
|
|
140
|
+
const MAX_RECEIPT_BYTES = 1048576;
|
|
141
|
+
const RECEIPT = "native-android.json";
|
|
142
|
+
const fileKey = (key) => `native-android/v1/${key}`;
|
|
143
|
+
async function readExactly(file, size, position, signal) {
|
|
144
|
+
const buffer = Buffer.alloc(size);
|
|
145
|
+
let offset = 0;
|
|
146
|
+
while (offset < size) {
|
|
147
|
+
signal.throwIfAborted();
|
|
148
|
+
const { bytesRead } = await file.read(buffer, offset, size - offset, position + offset);
|
|
149
|
+
if (!bytesRead) throw new Error("The shared native APK entry is truncated.");
|
|
150
|
+
offset += bytesRead;
|
|
151
|
+
}
|
|
152
|
+
return buffer;
|
|
153
|
+
}
|
|
154
|
+
async function unpack(source, directory, signal) {
|
|
155
|
+
const file = await open(source, "r");
|
|
156
|
+
try {
|
|
157
|
+
const header = await readExactly(file, HEADER_BYTES, 0, signal);
|
|
158
|
+
const size = header.readUInt32BE(MAGIC.length);
|
|
159
|
+
if (!header.subarray(0, MAGIC.length).equals(MAGIC) || size === 0 || size > MAX_RECEIPT_BYTES) throw new Error("The shared native APK entry has an unsupported header.");
|
|
160
|
+
const receipt = await readExactly(file, size, HEADER_BYTES, signal);
|
|
161
|
+
const apk = join(directory, "artifact.apk");
|
|
162
|
+
await writeFile(join(directory, RECEIPT), receipt, {
|
|
163
|
+
flag: "wx",
|
|
164
|
+
mode: 384,
|
|
165
|
+
signal
|
|
166
|
+
});
|
|
167
|
+
await pipeline(file.createReadStream({
|
|
168
|
+
start: HEADER_BYTES + size,
|
|
169
|
+
autoClose: false
|
|
170
|
+
}), createWriteStream(apk, {
|
|
171
|
+
flags: "wx",
|
|
172
|
+
mode: 384
|
|
173
|
+
}), { signal });
|
|
174
|
+
return apk;
|
|
175
|
+
} finally {
|
|
176
|
+
await file.close();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function nativeAndroidFileCache(files, sdk, abi, operation) {
|
|
180
|
+
return {
|
|
181
|
+
async resolve({ key, destinationDir, signal }) {
|
|
182
|
+
const directory = await mkdtemp(join(destinationDir, "native-apk-"));
|
|
183
|
+
let keep = false;
|
|
184
|
+
try {
|
|
185
|
+
const source = await files.resolve({
|
|
186
|
+
key: fileKey(key),
|
|
187
|
+
destinationDir: directory,
|
|
188
|
+
signal
|
|
189
|
+
});
|
|
190
|
+
if (!source) return null;
|
|
191
|
+
const contained = relative(await realpath(directory), await realpath(source));
|
|
192
|
+
if (isAbsolute(contained) || contained === ".." || contained.startsWith(`..${sep}`)) throw new Error("The shared native APK file is outside its download directory.");
|
|
193
|
+
if (!(await stat(source)).isFile()) throw new Error("The shared native APK entry is not a regular file.");
|
|
194
|
+
const apk = await unpack(source, await mkdtemp(join(directory, "unpacked-")), signal);
|
|
195
|
+
if (!await materializeNativeApk(key, apk, sdk, abi, operation, signal)) throw new Error("The shared native APK does not match its verification receipt.");
|
|
196
|
+
keep = true;
|
|
197
|
+
return apk;
|
|
198
|
+
} finally {
|
|
199
|
+
if (!keep) await rm(directory, {
|
|
200
|
+
recursive: true,
|
|
201
|
+
force: true
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
async store({ key, sourcePath, overwrite, signal }) {
|
|
206
|
+
const cached = artifactIn(entryDir("android", key));
|
|
207
|
+
if (!cached) throw new Error("No native APK is stored locally for this key.");
|
|
208
|
+
const metadata = await readFile(join(dirname(cached), RECEIPT), { signal });
|
|
209
|
+
if (metadata.length > MAX_RECEIPT_BYTES) throw new Error("The native APK receipt is too large.");
|
|
210
|
+
const receipt = JSON.parse(metadata.toString("utf8"));
|
|
211
|
+
if (receipt.schema !== 1 || receipt.key !== key) throw new Error("The native APK has no matching cache receipt.");
|
|
212
|
+
const directory = await mkdtemp(join(tmpdir(), "stim-native-apk-file-"));
|
|
213
|
+
try {
|
|
214
|
+
const envelope = join(directory, "artifact");
|
|
215
|
+
const header = Buffer.alloc(HEADER_BYTES);
|
|
216
|
+
MAGIC.copy(header);
|
|
217
|
+
header.writeUInt32BE(metadata.length, MAGIC.length);
|
|
218
|
+
const payload = async function* () {
|
|
219
|
+
yield header;
|
|
220
|
+
yield metadata;
|
|
221
|
+
const hash = createHash("sha256");
|
|
222
|
+
for await (const chunk of createReadStream(sourcePath, { signal })) {
|
|
223
|
+
hash.update(chunk);
|
|
224
|
+
yield chunk;
|
|
225
|
+
}
|
|
226
|
+
if (hash.digest("hex") !== receipt.sha256) throw new Error("The native APK changed while its shared entry was packed.");
|
|
227
|
+
};
|
|
228
|
+
await pipeline(Readable.from(payload()), createWriteStream(envelope, {
|
|
229
|
+
flags: "wx",
|
|
230
|
+
mode: 384
|
|
231
|
+
}), { signal });
|
|
232
|
+
signal.throwIfAborted();
|
|
233
|
+
await files.store({
|
|
234
|
+
key: fileKey(key),
|
|
235
|
+
sourcePath: envelope,
|
|
236
|
+
overwrite,
|
|
237
|
+
signal
|
|
238
|
+
});
|
|
239
|
+
} finally {
|
|
240
|
+
await rm(directory, {
|
|
241
|
+
recursive: true,
|
|
242
|
+
force: true
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/integrations/native-android-plan.ts
|
|
250
|
+
async function planNativeAndroid(root, options, resolved, operation) {
|
|
251
|
+
if (options.easProfile !== void 0) return { refusal: planFlagRefusal("--eas-profile") };
|
|
252
|
+
try {
|
|
253
|
+
const slot = validateDeviceSlot(options.slot);
|
|
254
|
+
const { context, settings } = resolved;
|
|
255
|
+
const { env, signal } = operation;
|
|
256
|
+
const declared = settingValueAt(settings, "android.artifactInputs");
|
|
257
|
+
gradleArtifactInputs(declared);
|
|
258
|
+
const planned = await resolveAndroidRunPlan({
|
|
259
|
+
settings,
|
|
260
|
+
settingsContext: context,
|
|
261
|
+
env,
|
|
262
|
+
signal,
|
|
263
|
+
slot,
|
|
264
|
+
variant: options.variant ?? null,
|
|
265
|
+
systemImage: options.systemImage ?? null,
|
|
266
|
+
deviceProfile: options.deviceProfile ?? null,
|
|
267
|
+
device: null,
|
|
268
|
+
wait: void 0,
|
|
269
|
+
waitConflict: false,
|
|
270
|
+
remote: null,
|
|
271
|
+
buildCache: options.buildCache !== false
|
|
272
|
+
}, {
|
|
273
|
+
runtimeKind: () => "process",
|
|
274
|
+
variantProblem: () => null,
|
|
275
|
+
resolveCompilerCache: ({ optimizations }) => {
|
|
276
|
+
if (optimizations.android.compilerCache === "cas") throw new Error("Native Android planning does not initialize the experimental CAS toolchain.");
|
|
277
|
+
return {
|
|
278
|
+
cas: null,
|
|
279
|
+
optimizations,
|
|
280
|
+
warning: null
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
warn: (label, message) => operation.output("stderr", `${label}: ${message}\n`)
|
|
284
|
+
});
|
|
285
|
+
if (!planned.ok) return { refusal: planned };
|
|
286
|
+
const { build, target } = planned.plan;
|
|
287
|
+
if (target.kind !== "emulator") throw new Error("Native Android planning requires a local emulator target.");
|
|
288
|
+
const recorded = deviceSlotPlatforms(getProject(root), slot)?.android;
|
|
289
|
+
let reuseRecorded = Boolean(recorded?.owned && recorded.avdName && !recorded.setupIncomplete && ownedAvdDirectory(recorded.avdName));
|
|
290
|
+
const recordedImage = reuseRecorded && recorded?.avdName ? ownedAvdSystemImage(recorded.avdName) : null;
|
|
291
|
+
const requestedImage = options.systemImage?.trim();
|
|
292
|
+
if (recordedImage && requestedImage && recordedImage !== requestedImage) {
|
|
293
|
+
if (!recorded?.bootPending) return { refusal: {
|
|
294
|
+
code: "STIM_BAD_ARG",
|
|
295
|
+
message: `The recorded emulator uses ${recordedImage}; --system-image ${requestedImage} only replaces an emulator that never finished booting.`,
|
|
296
|
+
remedy: "Use the existing image or pass --slot <name> to create the requested emulator beside it."
|
|
297
|
+
} };
|
|
298
|
+
reuseRecorded = false;
|
|
299
|
+
}
|
|
300
|
+
if (reuseRecorded && recorded?.avdName && target.deviceProfile) {
|
|
301
|
+
const recordedProfile = ownedAvdDeviceProfile(recorded.avdName);
|
|
302
|
+
if (recordedProfile && recordedProfile !== target.deviceProfile) return { refusal: {
|
|
303
|
+
code: "STIM_BAD_ARG",
|
|
304
|
+
message: `The recorded emulator uses device profile ${recordedProfile}, but ${target.deviceProfile} was requested.`,
|
|
305
|
+
remedy: "Use the existing profile or pass --slot <name> to create the requested emulator beside it."
|
|
306
|
+
} };
|
|
307
|
+
}
|
|
308
|
+
let abi = null;
|
|
309
|
+
if (build.targetAbiOnly && !build.release) {
|
|
310
|
+
if (recorded?.avdName && !recorded.owned) return { refusal: {
|
|
311
|
+
code: "STIM_BAD_ARG",
|
|
312
|
+
message: "The legacy emulator assignment does not establish a build ABI for native planning.",
|
|
313
|
+
remedy: "Run stim android without --plan to reconcile the assignment, or use --slot <name> for an owned emulator."
|
|
314
|
+
} };
|
|
315
|
+
const image = reuseRecorded ? recordedImage : pickDefaultSystemImage(listInstalledSystemImages(), target.systemImage ? { systemImage: target.systemImage } : {})?.pkg;
|
|
316
|
+
abi = androidSystemImageAbi(image);
|
|
317
|
+
if (!abi) throw new Error("No installed emulator image identifies the native Android build ABI.");
|
|
318
|
+
}
|
|
319
|
+
const snapshot = await nativeGradleArtifactSnapshot(root, declared, build, abi, env, signal);
|
|
320
|
+
const hit = build.cache.read && await plannedNativeApk(snapshot.key, snapshot.sdkDirectory, abi, operation);
|
|
321
|
+
return planPayload({
|
|
322
|
+
root,
|
|
323
|
+
platform: "android",
|
|
324
|
+
slot,
|
|
325
|
+
projectKey: statsProjectKey({
|
|
326
|
+
root,
|
|
327
|
+
commonDir: context.gitCommonDir,
|
|
328
|
+
repoRoot: context.repoRoot
|
|
329
|
+
})
|
|
330
|
+
}, {
|
|
331
|
+
fingerprint: snapshot.hash,
|
|
332
|
+
cacheKey: snapshot.key,
|
|
333
|
+
cacheHit: hit ? "local" : false,
|
|
334
|
+
cacheSkipped: !build.cache.read,
|
|
335
|
+
provider: null,
|
|
336
|
+
prebuild: null,
|
|
337
|
+
refusal: null
|
|
338
|
+
});
|
|
339
|
+
} catch (error) {
|
|
340
|
+
operation.signal.throwIfAborted();
|
|
341
|
+
return { refusal: {
|
|
342
|
+
code: "STIM_BAD_ARG",
|
|
343
|
+
message: error.message,
|
|
344
|
+
remedy: "Check android.artifactInputs and the local Android toolchain, or run stim android without --plan for an uncached build."
|
|
345
|
+
} };
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/integrations/native-android.ts
|
|
350
|
+
const CACHE_LIMIT = `${NATIVE_GRADLE_CACHE_LIMIT} Offload requires a separate complete android.offloadInputs declaration.`;
|
|
351
|
+
const MODEL_LIMIT = "Native Android requires AGP with androidComponents, one application module and configuration-on-demand disabled. Gradle resolves the exact variant and APK outputs during the build.";
|
|
352
|
+
function refusal(reason) {
|
|
353
|
+
return {
|
|
354
|
+
code: "STIM_BUILD_FAILED",
|
|
355
|
+
reason,
|
|
356
|
+
remedy: "Select one signed standalone APK for the requested variant and target ABI in the Android application module, then retry. Stim does not sign APKs or install split APK sets."
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function selectNativeApk(value, variant, abi) {
|
|
360
|
+
const model = value;
|
|
361
|
+
if (!model || model.schema !== 1 || typeof model.module !== "string" || !model.module.startsWith(":") || model.variant !== variant || typeof model.applicationId !== "string" || !/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)+$/.test(model.applicationId) || typeof model.sdkDirectory !== "string" || !isAbsolute(model.sdkDirectory) || !Array.isArray(model.elements) || !model.elements.every((element) => element && typeof element.path === "string" && isAbsolute(element.path) && element.path.endsWith(".apk") && Array.isArray(element.filters) && element.filters.every((filter) => filter && typeof filter.type === "string" && typeof filter.value === "string"))) return refusal("Gradle did not export a valid model for the requested native Android variant.");
|
|
362
|
+
const universal = model.elements.filter((element) => element.filters.length === 0);
|
|
363
|
+
const candidates = universal.length ? universal : model.elements.filter((element) => abi !== null && element.filters.length === 1 && element.filters[0].type === "ABI" && element.filters[0].value === abi);
|
|
364
|
+
if (candidates.length !== 1) return refusal(`Native variant "${variant}" has ${candidates.length} installable APK candidates for ${abi ?? "an unspecified ABI"}. Density splits and ambiguous output sets are unsupported.`);
|
|
365
|
+
return {
|
|
366
|
+
apkPath: candidates[0].path,
|
|
367
|
+
androidPackage: model.applicationId
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
async function locateNativeApk(modelFile, variant, abi) {
|
|
371
|
+
let value;
|
|
372
|
+
try {
|
|
373
|
+
value = JSON.parse(readFileSync(modelFile, "utf8"));
|
|
374
|
+
} catch {
|
|
375
|
+
return refusal("Gradle succeeded without exporting the native Android APK model.");
|
|
376
|
+
}
|
|
377
|
+
const located = selectNativeApk(value, variant, abi);
|
|
378
|
+
if ("code" in located) return located;
|
|
379
|
+
try {
|
|
380
|
+
if (!statSync(located.apkPath).isFile()) return refusal("The APK selected by Gradle is not a file.");
|
|
381
|
+
} catch {
|
|
382
|
+
return refusal("The APK selected by Gradle does not exist.");
|
|
383
|
+
}
|
|
384
|
+
const signer = findBuildTool(["apksigner"], { home: value.sdkDirectory });
|
|
385
|
+
if (!signer) return refusal("No Android SDK apksigner is available to verify the native APK signature.");
|
|
386
|
+
try {
|
|
387
|
+
await getExecutor().runFileAsync(signer.path, ["verify", located.apkPath], { timeoutMs: 3e4 });
|
|
388
|
+
} catch (error) {
|
|
389
|
+
return refusal(`The native APK signature could not be verified: ${error.message}`);
|
|
390
|
+
}
|
|
391
|
+
return located;
|
|
392
|
+
}
|
|
393
|
+
function nativeAndroidProject(root) {
|
|
394
|
+
return {
|
|
395
|
+
isExpo: false,
|
|
396
|
+
packageRemedy: "Check the applicationId reported by AGP for the selected application variant.",
|
|
397
|
+
appIds: () => ({
|
|
398
|
+
bundleId: null,
|
|
399
|
+
androidPackage: null
|
|
400
|
+
}),
|
|
401
|
+
variantProblem: () => null,
|
|
402
|
+
targets: [
|
|
403
|
+
"emulator",
|
|
404
|
+
"physical",
|
|
405
|
+
"hosted"
|
|
406
|
+
],
|
|
407
|
+
eas: false,
|
|
408
|
+
runtimeKind: () => "process",
|
|
409
|
+
plan: (options, resolved, operation) => planNativeAndroid(root, options, resolved, operation),
|
|
410
|
+
runtime: ({ phase }) => androidProcessRuntime(async () => {
|
|
411
|
+
phase("metro", "skipped (native process)");
|
|
412
|
+
return {
|
|
413
|
+
ok: true,
|
|
414
|
+
prepared: { metroPort: null }
|
|
415
|
+
};
|
|
416
|
+
}),
|
|
417
|
+
artifact: ({ operation, artifactScope, writer, buildPlan, target, out, estimates, settings }) => {
|
|
418
|
+
const variant = buildPlan.variant ?? "debug";
|
|
419
|
+
const inputs = settingValueAt(settings, "android.offloadInputs");
|
|
420
|
+
const artifactInputs = settingValueAt(settings, "android.artifactInputs");
|
|
421
|
+
let snapshot = null;
|
|
422
|
+
let cacheRefusal = CACHE_LIMIT;
|
|
423
|
+
let compiledPackage = null;
|
|
424
|
+
let compiledSdk = null;
|
|
425
|
+
const signal = runCancellationSignal(operation) ?? operation?.signal;
|
|
426
|
+
const read = async () => {
|
|
427
|
+
if (!operation) throw new Error("Native APK caching requires an operation context.");
|
|
428
|
+
const identity = await nativeGradleArtifactSnapshot(root, artifactInputs, buildPlan, target.abi, operation.env, signal);
|
|
429
|
+
if (!artifactScope) return identity;
|
|
430
|
+
const scoped = {
|
|
431
|
+
...identity,
|
|
432
|
+
...nativeGradleWorkerArtifactIdentity(identity.hash, artifactScope.key, variant, target.abi)
|
|
433
|
+
};
|
|
434
|
+
artifactScope.record?.({
|
|
435
|
+
hash: scoped.hash,
|
|
436
|
+
key: scoped.key
|
|
437
|
+
}, identity.receipt);
|
|
438
|
+
return scoped;
|
|
439
|
+
};
|
|
440
|
+
let transfer = null;
|
|
441
|
+
const modelFile = join(workspaceDir(root), "gradle-build", `native-apk-${encodeURIComponent(variant)}.json`);
|
|
442
|
+
return {
|
|
443
|
+
providerCache: (provider) => {
|
|
444
|
+
if (!provider.files) return void 0;
|
|
445
|
+
if (!snapshot) throw new Error(CACHE_LIMIT);
|
|
446
|
+
return nativeAndroidFileCache(provider.files, snapshot.sdkDirectory, target.abi, operation);
|
|
447
|
+
},
|
|
448
|
+
identity: async () => {
|
|
449
|
+
try {
|
|
450
|
+
snapshot = await read();
|
|
451
|
+
cacheRefusal = null;
|
|
452
|
+
return snapshot;
|
|
453
|
+
} catch (error) {
|
|
454
|
+
signal?.throwIfAborted();
|
|
455
|
+
cacheRefusal = error instanceof Error ? error.message : String(error);
|
|
456
|
+
return { cacheIneligible: cacheRefusal };
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
cache: () => {
|
|
460
|
+
if (!snapshot) throw new Error(CACHE_LIMIT);
|
|
461
|
+
return nativeAndroidCache(snapshot.sdkDirectory, target.abi, () => compiledPackage, operation);
|
|
462
|
+
},
|
|
463
|
+
prepare: async () => {},
|
|
464
|
+
reconcile: async () => {
|
|
465
|
+
if (snapshot) try {
|
|
466
|
+
snapshot = await read();
|
|
467
|
+
} catch {
|
|
468
|
+
signal?.throwIfAborted();
|
|
469
|
+
snapshot = null;
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
identity: snapshot,
|
|
473
|
+
rekeyedBy: [],
|
|
474
|
+
cacheRefusal: null
|
|
475
|
+
};
|
|
476
|
+
},
|
|
477
|
+
validate: async () => {
|
|
478
|
+
if (!snapshot || compiledSdk !== snapshot.sdkDirectory) return null;
|
|
479
|
+
try {
|
|
480
|
+
return (await read()).hash === snapshot.hash ? snapshot : null;
|
|
481
|
+
} catch {
|
|
482
|
+
signal?.throwIfAborted();
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
materialize: async (key, path) => {
|
|
487
|
+
if (!snapshot) return null;
|
|
488
|
+
try {
|
|
489
|
+
if ((await read()).hash !== snapshot.hash) return null;
|
|
490
|
+
return await materializeNativeApk(key, path, snapshot.sdkDirectory, target.abi, operation);
|
|
491
|
+
} catch {
|
|
492
|
+
signal?.throwIfAborted();
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
explain: (rekeyedBy) => ({
|
|
497
|
+
reason: snapshot ? explainBuildMiss({
|
|
498
|
+
root,
|
|
499
|
+
platform: "android",
|
|
500
|
+
current: {
|
|
501
|
+
hash: snapshot.hash,
|
|
502
|
+
sources: []
|
|
503
|
+
},
|
|
504
|
+
rekeyedBy
|
|
505
|
+
}).reason : skippedMissReason(cacheRefusal ?? CACHE_LIMIT),
|
|
506
|
+
diff: null
|
|
507
|
+
}),
|
|
508
|
+
untrackedLine: () => null,
|
|
509
|
+
expoCache: null,
|
|
510
|
+
offload: {
|
|
511
|
+
supportsUncachedArtifacts: true,
|
|
512
|
+
uncachedArtifacts: true,
|
|
513
|
+
get unsupported() {
|
|
514
|
+
if (buildPlan.cas) return "Apple Clang CAS builds build here";
|
|
515
|
+
try {
|
|
516
|
+
gradleOffloadInputs(inputs);
|
|
517
|
+
return null;
|
|
518
|
+
} catch (error) {
|
|
519
|
+
return error.message;
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
target: async () => {
|
|
523
|
+
transfer = await nativeGradleTransfer(root, inputs, runCancellationSignal(operation) ?? operation?.signal);
|
|
524
|
+
return {
|
|
525
|
+
platform: "android",
|
|
526
|
+
native: "gradle",
|
|
527
|
+
local: await androidToolchainAsync(operation?.env),
|
|
528
|
+
requires: {
|
|
529
|
+
ndk: null,
|
|
530
|
+
buildTools: null,
|
|
531
|
+
compileSdk: null
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
},
|
|
535
|
+
get request() {
|
|
536
|
+
if (!transfer) throw new Error("Native Gradle offload needs a declared source inventory.");
|
|
537
|
+
return {
|
|
538
|
+
platform: "android",
|
|
539
|
+
isExpo: false,
|
|
540
|
+
native: {
|
|
541
|
+
provider: "gradle",
|
|
542
|
+
transfer,
|
|
543
|
+
cache: buildPlan.cache
|
|
544
|
+
},
|
|
545
|
+
android: {
|
|
546
|
+
variant,
|
|
547
|
+
abi: target.abi,
|
|
548
|
+
gradleBuildCache: buildPlan.gradleBuildCache,
|
|
549
|
+
pch: buildPlan.pch,
|
|
550
|
+
compilerCache: buildPlan.compilerCache === "none" ? "none" : "ccache"
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
},
|
|
554
|
+
unchanged: async () => transfer !== null && (await nativeGradleTransfer(root, inputs, runCancellationSignal(operation) ?? operation?.signal)).digest === transfer.digest
|
|
555
|
+
},
|
|
556
|
+
compile: async () => {
|
|
557
|
+
const script = ["../shim/native-android.gradle", "../../shim/native-android.gradle"].map((path) => fileURLToPath(new URL(path, import.meta.url))).find(existsSync);
|
|
558
|
+
if (!script) throw new Error("Stim installation is missing shim/native-android.gradle.");
|
|
559
|
+
const result = await buildGradle({
|
|
560
|
+
root,
|
|
561
|
+
logWriter: writer,
|
|
562
|
+
variant,
|
|
563
|
+
project: {
|
|
564
|
+
directory: root,
|
|
565
|
+
gradlew: join(root, process.platform === "win32" ? "gradlew.bat" : "gradlew"),
|
|
566
|
+
module: ":",
|
|
567
|
+
outputsDir: root
|
|
568
|
+
},
|
|
569
|
+
task: ":stimExportAndroidApk",
|
|
570
|
+
projectArgs: [
|
|
571
|
+
"--init-script",
|
|
572
|
+
script,
|
|
573
|
+
`-Pstim.native.variant=${variant}`,
|
|
574
|
+
`-Pstim.native.model=${modelFile}`
|
|
575
|
+
],
|
|
576
|
+
locate: async () => {
|
|
577
|
+
const located = await locateNativeApk(modelFile, variant, target.abi);
|
|
578
|
+
if (!("code" in located)) {
|
|
579
|
+
compiledSdk = await realpath(JSON.parse(readFileSync(modelFile, "utf8")).sdkDirectory);
|
|
580
|
+
compiledPackage = located.androidPackage ?? null;
|
|
581
|
+
}
|
|
582
|
+
return located;
|
|
583
|
+
}
|
|
584
|
+
}, {
|
|
585
|
+
estimateMs: estimates().coldBuildMs,
|
|
586
|
+
onHeartbeat: out,
|
|
587
|
+
onNote: out,
|
|
588
|
+
ccache: buildPlan.compilerCache === "ccache" ? resolveCcache({
|
|
589
|
+
root,
|
|
590
|
+
onNote: out,
|
|
591
|
+
env: operation?.env
|
|
592
|
+
}) : null,
|
|
593
|
+
cas: buildPlan.cas,
|
|
594
|
+
buildCache: buildPlan.gradleBuildCache,
|
|
595
|
+
pch: buildPlan.pch,
|
|
596
|
+
compilerCacheDisabled: buildPlan.compilerCache === "none"
|
|
597
|
+
});
|
|
598
|
+
if (result.ok) await artifactScope?.validate();
|
|
599
|
+
return result;
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function nativeAndroidDoctor(root) {
|
|
606
|
+
return { inspect: ({ settings }) => {
|
|
607
|
+
let cache = CACHE_LIMIT;
|
|
608
|
+
try {
|
|
609
|
+
gradleArtifactInputs(settingValueAt(settings, "android.artifactInputs"));
|
|
610
|
+
cache = "Native APK caching uses complete inputs in the local or worker context. Build workers also need their separate android.offloadInputs declaration.";
|
|
611
|
+
} catch {}
|
|
612
|
+
const sdkPath = androidHome();
|
|
613
|
+
const sdk = androidSdkRefusal({
|
|
614
|
+
sdkPath,
|
|
615
|
+
sdkExists: existsSync(sdkPath),
|
|
616
|
+
hasLocalProperties: existsSync(join(root, "local.properties")),
|
|
617
|
+
localPropertiesPath: "local.properties"
|
|
618
|
+
});
|
|
619
|
+
const wrapper = join(root, process.platform === "win32" ? "gradlew.bat" : "gradlew");
|
|
620
|
+
return [
|
|
621
|
+
{
|
|
622
|
+
level: "note",
|
|
623
|
+
title: "Native Android Gradle project",
|
|
624
|
+
detail: `${MODEL_LIMIT} ${cache} Metro and EAS are unsupported; local, physical and hosted targets use native process readiness.`,
|
|
625
|
+
fix: null
|
|
626
|
+
},
|
|
627
|
+
...sdk ? [{
|
|
628
|
+
level: "cost",
|
|
629
|
+
code: "android-sdk-missing",
|
|
630
|
+
title: "No Android SDK was found",
|
|
631
|
+
detail: sdk.reason,
|
|
632
|
+
fix: sdk.remedy
|
|
633
|
+
}] : [],
|
|
634
|
+
...!existsSync(wrapper) ? [{
|
|
635
|
+
level: "cost",
|
|
636
|
+
code: "android-wrapper-missing",
|
|
637
|
+
title: "The Gradle wrapper for this host is missing",
|
|
638
|
+
detail: wrapper,
|
|
639
|
+
fix: "Restore the project Gradle wrapper."
|
|
640
|
+
}] : []
|
|
641
|
+
];
|
|
642
|
+
} };
|
|
643
|
+
}
|
|
644
|
+
//#endregion
|
|
645
|
+
export { nativeAndroidDoctor, nativeAndroidProject };
|