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

Flip incompatible_disallow_struct_provider_syntax #23831

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public final class BuildLanguageOptions extends OptionsBase {

@Option(
name = "incompatible_disallow_struct_provider_syntax",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
Expand Down Expand Up @@ -960,7 +960,7 @@ public StarlarkSemantics toStarlarkSemantics() {
"-incompatible_disable_target_provider_fields";
public static final String INCOMPATIBLE_DISALLOW_EMPTY_GLOB = "-incompatible_disallow_empty_glob";
public static final String INCOMPATIBLE_DISALLOW_STRUCT_PROVIDER_SYNTAX =
"-incompatible_disallow_struct_provider_syntax";
"+incompatible_disallow_struct_provider_syntax";
public static final String INCOMPATIBLE_PACKAGE_GROUP_HAS_PUBLIC_SYNTAX =
FlagConstants.INCOMPATIBLE_PACKAGE_GROUP_HAS_PUBLIC_SYNTAX;
public static final String INCOMPATIBLE_FIX_PACKAGE_GROUP_REPOROOT_SYNTAX =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3329,9 +3329,9 @@ def f(ctx):
"r/def.bzl",
"""
load(":create.bzl", "create")

Info = provider()
def f(ctx):
return struct(value = "NEW")
return Info(value = "NEW")

r = create(f)
""");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.packages.StarlarkInfo;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.Root;
Expand Down Expand Up @@ -195,7 +196,7 @@ def _genfile_impl(ctx):
implementation = _genfile_impl,
outputs = {"my_output": "%{name}.txt"},
)

CheckInfo = provider()
def _check_impl(ctx):
source_file = ctx.attr.srcs[0].files.to_list()[0]
generated_file = ctx.attr.srcs[1].files.to_list()[0]
Expand All @@ -213,7 +214,7 @@ def _check_impl(ctx):
"source_root": source_file.root,
"generated_root": generated_file.root,
}
return struct(**prepare_params(objects))
return CheckInfo(**prepare_params(objects))

check = rule(
implementation = _check_impl,
Expand Down Expand Up @@ -329,13 +330,14 @@ public void testStringRepresentations_select() throws Exception {
public void testStringRepresentations_ruleContext() throws Exception {
generateFilesToTestStrings();
ConfiguredTarget target = getConfiguredTarget("//test/starlark:check");
StarlarkInfo checkInfo = getStarlarkProvider(target, "CheckInfo");

for (String suffix : SUFFIXES) {
assertThat(target.get("rule_ctx" + suffix))
assertThat(checkInfo.getValue("rule_ctx" + suffix))
.isEqualTo("<rule context for //test/starlark:check>");
assertThat(target.get("aspect_ctx" + suffix))
assertThat(checkInfo.getValue("aspect_ctx" + suffix))
.isEqualTo("<aspect context for //test/starlark:bar>");
assertThat(target.get("aspect_ctx.rule" + suffix))
assertThat(checkInfo.getValue("aspect_ctx.rule" + suffix))
.isEqualTo("<rule collection for //test/starlark:bar>");
}
}
Expand All @@ -344,11 +346,12 @@ public void testStringRepresentations_ruleContext() throws Exception {
public void testStringRepresentations_files() throws Exception {
generateFilesToTestStrings();
ConfiguredTarget target = getConfiguredTarget("//test/starlark:check");
StarlarkInfo checkInfo = getStarlarkProvider(target, "CheckInfo");

for (String suffix : SUFFIXES) {
assertThat(target.get("source_file" + suffix))
assertThat(checkInfo.getValue("source_file" + suffix))
.isEqualTo("<source file test/starlark/input.txt>");
assertThat(target.get("generated_file" + suffix))
assertThat(checkInfo.getValue("generated_file" + suffix))
.isEqualTo("<generated file test/starlark/output.txt>");
}
}
Expand All @@ -357,10 +360,11 @@ public void testStringRepresentations_files() throws Exception {
public void testStringRepresentations_root() throws Exception {
generateFilesToTestStrings();
ConfiguredTarget target = getConfiguredTarget("//test/starlark:check");
StarlarkInfo checkInfo = getStarlarkProvider(target, "CheckInfo");

for (String suffix : SUFFIXES) {
assertThat(target.get("source_root" + suffix)).isEqualTo("<source root>");
assertThat(target.get("generated_root" + suffix)).isEqualTo("<derived root>");
assertThat(checkInfo.getValue("source_root" + suffix)).isEqualTo("<source root>");
assertThat(checkInfo.getValue("generated_root" + suffix)).isEqualTo("<derived root>");
}
}

Expand Down Expand Up @@ -396,16 +400,17 @@ public void testStringRepresentations_attr() throws Exception {
public void testStringRepresentations_targets() throws Exception {
generateFilesToTestStrings();
ConfiguredTarget target = getConfiguredTarget("//test/starlark:check");
StarlarkInfo checkInfo = getStarlarkProvider(target, "CheckInfo");

for (String suffix : SUFFIXES) {
assertThat(target.get("target" + suffix)).isEqualTo("<target //test/starlark:foo>");
assertThat(target.get("input_target" + suffix))
assertThat(checkInfo.getValue("target" + suffix)).isEqualTo("<target //test/starlark:foo>");
assertThat(checkInfo.getValue("input_target" + suffix))
.isEqualTo("<input file target //test/starlark:input.txt>");
assertThat(target.get("output_target" + suffix))
assertThat(checkInfo.getValue("output_target" + suffix))
.isEqualTo("<output file target //test/starlark:output.txt>");
assertThat(target.get("alias_target" + suffix))
assertThat(checkInfo.getValue("alias_target" + suffix))
.isEqualTo("<alias target //test/starlark:foobar of //test/starlark:foo>");
assertThat(target.get("aspect_target" + suffix))
assertThat(checkInfo.getValue("aspect_target" + suffix))
.isEqualTo("<merged target //test/starlark:bar>");
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/shell/bazel/bazel_java_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ def _impl(ctx):
strict_deps = "ERROR",
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo],
)
return struct(
files = depset([output_jar]),
providers = [compilation_provider]
)
return [
DefaultInfo(files = depset([output_jar])),
compilation_provider,
]

java_custom_library = rule(
implementation = _impl,
Expand Down
4 changes: 2 additions & 2 deletions src/test/shell/bazel/external_starlark_load_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ EOF

cat > rule.bzl <<EOF
def test_aspect_impl(target, ctx):
return struct()
return []

test_aspect = aspect(
attrs = {
Expand All @@ -243,7 +243,7 @@ test_aspect = aspect(
)

def test_rule_impl(ctx):
return struct()
return []

test_rule = rule(
attrs = {
Expand Down