Skip to content

Commit

Permalink
👷 Add macos-latest build to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurlm committed Nov 29, 2023
1 parent 1f1f2fa commit 985127f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
Expand Down
34 changes: 29 additions & 5 deletions quickfix-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn read_cmake_opt(flag: &str) -> &'static str {

fn main() {
let out_dir = env::var("OUT_DIR").expect("Missing OUT_DIR");
let target_os = TargetOs::from_env();

// Make sure sub-repositories are correctly init
update_sub_repositories();
Expand Down Expand Up @@ -74,9 +75,7 @@ fn main() {
quickfix_bind_dst.display()
);

if matches!(env::var("PROFILE").as_deref(), Ok("debug"))
&& matches!(env::var("CARGO_CFG_TARGET_OS").as_deref(), Ok("windows"))
{
if matches!(env::var("PROFILE").as_deref(), Ok("debug")) && target_os == TargetOs::Windows {
// libquickfix as a different name on windows with debug profile.
println!("cargo:rustc-link-lib=static=quickfixd");
} else {
Expand All @@ -86,8 +85,8 @@ fn main() {
println!("cargo:rustc-link-lib=static=quickfixbind");

// Lib std C++ is only available on UNIX platform.
if env::var("CARGO_CFG_UNIX").is_ok() {
println!("cargo:rustc-link-lib=stdc++");
if let Some(lib_cpp_name) = target_os.lib_std_cpp_name() {
println!("cargo:rustc-link-lib={lib_cpp_name}");
}

// Link with external libraries if needed.
Expand All @@ -114,3 +113,28 @@ fn update_sub_repositories() {
panic!("Fail to update sub repo");
}
}

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
enum TargetOs {
Windows,
Linux,
Other,
}

impl TargetOs {
fn from_env() -> Self {
match env::var("CARGO_CFG_TARGET_OS").as_deref() {
Ok("windows") => Self::Windows,
Ok("linux") => Self::Linux,
_ => Self::Other,
}
}

fn lib_std_cpp_name(&self) -> Option<&'static str> {
match self {
Self::Windows => None,
Self::Linux => Some("stdc++"),
Self::Other => Some("c++"),
}
}
}

0 comments on commit 985127f

Please sign in to comment.