|
@@ -62,7 +62,7 @@ lazy_static! {
|
|
|
|
|
|
handlebars
|
|
|
.register_template_string("main.wxs", include_str!("templates/main.wxs"))
|
|
|
- .or_else(|e| Err(e.to_string()))
|
|
|
+ .map_err(|e| e.to_string())
|
|
|
.expect("Failed to setup handlebar template");
|
|
|
handlebars
|
|
|
};
|
|
@@ -143,7 +143,7 @@ impl ResourceDirectory {
|
|
|
}
|
|
|
directories.push_str(wix_string.as_str());
|
|
|
}
|
|
|
- let wix_string = if self.name == "" {
|
|
|
+ let wix_string = if self.name.is_empty() {
|
|
|
format!("{}{}", files, directories)
|
|
|
} else {
|
|
|
format!(
|
|
@@ -278,64 +278,12 @@ pub fn get_and_extract_wix(path: &Path) -> crate::Result<()> {
|
|
|
extract_zip(&data, path)
|
|
|
}
|
|
|
|
|
|
-// For if bundler needs DLL files.
|
|
|
-
|
|
|
-// fn run_heat_exe(
|
|
|
-// wix_toolset_path: &Path,
|
|
|
-// build_path: &Path,
|
|
|
-// harvest_dir: &Path,
|
|
|
-// platform: &str,
|
|
|
-// ) -> Result<(), String> {
|
|
|
-// let mut args = vec!["dir"];
|
|
|
-
|
|
|
-// let harvest_str = harvest_dir.display().to_string();
|
|
|
-
|
|
|
-// args.push(&harvest_str);
|
|
|
-// args.push("-platform");
|
|
|
-// args.push(platform);
|
|
|
-// args.push("-cg");
|
|
|
-// args.push("AppFiles");
|
|
|
-// args.push("-dr");
|
|
|
-// args.push("APPLICATIONFOLDER");
|
|
|
-// args.push("-gg");
|
|
|
-// args.push("-srd");
|
|
|
-// args.push("-out");
|
|
|
-// args.push("appdir.wxs");
|
|
|
-// args.push("-var");
|
|
|
-// args.push("var.SourceDir");
|
|
|
-
|
|
|
-// let heat_exe = wix_toolset_path.join("heat.exe");
|
|
|
-
|
|
|
-// let mut cmd = Command::new(&heat_exe)
|
|
|
-// .args(&args)
|
|
|
-// .stdout(Stdio::piped())
|
|
|
-// .current_dir(build_path)
|
|
|
-// .spawn()
|
|
|
-// .expect("error running heat.exe");
|
|
|
-
|
|
|
-// {
|
|
|
-// let stdout = cmd.stdout.as_mut().unwrap();
|
|
|
-// let reader = BufReader::new(stdout);
|
|
|
-
|
|
|
-// for line in reader.lines() {
|
|
|
-// info!(logger, "{}", line.unwrap());
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// let status = cmd.wait().unwrap();
|
|
|
-// if status.success() {
|
|
|
-// Ok(())
|
|
|
-// } else {
|
|
|
-// Err("error running heat.exe".to_string())
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
/// Runs the Candle.exe executable for Wix. Candle parses the wxs file and generates the code for building the installer.
|
|
|
fn run_candle(
|
|
|
settings: &Settings,
|
|
|
wix_toolset_path: &Path,
|
|
|
- build_path: &Path,
|
|
|
- wxs_file_name: &str,
|
|
|
+ cwd: &Path,
|
|
|
+ wxs_file_path: &Path,
|
|
|
) -> crate::Result<()> {
|
|
|
let arch = match settings.binary_arch() {
|
|
|
"x86_64" => "x64",
|
|
@@ -357,7 +305,7 @@ fn run_candle(
|
|
|
let args = vec![
|
|
|
"-arch".to_string(),
|
|
|
arch.to_string(),
|
|
|
- wxs_file_name.to_string(),
|
|
|
+ wxs_file_path.to_string_lossy().to_string(),
|
|
|
format!(
|
|
|
"-dSourceDir={}",
|
|
|
settings.binary_path(main_binary).display()
|
|
@@ -365,13 +313,10 @@ fn run_candle(
|
|
|
];
|
|
|
|
|
|
let candle_exe = wix_toolset_path.join("candle.exe");
|
|
|
- common::print_info(format!("running candle for {}", wxs_file_name).as_str())?;
|
|
|
+ common::print_info(format!("running candle for {:?}", wxs_file_path).as_str())?;
|
|
|
|
|
|
let mut cmd = Command::new(&candle_exe);
|
|
|
- cmd
|
|
|
- .args(&args)
|
|
|
- .stdout(Stdio::piped())
|
|
|
- .current_dir(build_path);
|
|
|
+ cmd.args(&args).stdout(Stdio::piped()).current_dir(cwd);
|
|
|
|
|
|
common::print_info("running candle.exe")?;
|
|
|
common::execute_with_verbosity(&mut cmd, &settings).map_err(|_| {
|
|
@@ -532,6 +477,17 @@ pub fn build_wix_app_installer(
|
|
|
|
|
|
data.insert("icon_path", to_json(icon_path));
|
|
|
|
|
|
+ let mut fragment_paths = Vec::new();
|
|
|
+
|
|
|
+ if let Some(wix) = &settings.windows().wix {
|
|
|
+ data.insert("component_group_refs", to_json(&wix.component_group_refs));
|
|
|
+ data.insert("component_refs", to_json(&wix.component_refs));
|
|
|
+ data.insert("feature_group_refs", to_json(&wix.feature_group_refs));
|
|
|
+ data.insert("feature_refs", to_json(&wix.feature_refs));
|
|
|
+ data.insert("merge_refs", to_json(&wix.merge_refs));
|
|
|
+ fragment_paths = wix.fragment_paths.clone();
|
|
|
+ }
|
|
|
+
|
|
|
let temp = HANDLEBARS.render("main.wxs", &data)?;
|
|
|
|
|
|
if output_path.exists() {
|
|
@@ -543,14 +499,18 @@ pub fn build_wix_app_installer(
|
|
|
let main_wxs_path = output_path.join("main.wxs");
|
|
|
write(&main_wxs_path, temp)?;
|
|
|
|
|
|
- let input_basenames = vec!["main"];
|
|
|
+ let mut candle_inputs = vec!["main.wxs".into()];
|
|
|
+
|
|
|
+ let current_dir = std::env::current_dir()?;
|
|
|
+ for fragment_path in fragment_paths {
|
|
|
+ candle_inputs.push(current_dir.join(fragment_path));
|
|
|
+ }
|
|
|
|
|
|
- for basename in &input_basenames {
|
|
|
- let wxs = format!("{}.wxs", basename);
|
|
|
+ for wxs in &candle_inputs {
|
|
|
run_candle(settings, &wix_toolset_path, &output_path, &wxs)?;
|
|
|
}
|
|
|
|
|
|
- let wixobjs = vec!["main.wixobj"];
|
|
|
+ let wixobjs = vec!["*.wixobj"];
|
|
|
let target = run_light(
|
|
|
&wix_toolset_path,
|
|
|
&output_path,
|
|
@@ -600,12 +560,12 @@ fn locate_signtool() -> crate::Result<PathBuf> {
|
|
|
let mut kit_bin_paths: Vec<PathBuf> = installed_kits
|
|
|
.iter()
|
|
|
.rev()
|
|
|
- .map(|kit| kits_root_10_bin_path.join(kit).to_path_buf())
|
|
|
+ .map(|kit| kits_root_10_bin_path.join(kit))
|
|
|
.collect();
|
|
|
|
|
|
/* Add kits root bin path.
|
|
|
For Windows SDK 10 versions earlier than v10.0.15063.468, signtool will be located there. */
|
|
|
- kit_bin_paths.push(kits_root_10_bin_path.to_path_buf());
|
|
|
+ kit_bin_paths.push(kits_root_10_bin_path);
|
|
|
|
|
|
// Choose which version of SignTool to use based on OS bitness
|
|
|
let arch_dir = match bitness::os_bitness().expect("failed to get os bitness") {
|
|
@@ -622,7 +582,7 @@ fn locate_signtool() -> crate::Result<PathBuf> {
|
|
|
/* Check if SignTool exists at this location. */
|
|
|
if signtool_path.exists() {
|
|
|
// SignTool found. Return it.
|
|
|
- return Ok(signtool_path.to_path_buf());
|
|
|
+ return Ok(signtool_path);
|
|
|
}
|
|
|
}
|
|
|
|