Skip to content

Commit 13d212d

Browse files
committed
Merge pull request #146 from bazelbuild:meteorcloudy-patch-1
PiperOrigin-RevId: 475272913 Change-Id: Id75eee2933ee396ae5fc5cbe4941369b813b2c8e
2 parents 2f8c04c + 4ae6132 commit 13d212d

File tree

14 files changed

+111
-16
lines changed

14 files changed

+111
-16
lines changed

.bcr/metadata.template.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"homepage": "https://github.com/bazelbuild/rules_cc"
3+
"maintainers": [],
4+
"versions": [],
5+
"yanked_versions": {}
6+
}

.bcr/presubmit.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
matrix:
2+
platform: ["centos7", "debian10", "macos", "ubuntu2004", "windows"]
3+
tasks:
4+
verify_targets:
5+
name: "Verify build targets"
6+
platform: ${{ platform }}
7+
build_targets:
8+
- "@rules_cc//cc/..."
9+
- "@rules_cc//tools/runfiles"

.bcr/source.template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "",
3+
"strip_prefix": "{REPO}-{VERSION}",
4+
"url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz"
5+
}

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @oquenchil @c-mita @comius
1+
* @oquenchil @c-mita @comius @buildbreaker2021

MODULE.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module(
22
name = "rules_cc",
33
compatibility_level = 1,
4-
toolchains_to_register = ["@local_config_cc_toolchains//:all"],
5-
version = "0.0.1",
4+
version = "0.0.3",
65
)
76

87
bazel_dep(name = "bazel_skylib", version = "1.0.3")
@@ -11,3 +10,5 @@ bazel_dep(name = "platforms", version = "0.0.4")
1110
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure")
1211

1312
use_repo(cc_configure, "local_config_cc_toolchains")
13+
14+
register_toolchains("@local_config_cc_toolchains//:all")

WORKSPACE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@ workspace(name = "rules_cc")
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44

5+
http_archive(
6+
name = "platforms",
7+
sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca",
8+
urls = [
9+
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
10+
"https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz",
11+
],
12+
)
13+
14+
http_archive(
15+
name = "io_bazel_rules_go",
16+
sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
17+
urls = [
18+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
19+
"https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
20+
],
21+
)
22+
23+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
24+
25+
go_rules_dependencies()
26+
27+
go_register_toolchains(version = "1.18.4")
28+
529
http_archive(
630
name = "bazel_federation",
731
sha256 = "0d6893f0d18f417a3324ce7f0ed2e6e5b825d6d5ab42f0f3d7877cb313f36453",

cc/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ filegroup(
2727
exports_files([
2828
"defs.bzl",
2929
"action_names.bzl",
30+
"system_library.bzl",
3031
])
3132

3233
# The toolchain type used to distinguish cc toolchains.

cc/defs.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
load("//cc/private/rules_impl:cc_flags_supplier.bzl", _cc_flags_supplier = "cc_flags_supplier")
1818
load("//cc/private/rules_impl:compiler_flag.bzl", _compiler_flag = "compiler_flag")
19+
load("//cc/private/rules_impl:native.bzl", "NativeCcInfo", "NativeCcToolchainConfigInfo", "NativeDebugPackageInfo", "native_cc_common")
1920

2021
_MIGRATION_TAG = "__CC_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
2122

@@ -173,3 +174,11 @@ def compiler_flag(**attrs):
173174
**attrs: Rule attributes
174175
"""
175176
_compiler_flag(**_add_tags(attrs))
177+
178+
cc_common = native_cc_common
179+
180+
CcInfo = NativeCcInfo
181+
182+
CcToolchainConfigInfo = NativeCcToolchainConfigInfo
183+
184+
DebugPackageInfo = NativeDebugPackageInfo

cc/find_cc_toolchain.bzl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ Returns the current `CcToolchainInfo`.
7171
if not CC_TOOLCHAIN_TYPE in ctx.toolchains:
7272
fail("In order to use find_cc_toolchain, your rule has to depend on C++ toolchain. See find_cc_toolchain.bzl docs for details.")
7373
toolchain_info = ctx.toolchains[CC_TOOLCHAIN_TYPE]
74+
if toolchain_info == None:
75+
# No cpp toolchain was found, so report an error.
76+
fail("Unable to find a CC toolchain using toolchain resolution. Target: %s, Platform: %s, Exec platform: %s" %
77+
(ctx.label, ctx.fragments.platform.platform, ctx.fragments.platform.host_platform))
7478
if hasattr(toolchain_info, "cc_provider_in_toolchain") and hasattr(toolchain_info, "cc"):
7579
return toolchain_info.cc
7680
return toolchain_info
@@ -93,8 +97,7 @@ def find_cpp_toolchain(ctx):
9397
"""
9498
return find_cc_toolchain(ctx)
9599

96-
# buildifier: disable=unused-variable
97-
def use_cc_toolchain(mandatory = True):
100+
def use_cc_toolchain(mandatory = False):
98101
"""
99102
Helper to depend on the cc toolchain.
100103
@@ -107,9 +110,8 @@ def use_cc_toolchain(mandatory = True):
107110
108111
Args:
109112
mandatory: Whether or not it should be an error if the toolchain cannot be resolved.
110-
Currently ignored, this will be enabled when optional toolchain types are added.
111113
112114
Returns:
113115
A list that can be used as the value for `rule.toolchains`.
114116
"""
115-
return [CC_TOOLCHAIN_TYPE]
117+
return [config_common.toolchain_type(CC_TOOLCHAIN_TYPE, mandatory = mandatory)]

cc/private/rules_impl/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
licenses(["notice"]) # Apache 2.0
@@ -16,3 +18,9 @@ filegroup(
1618
"**/BUILD",
1719
]),
1820
)
21+
22+
bzl_library(
23+
name = "native_bzl",
24+
srcs = ["native.bzl"],
25+
visibility = ["//cc:__pkg__"],
26+
)

0 commit comments

Comments
 (0)