Skip to content

fix(build-ios): Use BUILD_DIR instead of CONFIGURATION_BUILD_DIR #4310

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

Merged
merged 4 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/definitions/platform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ interface IPlatformService extends IBuildPlatformAction, NodeJS.EventEmitter {
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<boolean>;

/**
*
*
* @param {Mobile.IDevice} device The device where the application should be installed.
* @param {IProjectData} projectData DTO with information about the project.
* @param {string} @optional outputPath Directory containing build information and artifacts.
Expand Down Expand Up @@ -259,9 +259,8 @@ interface IPlatformData {
projectRoot: string;
normalizedPlatformName: string;
appDestinationDirectoryPath: string;
deviceBuildOutputPath: string;
getBuildOutputPath(options: IBuildOutputOptions): string;
bundleBuildOutputPath?: string;
emulatorBuildOutputPath?: string;
getValidBuildOutputData(buildOptions: IBuildOutputOptions): IValidBuildOutputData;
frameworkFilesExtensions: string[];
frameworkDirectoriesExtensions?: string[];
Expand Down Expand Up @@ -315,7 +314,7 @@ interface INodeModulesDependenciesBuilder {
interface IBuildInfo {
prepareTime: string;
buildTime: string;
/**
/**
* Currently it is used only for iOS.
* As `xcrun` command does not throw an error when IPHONEOS_DEPLOYMENT_TARGET is provided in `xcconfig` file and
* the simulator's version does not match IPHONEOS_DEPLOYMENT_TARGET's value, we need to save it to buildInfo file
Expand Down
4 changes: 2 additions & 2 deletions lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
appDestinationDirectoryPath: path.join(...appDestinationDirectoryArr),
platformProjectService: this,
projectRoot: projectRoot,
deviceBuildOutputPath: path.join(...deviceBuildOutputArr),
getBuildOutputPath: () => path.join(...deviceBuildOutputArr),
bundleBuildOutputPath: path.join(projectRoot, constants.APP_FOLDER_NAME, constants.BUILD_DIR, constants.OUTPUTS_DIR, constants.BUNDLE_DIR),
getValidBuildOutputData: (buildOptions: IBuildOutputOptions): IValidBuildOutputData => {
const buildMode = buildOptions.release ? Configurations.Release.toLowerCase() : Configurations.Debug.toLowerCase();
Expand Down Expand Up @@ -332,7 +332,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
const gradleArgs = this.getGradleBuildOptions(buildConfig, projectData);
const baseTask = buildConfig.androidBundle ? "bundle" : "assemble";
const platformData = this.getPlatformData(projectData);
const outputPath = buildConfig.androidBundle ? platformData.bundleBuildOutputPath : platformData.deviceBuildOutputPath;
const outputPath = buildConfig.androidBundle ? platformData.bundleBuildOutputPath : platformData.getBuildOutputPath(buildConfig);
if (this.$logger.getLevel() === "TRACE") {
gradleArgs.unshift("--stacktrace");
gradleArgs.unshift("--debug");
Expand Down
27 changes: 18 additions & 9 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from "path";
import * as shell from "shelljs";
import * as semver from "semver";
import * as constants from "../constants";
import { Configurations } from "../common/constants";
import * as helpers from "../common/helpers";
import { attachAwaitDetach } from "../common/helpers";
import * as projectServiceBaseLib from "./platform-project-service-base";
Expand All @@ -21,6 +22,12 @@ interface INativeSourceCodeGroup {
files: string[];
}

const DevicePlatformSdkName = "iphoneos";
const SimulatorPlatformSdkName = "iphonesimulator";

const getPlatformSdkName = (forDevice: boolean): string => forDevice ? DevicePlatformSdkName : SimulatorPlatformSdkName;
const getConfigurationName = (release: boolean): string => release ? Configurations.Release : Configurations.Debug;

export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServiceBase implements IPlatformProjectService {
private static XCODEBUILD_MIN_VERSION = "6.0";
private static IOS_PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__";
Expand Down Expand Up @@ -67,8 +74,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
appDestinationDirectoryPath: path.join(projectRoot, projectData.projectName),
platformProjectService: this,
projectRoot: projectRoot,
deviceBuildOutputPath: path.join(projectRoot, constants.BUILD_DIR, "device"),
emulatorBuildOutputPath: path.join(projectRoot, constants.BUILD_DIR, "emulator"),
getBuildOutputPath: (options : IBuildOutputOptions): string => {
const config = getConfigurationName(!options || options.release);
return path.join(projectRoot, constants.BUILD_DIR, `${config}-${getPlatformSdkName(!options || options.buildForDevice)}`);
},
getValidBuildOutputData: (buildOptions: IBuildOutputOptions): IValidBuildOutputData => {
const forDevice = !buildOptions || !!buildOptions.buildForDevice;
if (forDevice) {
Expand Down Expand Up @@ -209,7 +218,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
const projectRoot = this.getPlatformData(projectData).projectRoot;
const archivePath = options && options.archivePath ? path.resolve(options.archivePath) : path.join(projectRoot, "/build/archive/", projectData.projectName + ".xcarchive");
let args = ["archive", "-archivePath", archivePath, "-configuration",
(!buildConfig || buildConfig.release) ? "Release" : "Debug"]
getConfigurationName(!buildConfig || buildConfig.release)]
.concat(this.xcbuildProjectArgs(projectRoot, projectData, "scheme"));

if (options && options.additionalArgs) {
Expand Down Expand Up @@ -282,7 +291,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
const platformData = this.getPlatformData(projectData);
const projectRoot = platformData.projectRoot;
const archivePath = options.archivePath;
const buildOutputPath = path.join(projectRoot, "build", "device");
const buildOutputPath = path.join(projectRoot, "build");
const exportOptionsMethod = await this.getExportOptionsMethod(projectData);
let plistTemplate = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand Down Expand Up @@ -407,8 +416,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
args = args.concat((buildConfig && buildConfig.architectures) || this.getBuildArchitectures(projectData, buildConfig, ["armv7", "arm64"]));

args = args.concat([
"-sdk", "iphoneos",
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "device")
"-sdk", DevicePlatformSdkName,
"BUILD_DIR=" + path.join(projectRoot, "build")
]);

const xcodeBuildVersion = await this.getXcodeVersion();
Expand Down Expand Up @@ -574,10 +583,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
.concat(architectures)
.concat([
"build",
"-configuration", buildConfig.release ? "Release" : "Debug",
"-sdk", "iphonesimulator",
"-configuration", getConfigurationName(buildConfig.release),
"-sdk", SimulatorPlatformSdkName,
"ONLY_ACTIVE_ARCH=NO",
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator"),
"BUILD_DIR=" + path.join(projectRoot, "build"),
"CODE_SIGN_IDENTITY=",
])
.concat(this.xcbuildProjectArgs(projectRoot, projectData));
Expand Down
15 changes: 7 additions & 8 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}

const platformData = this.$platformsData.getPlatformData(platform, projectData);
const forDevice = !buildConfig || !!buildConfig.buildForDevice;
outputPath = outputPath || (forDevice ? platformData.deviceBuildOutputPath : platformData.emulatorBuildOutputPath || platformData.deviceBuildOutputPath);
outputPath = outputPath || platformData.getBuildOutputPath(buildConfig);
if (!this.$fs.exists(outputPath)) {
return true;
}
Expand Down Expand Up @@ -533,7 +532,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}

let hashes = {};
const hashesFilePath = path.join(outputFilePath || platformData.deviceBuildOutputPath, constants.HASHES_FILE_NAME);
const hashesFilePath = path.join(outputFilePath || platformData.getBuildOutputPath(null), constants.HASHES_FILE_NAME);
if (this.$fs.exists(hashesFilePath)) {
hashes = this.$fs.readJson(hashesFilePath);
}
Expand Down Expand Up @@ -618,10 +617,10 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}

if (platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
return options.buildForDevice ? platformData.deviceBuildOutputPath : platformData.emulatorBuildOutputPath;
return platformData.getBuildOutputPath(options);
}

return platformData.deviceBuildOutputPath;
return platformData.getBuildOutputPath(options);
}

private async getDeviceBuildInfoFilePath(device: Mobile.IDevice, projectData: IProjectData): Promise<string> {
Expand Down Expand Up @@ -904,13 +903,13 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}

public getLatestApplicationPackageForDevice(platformData: IPlatformData, buildConfig: IBuildConfig, outputPath?: string): IApplicationPackage {
return this.getLatestApplicationPackage(outputPath || platformData.deviceBuildOutputPath, platformData.getValidBuildOutputData({ buildForDevice: true, release: buildConfig.release, androidBundle: buildConfig.androidBundle }));
return this.getLatestApplicationPackage(outputPath || platformData.getBuildOutputPath(buildConfig), platformData.getValidBuildOutputData({ buildForDevice: true, release: buildConfig.release, androidBundle: buildConfig.androidBundle }));
}

public getLatestApplicationPackageForEmulator(platformData: IPlatformData, buildConfig: IBuildConfig, outputPath?: string): IApplicationPackage {
outputPath = outputPath || this.getBuildOutputPath(platformData.normalizedPlatformName.toLowerCase(), platformData, buildConfig);
const buildOutputOptions: IBuildOutputOptions = { buildForDevice: false, release: buildConfig.release, androidBundle: buildConfig.androidBundle };
outputPath = outputPath || this.getBuildOutputPath(platformData.normalizedPlatformName.toLowerCase(), platformData, buildOutputOptions);
return this.getLatestApplicationPackage(outputPath || platformData.emulatorBuildOutputPath || platformData.deviceBuildOutputPath, platformData.getValidBuildOutputData(buildOutputOptions));
return this.getLatestApplicationPackage(outputPath || platformData.getBuildOutputPath(buildConfig), platformData.getValidBuildOutputData(buildOutputOptions));
}

private async updatePlatform(platform: string, version: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion test/platform-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PlatformData implements IPlatformData {
}
};
projectRoot = "";
deviceBuildOutputPath = "";
getBuildOutputPath = () => "";
getValidBuildOutputData = (buildOptions: IBuildOutputOptions) => ({ packageNames: [""] });
validPackageNamesForDevice: string[] = [];
frameworkFilesExtensions = [".jar", ".dat"];
Expand Down
3 changes: 2 additions & 1 deletion test/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ describe('Platform Service Tests', () => {
projectRoot: "",
normalizedPlatformName: "",
appDestinationDirectoryPath: "",
deviceBuildOutputPath: "",
getBuildOutputPath: () => "",
getValidBuildOutputData: (buildOptions: IBuildOutputOptions) => ({ packageNames: [] }),
frameworkFilesExtensions: [],
relativeToFrameworkConfigurationFilePath: "",
Expand Down Expand Up @@ -981,6 +981,7 @@ describe('Platform Service Tests', () => {
return {
deviceBuildOutputPath: "",
normalizedPlatformName: "",
getBuildOutputPath: () => "",
platformProjectService: {
buildProject: () => Promise.resolve(),
on: () => ({}),
Expand Down
3 changes: 2 additions & 1 deletion test/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ describe("androidDeviceDebugService", () => {
const getPlatformDataStub: sinon.SinonStub = sandbox.stub(androidProjectService, "getPlatformData");
getPlatformDataStub.callsFake(() => {
return {
configurationFilePath: ""
configurationFilePath: "",
getBuildOutputPath: () => ""
};
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export class PlatformProjectServiceStub extends EventEmitter implements IPlatfor
normalizedPlatformName: "",
platformProjectService: this,
projectRoot: "",
deviceBuildOutputPath: "",
getBuildOutputPath: () => "",
getValidBuildOutputData: (buildOptions: IBuildOutputOptions) => ({ packageNames: [] }),
frameworkFilesExtensions: [],
appDestinationDirectoryPath: "",
Expand Down Expand Up @@ -490,7 +490,7 @@ export class PlatformsDataStub extends EventEmitter implements IPlatformsData {
projectRoot: "",
normalizedPlatformName: "",
appDestinationDirectoryPath: "",
deviceBuildOutputPath: "",
getBuildOutputPath: () => "",
getValidBuildOutputData: (buildOptions: IBuildOutputOptions) => ({ packageNames: [] }),
frameworkFilesExtensions: [],
relativeToFrameworkConfigurationFilePath: "",
Expand Down