@@ -43,7 +43,7 @@ pub enum BuildMode {
43
43
Fat ,
44
44
45
45
/// A "thin" build generated with `rustc` directly and dx as a custom linker
46
- Thin { rustc_args : Vec < String > } ,
46
+ Thin ,
47
47
}
48
48
49
49
pub struct CargoBuildResult {
@@ -82,25 +82,21 @@ impl BuildRequest {
82
82
) ;
83
83
84
84
let ( app, server) = match self . build . force_sequential {
85
- true => self . build_sequential ( ) . await ?,
86
- false => self . build_concurrent ( ) . await ?,
85
+ true => futures_util :: future :: try_join ( self . cargo_build ( ) , self . build_server ( ) ) . await ?,
86
+ false => ( self . cargo_build ( ) . await ?, self . build_server ( ) . await ? ) ,
87
87
} ;
88
88
89
- AppBundle :: new ( self , app , server ) . await
90
- }
91
-
92
- /// Run the build command with a pretty loader, returning the executable output location
93
- async fn build_concurrent ( & self ) -> Result < ( BuildArtifacts , Option < BuildArtifacts > ) > {
94
- let ( app , server ) =
95
- futures_util :: future :: try_join ( self . cargo_build ( ) , self . build_server ( ) ) . await ? ;
89
+ // let mut app_bundle = AppBundle::new {
90
+ // app,
91
+ // server,
92
+ // build: self,
93
+ // assets: Default::default(),
94
+ // server_assets: Default::default(),
95
+ // } ;
96
96
97
- Ok ( ( app, server) )
98
- }
97
+ // Ok(app_bundle)
99
98
100
- async fn build_sequential ( & self ) -> Result < ( BuildArtifacts , Option < BuildArtifacts > ) > {
101
- let app = self . cargo_build ( ) . await ?;
102
- let server = self . build_server ( ) . await ?;
103
- Ok ( ( app, server) )
99
+ todo ! ( )
104
100
}
105
101
106
102
pub ( crate ) async fn build_server ( & self ) -> Result < Option < BuildArtifacts > > {
@@ -235,58 +231,47 @@ impl BuildRequest {
235
231
236
232
pub ( crate ) async fn build_thin_rustc ( & self ) { }
237
233
238
- // #[tracing::instrument(
239
- // skip(self),
240
- // level = "trace",
241
- // name = "BuildRequest::assemble_build_command"
242
- // )]
234
+ #[ tracing:: instrument(
235
+ skip( self ) ,
236
+ level = "trace" ,
237
+ fields ( dx_src = ? TraceSrc :: Build )
238
+ ) ]
243
239
fn assemble_build_command ( & self ) -> Result < Command > {
244
- let mut cmd = match & self . mode {
245
- BuildMode :: Fat | BuildMode :: Base => {
246
- let mut cmd = Command :: new ( "cargo" ) ;
247
- cmd. arg ( "rustc" )
248
- . current_dir ( self . krate . crate_dir ( ) )
249
- . arg ( "--message-format" )
250
- . arg ( "json-diagnostic-rendered-ansi" )
251
- . args ( self . build_arguments ( ) )
252
- . envs ( self . env_vars ( ) ?) ;
253
- cmd
254
- }
255
- BuildMode :: Thin { rustc_args } => {
256
- let mut cmd = Command :: new ( rustc_args[ 0 ] . clone ( ) ) ;
257
- cmd. args ( rustc_args[ 1 ..] . iter ( ) )
258
- . env (
259
- LinkAction :: ENV_VAR_NAME ,
260
- LinkAction :: FatLink {
261
- platform : self . build . platform ( ) ,
262
- linker : None ,
263
- incremental_dir : self . incremental_cache_dir ( ) ,
264
- }
265
- . to_json ( ) ,
266
- )
267
- . stdout ( Stdio :: piped ( ) )
268
- . stderr ( Stdio :: piped ( ) ) ;
269
- cmd
270
- }
271
- } ;
272
-
273
- if let Some ( target_dir) = self . custom_target_dir . as_ref ( ) {
274
- cmd. env ( "CARGO_TARGET_DIR" , target_dir) ;
275
- }
276
-
277
- if self . build . platform ( ) == Platform :: Android {
278
- let ndk = self
279
- . krate
280
- . android_ndk ( )
281
- . context ( "Could not autodetect android linker" ) ?;
282
- let arch = self . build . target_args . arch ( ) ;
283
- let linker = arch. android_linker ( & ndk) ;
284
-
285
- cmd. env (
286
- LinkAction :: ENV_VAR_NAME ,
287
- LinkAction :: LinkAndroid { linker } . to_json ( ) ,
288
- ) ;
289
- }
240
+ // let mut cmd = match &self.mode {
241
+ // BuildMode::Fat | BuildMode::Base => {
242
+ // let mut cmd = Command::new("cargo");
243
+ // cmd.arg("rustc")
244
+ // .current_dir(self.krate.crate_dir())
245
+ // .arg("--message-format")
246
+ // .arg("json-diagnostic-rendered-ansi")
247
+ // .args(self.build_arguments())
248
+ // .envs(self.env_vars()?);
249
+ // cmd
250
+ // } // BuildMode::Thin { rustc_args } => {
251
+ // // let mut cmd = Command::new(rustc_args[0].clone());
252
+ // // cmd.args(rustc_args[1..].iter())
253
+ // // .env(
254
+ // // LinkAction::ENV_VAR_NAME,
255
+ // // LinkAction::FatLink {
256
+ // // platform: self.build.platform(),
257
+ // // linker: None,
258
+ // // incremental_dir: self.incremental_cache_dir(),
259
+ // // }
260
+ // // .to_json(),
261
+ // // )
262
+ // // .stdout(Stdio::piped())
263
+ // // .stderr(Stdio::piped());
264
+ // // cmd
265
+ // // }
266
+ // };
267
+
268
+ let mut cmd = Command :: new ( "cargo" ) ;
269
+ cmd. arg ( "rustc" )
270
+ . current_dir ( self . krate . crate_dir ( ) )
271
+ . arg ( "--message-format" )
272
+ . arg ( "json-diagnostic-rendered-ansi" )
273
+ . args ( self . build_arguments ( ) )
274
+ . envs ( self . env_vars ( ) ?) ;
290
275
291
276
Ok ( cmd)
292
277
}
@@ -372,14 +357,25 @@ impl BuildRequest {
372
357
373
358
cargo_args. push ( self . krate . executable_name ( ) . to_string ( ) ) ;
374
359
360
+ cargo_args. push ( "--" . to_string ( ) ) ;
361
+
375
362
// the bundle splitter needs relocation data
376
363
// we'll trim these out if we don't need them during the bundling process
377
364
// todo(jon): for wasm binary patching we might want to leave these on all the time.
378
365
if self . build . platform ( ) == Platform :: Web && self . build . experimental_wasm_split {
379
- cargo_args. push ( "--" . to_string ( ) ) ;
380
366
cargo_args. push ( "-Clink-args=--emit-relocs" . to_string ( ) ) ;
381
367
}
382
368
369
+ match self . mode {
370
+ BuildMode :: Fat | BuildMode :: Thin => cargo_args. push ( format ! (
371
+ "-Clinker={}" ,
372
+ dunce:: canonicalize( std:: env:: current_exe( ) . unwrap( ) )
373
+ . unwrap( )
374
+ . display( )
375
+ ) ) ,
376
+ _ => { }
377
+ }
378
+
383
379
tracing:: debug!( dx_src = ?TraceSrc :: Build , "cargo args: {:?}" , cargo_args) ;
384
380
385
381
cargo_args
@@ -556,6 +552,57 @@ impl BuildRequest {
556
552
// env_vars.push(("PATH", extended_path));
557
553
} ;
558
554
555
+ let linker = match self . build . platform ( ) {
556
+ Platform :: Web => todo ! ( ) ,
557
+ Platform :: MacOS => todo ! ( ) ,
558
+ Platform :: Windows => todo ! ( ) ,
559
+ Platform :: Linux => todo ! ( ) ,
560
+ Platform :: Ios => todo ! ( ) ,
561
+ Platform :: Android => todo ! ( ) ,
562
+ Platform :: Server => todo ! ( ) ,
563
+ Platform :: Liveview => todo ! ( ) ,
564
+ } ;
565
+
566
+ let custom_linker = if self . build . platform ( ) == Platform :: Android {
567
+ let ndk = self
568
+ . krate
569
+ . android_ndk ( )
570
+ . context ( "Could not autodetect android linker" ) ?;
571
+
572
+ let linker = self . build . target_args . arch ( ) . android_linker ( & ndk) ;
573
+ Some ( linker)
574
+ } else {
575
+ None
576
+ } ;
577
+
578
+ match & self . mode {
579
+ BuildMode :: Base | BuildMode :: Fat => env_vars. push ( (
580
+ LinkAction :: ENV_VAR_NAME ,
581
+ LinkAction :: BaseLink {
582
+ platform : self . build . platform ( ) ,
583
+ linker : "cc" . into ( ) ,
584
+ incremental_dir : self . incremental_cache_dir ( ) ,
585
+ strip : matches ! ( self . mode, BuildMode :: Base ) ,
586
+ }
587
+ . to_json ( ) ,
588
+ ) ) ,
589
+ BuildMode :: Thin => env_vars. push ( (
590
+ LinkAction :: ENV_VAR_NAME ,
591
+ LinkAction :: ThinLink {
592
+ platform : self . build . platform ( ) ,
593
+ linker : "cc" . into ( ) ,
594
+ incremental_dir : self . incremental_cache_dir ( ) ,
595
+ main_ptr : todo ! ( ) ,
596
+ patch_target : todo ! ( ) ,
597
+ }
598
+ . to_json ( ) ,
599
+ ) ) ,
600
+ }
601
+
602
+ if let Some ( target_dir) = self . custom_target_dir . as_ref ( ) {
603
+ env_vars. push ( ( "CARGO_TARGET_DIR" , target_dir. display ( ) . to_string ( ) ) ) ;
604
+ }
605
+
559
606
// If this is a release build, bake the base path and title
560
607
// into the binary with env vars
561
608
if self . build . release {
@@ -988,4 +1035,8 @@ impl BuildRequest {
988
1035
989
1036
todo ! ( )
990
1037
}
1038
+
1039
+ pub ( crate ) fn is_patch ( & self ) -> bool {
1040
+ matches ! ( & self . mode, BuildMode :: Thin { .. } )
1041
+ }
991
1042
}
0 commit comments