Skip to content

Commit

Permalink
Fix Build Script and Compilation Conditions
Browse files Browse the repository at this point in the history
See rust-lang/cargo#14881 for rationale
  • Loading branch information
FaceFTW committed Dec 2, 2024
1 parent 07107ff commit 7cc0872
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 11 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
use std::io;

#[cfg(all(target_os = "windows", any(target_env = "msvc", target_env = "gnu")))]
#[cfg(not(target_os = "windows"))]
fn main() -> io::Result<()> {
if cfg!(target_os = "windows") && !cfg!(test) {
Ok(())
}

#[cfg(target_os = "windows")]
fn main() -> io::Result<()> {
//Only perform Windows Resource application if we are targeting Windows
//See https://github.com/rust-lang/cargo/issues/14881#issuecomment-2510440862
let target_os =
std::env::var("CARGO_CFG_TARGET_OS").expect("Cargo did not set the vars we expected!");
if target_os == "windows" {
let mut res = winres::WindowsResource::new();
res.set_icon("src/icon.ico")
.set("InternalName", "rust-pipes.exe");
Expand All @@ -11,8 +20,3 @@ fn main() -> io::Result<()> {

Ok(())
}

#[cfg(any(not(target_os = "windows"), not(any(target_env = "msvc"))))]
fn main() -> io::Result<()> {
Ok(())
}
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#![allow(special_module_name)]

mod engine;

cfg_if::cfg_if! {
if #[cfg(target_arch="wasm32")]{
mod engine;

// Entry point for wasm
use wasm_bindgen::prelude::*;
Expand All @@ -13,7 +15,6 @@ cfg_if::cfg_if! {
}
}
}
mod engine;

pub fn entry_point() {
engine::real_main();
Expand Down

0 comments on commit 7cc0872

Please sign in to comment.