I wonder, can we have custom compilation modes? Basically, it is great thing that one can specify compiler flags in CROSSTOOL files and depend on features.
But sometimes `opt`, `dbg` and `fastbuild` are not enough, and in this case we have to create custom `--define` settings, wrap around `cc_binary`, `cc_library` and so on and implement custom `compilation_mode` and add options `select`ing proper `config_setting`.
Is there any chance we could use custom values for `compilation_mode` (better) or use `define` values as a selector (worse) right in CROSSTOOL, without touching `cc_binary`/`cc_library`?
Kind regards,
Vladimir.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/fdf1c56f-5eb7-4240-aa0e-36998a32ea60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/44808143-7dc8-45a3-aee3-de3de9c71143%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Just in case somebody else will be interested, I provide working code (Bazel 0.20.0):
```
def _feature_enabled(ctx):
toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]
feature = ctx.attr.feature_name
feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)
result = cc_common.is_enabled(feature_configuration=feature_configuration, feature_name=feature)
return [config_common.FeatureFlagInfo(value = str(result))]
feature_enabled_flag = rule(
implementation = _feature_enabled,
attrs = {
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
"feature_name": attr.string()
},
)
```
I have another question though. How would I use this provider info? Ideally I would want to make high-level `select` in one of the `BUILD` files.
I can make a rule where I can read this result but I do not currently understand how to make a dependency enabled or disabled depending on this value.
Kind regards,
Vladimir.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/50664918-04d4-417c-a455-fd26122467e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.