@@ -62,7 +62,7 @@ lazy_static! {
6262
6363 handlebars
6464 . register_template_string( "main.wxs" , include_str!( "templates/main.wxs" ) )
65- . or_else ( |e| Err ( e. to_string( ) ) )
65+ . map_err ( |e| e. to_string( ) )
6666 . expect( "Failed to setup handlebar template" ) ;
6767 handlebars
6868 } ;
@@ -143,7 +143,7 @@ impl ResourceDirectory {
143143 }
144144 directories. push_str ( wix_string. as_str ( ) ) ;
145145 }
146- let wix_string = if self . name == "" {
146+ let wix_string = if self . name . is_empty ( ) {
147147 format ! ( "{}{}" , files, directories)
148148 } else {
149149 format ! (
@@ -278,64 +278,12 @@ pub fn get_and_extract_wix(path: &Path) -> crate::Result<()> {
278278 extract_zip ( & data, path)
279279}
280280
281- // For if bundler needs DLL files.
282-
283- // fn run_heat_exe(
284- // wix_toolset_path: &Path,
285- // build_path: &Path,
286- // harvest_dir: &Path,
287- // platform: &str,
288- // ) -> Result<(), String> {
289- // let mut args = vec!["dir"];
290-
291- // let harvest_str = harvest_dir.display().to_string();
292-
293- // args.push(&harvest_str);
294- // args.push("-platform");
295- // args.push(platform);
296- // args.push("-cg");
297- // args.push("AppFiles");
298- // args.push("-dr");
299- // args.push("APPLICATIONFOLDER");
300- // args.push("-gg");
301- // args.push("-srd");
302- // args.push("-out");
303- // args.push("appdir.wxs");
304- // args.push("-var");
305- // args.push("var.SourceDir");
306-
307- // let heat_exe = wix_toolset_path.join("heat.exe");
308-
309- // let mut cmd = Command::new(&heat_exe)
310- // .args(&args)
311- // .stdout(Stdio::piped())
312- // .current_dir(build_path)
313- // .spawn()
314- // .expect("error running heat.exe");
315-
316- // {
317- // let stdout = cmd.stdout.as_mut().unwrap();
318- // let reader = BufReader::new(stdout);
319-
320- // for line in reader.lines() {
321- // info!(logger, "{}", line.unwrap());
322- // }
323- // }
324-
325- // let status = cmd.wait().unwrap();
326- // if status.success() {
327- // Ok(())
328- // } else {
329- // Err("error running heat.exe".to_string())
330- // }
331- // }
332-
333281/// Runs the Candle.exe executable for Wix. Candle parses the wxs file and generates the code for building the installer.
334282fn run_candle (
335283 settings : & Settings ,
336284 wix_toolset_path : & Path ,
337- build_path : & Path ,
338- wxs_file_name : & str ,
285+ cwd : & Path ,
286+ wxs_file_path : & Path ,
339287) -> crate :: Result < ( ) > {
340288 let arch = match settings. binary_arch ( ) {
341289 "x86_64" => "x64" ,
@@ -357,21 +305,18 @@ fn run_candle(
357305 let args = vec ! [
358306 "-arch" . to_string( ) ,
359307 arch. to_string( ) ,
360- wxs_file_name . to_string( ) ,
308+ wxs_file_path . to_string_lossy ( ) . to_string( ) ,
361309 format!(
362310 "-dSourceDir={}" ,
363311 settings. binary_path( main_binary) . display( )
364312 ) ,
365313 ] ;
366314
367315 let candle_exe = wix_toolset_path. join ( "candle.exe" ) ;
368- common:: print_info ( format ! ( "running candle for {}" , wxs_file_name ) . as_str ( ) ) ?;
316+ common:: print_info ( format ! ( "running candle for {:? }" , wxs_file_path ) . as_str ( ) ) ?;
369317
370318 let mut cmd = Command :: new ( & candle_exe) ;
371- cmd
372- . args ( & args)
373- . stdout ( Stdio :: piped ( ) )
374- . current_dir ( build_path) ;
319+ cmd. args ( & args) . stdout ( Stdio :: piped ( ) ) . current_dir ( cwd) ;
375320
376321 common:: print_info ( "running candle.exe" ) ?;
377322 common:: execute_with_verbosity ( & mut cmd, & settings) . map_err ( |_| {
@@ -532,6 +477,17 @@ pub fn build_wix_app_installer(
532477
533478 data. insert ( "icon_path" , to_json ( icon_path) ) ;
534479
480+ let mut fragment_paths = Vec :: new ( ) ;
481+
482+ if let Some ( wix) = & settings. windows ( ) . wix {
483+ data. insert ( "component_group_refs" , to_json ( & wix. component_group_refs ) ) ;
484+ data. insert ( "component_refs" , to_json ( & wix. component_refs ) ) ;
485+ data. insert ( "feature_group_refs" , to_json ( & wix. feature_group_refs ) ) ;
486+ data. insert ( "feature_refs" , to_json ( & wix. feature_refs ) ) ;
487+ data. insert ( "merge_refs" , to_json ( & wix. merge_refs ) ) ;
488+ fragment_paths = wix. fragment_paths . clone ( ) ;
489+ }
490+
535491 let temp = HANDLEBARS . render ( "main.wxs" , & data) ?;
536492
537493 if output_path. exists ( ) {
@@ -543,14 +499,18 @@ pub fn build_wix_app_installer(
543499 let main_wxs_path = output_path. join ( "main.wxs" ) ;
544500 write ( & main_wxs_path, temp) ?;
545501
546- let input_basenames = vec ! [ "main" ] ;
502+ let mut candle_inputs = vec ! [ "main.wxs" . into( ) ] ;
503+
504+ let current_dir = std:: env:: current_dir ( ) ?;
505+ for fragment_path in fragment_paths {
506+ candle_inputs. push ( current_dir. join ( fragment_path) ) ;
507+ }
547508
548- for basename in & input_basenames {
549- let wxs = format ! ( "{}.wxs" , basename) ;
509+ for wxs in & candle_inputs {
550510 run_candle ( settings, & wix_toolset_path, & output_path, & wxs) ?;
551511 }
552512
553- let wixobjs = vec ! [ "main .wixobj" ] ;
513+ let wixobjs = vec ! [ "* .wixobj" ] ;
554514 let target = run_light (
555515 & wix_toolset_path,
556516 & output_path,
@@ -600,12 +560,12 @@ fn locate_signtool() -> crate::Result<PathBuf> {
600560 let mut kit_bin_paths: Vec < PathBuf > = installed_kits
601561 . iter ( )
602562 . rev ( )
603- . map ( |kit| kits_root_10_bin_path. join ( kit) . to_path_buf ( ) )
563+ . map ( |kit| kits_root_10_bin_path. join ( kit) )
604564 . collect ( ) ;
605565
606566 /* Add kits root bin path.
607567 For Windows SDK 10 versions earlier than v10.0.15063.468, signtool will be located there. */
608- kit_bin_paths. push ( kits_root_10_bin_path. to_path_buf ( ) ) ;
568+ kit_bin_paths. push ( kits_root_10_bin_path) ;
609569
610570 // Choose which version of SignTool to use based on OS bitness
611571 let arch_dir = match bitness:: os_bitness ( ) . expect ( "failed to get os bitness" ) {
@@ -622,7 +582,7 @@ fn locate_signtool() -> crate::Result<PathBuf> {
622582 /* Check if SignTool exists at this location. */
623583 if signtool_path. exists ( ) {
624584 // SignTool found. Return it.
625- return Ok ( signtool_path. to_path_buf ( ) ) ;
585+ return Ok ( signtool_path) ;
626586 }
627587 }
628588
0 commit comments