Skip to content

Commit

Permalink
Prepare to move CcModule to builtins.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 513236171
Change-Id: I9fca806aef9c88ab1dbb874c1b1c88f0e661a382
  • Loading branch information
buildbreaker2021 authored and copybara-github committed Mar 1, 2023
1 parent 661ebef commit c138210
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ load(":common/cc/semantics.bzl", "semantics")
load(":common/cc/experimental_cc_shared_library.bzl", "GraphNodeInfo", "build_exports_map_from_only_dynamic_deps", "build_link_once_static_libs_map", "merge_cc_shared_library_infos", "throw_linked_but_not_exported_errors")
load(":common/cc/cc_helper.bzl", "cc_helper", "linker_mode")
load(":common/cc/cc_info.bzl", "CcInfo")
load(":common/cc/cc_common.bzl", "cc_common")

DebugPackageInfo = _builtins.toplevel.DebugPackageInfo
cc_common = _builtins.toplevel.cc_common
cc_internal = _builtins.internal.cc_internal
StaticallyLinkedMarkerInfo = _builtins.internal.StaticallyLinkedMarkerProvider

Expand Down
17 changes: 17 additions & 0 deletions src/main/starlark/builtins_bzl/common/cc/cc_common.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2023 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.

"""Utilites related to C++ support."""

cc_common = _builtins.toplevel.cc_common
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
load(":common/objc/semantics.bzl", objc_semantics = "semantics")
load(":common/paths.bzl", "paths")
load(":common/cc/cc_info.bzl", "CcInfo")
load(":common/cc/cc_common.bzl", "cc_common")

cc_common = _builtins.toplevel.cc_common
cc_internal = _builtins.internal.cc_internal
CcNativeLibraryInfo = _builtins.internal.CcNativeLibraryInfo
config_common = _builtins.toplevel.config_common
Expand Down
3 changes: 1 addition & 2 deletions src/main/starlark/builtins_bzl/common/cc/cc_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ rely on this. Pass the flag --experimental_starlark_cc_import
load(":common/cc/cc_helper.bzl", "cc_helper")
load(":common/objc/semantics.bzl", "semantics")
load(":common/cc/cc_info.bzl", "CcInfo")

cc_common = _builtins.toplevel.cc_common
load(":common/cc/cc_common.bzl", "cc_common")

CPP_LINK_STATIC_LIBRARY_ACTION_NAME = "c++-link-static-library"

Expand Down
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
load(":common/cc/cc_helper.bzl", "cc_helper")
load(":common/cc/semantics.bzl", "semantics")
load(":common/cc/cc_info.bzl", "CcInfo")
load(":common/cc/cc_common.bzl", "cc_common")

cc_common = _builtins.toplevel.cc_common
cc_internal = _builtins.internal.cc_internal

def _cc_library_impl(ctx):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ load(":common/proto/proto_info.bzl", "ProtoInfo")
load(":common/cc/cc_helper.bzl", "cc_helper")
load(":common/proto/proto_common.bzl", "ProtoLangToolchainInfo", proto_common = "proto_common_do_not_use")
load(":common/cc/cc_info.bzl", "CcInfo")

cc_common = _builtins.toplevel.cc_common
load(":common/cc/cc_common.bzl", "cc_common")

ProtoCcFilesInfo = provider(fields = ["files"], doc = "Provide cc proto files.")
ProtoCcHeaderInfo = provider(fields = ["headers"], doc = "Provide cc proto headers.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

load(":common/cc/semantics.bzl", "semantics")
load(":common/cc/cc_helper.bzl", "cc_helper")
load(":common/cc/cc_common.bzl", "cc_common")

CcToolchainInfo = _builtins.toplevel.cc_common.CcToolchainInfo
CcToolchainInfo = cc_common.CcToolchainInfo
TemplateVariableInfo = _builtins.toplevel.platform_common.TemplateVariableInfo
ToolchainInfo = _builtins.toplevel.platform_common.ToolchainInfo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ load(":common/cc/cc_helper.bzl", "cc_helper")
load(":common/cc/semantics.bzl", "semantics")
load(":common/proto/proto_info.bzl", "ProtoInfo")
load(":common/cc/cc_info.bzl", "CcInfo")

cc_common = _builtins.toplevel.cc_common
load(":common/cc/cc_common.bzl", "cc_common")

# TODO(#5200): Add export_define to library_to_link and cc_library

Expand Down
2 changes: 2 additions & 0 deletions src/main/starlark/builtins_bzl/common/exports.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ load("@_builtins//:common/python/providers.bzl", "PyCcLinkParamsProvider", "PyIn
load("@_builtins//:common/java/proto/java_lite_proto_library.bzl", "java_lite_proto_library")
load("@_builtins//:common/cc/cc_library.bzl", "cc_library")
load("@_builtins//:common/cc/cc_toolchain_alias.bzl", "cc_toolchain_alias")
load("@_builtins//:common/cc/cc_common.bzl", "cc_common")

exported_toplevels = {
# This dummy symbol is not part of the public API; it is only used to test
Expand All @@ -45,6 +46,7 @@ exported_toplevels = {
"PyCcLinkParamsProvider": PyCcLinkParamsProvider,
"py_internal": py_internal,
"ProtoInfo": ProtoInfo,
"cc_common": cc_common,
}

# A list of Starlarkified native rules.
Expand Down
3 changes: 1 addition & 2 deletions src/main/starlark/builtins_bzl/common/java/java_helper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
load(":common/java/java_semantics.bzl", "semantics")
load(":common/cc/cc_helper.bzl", "cc_helper")
load(":common/paths.bzl", "paths")

cc_common = _builtins.toplevel.cc_common
load(":common/cc/cc_common.bzl", "cc_common")

def _collect_all_targets_as_runtime_deps(ctx):
return _collect_all_targets_as_deps(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
load("@_builtins//:common/objc/objc_common.bzl", "objc_common")
load(":common/cc/cc_common.bzl", "cc_common")

objc_internal = _builtins.internal.objc_internal
cc_common = _builtins.toplevel.cc_common

def _build_variable_extensions(ctx, arc_enabled):
extensions = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

load("@_builtins//:common/objc/compilation_support.bzl", "compilation_support")
load(":common/cc/cc_info.bzl", "CcInfo")
load(":common/cc/cc_common.bzl", "cc_common")

cc_common = _builtins.toplevel.cc_common
apple_common = _builtins.toplevel.apple_common
objc_internal = _builtins.internal.objc_internal

Expand Down
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/objc/objc_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ load("@_builtins//:common/objc/attrs.bzl", "common_attrs")
load("@_builtins//:common/objc/compilation_support.bzl", "compilation_support")
load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
load(":common/cc/cc_info.bzl", "CcInfo")
load(":common/cc/cc_common.bzl", "cc_common")

objc_internal = _builtins.internal.objc_internal
cc_common = _builtins.toplevel.cc_common

def _objc_import_impl(ctx):
cc_toolchain = cc_helper.find_cpp_toolchain(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
load(":common/cc/cc_info.bzl", "CcInfo")

objc_internal = _builtins.internal.objc_internal
cc_common = _builtins.toplevel.cc_common
coverage_common = _builtins.toplevel.coverage_common
apple_common = _builtins.toplevel.apple_common

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ load(":common/paths.bzl", "paths")
load(":common/python/providers.bzl", "PyCcLinkParamsProvider")
load(":common/python/common.bzl", "is_bool")
load(":common/cc/cc_info.bzl", _CcInfo = "CcInfo")
load(":common/cc/cc_common.bzl", _cc_common = "cc_common")

_py_builtins = _builtins.internal.py_builtins
_cc_common = _builtins.toplevel.cc_common

def collect_cc_info(ctx, extra_deps = []):
"""Collect C++ information from dependencies for Bazel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ load(
"IS_BAZEL",
"PY_RUNTIME_ATTR_NAME",
)
load(":common/cc/cc_common.bzl", _cc_common = "cc_common")

_cc_common = _builtins.toplevel.cc_common
_py_builtins = _builtins.internal.py_builtins

# Non-Google-specific attributes for executables
Expand Down

0 comments on commit c138210

Please sign in to comment.