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

pass variable to rule by command line #22869

Open
xiedeacc opened this issue Jun 24, 2024 · 3 comments
Open

pass variable to rule by command line #22869

xiedeacc opened this issue Jun 24, 2024 · 3 comments

Comments

@xiedeacc
Copy link

Description of the feature request:

when I write a bazel rule for jemalloc, and need support self define namespace, after googled a lot, I find this is impossible. so bazel should add mechanism to pass a variable to bazel rule, that mechanism may like config_setting

Which category does this issue belong to?

No response

What underlying problem are you trying to solve with this feature?

No response

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

No response

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@fmeum
Copy link
Collaborator

fmeum commented Jun 24, 2024

If the rule supports Make variable expansion, you can use https://github.com/bazelbuild/bazel-skylib/blob/main/docs/common_settings_doc.md#string_flag-make_variable to achieve this.

@xiedeacc
Copy link
Author

finally, I write a rule use ctx.var.get archive get variable from command line, but why cannot pass variable to BUILD file, it' seems silly to write a rule just substitute some value then to call another native cc_library

@xiedeacc
Copy link
Author

xiedeacc commented Jun 24, 2024

If the rule supports Make variable expansion, you can use https://github.com/bazelbuild/bazel-skylib/blob/main/docs/common_settings_doc.md#string_flag-make_variable to achieve this.

after read the doc and example from https://github.com/bazelbuild/examples/blob/4d9f5e6c1332ac902a0798b634c67fda4ec5c43b/configurations/select_on_build_setting/BUILD , it seams Make variable cannot archieve it, under jemalloc private namespace scene, private namespace can be any name, but make varialble seams limit to value defined in config_setting, am I right?
@fmeum

@xiedeacc xiedeacc reopened this Jun 24, 2024
@iancha1992 iancha1992 added the team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel label Jun 24, 2024
@iancha1992 iancha1992 added team-Rules-CPP Issues for C++ rules and removed team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel labels Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants