mirror of https://github.com/bazelbuild/rules_cc
Move examples from deprecated find_cpp_toolchain -> find_cc_toolchain
This commit is contained in:
parent
58f8e026c0
commit
ab8b67a0ab
|
@ -15,11 +15,11 @@
|
||||||
"""Example showing how to create a rule that rules_cc can depend on."""
|
"""Example showing how to create a rule that rules_cc can depend on."""
|
||||||
|
|
||||||
load("@rules_cc//cc:action_names.bzl", "CPP_LINK_STATIC_LIBRARY_ACTION_NAME")
|
load("@rules_cc//cc:action_names.bzl", "CPP_LINK_STATIC_LIBRARY_ACTION_NAME")
|
||||||
load("@rules_cc//cc:toolchain_utils.bzl", "find_cpp_toolchain")
|
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
|
||||||
load("//examples/my_c_compile:my_c_compile.bzl", "MyCCompileInfo")
|
load("//examples/my_c_compile:my_c_compile.bzl", "MyCCompileInfo")
|
||||||
|
|
||||||
def _my_c_archive_impl(ctx):
|
def _my_c_archive_impl(ctx):
|
||||||
cc_toolchain = find_cpp_toolchain(ctx)
|
cc_toolchain = find_cc_toolchain(ctx)
|
||||||
object_file = ctx.attr.object[MyCCompileInfo].object
|
object_file = ctx.attr.object[MyCCompileInfo].object
|
||||||
output_file = ctx.actions.declare_file(ctx.label.name + ".a")
|
output_file = ctx.actions.declare_file(ctx.label.name + ".a")
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"""Example showing how to create a rule that just compiles C sources."""
|
"""Example showing how to create a rule that just compiles C sources."""
|
||||||
|
|
||||||
load("@rules_cc//cc:action_names.bzl", "C_COMPILE_ACTION_NAME")
|
load("@rules_cc//cc:action_names.bzl", "C_COMPILE_ACTION_NAME")
|
||||||
load("@rules_cc//cc:toolchain_utils.bzl", "find_cpp_toolchain")
|
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
|
||||||
|
|
||||||
MyCCompileInfo = provider(doc = "", fields = ["object"])
|
MyCCompileInfo = provider(doc = "", fields = ["object"])
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ DISABLED_FEATURES = [
|
||||||
]
|
]
|
||||||
|
|
||||||
def _my_c_compile_impl(ctx):
|
def _my_c_compile_impl(ctx):
|
||||||
cc_toolchain = find_cpp_toolchain(ctx)
|
cc_toolchain = find_cc_toolchain(ctx)
|
||||||
source_file = ctx.file.src
|
source_file = ctx.file.src
|
||||||
output_file = ctx.actions.declare_file(ctx.label.name + ".o")
|
output_file = ctx.actions.declare_file(ctx.label.name + ".o")
|
||||||
feature_configuration = cc_common.configure_features(
|
feature_configuration = cc_common.configure_features(
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
"""Example showing how to get CcToolchainInfo in a custom rule."""
|
"""Example showing how to get CcToolchainInfo in a custom rule."""
|
||||||
|
|
||||||
load("@rules_cc//cc:toolchain_utils.bzl", "find_cpp_toolchain")
|
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
|
||||||
|
|
||||||
def _write_cc_toolchain_cpu_impl(ctx):
|
def _write_cc_toolchain_cpu_impl(ctx):
|
||||||
cc_toolchain = find_cpp_toolchain(ctx)
|
cc_toolchain = find_cc_toolchain(ctx)
|
||||||
output = ctx.actions.declare_file(ctx.label.name + "_cpu")
|
output = ctx.actions.declare_file(ctx.label.name + "_cpu")
|
||||||
ctx.actions.write(output, cc_toolchain.cpu)
|
ctx.actions.write(output, cc_toolchain.cpu)
|
||||||
return [DefaultInfo(files = depset([output]))]
|
return [DefaultInfo(files = depset([output]))]
|
||||||
|
|
Loading…
Reference in New Issue