Skip to content

Commit

Permalink
💚 Make sure sub-repository are correctly clone before building quickf…
Browse files Browse the repository at this point in the history
…ix-ffi
  • Loading branch information
arthurlm committed Nov 29, 2023
1 parent 2605a96 commit 745e4b1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion quickfix-ffi/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{env, fs, path::Path};
use std::{env, fs, path::Path, process::Command};

use cmake::Config;
use fs_extra::dir::CopyOptions;
Expand All @@ -22,6 +22,9 @@ fn read_cmake_opt(flag: &str) -> &'static str {
fn main() {
let out_dir = env::var("OUT_DIR").expect("Missing OUT_DIR");

// Make sure sub-repositories are correctly init
update_sub_repositories();

// Tell Cargo that if the given file changes, to rerun this build script.
println!("cargo:rerun-if-changed=./CMakeLists.txt");
println!("cargo:rerun-if-changed=./libquickfix");
Expand Down Expand Up @@ -81,3 +84,19 @@ fn main() {
println!("cargo:rustc-link-lib=pq");
}
}

fn update_sub_repositories() {
if Path::new("libquickfix/LICENSE").exists() {
return;
}

if !Command::new("git")
.args(["submodule", "update", "--init", "--recursive"])
.current_dir("..")
.status()
.expect("Fail to get command status")
.success()
{
panic!("Fail to update sub repo");
}
}

0 comments on commit 745e4b1

Please sign in to comment.