Skip to content

Commit

Permalink
examples: Honor rust-toolchain.toml file in xtask
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
  • Loading branch information
vadorovsky committed Jan 22, 2023
1 parent 9d69141 commit 32a41fa
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 8 deletions.
7 changes: 6 additions & 1 deletion examples/aya-tool/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("myapp-ebpf");
let target = format!("--target={}", opts.target);
let args = vec![
"+nightly",
"build",
"--verbose",
target.as_str(),
Expand All @@ -52,8 +51,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
"--profile",
opts.profile.as_str(),
];

// Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// so the rust-toolchain.toml file in the -ebpf folder is honored.

let status = Command::new("cargo")
.current_dir(&dir)
.env_remove("RUSTUP_TOOLCHAIN")
.args(&args)
.status()
.expect("failed to build bpf program");
Expand Down
7 changes: 6 additions & 1 deletion examples/cgroup-skb-egress/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("cgroup-skb-egress-ebpf");
let target = format!("--target={}", opts.target);
let mut args = vec![
"+nightly",
"build",
"--verbose",
target.as_str(),
Expand All @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
if opts.release {
args.push("--release")
}

// Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// so the rust-toolchain.toml file in the -ebpf folder is honored.

let status = Command::new("cargo")
.current_dir(&dir)
.env_remove("RUSTUP_TOOLCHAIN")
.args(&args)
.status()
.expect("failed to build bpf program");
Expand Down
7 changes: 6 additions & 1 deletion examples/kprobetcp/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("kprobetcp-ebpf");
let target = format!("--target={}", opts.target);
let mut args = vec![
"+nightly",
"build",
"--verbose",
target.as_str(),
Expand All @@ -53,8 +52,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
if opts.release {
args.push("--release")
}

// Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// so the rust-toolchain.toml file in the -ebpf folder is honored.

let status = Command::new("cargo")
.current_dir(&dir)
.env_remove("RUSTUP_TOOLCHAIN")
.args(&args)
.status()
.expect("failed to build bpf program");
Expand Down
7 changes: 6 additions & 1 deletion examples/lsm-nice/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("lsm-nice-ebpf");
let target = format!("--target={}", opts.target);
let args = vec![
"+nightly",
"build",
"--verbose",
target.as_str(),
Expand All @@ -52,8 +51,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
"--profile",
opts.profile.as_str(),
];

// Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// so the rust-toolchain.toml file in the -ebpf folder is honored.

let status = Command::new("cargo")
.current_dir(&dir)
.env_remove("RUSTUP_TOOLCHAIN")
.args(&args)
.status()
.expect("failed to build bpf program");
Expand Down
7 changes: 6 additions & 1 deletion examples/tc-egress/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("tc-egress-ebpf");
let target = format!("--target={}", opts.target);
let mut args = vec![
"+nightly",
"build",
"--verbose",
target.as_str(),
Expand All @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
if opts.release {
args.push("--release")
}

// Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// so the rust-toolchain.toml file in the -ebpf folder is honored.

let status = Command::new("cargo")
.current_dir(&dir)
.env_remove("RUSTUP_TOOLCHAIN")
.args(&args)
.status()
.expect("failed to build bpf program");
Expand Down
7 changes: 6 additions & 1 deletion examples/xdp-drop/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("xdp-drop-ebpf");
let target = format!("--target={}", opts.target);
let mut args = vec![
"+nightly",
"build",
"--verbose",
target.as_str(),
Expand All @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
if opts.release {
args.push("--release")
}

// Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// so the rust-toolchain.toml file in the -ebpf folder is honored.

let status = Command::new("cargo")
.current_dir(&dir)
.env_remove("RUSTUP_TOOLCHAIN")
.args(&args)
.status()
.expect("failed to build bpf program");
Expand Down
7 changes: 6 additions & 1 deletion examples/xdp-hello/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("xdp-hello-ebpf");
let target = format!("--target={}", opts.target);
let mut args = vec![
"+nightly",
"build",
"--verbose",
target.as_str(),
Expand All @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
if opts.release {
args.push("--release")
}

// Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// so the rust-toolchain.toml file in the -ebpf folder is honored.

let status = Command::new("cargo")
.current_dir(&dir)
.env_remove("RUSTUP_TOOLCHAIN")
.args(&args)
.status()
.expect("failed to build bpf program");
Expand Down
7 changes: 6 additions & 1 deletion examples/xdp-log/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("xdp-log-ebpf");
let target = format!("--target={}", opts.target);
let mut args = vec![
"+nightly",
"build",
"--verbose",
target.as_str(),
Expand All @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
if opts.release {
args.push("--release")
}

// Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
// so the rust-toolchain.toml file in the -ebpf folder is honored.

let status = Command::new("cargo")
.current_dir(&dir)
.env_remove("RUSTUP_TOOLCHAIN")
.args(&args)
.status()
.expect("failed to build bpf program");
Expand Down

0 comments on commit 32a41fa

Please sign in to comment.