2
0
Fork 0
mirror of https://github.com/bazelbuild/rules_cc synced 2024-11-26 20:02:22 +00:00

Restructure rules_cc

BEGIN_PUBLIC
Restructure rules_cc

Design doc: https://docs.google.com/document/d/1L1JFgjpZ7SrBinb24DC_5nTIELeYDacikcme-YcA7xs/edit
END_PUBLIC

PiperOrigin-RevId: 643879458
Change-Id: Id3fd760fde1c1145cb5044fff9020b61652d2f25
This commit is contained in:
Googler 2024-06-16 22:40:12 -07:00 committed by Copybara-Service
parent 5e848c1434
commit 94d34d7954
27 changed files with 530 additions and 184 deletions

43
cc/cc_binary.bzl Normal file
View file

@ -0,0 +1,43 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""cc_binary rule"""
# TODO(bazel-team): To avoid breaking changes, if the below are no longer
# forwarding to native rules, flag @bazel_tools@bazel_tools//tools/cpp:link_extra_libs
# should either: (a) alias the flag @rules_cc//:link_extra_libs, or (b) be
# added as a dependency to @rules_cc//:link_extra_lib. The intermediate library
# @bazel_tools@bazel_tools//tools/cpp:link_extra_lib should either be added as a dependency
# to @rules_cc//:link_extra_lib, or removed entirely (if possible).
_LINK_EXTRA_LIB = "@rules_cc//:link_extra_lib" # copybara-use-repo-external-label
def cc_binary(**attrs):
"""Bazel cc_binary rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_binary
Args:
**attrs: Rule attributes
"""
is_library = "linkshared" in attrs and attrs["linkshared"]
# Executable builds also include the "link_extra_lib" library.
if not is_library:
if "deps" in attrs and attrs["deps"] != None:
attrs["deps"] = attrs["deps"] + [_LINK_EXTRA_LIB]
else:
attrs["deps"] = [_LINK_EXTRA_LIB]
# buildifier: disable=native-cc
native.cc_binary(**attrs)

17
cc/cc_import.bzl Normal file
View file

@ -0,0 +1,17 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""cc_import rule"""
def cc_import(**kwargs):
native.cc_import(**kwargs) # buildifier: disable=native-cc

17
cc/cc_library.bzl Normal file
View file

@ -0,0 +1,17 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""cc_library rule"""
def cc_library(**kwargs):
native.cc_library(**kwargs) # buildifier: disable=native-cc

17
cc/cc_shared_library.bzl Normal file
View file

@ -0,0 +1,17 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""cc_library rule"""
def cc_shared_library(**kwargs):
native.cc_shared_library(**kwargs) # buildifier: disable=native-cc

44
cc/cc_test.bzl Normal file
View file

@ -0,0 +1,44 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""cc_test rule"""
# TODO(bazel-team): To avoid breaking changes, if the below are no longer
# forwarding to native rules, flag @bazel_tools@bazel_tools//tools/cpp:link_extra_libs
# should either: (a) alias the flag @rules_cc//:link_extra_libs, or (b) be
# added as a dependency to @rules_cc//:link_extra_lib. The intermediate library
# @bazel_tools@bazel_tools//tools/cpp:link_extra_lib should either be added as a dependency
# to @rules_cc//:link_extra_lib, or removed entirely (if possible).
_LINK_EXTRA_LIB = "@rules_cc//:link_extra_lib" # copybara-use-repo-external-label
def cc_test(**attrs):
"""Bazel cc_test rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_test
Args:
**attrs: Rule attributes
"""
is_library = "linkshared" in attrs and attrs["linkshared"]
# Executable builds also include the "link_extra_lib" library.
if not is_library:
if "deps" in attrs and attrs["deps"] != None:
attrs["deps"] = attrs["deps"] + [_LINK_EXTRA_LIB]
else:
attrs["deps"] = [_LINK_EXTRA_LIB]
# buildifier: disable=native-cc
native.cc_test(**attrs)

31
cc/common/BUILD Normal file
View file

@ -0,0 +1,31 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "common",
srcs = glob(["*.bzl"]),
visibility = ["//visibility:public"],
deps = ["//cc/private/rules_impl:native_bzl"],
)
filegroup(
name = "srcs",
srcs = glob([
"**/*.bzl",
"**/BUILD",
]),
visibility = ["//visibility:public"],
)

19
cc/common/cc_common.bzl Normal file
View file

@ -0,0 +1,19 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""cc_common module"""
load("//cc/private/rules_impl:native.bzl", "native_cc_common")
cc_common = native_cc_common

19
cc/common/cc_info.bzl Normal file
View file

@ -0,0 +1,19 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""CcInfo"""
load("//cc/private/rules_impl:native.bzl", "NativeCcInfo")
CcInfo = NativeCcInfo

View file

@ -0,0 +1,18 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""CcSharedLibraryInfo"""
load("//cc/private/rules_impl:native.bzl", "NativeCcSharedLibraryHintInfo")
CcSharedLibraryHintInfo = NativeCcSharedLibraryHintInfo

View file

@ -0,0 +1,18 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""CcSharedLibraryInfo"""
load("//cc/private/rules_impl:native.bzl", "NativeCcSharedLibraryInfo")
CcSharedLibraryInfo = NativeCcSharedLibraryInfo

View file

@ -0,0 +1,18 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""DebugPackageInfo"""
load("//cc/private/rules_impl:native.bzl", "NativeDebugPackageInfo")
DebugPackageInfo = NativeDebugPackageInfo

View file

@ -11,193 +11,51 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
"""Starlark rules for building C++ projects.""" """Starlark rules for building C++ projects."""
load("//cc/private/rules_impl:cc_flags_supplier.bzl", _cc_flags_supplier = "cc_flags_supplier") load("//cc:cc_binary.bzl", _cc_binary = "cc_binary")
load("//cc/private/rules_impl:compiler_flag.bzl", _compiler_flag = "compiler_flag") load("//cc:cc_import.bzl", _cc_import = "cc_import")
load("//cc/private/rules_impl:native.bzl", "NativeCcInfo", "NativeCcToolchainConfigInfo", "NativeDebugPackageInfo", "native_cc_common") load("//cc:cc_library.bzl", _cc_library = "cc_library")
load("//cc:cc_shared_library.bzl", _cc_shared_library = "cc_shared_library")
load("//cc:cc_test.bzl", _cc_test = "cc_test")
load("//cc:objc_import.bzl", _objc_import = "objc_import")
load("//cc:objc_library.bzl", _objc_library = "objc_library")
load("//cc/common:cc_common.bzl", _cc_common = "cc_common")
load("//cc/common:cc_info.bzl", _CcInfo = "CcInfo")
load("//cc/common:debug_package_info.bzl", _DebugPackageInfo = "DebugPackageInfo")
load("//cc/toolchains:cc_flags_supplier.bzl", _cc_flags_supplier = "cc_flags_supplier")
load("//cc/toolchains:cc_toolchain.bzl", _cc_toolchain = "cc_toolchain")
load("//cc/toolchains:cc_toolchain_config_info.bzl", _CcToolchainConfigInfo = "CcToolchainConfigInfo")
load("//cc/toolchains:cc_toolchain_suite.bzl", _cc_toolchain_suite = "cc_toolchain_suite")
load("//cc/toolchains:compiler_flag.bzl", _compiler_flag = "compiler_flag")
load("//cc/toolchains:fdo_prefetch_hints.bzl", _fdo_prefetch_hints = "fdo_prefetch_hints")
load("//cc/toolchains:fdo_profile.bzl", _fdo_profile = "fdo_profile")
_MIGRATION_TAG = "__CC_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__" # Rules
# TODO(bazel-team): To avoid breaking changes, if the below are no longer cc_library = _cc_library
# forwarding to native rules, flag @bazel_tools@bazel_tools//tools/cpp:link_extra_libs cc_binary = _cc_binary
# should either: (a) alias the flag @rules_cc//:link_extra_libs, or (b) be cc_test = _cc_test
# added as a dependency to @rules_cc//:link_extra_lib. The intermediate library cc_import = _cc_import
# @bazel_tools@bazel_tools//tools/cpp:link_extra_lib should either be added as a dependency cc_shared_library = _cc_shared_library
# to @rules_cc//:link_extra_lib, or removed entirely (if possible).
_LINK_EXTRA_LIB = "@rules_cc//:link_extra_lib" # copybara-use-repo-external-label
def _add_tags(attrs, is_binary = False): objc_library = _objc_library
if "tags" in attrs and attrs["tags"] != None: objc_import = _objc_import
attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG]
else:
attrs["tags"] = [_MIGRATION_TAG]
if is_binary: cc_proto_library = native.cc_proto_library # For compatibility with current users
is_library = "linkshared" in attrs and attrs["linkshared"]
# Executable builds also include the "link_extra_lib" library. # Toolchain rules
if not is_library:
if "deps" in attrs and attrs["deps"] != None:
attrs["deps"] = attrs["deps"] + [_LINK_EXTRA_LIB]
else:
attrs["deps"] = [_LINK_EXTRA_LIB]
return attrs cc_toolchain = _cc_toolchain
fdo_profile = _fdo_profile
fdo_prefetch_hints = _fdo_prefetch_hints
cc_toolchain_suite = _cc_toolchain_suite
compiler_flag = _compiler_flag
cc_flags_supplier = _cc_flags_supplier
def cc_binary(**attrs): # Modules and providers
"""Bazel cc_binary rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_binary cc_common = _cc_common
CcInfo = _CcInfo
Args: DebugPackageInfo = _DebugPackageInfo
**attrs: Rule attributes CcToolchainConfigInfo = _CcToolchainConfigInfo
"""
# buildifier: disable=native-cc
native.cc_binary(**_add_tags(attrs, True))
def cc_test(**attrs):
"""Bazel cc_test rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_test
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.cc_test(**_add_tags(attrs, True))
def cc_library(**attrs):
"""Bazel cc_library rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_library
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.cc_library(**_add_tags(attrs))
def cc_import(**attrs):
"""Bazel cc_import rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_import
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.cc_import(**_add_tags(attrs))
def cc_proto_library(**attrs):
"""Bazel cc_proto_library rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_proto_library
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc-proto
native.cc_proto_library(**_add_tags(attrs))
def fdo_prefetch_hints(**attrs):
"""Bazel fdo_prefetch_hints rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#fdo_prefetch_hints
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.fdo_prefetch_hints(**_add_tags(attrs))
def fdo_profile(**attrs):
"""Bazel fdo_profile rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#fdo_profile
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.fdo_profile(**_add_tags(attrs))
def cc_toolchain(**attrs):
"""Bazel cc_toolchain rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_toolchain
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.cc_toolchain(**_add_tags(attrs))
def cc_toolchain_suite(**attrs):
"""Bazel cc_toolchain_suite rule.
https://docs.bazel.build/versions/main/be/c-cpp.html#cc_toolchain_suite
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.cc_toolchain_suite(**_add_tags(attrs))
def objc_library(**attrs):
"""Bazel objc_library rule.
https://docs.bazel.build/versions/main/be/objective-c.html#objc_library
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.objc_library(**_add_tags(attrs))
def objc_import(**attrs):
"""Bazel objc_import rule.
https://docs.bazel.build/versions/main/be/objective-c.html#objc_import
Args:
**attrs: Rule attributes
"""
# buildifier: disable=native-cc
native.objc_import(**_add_tags(attrs))
def cc_flags_supplier(**attrs):
"""Bazel cc_flags_supplier rule.
Args:
**attrs: Rule attributes
"""
_cc_flags_supplier(**_add_tags(attrs))
def compiler_flag(**attrs):
"""Bazel compiler_flag rule.
Args:
**attrs: Rule attributes
"""
_compiler_flag(**_add_tags(attrs))
cc_common = native_cc_common
CcInfo = NativeCcInfo
CcToolchainConfigInfo = NativeCcToolchainConfigInfo
DebugPackageInfo = NativeDebugPackageInfo

17
cc/objc_import.bzl Normal file
View file

@ -0,0 +1,17 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""objc_import rule"""
def objc_import(**kwargs):
native.objc_import(**kwargs) # buildifier: disable=native-cc

17
cc/objc_library.bzl Normal file
View file

@ -0,0 +1,17 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""objc_library rule"""
def objc_library(**kwargs):
native.objc_library(**kwargs) # buildifier: disable=native-cc

25
cc/private/BUILD Normal file
View file

@ -0,0 +1,25 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
filegroup(
name = "srcs",
srcs = glob([
"**/*.bzl",
"**/BUILD",
]) + [
"//cc/private/rules_impl:srcs",
"//cc/private/toolchain:srcs",
],
visibility = ["//visibility:public"],
)

View file

@ -1,3 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0 licenses(["notice"]) # Apache 2.0
@ -16,3 +18,15 @@ filegroup(
"**/BUILD", "**/BUILD",
]), ]),
) )
bzl_library(
name = "cc_flags_supplier_lib_bzl",
srcs = ["cc_flags_supplier_lib.bzl"],
visibility = ["//cc:__subpackages__"],
)
bzl_library(
name = "native_bzl",
srcs = ["native.bzl"],
visibility = ["//cc:__subpackages__"],
)

View file

@ -32,3 +32,9 @@ NativeCcToolchainConfigInfo = CcToolchainConfigInfo
# buildifier: disable=native-cc # buildifier: disable=native-cc
native_cc_common = cc_common native_cc_common = cc_common
# buildifier: disable=native-cc
NativeCcSharedLibraryInfo = CcSharedLibraryInfo
# buildifier: disable=native-cc
NativeCcSharedLibraryHintInfo = CcSharedLibraryHintInfo

View file

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
bool_flag( bool_flag(
@ -19,3 +20,25 @@ bool_flag(
build_setting_default = False, build_setting_default = False,
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
bzl_library(
name = "toolchain_rules",
srcs = glob(["*.bzl"]),
visibility = ["//visibility:public"],
deps = [
"//cc:action_names_bzl",
"//cc:find_cc_toolchain_bzl",
"//cc/private/rules_impl:cc_flags_supplier_lib_bzl",
"//cc/private/rules_impl:native_bzl",
"@bazel_skylib//rules/directory:glob",
],
)
filegroup(
name = "srcs",
srcs = glob([
"**/*.bzl",
"**/BUILD",
]),
visibility = ["//visibility:public"],
)

View file

@ -13,8 +13,8 @@
# limitations under the License. # limitations under the License.
"""Rule that provides the CC_FLAGS Make variable.""" """Rule that provides the CC_FLAGS Make variable."""
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
load("//cc:action_names.bzl", "CC_FLAGS_MAKE_VARIABLE_ACTION_NAME") load("//cc:action_names.bzl", "CC_FLAGS_MAKE_VARIABLE_ACTION_NAME")
load("//cc:find_cc_toolchain.bzl", "find_cpp_toolchain", "use_cc_toolchain")
load("//cc/private/rules_impl:cc_flags_supplier_lib.bzl", "build_cc_flags") load("//cc/private/rules_impl:cc_flags_supplier_lib.bzl", "build_cc_flags")
def _cc_flags_supplier_impl(ctx): def _cc_flags_supplier_impl(ctx):
@ -30,6 +30,6 @@ cc_flags_supplier = rule(
attrs = { attrs = {
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")), "_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
}, },
toolchains = use_cpp_toolchain(), toolchains = use_cc_toolchain(),
fragments = ["cpp"], fragments = ["cpp"],
) )

View file

@ -0,0 +1,18 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""cc_toolchain rule"""
def cc_toolchain(**kwargs):
native.cc_toolchain(**kwargs) # buildifier: disable=native-cc

View file

@ -0,0 +1,19 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""CcToolchainConfigInfo"""
load("//cc/private/rules_impl:native.bzl", "NativeCcToolchainConfigInfo")
CcToolchainConfigInfo = NativeCcToolchainConfigInfo

View file

@ -0,0 +1,18 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""cc_toolchain_suite rule"""
def cc_toolchain_suite(**kwargs):
native.cc_toolchain_suite(**kwargs) # buildifier: disable=native-cc

View file

@ -14,7 +14,7 @@
"""Rule that allows select() to differentiate between compilers.""" """Rule that allows select() to differentiate between compilers."""
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") load("//cc:find_cc_toolchain.bzl", "find_cpp_toolchain", "use_cc_toolchain")
def _compiler_flag_impl(ctx): def _compiler_flag_impl(ctx):
toolchain = find_cpp_toolchain(ctx) toolchain = find_cpp_toolchain(ctx)
@ -25,5 +25,5 @@ compiler_flag = rule(
attrs = { attrs = {
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")), "_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
}, },
toolchains = use_cpp_toolchain(), toolchains = use_cc_toolchain(),
) )

View file

@ -0,0 +1,18 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""fdo_prefetch_hints rule"""
def fdo_prefetch_hints(**kwargs):
native.fdo_prefetch_hints(**kwargs) # buildifier: disable=native-cc

View file

@ -0,0 +1,18 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""fdo_profile rule"""
def fdo_profile(**kwargs):
native.fdo_profile(**kwargs) # buildifier: disable=native-cc

View file

@ -0,0 +1,17 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""memprof_profile rule"""
memprof_profile = native.memprof_profile

View file

@ -0,0 +1,17 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""propeller_optimize rule"""
propeller_optimize = native.propeller_optimize