Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crate_universe: Enable modext isolation. #17088

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ common --registry=file:///%workspace%/misc/bazel/registry
common --registry=https://bcr.bazel.build

common --@rules_dotnet//dotnet/settings:strict_deps=false
common --experimental_isolated_extension_usages

try-import %workspace%/local.bazelrc
1 change: 1 addition & 0 deletions .bazelrc.internal
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ common --registry=https://bcr.bazel.build
# its implementation packages without providing any code itself.
# We either can depend on internal implementation details, or turn of strict deps.
common --@rules_dotnet//dotnet/settings:strict_deps=false
common --experimental_isolated_extension_usages
23 changes: 17 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module(
name = "codeql",
name = "ql",
version = "0.0",
repo_name = "codeql",
)

# this points to our internal repository when `codeql` is checked out as a submodule thereof
Expand Down Expand Up @@ -30,27 +31,37 @@ bazel_dep(name = "rules_rust", version = "0.49.1")

bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)

crate = use_extension(
# crate_py but shortened due to Windows file path considerations
cp = use_extension(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really minor cosmetic nit, but is there any reason to use cp here and just r for ruby? If cr for ruby is already too much, maybe then also use p here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wanted to limit the use of single-letter repo names to where we really need them (as there's only 26 of them available). The more letters, the easier to search for the repo name in our source code, too.

"@rules_rust//crate_universe:extension.bzl",
"crate",
isolate = True,
)
crate.from_cargo(
cp.from_cargo(
name = "py_deps",
cargo_lockfile = "//python/extractor/tsg-python:Cargo.lock",
manifests = [
"//python/extractor/tsg-python:Cargo.toml",
"//python/extractor/tsg-python/tsp:Cargo.toml",
],
)
crate.from_cargo(
name = "ruby_deps",
use_repo(cp, "py_deps")

# crate_ruby, but shortened due to windows file paths
r = use_extension(
"@rules_rust//crate_universe:extension.bzl",
"crate",
isolate = True,
)
r.from_cargo(
name = "rd",
cargo_lockfile = "//ruby/extractor:Cargo.lock",
manifests = [
"//ruby/extractor:Cargo.toml",
"//ruby/extractor/codeql-extractor-fake-crate:Cargo.toml",
],
)
use_repo(crate, "py_deps", "ruby_deps")
use_repo(r, "rd")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also assign an alias here, avoiding the changes in the two build files:

Suggested change
use_repo(r, "rd")
use_repo(r, ruby_deps="rd")


dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
dotnet.toolchain(dotnet_version = "8.0.101")
Expand Down
2 changes: 1 addition & 1 deletion misc/bazel/internal/zipmerge/zipmerge_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ std::string get_file(const char* name) {
return ret;
}();
// this works from both `codeql` and the internal repository
for (auto prefix : {"_main", "codeql~"}) {
for (auto prefix : {"_main", "ql~"}) {
auto ret = runfiles->Rlocation(prefix + "/misc/bazel/internal/zipmerge/test-files/"s + name);
if (fs::exists(ret)) {
return ret;
Expand Down
2 changes: 1 addition & 1 deletion ruby/extractor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@ruby_deps//:defs.bzl", "aliases", "all_crate_deps")
load("@rd//:defs.bzl", "aliases", "all_crate_deps")
load("//misc/bazel:rust.bzl", "codeql_rust_binary")

codeql_rust_binary(
Expand Down
2 changes: 1 addition & 1 deletion shared/tree-sitter-extractor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@ruby_deps//:defs.bzl", "aliases", "all_crate_deps")
load("@rd//:defs.bzl", "aliases", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_library")

package(default_visibility = ["//visibility:public"])
Expand Down
Loading