@@ -20,12 +20,17 @@ pub use codegen::context::CodegenContext;
2020#[ derive( Debug ) ]
2121pub struct WindowsAttributes {
2222 window_icon_path : PathBuf ,
23+ /// The path to the sdk location. This can be a absolute or relative path. If not supplied
24+ /// this defaults to whatever `winres` crate determines is the best. See the
25+ /// [winres documentation](https://docs.rs/winres/*/winres/struct.WindowsResource.html#method.set_toolkit_path)
26+ sdk_dir : Option < PathBuf > ,
2327}
2428
2529impl Default for WindowsAttributes {
2630 fn default ( ) -> Self {
2731 Self {
2832 window_icon_path : PathBuf :: from ( "icons/icon.ico" ) ,
33+ sdk_dir : None ,
2934 }
3035 }
3136}
@@ -42,6 +47,13 @@ impl WindowsAttributes {
4247 self . window_icon_path = window_icon_path. as_ref ( ) . into ( ) ;
4348 self
4449 }
50+
51+ /// Sets the sdk dir for windows. Currently only used on Windows. This must be a vaild UTF-8
52+ /// path. Defaults to whatever the `winres` crate determines is best.
53+ pub fn sdk_dir < P : AsRef < Path > > ( mut self , sdk_dir : P ) -> Self {
54+ self . sdk_dir = Some ( sdk_dir. as_ref ( ) . into ( ) ) ;
55+ self
56+ }
4557}
4658
4759/// The attributes used on the build.
@@ -112,6 +124,15 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
112124
113125 if attributes. windows_attributes . window_icon_path . exists ( ) {
114126 let mut res = WindowsResource :: new ( ) ;
127+ if let Some ( sdk_dir) = & attributes. windows_attributes . sdk_dir {
128+ if let Some ( sdk_dir_str) = sdk_dir. to_str ( ) {
129+ res. set_toolkit_path ( sdk_dir_str) ;
130+ } else {
131+ return Err ( anyhow ! (
132+ "sdk_dir path is not valid; only UTF-8 characters are allowed"
133+ ) ) ;
134+ }
135+ }
115136 if let Some ( version) = & config. package . version {
116137 res. set ( "FileVersion" , version) ;
117138 res. set ( "ProductVersion" , version) ;
0 commit comments