Merge pull request #146 from bazelbuild:meteorcloudy-patch-1

PiperOrigin-RevId: 475272913
Change-Id: Id75eee2933ee396ae5fc5cbe4941369b813b2c8e
This commit is contained in:
Ivo List 2022-09-19 13:51:00 +00:00
commit 13d212d39b
14 changed files with 111 additions and 16 deletions

View File

@ -0,0 +1,6 @@
{
"homepage": "https://github.com/bazelbuild/rules_cc"
"maintainers": [],
"versions": [],
"yanked_versions": {}
}

9
.bcr/presubmit.yml Normal file
View File

@ -0,0 +1,9 @@
matrix:
platform: ["centos7", "debian10", "macos", "ubuntu2004", "windows"]
tasks:
verify_targets:
name: "Verify build targets"
platform: ${{ platform }}
build_targets:
- "@rules_cc//cc/..."
- "@rules_cc//tools/runfiles"

View File

@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz"
}

View File

@ -1 +1 @@
* @oquenchil @c-mita @comius
* @oquenchil @c-mita @comius @buildbreaker2021

View File

@ -1,8 +1,7 @@
module(
name = "rules_cc",
compatibility_level = 1,
toolchains_to_register = ["@local_config_cc_toolchains//:all"],
version = "0.0.1",
version = "0.0.3",
)
bazel_dep(name = "bazel_skylib", version = "1.0.3")
@ -11,3 +10,5 @@ bazel_dep(name = "platforms", version = "0.0.4")
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure")
use_repo(cc_configure, "local_config_cc_toolchains")
register_toolchains("@local_config_cc_toolchains//:all")

View File

@ -2,6 +2,30 @@ workspace(name = "rules_cc")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "platforms",
sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
],
)
http_archive(
name = "io_bazel_rules_go",
sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
],
)
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains(version = "1.18.4")
http_archive(
name = "bazel_federation",
sha256 = "0d6893f0d18f417a3324ce7f0ed2e6e5b825d6d5ab42f0f3d7877cb313f36453",

View File

@ -27,6 +27,7 @@ filegroup(
exports_files([
"defs.bzl",
"action_names.bzl",
"system_library.bzl",
])
# The toolchain type used to distinguish cc toolchains.

View File

@ -16,6 +16,7 @@
load("//cc/private/rules_impl:cc_flags_supplier.bzl", _cc_flags_supplier = "cc_flags_supplier")
load("//cc/private/rules_impl:compiler_flag.bzl", _compiler_flag = "compiler_flag")
load("//cc/private/rules_impl:native.bzl", "NativeCcInfo", "NativeCcToolchainConfigInfo", "NativeDebugPackageInfo", "native_cc_common")
_MIGRATION_TAG = "__CC_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
@ -173,3 +174,11 @@ def compiler_flag(**attrs):
**attrs: Rule attributes
"""
_compiler_flag(**_add_tags(attrs))
cc_common = native_cc_common
CcInfo = NativeCcInfo
CcToolchainConfigInfo = NativeCcToolchainConfigInfo
DebugPackageInfo = NativeDebugPackageInfo

View File

@ -71,6 +71,10 @@ Returns the current `CcToolchainInfo`.
if not CC_TOOLCHAIN_TYPE in ctx.toolchains:
fail("In order to use find_cc_toolchain, your rule has to depend on C++ toolchain. See find_cc_toolchain.bzl docs for details.")
toolchain_info = ctx.toolchains[CC_TOOLCHAIN_TYPE]
if toolchain_info == None:
# No cpp toolchain was found, so report an error.
fail("Unable to find a CC toolchain using toolchain resolution. Target: %s, Platform: %s, Exec platform: %s" %
(ctx.label, ctx.fragments.platform.platform, ctx.fragments.platform.host_platform))
if hasattr(toolchain_info, "cc_provider_in_toolchain") and hasattr(toolchain_info, "cc"):
return toolchain_info.cc
return toolchain_info
@ -93,8 +97,7 @@ def find_cpp_toolchain(ctx):
"""
return find_cc_toolchain(ctx)
# buildifier: disable=unused-variable
def use_cc_toolchain(mandatory = True):
def use_cc_toolchain(mandatory = False):
"""
Helper to depend on the cc toolchain.
@ -107,9 +110,8 @@ def use_cc_toolchain(mandatory = True):
Args:
mandatory: Whether or not it should be an error if the toolchain cannot be resolved.
Currently ignored, this will be enabled when optional toolchain types are added.
Returns:
A list that can be used as the value for `rule.toolchains`.
"""
return [CC_TOOLCHAIN_TYPE]
return [config_common.toolchain_type(CC_TOOLCHAIN_TYPE, mandatory = mandatory)]

View File

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

View File

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

View File

@ -0,0 +1,34 @@
# Copyright 2022 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.
# Redefine native symbols with a new name as a workaround for
# exporting them in `//third_party/bazel_rules/rules_proto/proto:defs.bzl` with their original name.
#
# While we cannot force users to load these symbol due to the lack of a
# allowlisting mechanism, we can still export them and tell users to
# load it to make a future migration to pure Starlark easier.
"""Lovely workaround to be able to expose native constants pretending to be Starlark."""
# buildifier: disable=native-cc
NativeCcInfo = CcInfo
# buildifier: disable=native-cc
NativeDebugPackageInfo = DebugPackageInfo
# buildifier: disable=native-cc
NativeCcToolchainConfigInfo = CcToolchainConfigInfo
# buildifier: disable=native-cc
native_cc_common = cc_common

View File

@ -382,10 +382,8 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
False,
), ":")
bazel_linkopts = "-lstdc++:-lm"
bazel_linklibs = ""
if hasattr(repository_ctx, "flag_enabled") and repository_ctx.flag_enabled("incompatible_linkopts_to_linklibs"):
bazel_linkopts, bazel_linklibs = bazel_linklibs, bazel_linkopts
bazel_linklibs = "-lstdc++:-lm"
bazel_linkopts = ""
link_opts = split_escaped(get_env_var(
repository_ctx,
"BAZEL_LINKOPTS",

View File

@ -22,7 +22,7 @@ load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
licenses(["notice"])
py_binary(
name = "legacy_fields_migrator",