bazel: CPP fragments in Skylark rule does not provide all fields
Description of the problem / feature request / question:
When using Skylark rules with ‘cpp’ fragments, not all fields that are described in the documentation are accessible.
Here is a simple example: rules.bzl
def _my_rule_impl(ctx):
print(ctx.fragments.cpp.ar_executable)
print(ctx.fragments.cpp.built_in_include_directories)
print(ctx.fragments.cpp.c_options)
print(ctx.fragments.cpp.compiler)
print(ctx.fragments.cpp.compiler_executable)
# print(ctx.fragments.cpp.compiler_options)
print(ctx.fragments.cpp.cpu)
# print(ctx.fragments.cpp.cxx_options)
# print(ctx.fragments.cpp.dynamic_link_options)
# print(ctx.fragments.cpp.fully_static_link_options)
print(ctx.fragments.cpp.libc)
print(ctx.fragments.cpp.link_options)
# print(ctx.fragments.cpp.mostly_static_link_options)
print(ctx.fragments.cpp.nm_executable)
print(ctx.fragments.cpp.objcopy_executable)
print(ctx.fragments.cpp.objdump_executable)
print(ctx.fragments.cpp.preprocessor_executable)
print(ctx.fragments.cpp.strip_executable)
# print(ctx.fragments.cpp.sysroot)
print(ctx.fragments.cpp.target_gnu_system_name)
# print(ctx.fragments.cpp.unfiltered_compiler_options)
my_rule = rule(
implementation = _my_rule_impl,
fragments = [ 'cpp' ],
)
BUILD
load(':rule.bzl', 'my_rule')
my_rule(
name = 'testing',
)
All the commented out lines in rules.bzl do not function.
Environment info
-
Operating System: Linux
-
Bazel version (output of
bazel info release
): I tried with:
- release 0.5.3
- development version (24624776cc23dfacac20eb554ccefe268f3b1a0a)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 26 (26 by maintainers)
If we allowed you to create all the compilation and linking actions that cc_library does, and gave you an API to do so from Skylark, would that work for you too? In other words, instead of you taking the flags and creating actions yourselves, you would pass data to something like cc_common.compile/cc_common.link, and get some providers back, will that work?