Browse Source

basic icon implementation.

tensor-programming 6 năm trước cách đây
mục cha
commit
5464896469

+ 1 - 1
tools/rust/cargo-proton-bundle/rustfmt.toml

@@ -6,7 +6,7 @@ use_small_heuristics = "Default"
 reorder_imports = true
 reorder_modules = true
 remove_nested_parens = true
-edition = "2015"
+edition = "2018"
 merge_derives = true
 use_try_shorthand = false
 use_field_init_shorthand = false

+ 5 - 1
tools/rust/cargo-proton-bundle/src/bundle/templates/main.wxs

@@ -9,6 +9,7 @@
 <?endif?>
 
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+
     <Product
             Id="*"
             Name="{{{product_name}}}"
@@ -27,7 +28,10 @@
                  SummaryCodepage="1252"/>
 
         <Media Id="1" Cabinet="app.cab" EmbedCab="yes" />
-
+        <Icon Id="ProductIcon" SourceFile="{{{icon_path}}}"/>
+        <Property Id="ARPPRODUCTICON" Value="ProductIcon"/>
+        <Property Id="ARPNOREPAIR" Value="1"/>
+        <Property Id="ARPNOMODIFY" Value="1"/>
 
         <Directory Id="TARGETDIR" Name="SourceDir">
             <Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">

+ 20 - 1
tools/rust/cargo-proton-bundle/src/bundle/wix.rs

@@ -199,7 +199,16 @@ fn run_candle(
   build_path: &Path,
   wxs_file_name: &str,
 ) -> crate::Result<()> {
-  let arch = "x64";
+  let arch = match settings.binary_arch() {
+    "x86_64" => "x64",
+    "x86" => "x86",
+    target => {
+      return Err(crate::Error::from(format!(
+        "unsupported target: {}",
+        target
+      )))
+    }
+  };
 
   let args = vec![
     "-arch".to_string(),
@@ -274,6 +283,10 @@ fn run_light(
   }
 }
 
+// fn get_icon_data() -> crate::Result<()> {
+//   Ok(())
+// }
+
 // Entry point for bundling and creating the MSI installer.  For now the only supported platform is Windows x64.
 pub fn build_wix_app_installer(
   settings: &Settings,
@@ -320,6 +333,12 @@ pub fn build_wix_app_installer(
 
   data.insert("app_exe_source", &app_exe_source);
 
+  let image_path = PathBuf::from("../../../../icons/icon.ico")
+    .display()
+    .to_string();
+
+  data.insert("icon_path", &image_path);
+
   let temp = HANDLEBARS
     .render("main.wxs", &data)
     .or_else(|e| Err(e.to_string()))?;