Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Try to fix cargo run not building worker binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnski committed Aug 9, 2023
1 parent dcbd057 commit 8d50a4c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
6 changes: 0 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,6 @@ members = [
"utils/generate-bags",
]

default-members = [
".",
"bin/execute-worker",
"bin/prepare-worker",
]

[badges]
maintenance = { status = "actively-developed" }

Expand Down
52 changes: 52 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,59 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! Build script to ensure that PVF worker binaries are always built whenever polkadot is built.
//!
//! This is needed because `default-members` does the same thing, but only for `cargo build` -- it
//! does not work for `cargo run`.

use std::{env::var, path::Path, process::Command};

use polkadot_node_core_pvf::{EXECUTE_BINARY_NAME, PREPARE_BINARY_NAME};

// TODO: unskip
#[rustfmt::skip]
fn main() {
// Build additional artifacts if a single package build is explicitly requested.
{
let cargo = dbg!(var("CARGO").expect("`CARGO` env variable is always set by cargo"));
let target = dbg!(var("TARGET").expect("`TARGET` env variable is always set by cargo"));
let profile = dbg!(var("PROFILE").expect("`PROFILE` env variable is always set by cargo"));
let out_dir = dbg!(var("OUT_DIR").expect("`OUT_DIR` env variable is always set by cargo"));
let target_dir = format!("{}/workers", out_dir);

// assert!(false);

// TODO: opt-level, debug, features, etc.
let mut args = vec![
"build",
"-p",
EXECUTE_BINARY_NAME,
"-p",
PREPARE_BINARY_NAME,
"--target",
&target,
"--target-dir",
&target_dir,
];
if profile != "debug" {
args.push("--profile");
args.push(&profile);
}

Command::new(cargo).args(&args).status().unwrap();
std::fs::rename(
Path::new(&format!("{target_dir}/{target}/{profile}/{EXECUTE_BINARY_NAME}")),
Path::new(&format!("{target_dir}/../../../../{EXECUTE_BINARY_NAME}")),
)
.unwrap();
std::fs::rename(
Path::new(&format!("{target_dir}/{target}/{profile}/{PREPARE_BINARY_NAME}")),
Path::new(&format!("{target_dir}/../../../../{PREPARE_BINARY_NAME}")),
)
.unwrap();
}

// TODO: is this needed here?
substrate_build_script_utils::generate_cargo_keys();
// For the node/worker version check, make sure we always rebuild the node and binary workers
// when the version changes.
Expand Down

0 comments on commit 8d50a4c

Please sign in to comment.