@@ -4,11 +4,10 @@ import { cache, performanceLog } from "../common/decorators";
44import { EventEmitter } from "events" ;
55
66export class RunController extends EventEmitter implements IRunController {
7- private rebuiltInformation : IDictionary < any > = { } ;
7+ private rebuiltInformation : IDictionary < { packageFilePath : string , platform : string , isEmulator : boolean } > = { } ;
88
99 constructor (
1010 protected $analyticsService : IAnalyticsService ,
11- private $buildDataService : IBuildDataService ,
1211 private $buildController : IBuildController ,
1312 private $debugController : IDebugController ,
1413 private $deviceInstallAppService : IDeviceInstallAppService ,
@@ -191,7 +190,7 @@ export class RunController extends EventEmitter implements IRunController {
191190 projectDir : projectData . projectDir ,
192191 deviceIdentifier,
193192 debugOptions : deviceDescriptor . debugOptions ,
194- outputPath : deviceDescriptor . outputPath
193+ outputPath : deviceDescriptor . buildData . outputPath
195194 } ;
196195 this . emit ( USER_INTERACTION_NEEDED_EVENT_NAME , attachDebuggerOptions ) ;
197196 }
@@ -242,9 +241,16 @@ export class RunController extends EventEmitter implements IRunController {
242241 const deviceAction = async ( device : Mobile . IDevice ) => {
243242 const deviceDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
244243 const platformData = this . $platformsDataService . getPlatformData ( device . deviceInfo . platform , projectData ) ;
245- const prepareData = this . $prepareDataService . getPrepareData ( liveSyncInfo . projectDir , device . deviceInfo . platform , { ...liveSyncInfo , watch : ! liveSyncInfo . skipWatcher , nativePrepare : { skipNativePrepare : ! ! deviceDescriptor . skipNativePrepare } } ) ;
246- const buildData = this . $buildDataService . getBuildData ( projectData . projectDir , device . deviceInfo . platform , { ...liveSyncInfo , outputPath : deviceDescriptor . outputPath , buildForDevice : ! device . isEmulator } ) ;
244+ const prepareData = this . $prepareDataService . getPrepareData ( liveSyncInfo . projectDir , device . deviceInfo . platform ,
245+ {
246+ ...liveSyncInfo ,
247+ ...deviceDescriptor . buildData ,
248+ nativePrepare : { skipNativePrepare : ! ! deviceDescriptor . skipNativePrepare } ,
249+ watch : ! liveSyncInfo . skipWatcher ,
250+ } ) ;
251+
247252 const prepareResultData = await this . $prepareController . prepare ( prepareData ) ;
253+ const buildData = { ...deviceDescriptor . buildData , buildForDevice : ! device . isEmulator } ;
248254
249255 try {
250256 let packageFilePath : string = null ;
@@ -312,14 +318,24 @@ export class RunController extends EventEmitter implements IRunController {
312318 const deviceAction = async ( device : Mobile . IDevice ) => {
313319 const deviceDescriptor = _ . find ( deviceDescriptors , dd => dd . identifier === device . deviceInfo . identifier ) ;
314320 const platformData = this . $platformsDataService . getPlatformData ( data . platform , projectData ) ;
315- const prepareData = this . $prepareDataService . getPrepareData ( projectData . projectDir , data . platform , { ...liveSyncInfo , watch : ! liveSyncInfo . skipWatcher } ) ;
321+ const prepareData = this . $prepareDataService . getPrepareData ( liveSyncInfo . projectDir , device . deviceInfo . platform ,
322+ {
323+ ...liveSyncInfo ,
324+ ...deviceDescriptor . buildData ,
325+ nativePrepare : { skipNativePrepare : ! ! deviceDescriptor . skipNativePrepare } ,
326+ watch : ! liveSyncInfo . skipWatcher ,
327+ } ) ;
316328
317329 try {
318- const rebuiltInfo = this . rebuiltInformation [ platformData . platformNameLowerCase ] && ( this . $mobileHelper . isAndroidPlatform ( platformData . platformNameLowerCase ) || this . rebuiltInformation [ platformData . platformNameLowerCase ] . isEmulator === device . isEmulator ) ;
319- if ( data . hasNativeChanges && ! rebuiltInfo ) {
320- await this . $prepareNativePlatformService . prepareNativePlatform ( platformData , projectData , prepareData ) ;
321- await deviceDescriptor . buildAction ( ) ;
322- this . rebuiltInformation [ platformData . platformNameLowerCase ] = { isEmulator : device . isEmulator , platform : platformData . platformNameLowerCase , packageFilePath : null } ;
330+ if ( data . hasNativeChanges ) {
331+ const rebuiltInfo = this . rebuiltInformation [ platformData . platformNameLowerCase ] && ( this . $mobileHelper . isAndroidPlatform ( platformData . platformNameLowerCase ) || this . rebuiltInformation [ platformData . platformNameLowerCase ] . isEmulator === device . isEmulator ) ;
332+ if ( ! rebuiltInfo ) {
333+ await this . $prepareNativePlatformService . prepareNativePlatform ( platformData , projectData , prepareData ) ;
334+ await deviceDescriptor . buildAction ( ) ;
335+ this . rebuiltInformation [ platformData . platformNameLowerCase ] = { isEmulator : device . isEmulator , platform : platformData . platformNameLowerCase , packageFilePath : null } ;
336+ }
337+
338+ await this . $deviceInstallAppService . installOnDevice ( device , deviceDescriptor . buildData , this . rebuiltInformation [ platformData . platformNameLowerCase ] . packageFilePath ) ;
323339 }
324340
325341 const isInHMRMode = liveSyncInfo . useHotModuleReload && data . hmrData && data . hmrData . hash ;
0 commit comments