Skip to content

Commit 16647fc

Browse files
committed
Merge pull request #853 from NativeScript/toteov/more-static-bindings
Add --static-bindings to run and deploy commands
2 parents 10b2216 + 937cf50 commit 16647fc

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

lib/commands/deploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export class DeployOnDeviceCommand implements ICommand {
88
private $errors: IErrors) { }
99

1010
execute(args: string[]): IFuture<void> {
11-
return this.$platformService.deployOnDevice(args[0]);
11+
let config = this.$options.staticBindings ? { runSbGenerator: true } : undefined;
12+
return this.$platformService.deployOnDevice(args[0], config);
1213
}
1314

1415
public canExecute(args: string[]): IFuture<boolean> {

lib/commands/run.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
export class RunCommandBase {
55
constructor(private $platformService: IPlatformService) { }
66

7-
public executeCore(args: string[]): IFuture<void> {
8-
return this.$platformService.runPlatform(args[0]);
7+
public executeCore(args: string[], buildConfig?: IBuildConfig): IFuture<void> {
8+
return this.$platformService.runPlatform(args[0], buildConfig);
99
}
1010
}
1111

@@ -34,7 +34,8 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
3434
public allowedParameters: ICommandParameter[] = [];
3535

3636
public execute(args: string[]): IFuture<void> {
37-
return this.executeCore([this.$platformsData.availablePlatforms.Android]);
37+
let config = this.$options.staticBindings ? { runSbGenerator: true } : undefined;
38+
return this.executeCore([this.$platformsData.availablePlatforms.Android], config);
3839
}
3940

4041
public canExecute(args: string[]): IFuture<boolean> {

lib/definitions/platform.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ interface IPlatformService {
55
getPreparedPlatforms(): IFuture<string[]>;
66
removePlatforms(platforms: string[]): IFuture<void>;
77
updatePlatforms(platforms: string[]): IFuture<void>;
8-
runPlatform(platform: string): IFuture<void>;
8+
runPlatform(platform: string, buildConfig?: IBuildConfig): IFuture<void>;
99
preparePlatform(platform: string): IFuture<void>;
1010
buildPlatform(platform: string, buildConfig?: IBuildConfig): IFuture<void>;
11-
deployOnDevice(platform: string): IFuture<void>;
12-
deployOnEmulator(platform: string): IFuture<void>;
11+
deployOnDevice(platform: string, buildConfig?: IBuildConfig): IFuture<void>;
12+
deployOnEmulator(platform: string, buildConfig?: IBuildConfig): IFuture<void>;
1313
validatePlatformInstalled(platform: string): void;
1414
validatePlatform(platform: string): void;
1515
addLibrary(platform: string, libraryPath: string): IFuture<void>;

lib/services/ios-project-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
364364
if(firstPostInstallIndex !== -1 && firstPostInstallIndex !== projectPodfileContent.lastIndexOf(IOSProjectService.PODFILE_POST_INSTALL_SECTION_NAME)) {
365365
this.$logger.warn(`Podfile contains more than one post_install sections. You need to open ${this.projectPodFilePath} file and manually resolve this issue.`);
366366
}
367-
367+
368368
let pbxprojFilePath = path.join(this.platformData.projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "xcuserdata");
369369
if(!this.$fs.exists(pbxprojFilePath).wait()) {
370370
this.$logger.info("Creating project scheme...");
371371
let createSchemeRubyScript = `ruby -e "require 'xcodeproj'; xcproj = Xcodeproj::Project.open('${this.$projectData.projectName}.xcodeproj'); xcproj.recreate_user_schemes; xcproj.save"`;
372372
this.$childProcess.exec(createSchemeRubyScript, { cwd: this.platformData.projectRoot }).wait();
373373
}
374-
374+
375375
this.$logger.info("Installing pods...");
376376
this.$childProcess.exec("pod install", { cwd: this.platformData.projectRoot }).wait();
377377
}

lib/services/platform-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ export class PlatformService implements IPlatformService {
247247
}).future<void>()();
248248
}
249249

250-
public deployOnDevice(platform: string): IFuture<void> {
250+
public deployOnDevice(platform: string, buildConfig?: IBuildConfig): IFuture<void> {
251251
return (() => {
252252
platform = platform.toLowerCase();
253253
this.ensurePlatformInstalled(platform).wait();
254254
let platformData = this.$platformsData.getPlatformData(platform);
255255

256256
let cachedDeviceOption = this.$options.forDevice;
257257
this.$options.forDevice = true;
258-
this.buildPlatform(platform).wait();
258+
this.buildPlatform(platform, buildConfig).wait();
259259
this.$options.forDevice = !!cachedDeviceOption;
260260

261261
// Get latest package that is produced from build
@@ -277,7 +277,7 @@ export class PlatformService implements IPlatformService {
277277
}).future<void>()();
278278
}
279279

280-
public deployOnEmulator(platform: string): IFuture<void> {
280+
public deployOnEmulator(platform: string, buildConfig?: IBuildConfig): IFuture<void> {
281281
return (() => {
282282
let packageFile: string, logFilePath: string;
283283
this.ensurePlatformInstalled(platform).wait();
@@ -290,7 +290,7 @@ export class PlatformService implements IPlatformService {
290290
emulatorServices.checkDependencies().wait();
291291

292292
if(!this.$options.availableDevices) {
293-
this.buildPlatform(platform).wait();
293+
this.buildPlatform(platform, buildConfig).wait();
294294

295295
packageFile = this.getLatestApplicationPackageForEmulator(platformData).wait().packageName;
296296
this.$logger.out("Using ", packageFile);

0 commit comments

Comments
 (0)