Skip to content

Commit

Permalink
Merge pull request #1108 from etsal/etsal/cargo-rerun-multi-build
Browse files Browse the repository at this point in the history
fix missing rerun-if-changed statements
  • Loading branch information
etsal authored Dec 16, 2024
2 parents e8e68e8 + 76de600 commit a6faacc
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions rust/scx_utils/src/bpf_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ impl BpfBuilder {
.clang_args(&self.cflags)
.generate(&skel_path)?;

self.gen_cargo_reruns(None)?;

Ok(())
}

Expand Down Expand Up @@ -403,26 +405,38 @@ impl BpfBuilder {
Ok(())
}

/// Build and generate the enabled bindings.
pub fn build(&self) -> Result<()> {
let mut deps = BTreeSet::new();

self.input_insert_deps(&mut deps);

self.bindgen_bpf_intf()?;
self.gen_bpf_skel(&mut deps)?;

fn gen_cargo_reruns(&self, dependencies: Option<&BTreeSet<String>>) -> Result<()> {
println!("cargo:rerun-if-env-changed=BPF_CLANG");
println!("cargo:rerun-if-env-changed=BPF_CFLAGS");
println!("cargo:rerun-if-env-changed=BPF_BASE_CFLAGS");
println!("cargo:rerun-if-env-changed=BPF_EXTRA_CFLAGS_PRE_INCL");
println!("cargo:rerun-if-env-changed=BPF_EXTRA_CFLAGS_POST_INCL");
for dep in deps.iter() {
println!("cargo:rerun-if-changed={}", dep);
}
match dependencies {
Some(deps) => {
for dep in deps.iter() {
println!("cargo:rerun-if-changed={}", dep);
}
}

None => (),
};

for source in self.sources.iter() {
println!("cargo:rerun-if-changed={}", source);
}

Ok(())
}

/// Build and generate the enabled bindings.
pub fn build(&self) -> Result<()> {
let mut deps = BTreeSet::new();

self.input_insert_deps(&mut deps);

self.bindgen_bpf_intf()?;
self.gen_bpf_skel(&mut deps)?;
self.gen_cargo_reruns(Some(&deps))?;
Ok(())
}
}
Expand Down

0 comments on commit a6faacc

Please sign in to comment.