Skip to content

Commit

Permalink
fix xtask build-tools
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin JEROME <[email protected]>
  • Loading branch information
qjerome committed Sep 22, 2023
1 parent b8d2705 commit 6379125
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn main() -> Result<(), anyhow::Error> {
println!("Synchronizing repo:{linker_repo} branch:{linker_branch}");
git::sync(linker_branch, linker_repo, &linker_dir)?;

tools::build_linker(&llvm_install, linker_dir)?;
tools::build_linker(&llvm_install, linker_dir, &opts)?;
}
}

Expand Down
9 changes: 9 additions & 0 deletions xtask/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ use std::path::{Path, PathBuf};

#[derive(Debug, Parser)]
pub struct Options {
/// generates a cache key (mostly to be used in CI)
#[clap(long)]
pub action_cache_key: bool,
/// force LLVM build
#[clap(long)]
pub force_llvm_build: bool,
/// free up space by removing LLVM build artifacts
#[clap(long)]
pub free_space: bool,
/// update bpf-linker
#[clap(long)]
pub update: bool,
/// target to build the build-tools for
#[clap(default_value = "x86_64-unknown-linux-gnu", long)]
pub target: super::user::Target,
}

pub struct LLVMBuilder {
Expand Down Expand Up @@ -76,6 +83,7 @@ impl LLVMBuilder {
pub fn build_linker<T: AsRef<Path>, U: AsRef<Path>>(
llvm_build_dir: T,
linker_dir: U,
opts: &Options,
) -> Result<(), anyhow::Error> {
let llvm_build_dir = llvm_build_dir.as_ref();
let linker_dir = linker_dir.as_ref();
Expand All @@ -96,6 +104,7 @@ pub fn build_linker<T: AsRef<Path>, U: AsRef<Path>>(
.current_dir(linker_dir)
.env("LLVM_SYS_160_PREFIX", llvm_build_dir)
.arg("build")
.arg(&format!("--target={}", opts.target))
.arg("--release")
.arg("--bins")
.status()
Expand Down
3 changes: 3 additions & 0 deletions xtask/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::ebpf::{self, BpfTarget};
#[derive(Debug, Copy, Clone)]
pub enum Target {
X86_64Musl,
X86_64Gnu,
}

impl std::str::FromStr for Target {
Expand All @@ -16,6 +17,7 @@ impl std::str::FromStr for Target {
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"x86_64-unknown-linux-musl" => Target::X86_64Musl,
"x86_64-unknown-linux-gnu" => Target::X86_64Gnu,
_ => return Err("invalid target".to_owned()),
})
}
Expand All @@ -25,6 +27,7 @@ impl std::fmt::Display for Target {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Target::X86_64Musl => "x86_64-unknown-linux-musl",
Target::X86_64Gnu => "x86_64-unknown-linux-gnu",
})
}
}
Expand Down

0 comments on commit 6379125

Please sign in to comment.