Skip to content

Commit

Permalink
create Build::update_existing_submodule and use for llvm
Browse files Browse the repository at this point in the history
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Mar 28, 2024
1 parent b75e6b4 commit 3683b11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/bootstrap/src/core/build_steps/llvm.rs
Expand Up @@ -76,6 +76,9 @@ pub fn prebuilt_llvm_config(
builder: &Builder<'_>,
target: TargetSelection,
) -> Result<LlvmResult, Meta> {
// If we have llvm submodule initialized already, sync it.
builder.update_existing_submodule(&Path::new("src").join("llvm-project"));

builder.config.maybe_download_ci_llvm();

// If we're using a custom LLVM bail out here, but we can only use a
Expand All @@ -94,7 +97,9 @@ pub fn prebuilt_llvm_config(
}
}

// Initialize the llvm submodule if not initialized already.
builder.update_submodule(&Path::new("src").join("llvm-project"));

let root = "src/llvm-project/llvm";
let out_dir = builder.llvm_out(target);

Expand Down
12 changes: 12 additions & 0 deletions src/bootstrap/src/lib.rs
Expand Up @@ -625,6 +625,18 @@ impl Build {
}
}

/// Updates the given submodule only if it's initialized already; nothing happens otherwise.
pub fn update_existing_submodule(&self, submodule: &Path) {
// Avoid running git when there isn't a git checkout.
if !self.config.submodules(self.rust_info()) {
return;
}

if GitInfo::new(false, submodule).is_managed_git_subrepository() {
self.update_submodule(submodule);
}
}

/// Executes the entire build, as configured by the flags and configuration.
pub fn build(&mut self) {
unsafe {
Expand Down

0 comments on commit 3683b11

Please sign in to comment.