diff options
| -rw-r--r-- | api/Divina.lua | 2 | ||||
| -rw-r--r-- | crates/divina_compile/src/lib.rs | 37 | ||||
| -rw-r--r-- | crates/divina_config/src/lib.rs | 10 | ||||
| -rw-r--r-- | examples/greet/Divina.lua | 2 |
4 files changed, 37 insertions, 14 deletions
diff --git a/api/Divina.lua b/api/Divina.lua index f007bf6..2a98357 100644 --- a/api/Divina.lua +++ b/api/Divina.lua @@ -25,6 +25,7 @@ function test() end --- @field public minimum_divina_version string --- @field public sources string[] --- @field public compiler string +--- @field public visual_studio string Package = { name, version, @@ -35,6 +36,7 @@ Package = { type, arch, compiler, + visual_studio, } --- @class Workspace 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" + "# } } diff --git a/crates/divina_config/src/lib.rs b/crates/divina_config/src/lib.rs index dee15a7..e280f0d 100644 --- a/crates/divina_config/src/lib.rs +++ b/crates/divina_config/src/lib.rs @@ -186,6 +186,7 @@ pub struct Config { pub path: Option<String>, pub arch: Option<Arch>, pub compiler: Option<String>, + pub visual_studio: Option<String>, } impl Config { /// Create a new `Config` @@ -367,6 +368,14 @@ impl Config { (self.compiler), GetRequired::No ); + get_or_none!( + config_table, + "Package", + "visual_studio", + String, + (self.visual_studio), + GetRequired::No + ); } else { get_table!(workspace_table, "Workspace", globals); @@ -419,6 +428,7 @@ impl Default for Config { path: None, arch: None, compiler: None, + visual_studio: None, } } } diff --git a/examples/greet/Divina.lua b/examples/greet/Divina.lua index 30649ea..d718d01 100644 --- a/examples/greet/Divina.lua +++ b/examples/greet/Divina.lua @@ -12,6 +12,7 @@ local name = "greet-" .. tostring(os.time()) --- @field public compile_options string[] --- @field public minimum_divina_version string --- @field public sources string[] +--- @field public visual_studio string Package = { name = name, version = "0.1.0", @@ -27,6 +28,7 @@ Package = { }, type = Divina.Type.Bin, arch = Divina.Arch.x64, + visual_studio = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat", } -- http://lua-users.org/wiki/ModulesTutorial |