Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move TraceInfo to a new place #88

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc_build/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ORDER = [
("LicenseInfo", "//rules:providers.bzl"),
("LicenseKindInfo", "//rules:providers.bzl"),
("PackageInfo", "//rules:providers.bzl"),
("trace", "//rules_gathering:trace.bzl"),
]

genrule(
Expand Down Expand Up @@ -90,7 +91,7 @@ bzl_library(
"//:version.bzl",
"//rules:standard_package",
"//rules/private:standard_package",
# "@bazel_skylib//lib:paths",
"//rules_gathering:standard_package",
],
visibility = ["//visibility:public"],
)
Expand Down
2 changes: 1 addition & 1 deletion rules/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
"""Rules for making license declarations."""

load("@rules_license//rules:licenses_core.bzl", "trace")
load("@rules_license//rules_gathering:trace.bzl", "trace")

package(
default_applicable_licenses = ["//:license"],
Expand Down
2 changes: 1 addition & 1 deletion rules/gather_licenses_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

load(
"@rules_license//rules:licenses_core.bzl",
"TraceInfo",
"gather_metadata_info_common",
"should_traverse",
)
load(
"@rules_license//rules/private:gathering_providers.bzl",
"TransitiveLicensesInfo",
)
load("@rules_license//rules_gathering:trace.bzl", "TraceInfo")

def _strip_null_repo(label):
"""Removes the null repo name (e.g. @//) from a string.
Expand Down
2 changes: 1 addition & 1 deletion rules/gather_metadata.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

load(
"@rules_license//rules:licenses_core.bzl",
"TraceInfo",
"gather_metadata_info_common",
"should_traverse",
)
Expand All @@ -28,6 +27,7 @@ load(
"@rules_license//rules/private:gathering_providers.bzl",
"TransitiveMetadataInfo",
)
load("@rules_license//rules_gathering:trace.bzl", "TraceInfo")

def _strip_null_repo(label):
"""Removes the null repo name (e.g. @//) from a string.
Expand Down
23 changes: 2 additions & 21 deletions rules/licenses_core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,14 @@
"""Rules and macros for collecting LicenseInfo providers."""

load("@rules_license//rules:filtered_rule_kinds.bzl", "aspect_filters")
load("@rules_license//rules:providers.bzl", "LicenseInfo")
load("@rules_license//rules:user_filtered_rule_kinds.bzl", "user_aspect_filters")
load(
"@rules_license//rules:providers.bzl",
"LicenseInfo",
)
load(
"@rules_license//rules/private:gathering_providers.bzl",
"LicensedTargetInfo",
"TransitiveLicensesInfo",
)


TraceInfo = provider(
doc = """Provides a target (as a string) to assist in debugging dependency issues.""",
fields = {
"trace": "String: a target to trace dependency edges to.",
},
)

def _trace_impl(ctx):
return TraceInfo(trace = ctx.build_setting_value)

trace = rule(
doc = """Used to allow the specification of a target to trace while collecting license dependencies.""",
implementation = _trace_impl,
build_setting = config.string(flag = True),
)
load("@rules_license//rules_gathering:trace.bzl", "TraceInfo")

def should_traverse(ctx, attr):
"""Checks if the dependent attribute should be traversed.
Expand Down
33 changes: 33 additions & 0 deletions rules_gathering/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 Google LLC
#
# 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
#
# https://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.
"""Rules for making license declarations."""

package(
default_applicable_licenses = ["//:license"],
default_visibility = ["//visibility:public"],
)

filegroup(
name = "standard_package",
srcs = glob(["**"]),
)

# Do not create a bzl_library(). That would create a dependency loop back
# to bazel-skylib. We export the .bzl files to the documentation maker.
exports_files(
glob([
"*.bzl",
]),
visibility = ["//doc_build:__pkg__"],
)
30 changes: 30 additions & 0 deletions rules_gathering/trace.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022 Google LLC
#
# 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
#
# https://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.
"""Rules and macros for collecting package metdata providers."""

TraceInfo = provider(
doc = """Provides a target (as a string) to assist in debugging dependency issues.""",
fields = {
"trace": "String: a target to trace dependency edges to.",
},
)

def _trace_impl(ctx):
return TraceInfo(trace = ctx.build_setting_value)

trace = rule(
doc = """Used to allow the specification of a target to trace while collecting license dependencies.""",
implementation = _trace_impl,
build_setting = config.string(flag = True),
)