bazel-contrib / bazel-contrib/rules_dotnet
Allow use of "$(location //foo)" in compiler_options
- Dominant language
- Starlark
- Stars
- 209
- Forks
- 98
- Avg merge
- 3h 59m
- Merged PRs (30d)
- 14
Description
We use "$(location //foo)" syntax https://bazel.build/reference/be/make-variables#predefined_label_variables and have patched 19.2 to call expand_location.
Can we request support for make variable substitution using technique.
Example patch for 19.2:
```
diff --git dotnet/private/rules/csharp/binary.bzl dotnet/private/rules/csharp/binary.bzl
index 005e5e1..ebfd504 100644
--- dotnet/private/rules/csharp/binary.bzl
+++ dotnet/private/rules/csharp/binary.bzl
@@ -15,6 +15,12 @@ load("//dotnet/private/transitions:tfm_transition.bzl", "tfm_transition")
def _compile_action(ctx, tfm):
toolchain = ctx.toolchains["//dotnet:toolchain_type"]
+
+ compiler_options = []
+ for opt in ctx.attr.compiler_options:
+ added = ctx.expand_location(opt, ctx.attr.compile_data)
+ compiler_options.append(added)
+
return AssemblyAction(
ctx.actions,
ctx.executable._compiler_wrapper_bat if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else ctx.executable._compiler_wrapper_sh,
@@ -53,7 +59,7 @@ def _compile_action(ctx, tfm):
is_analyzer = False,
is_language_specific_analyzer = False,
analyzer_configs = ctx.files.analyzer_configs,
- compiler_options = ctx.attr.compiler_options,
+ compiler_options = compiler_options,
is_windows = ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]),
)
```
Contributor guide
Research direction
Start in dotnet/private/rules/csharp/binary.bzl at _compile_action and inspect how ctx.attr.compiler_options is passed into AssemblyAction. Compare the existing example using ctx.expand_location with compile_data, then check whether the same option handling appears elsewhere. Done means $(location //foo) syntax is expanded in compiler_options as requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100