Skip to content

Commit 7c010fe

Browse files
committed
fix(android): in case we use buildFilterDevicesArch check if we need to rebuild for devices we are building for
1 parent ed2b84a commit 7c010fe

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

lib/services/android-project-service.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import {
4747
import { IInjector } from "../common/definitions/yok";
4848
import { injector } from "../common/yok";
4949
import { INotConfiguredEnvOptions } from "../common/definitions/commands";
50+
import { IProjectChangesInfo } from "../definitions/project-changes";
51+
import { AndroidPrepareData } from "../data/prepare-data";
52+
import { AndroidBuildData } from "../data/build-data";
5053

5154
interface NativeDependency {
5255
name: string;
@@ -148,6 +151,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
148151
private $androidPluginBuildService: IAndroidPluginBuildService,
149152
private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
150153
private $androidResourcesMigrationService: IAndroidResourcesMigrationService,
154+
private $liveSyncProcessDataService: ILiveSyncProcessDataService,
155+
private $devicesService: Mobile.IDevicesService,
151156
private $filesHashService: IFilesHashService,
152157
private $gradleCommandService: IGradleCommandService,
153158
private $gradleBuildService: IGradleBuildService,
@@ -879,8 +884,39 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
879884
await adb.executeShellCommand(["rm", "-rf", deviceRootPath]);
880885
}
881886

882-
public async checkForChanges(): Promise<void> {
883-
// Nothing android specific to check yet.
887+
public async checkForChanges(
888+
changesInfo: IProjectChangesInfo,
889+
prepareData: AndroidPrepareData,
890+
projectData: IProjectData
891+
): Promise<void> {
892+
//we need to check for abi change in connected device vs last built
893+
const deviceDescriptors = this.$liveSyncProcessDataService.getDeviceDescriptors(
894+
projectData.projectDir
895+
);
896+
const platformData = this.getPlatformData(projectData);
897+
deviceDescriptors.forEach(deviceDescriptor=>{
898+
const buildData = deviceDescriptor.buildData as AndroidBuildData;
899+
if (buildData.buildFilterDevicesArch) {
900+
const outputPath = platformData.getBuildOutputPath(deviceDescriptor.buildData);
901+
const apkOutputPath = path.join(outputPath, prepareData.release ? "release" : "debug");
902+
if (!this.$fs.exists(outputPath)) {
903+
return;
904+
}
905+
// check if we already build this arch
906+
// if not we need to say native has changed
907+
const device = this.$devicesService.getDevicesForPlatform(deviceDescriptor.buildData.platform).filter(d=>d.deviceInfo.identifier === deviceDescriptor.identifier)[0];
908+
const abis = device.deviceInfo.abis.filter(a=>!!a && a.length)[0];
909+
910+
const directoryContent = this.$fs.readDirectory(apkOutputPath);
911+
const regexp = new RegExp(`${abis}.*\.apk`);
912+
const files = _.filter(directoryContent, (entry: string) => {
913+
return regexp.test(entry);
914+
});
915+
if (files.length === 0) {
916+
changesInfo.nativeChanged = true;
917+
}
918+
}
919+
})
884920
}
885921

886922
public getDeploymentTarget(projectData: IProjectData): semver.SemVer {

0 commit comments

Comments
 (0)