Skip to content

Commit

Permalink
build: Make build copying more resilient
Browse files Browse the repository at this point in the history
This fixes an issue where:

  1. User tries to build before initializing all submodules.
  2. `uplink-c` directory is empty and copied into build.
  3. Build fails but leaves empty `uplink-c` directory in build
     directory
  4. User initializes `uplink-c` and then tries to build again without
     cleaning.
  5. `uplink-c` gets nested in a second level deeper, causing build
     issues.
  • Loading branch information
GodTamIt committed Nov 11, 2024
1 parent 497c270 commit 8342159
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions uplink-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ fn main() {

// Directory containing uplink-c project for building
let uplink_c_dir = out_dir.join("uplink-c");
// Copy project to OUT_DIR for building

// Make the output `uplink-c` directory if it doesn't exist.
Command::new("mkdir")
.args(["-p", &uplink_c_dir.to_string_lossy()])
.status()
.expect("Failed to create output uplink-c directory.");

// Copy the contents of the `uplink-c` project to the output `uplink-c` directory
Command::new("cp")
.args([
"-R",
&uplink_c_src.to_string_lossy(),
&uplink_c_src.join(".").to_string_lossy(),
&uplink_c_dir.to_string_lossy(),
])
.status()
Expand Down

0 comments on commit 8342159

Please sign in to comment.