diff options
| author | Fuwn <[email protected]> | 2022-02-21 21:35:19 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-06-09 00:46:11 -0700 |
| commit | 99f585f95da5fc9a1d775bd1e9053bfadbc9daa3 (patch) | |
| tree | 11f836f716bff31e41cf1eee7351b25d9014b3dc /crates/divina_compile/src/lib.rs | |
| parent | fix(divina_compile): update for vs2022 (diff) | |
| download | archived-divina-99f585f95da5fc9a1d775bd1e9053bfadbc9daa3.tar.xz archived-divina-99f585f95da5fc9a1d775bd1e9053bfadbc9daa3.zip | |
feat(divina_compile): allow custom vs path
Diffstat (limited to 'crates/divina_compile/src/lib.rs')
| -rw-r--r-- | crates/divina_compile/src/lib.rs | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/crates/divina_compile/src/lib.rs b/crates/divina_compile/src/lib.rs index 545ef10..291db8e 100644 --- a/crates/divina_compile/src/lib.rs +++ b/crates/divina_compile/src/lib.rs @@ -29,10 +29,11 @@ struct Source { #[derive(Debug)] struct Package { - name: String, - sources: Vec<Source>, - arch: Arch, - compiler: String, + name: String, + sources: Vec<Source>, + arch: Arch, + compiler: String, + visual_studio: Option<String>, } #[derive(Default, Debug)] @@ -50,18 +51,19 @@ impl Compiler { "!! could not access 'Config.members' from `workspace`, this *shouldn't* be possible", ) { let mut package = Package { - name: member.name.clone().expect( + name: member.name.clone().expect( "!! could not access `Config.?.name` from `workspace`, this *shouldn't* be possible", ), - sources: Vec::new(), - arch: member + sources: Vec::new(), + arch: member .arch .clone() .expect("!! could not access 'Config.members.?.arch', this *shouldn't* be possible"), - compiler: member + compiler: member .compiler .clone() .unwrap_or_else(|| "yasm".to_string()), + visual_studio: member.clone().visual_studio, }; member @@ -97,16 +99,16 @@ impl Compiler { } } else { let mut package = Package { - name: config + name: config .name .clone() .expect("!! could not access `Config.name` from `Package`, this *shouldn't* be possible"), - sources: Vec::new(), - arch: config + sources: Vec::new(), + arch: config .arch .clone() .expect("!! could not access 'Config.arch', this *shouldn't* be possible"), - compiler: if config.compiler.is_some() { + compiler: if config.compiler.is_some() { config .compiler .clone() @@ -114,6 +116,7 @@ impl Compiler { } else { "yasm".to_string() }, + visual_studio: config.clone().visual_studio, }; config @@ -270,7 +273,7 @@ impl Compiler { #[cfg(windows)] println!( - ":: {} @@ entering visual studio 2019 developer command prompt environment", + ":: {} @@ entering visual studio developer command prompt environment", package.name ); @@ -302,7 +305,9 @@ impl Compiler { #[cfg(windows)] { - if arch == &Arch::X64 { + if let Some(visual_studio_path) = &package.visual_studio { + windows::link_package_custom(&filenames.join(" "), &package.name, visual_studio_path); + } else if arch == &Arch::X64 { if self.is_package { windows::link_package_64(&filenames.join(" "), &package.name); } else { @@ -352,4 +357,8 @@ mod windows { pub fn link_package_64(objects: &str, filename: &str) -> String { r#" "link /subsystem:console /out:out/$FILENAME.exe $OBJECTS kernel32.lib msvcrt.lib legacy_stdio_definitions.lib" | cmd /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" "# } + #[shellfn::shell(cmd = "powershell")] + pub fn link_package_custom(objects: &str, filename: &str, vs: &str) -> String { r#" + "link /subsystem:console /out:out/$FILENAME.exe $OBJECTS kernel32.lib msvcrt.lib legacy_stdio_definitions.lib" | cmd /k "$VS" + "# } } |