Skip to content

gen_rust_project SUPPORT transparent transmission of compilation_mode or config #2169

Open
@YeahhhhLi

Description

@YeahhhhLi

There are some raw bazel cmds in gen_rust_project binary:

  1. aquery: https://github.com/bazelbuild/rules_rust/blob/main/tools/rust_analyzer/aquery.rs#L78
  2. info: https://github.com/bazelbuild/rules_rust/blob/main/tools/rust_analyzer/main.rs#L68
  3. build: https://github.com/bazelbuild/rules_rust/blob/main/tools/rust_analyzer/lib.rs#L23

The default compilation_mode in bazel is fastbuild. So the root_module value in rust-project.json looks like "xxx/bazel-out/k8-fastbuild/bin/xxx"

In our usage scenario, we manage build commands through bazel config, like:

build:scene1 -c opt
build:scene2 -c fastbuild 

When we build the target using opt mode, the generated content of rust-project.json will not match.

So, is there a way for us to support the transparent compilation_mode or config so that the internal bazel commands can also be built using the same mode?

bazel run --config:scene1 @rules_rust//tools/rust_analyzer:gen_rust_project -- {target}
# or
bazel run  @rules_rust//tools/rust_analyzer:gen_rust_project -- --inner_comilation_mode=opt {target}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions