-
-
Notifications
You must be signed in to change notification settings - Fork 206
feat(android): optionally pass the device ABIs to plugin builds #6134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,8 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { | |
| private $watchIgnoreListService: IWatchIgnoreListService, | ||
| ) {} | ||
|
|
||
| private static ABI_FILTERS_BUILD_DATA_KEY = "__abiFilters"; | ||
|
|
||
| private static MANIFEST_ROOT = { | ||
| $: { | ||
| "xmlns:android": "http://schemas.android.com/apk/res/android", | ||
|
|
@@ -233,6 +235,16 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { | |
| shortPluginName, | ||
| ); | ||
|
|
||
| // the aar of a plugin built for a subset of the ABIs is not the aar of the | ||
| // same sources built for another subset, so the ABIs take part in the | ||
| // decision to rebuild - the sources alone would not change when a device | ||
| // with another ABI joins the run. | ||
| if (options.abiFilters && options.abiFilters.length) { | ||
| pluginSourceFileHashesInfo[ | ||
| AndroidPluginBuildService.ABI_FILTERS_BUILD_DATA_KEY | ||
| ] = options.abiFilters.join(","); | ||
| } | ||
|
Comment on lines
+242
to
+246
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Cache the effective ABI filter and match the exact Gradle property. Lines 242-246 store Resolve the effective ABI filter before Also applies to: 840-847 🤖 Prompt for AI Agents |
||
|
|
||
| const shouldBuildAar = await this.shouldBuildAar({ | ||
| manifestFilePath, | ||
| androidSourceDirectories, | ||
|
|
@@ -264,6 +276,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { | |
| await this.buildPlugin({ | ||
| gradlePath: options.gradlePath, | ||
| gradleArgs: options.gradleArgs, | ||
| abiFilters: options.abiFilters, | ||
| pluginDir: pluginTempDir, | ||
| pluginName: options.pluginName, | ||
| projectDir: options.projectDir, | ||
|
|
@@ -821,6 +834,19 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { | |
| localArgs.push(pluginBuildSettings.gradleArgs); | ||
| } | ||
|
|
||
| // nothing in the gradle files generated here acts on `abiFilters` - it is | ||
| // passed for a plugin whose own include.gradle reads it to narrow a long | ||
| // native build down. An explicit `-PabiFilters` in the gradle args wins. | ||
| if ( | ||
| pluginBuildSettings.abiFilters && | ||
| pluginBuildSettings.abiFilters.length && | ||
| (pluginBuildSettings.gradleArgs || "").indexOf("-PabiFilters") === -1 | ||
| ) { | ||
| localArgs.push( | ||
| `-PabiFilters=${pluginBuildSettings.abiFilters.join(",")}` | ||
| ); | ||
| } | ||
|
|
||
| if (this.$logger.getLevel() === "INFO") { | ||
| localArgs.push("--quiet"); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import * as _ from "lodash"; | ||
|
|
||
| /** | ||
| * The ABIs of the devices a build is about to be deployed to - the first (most | ||
| * preferred) ABI of every device, deduplicated. `device`/`emulator` narrow the | ||
| * set down the same way they narrow the run itself. | ||
| */ | ||
| export function getDevicesAbis( | ||
| $devicesService: Mobile.IDevicesService, | ||
| platform: string, | ||
| filter: { device?: string; emulator?: boolean } = {} | ||
| ): string[] { | ||
| let devices = $devicesService.getDevicesForPlatform(platform); | ||
| if (filter.device) { | ||
| devices = devices.filter((d) => d.deviceInfo.identifier === filter.device); | ||
| } else if (filter.emulator) { | ||
| devices = devices.filter((d) => d.isEmulator); | ||
| } | ||
|
|
||
| return _.uniq( | ||
| devices.map((d) => (d.deviceInfo.abis || [])[0]).filter((abi) => !!abi) | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: NativeScript/nativescript-cli
Length of output: 4641
🏁 Script executed:
Repository: NativeScript/nativescript-cli
Length of output: 14156
🏁 Script executed:
Repository: NativeScript/nativescript-cli
Length of output: 22185
🏁 Script executed:
Repository: NativeScript/nativescript-cli
Length of output: 1185
🏁 Script executed:
Repository: NativeScript/nativescript-cli
Length of output: 10086
Preserve the full device ABI preference order.
getAbiscurrently placescpu.abilist64beforecpu.abilist. Android defines cross-bitness preference order throughro.product.cpu.abilist.getDevicesAbisselectsdeviceInfo.abis[0], socpu.abilist=armeabi-v7a,arm64-v8aselects the wrong ABI. Parsecpu.abilistfirst and use the 64-bit/32-bit concatenation only when it is absent. Add regression coverage for the full ABI list and selected ABI.🤖 Prompt for AI Agents