Skip to content

Commit 6dfacd0

Browse files
committed
Merge remote-tracking branch 'origin/main' into redsun82-rust-analyzer-update
2 parents e51dc86 + 5b46f51 commit 6dfacd0

5 files changed

Lines changed: 34 additions & 6 deletions

File tree

rust/extractor/src/config.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,23 @@ impl Config {
109109
figment.extract().context("loading configuration")
110110
}
111111

112+
fn get_extra_env(&self) -> FxHashMap<String, Option<String>> {
113+
let mut extra_env = FxHashMap::default();
114+
// RUSTUP_AUTO_INSTALL is set to 0 by rust-analyzer (https://github.com/rust-lang/rust-analyzer/issues/20719),
115+
// but we do want to allow rustup to auto-install toolchains if needed, so we set it to 1 here.
116+
extra_env.insert("RUSTUP_AUTO_INSTALL".to_owned(), Some("1".to_owned()));
117+
extra_env.extend(self.cargo_extra_env.clone());
118+
extra_env
119+
}
120+
112121
fn sysroot(&self, dir: &AbsPath) -> Sysroot {
113122
let sysroot_input = self.sysroot.as_ref().map(|p| join_path_buf(dir, p));
114123
let sysroot_src_input = self.sysroot_src.as_ref().map(|p| join_path_buf(dir, p));
115124
match (sysroot_input, sysroot_src_input) {
116-
(None, None) => Sysroot::discover(dir, &self.cargo_extra_env),
125+
(None, None) => Sysroot::discover(dir, &self.get_extra_env()),
117126
(Some(sysroot), None) => Sysroot::discover_rust_lib_src_dir(sysroot),
118127
(None, Some(sysroot_src)) => {
119-
Sysroot::discover_with_src_override(dir, &self.cargo_extra_env, sysroot_src)
128+
Sysroot::discover_with_src_override(dir, &self.get_extra_env(), sysroot_src)
120129
}
121130
(Some(sysroot), Some(sysroot_src)) => Sysroot::new(Some(sysroot), Some(sysroot_src)),
122131
}
@@ -167,7 +176,7 @@ impl Config {
167176
.map(ToOwned::to_owned)
168177
.map(RustLibSource::Path),
169178

170-
extra_env: self.cargo_extra_env.clone(),
179+
extra_env: self.get_extra_env(),
171180
extra_args: self.cargo_extra_args.clone(),
172181
extra_includes: self
173182
.extra_includes

unified/BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ codeql_pkg_files(
4141

4242
codeql_pkg_files(
4343
name = "extractor-arch",
44-
exes = [
45-
"//unified/extractor",
46-
] + select_os(
44+
exes = select_os(
45+
posix = ["//unified/extractor"],
46+
windows = ["//unified/extractor-unsupported-os:extractor"],
47+
) + select_os(
4748
linux = ["//unified/swift-syntax-rs:swift_runtime_libs"],
4849
otherwise = [],
4950
),
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
load("//misc/bazel:rust.bzl", "codeql_rust_binary")
2+
3+
codeql_rust_binary(
4+
name = "extractor",
5+
srcs = ["src/main.rs"],
6+
crate_root = "src/main.rs",
7+
visibility = ["//visibility:public"],
8+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "codeql-extractor-unified-unsupported-os"
3+
description = "Fallback executable for unsupported CodeQL Unified extractor platforms"
4+
version = "0.1.0"
5+
authors = ["GitHub"]
6+
edition = "2024"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
eprintln!("Unsupported OS. Extraction is not currently supported on Windows.");
3+
std::process::exit(1);
4+
}

0 commit comments

Comments
 (0)