From 6a620980fad69d698aca0637dd7ff729f75f1318 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 30 Oct 2024 13:22:40 -0700 Subject: [PATCH] Starlarkify objc/CompilationAttributes.java Closes #24009. PiperOrigin-RevId: 691531639 Change-Id: I7c9182f6785fd77acc53c93026f5b4723b4aa645 --- .../lib/rules/objc/CompilationAttributes.java | 519 ------------------ .../lib/rules/objc/ObjcStarlarkInternal.java | 36 -- .../common/objc/compilation_support.bzl | 29 +- .../lib/rules/objc/ObjcStarlarkTest.java | 16 +- 4 files changed, 37 insertions(+), 563 deletions(-) delete mode 100644 src/main/java/com/google/devtools/build/lib/rules/objc/CompilationAttributes.java diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationAttributes.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationAttributes.java deleted file mode 100644 index e096d3c9c179de..00000000000000 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationAttributes.java +++ /dev/null @@ -1,519 +0,0 @@ -// Copyright 2016 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. - -package com.google.devtools.build.lib.rules.objc; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.analysis.PrerequisiteArtifacts; -import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.collect.nestedset.Depset; -import com.google.devtools.build.lib.collect.nestedset.NestedSet; -import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; -import com.google.devtools.build.lib.collect.nestedset.Order; -import com.google.devtools.build.lib.packages.BuildType; -import com.google.devtools.build.lib.packages.Type; -import com.google.devtools.build.lib.packages.Types; -import com.google.devtools.build.lib.rules.cpp.CcCommon; -import com.google.devtools.build.lib.rules.cpp.CppHelper; -import com.google.devtools.build.lib.util.Pair; -import com.google.devtools.build.lib.vfs.PathFragment; -import com.google.errorprone.annotations.CanIgnoreReturnValue; -import net.starlark.java.annot.Param; -import net.starlark.java.annot.StarlarkMethod; -import net.starlark.java.eval.Sequence; -import net.starlark.java.eval.StarlarkList; -import net.starlark.java.eval.StarlarkValue; - -/** Provides a way to access attributes that are common to all compilation rules. */ -// TODO(bazel-team): Delete and move into support-specific attributes classes once ObjcCommon is -// gone. -final class CompilationAttributes implements StarlarkValue { - static class Builder { - private final NestedSetBuilder hdrs = NestedSetBuilder.stableOrder(); - private final NestedSetBuilder textualHdrs = NestedSetBuilder.stableOrder(); - private final NestedSetBuilder includes = NestedSetBuilder.stableOrder(); - private final NestedSetBuilder sdkIncludes = NestedSetBuilder.stableOrder(); - private final ImmutableList.Builder copts = ImmutableList.builder(); - private final ImmutableList.Builder linkopts = ImmutableList.builder(); - private final ImmutableList.Builder linkInputs = ImmutableList.builder(); - private final ImmutableList.Builder defines = ImmutableList.builder(); - private final NestedSetBuilder sdkFrameworks = NestedSetBuilder.stableOrder(); - private final NestedSetBuilder weakSdkFrameworks = NestedSetBuilder.stableOrder(); - private final NestedSetBuilder sdkDylibs = NestedSetBuilder.stableOrder(); - private Optional packageFragment = Optional.absent(); - private boolean enableModules; - - /** Adds the default values available through the rule's context. */ - static Builder fromRuleContext(RuleContext ruleContext) throws InterruptedException { - Builder builder = new Builder(); - - addHeadersFromRuleContext(builder, ruleContext); - addIncludesFromRuleContext(builder, ruleContext); - addSdkAttributesFromRuleContext(builder, ruleContext); - addCompileOptionsFromRuleContext(builder, ruleContext); - addModuleOptionsFromRuleContext(builder, ruleContext); - - return builder; - } - - /** Adds headers to be made available for dependents. */ - @CanIgnoreReturnValue - public Builder addHdrs(NestedSet hdrs) { - this.hdrs.addTransitive(hdrs); - return this; - } - - /** Adds headers that cannot be compiled individually. */ - @CanIgnoreReturnValue - public Builder addTextualHdrs(NestedSet textualHdrs) { - this.textualHdrs.addTransitive(textualHdrs); - return this; - } - - /** Adds include paths to be made available for compilation. */ - @CanIgnoreReturnValue - public Builder addIncludes(NestedSet includes) { - this.includes.addTransitive(includes); - return this; - } - - /** Adds paths for SDK includes. */ - @CanIgnoreReturnValue - public Builder addSdkIncludes(NestedSet sdkIncludes) { - this.sdkIncludes.addTransitive(sdkIncludes); - return this; - } - - /** Adds compile-time options. */ - @CanIgnoreReturnValue - public Builder addCopts(Iterable copts) { - this.copts.addAll(copts); - return this; - } - - /** Adds link-time options. */ - @CanIgnoreReturnValue - public Builder addLinkopts(Iterable linkopts) { - this.linkopts.addAll(linkopts); - return this; - } - - /** Adds additional linker inputs. */ - @CanIgnoreReturnValue - public Builder addLinkInputs(Iterable linkInputs) { - this.linkInputs.addAll(linkInputs); - return this; - } - - /** Adds defines. */ - @CanIgnoreReturnValue - public Builder addDefines(Iterable defines) { - this.defines.addAll(defines); - return this; - } - - /** Adds SDK frameworks to link against. */ - @CanIgnoreReturnValue - public Builder addSdkFrameworks(NestedSet sdkFrameworks) { - this.sdkFrameworks.addTransitive(sdkFrameworks); - return this; - } - - /** Adds SDK frameworks to be linked weakly. */ - @CanIgnoreReturnValue - public Builder addWeakSdkFrameworks(NestedSet weakSdkFrameworks) { - this.weakSdkFrameworks.addTransitive(weakSdkFrameworks); - return this; - } - - /** Adds SDK Dylibs to link against. */ - @CanIgnoreReturnValue - public Builder addSdkDylibs(NestedSet sdkDylibs) { - this.sdkDylibs.addTransitive(sdkDylibs); - return this; - } - - /** Sets the package path from which to base the header search paths. */ - @CanIgnoreReturnValue - public Builder setPackageFragment(PathFragment packageFragment) { - Preconditions.checkState( - !this.packageFragment.isPresent(), - "packageFragment is already set to %s", - this.packageFragment); - this.packageFragment = Optional.of(packageFragment); - return this; - } - - /** Enables the usage of clang modules maps during compilation. */ - @CanIgnoreReturnValue - public Builder enableModules() { - this.enableModules = true; - return this; - } - - /** - * Builds a {@code CompilationAttributes} object. - */ - public CompilationAttributes build() { - return new CompilationAttributes( - this.hdrs.build(), - this.textualHdrs.build(), - this.includes.build(), - this.sdkIncludes.build(), - this.sdkFrameworks.build(), - this.weakSdkFrameworks.build(), - this.sdkDylibs.build(), - this.packageFragment, - this.copts.build(), - this.linkopts.build(), - this.linkInputs.build(), - this.defines.build(), - this.enableModules); - } - - static void addHeadersFromRuleContext(Builder builder, RuleContext ruleContext) { - if (ruleContext.attributes().has("hdrs", BuildType.LABEL_LIST)) { - NestedSetBuilder headers = NestedSetBuilder.stableOrder(); - for (Pair header : CcCommon.getHeaders(ruleContext)) { - headers.add(header.first); - } - builder.addHdrs(headers.build()); - } - - if (ruleContext.attributes().has("textual_hdrs", BuildType.LABEL_LIST)) { - builder.addTextualHdrs( - PrerequisiteArtifacts.nestedSet( - ruleContext.getRulePrerequisitesCollection(), "textual_hdrs")); - } - } - - static void addIncludesFromRuleContext(Builder builder, RuleContext ruleContext) { - if (ruleContext.attributes().has("includes", Types.STRING_LIST)) { - NestedSetBuilder includes = NestedSetBuilder.stableOrder(); - includes.addAll( - Iterables.transform( - ruleContext.attributes().get("includes", Types.STRING_LIST), PathFragment::create)); - builder.addIncludes(includes.build()); - } - - if (ruleContext.attributes().has("sdk_includes", Types.STRING_LIST)) { - NestedSetBuilder sdkIncludes = NestedSetBuilder.stableOrder(); - sdkIncludes.addAll( - Iterables.transform( - ruleContext.attributes().get("sdk_includes", Types.STRING_LIST), - PathFragment::create)); - builder.addSdkIncludes(sdkIncludes.build()); - } - } - - static void addSdkAttributesFromRuleContext(Builder builder, RuleContext ruleContext) { - if (ruleContext.attributes().has("sdk_frameworks", Types.STRING_LIST)) { - NestedSetBuilder frameworks = NestedSetBuilder.stableOrder(); - for (String explicit : ruleContext.attributes().get("sdk_frameworks", Types.STRING_LIST)) { - frameworks.add(explicit); - } - if (ruleContext.getFragment(ObjcConfiguration.class).disallowSdkFrameworksAttributes() - && !frameworks.isEmpty()) { - ruleContext.attributeError( - "sdk_frameworks", - "sdk_frameworks attribute is disallowed. Use explicit dependencies instead."); - } - builder.addSdkFrameworks(frameworks.build()); - } - - if (ruleContext.attributes().has("weak_sdk_frameworks", Types.STRING_LIST)) { - NestedSetBuilder weakFrameworks = NestedSetBuilder.stableOrder(); - for (String frameworkName : - ruleContext.attributes().get("weak_sdk_frameworks", Types.STRING_LIST)) { - weakFrameworks.add(frameworkName); - } - if (ruleContext.getFragment(ObjcConfiguration.class).disallowSdkFrameworksAttributes() - && !weakFrameworks.isEmpty()) { - ruleContext.attributeError( - "weak_sdk_frameworks", - "weak_sdk_frameworks attribute is disallowed. Use explicit dependencies instead."); - } - builder.addWeakSdkFrameworks(weakFrameworks.build()); - } - - if (ruleContext.attributes().has("sdk_dylibs", Types.STRING_LIST)) { - NestedSetBuilder sdkDylibs = NestedSetBuilder.stableOrder(); - sdkDylibs.addAll(ruleContext.attributes().get("sdk_dylibs", Types.STRING_LIST)); - builder.addSdkDylibs(sdkDylibs.build()); - } - } - - private static void addCompileOptionsFromRuleContext(Builder builder, RuleContext ruleContext) - throws InterruptedException { - addCompileOptionsFromRuleContext(builder, ruleContext, /* copts= */ null); - } - - static void addCompileOptionsFromRuleContext( - Builder builder, RuleContext ruleContext, Iterable copts) - throws InterruptedException { - if (ruleContext.attributes().has("copts", Types.STRING_LIST)) { - if (copts == null) { - builder.addCopts(ruleContext.getExpander().withDataLocations().tokenized("copts")); - } else { - builder.addCopts(copts); - } - } - - if (ruleContext.attributes().has("linkopts", Types.STRING_LIST)) { - builder.addLinkopts(CppHelper.getLinkopts(ruleContext)); - } - - if (ruleContext.attributes().has("additional_linker_inputs", BuildType.LABEL_LIST)) { - builder.addLinkInputs( - ruleContext.getPrerequisiteArtifacts("additional_linker_inputs").list()); - } - - if (ruleContext.attributes().has("defines", Types.STRING_LIST)) { - builder.addDefines(ruleContext.getExpander().withDataLocations().tokenized("defines")); - } - } - - protected static void addModuleOptionsFromRuleContext( - Builder builder, RuleContext ruleContext) { - PathFragment packageFragment = ruleContext.getPackageDirectory(); - if (packageFragment != null) { - builder.setPackageFragment(packageFragment); - } - - if (ruleContext.attributes().has("enable_modules", Type.BOOLEAN) - && ruleContext.attributes().get("enable_modules", Type.BOOLEAN)) { - builder.enableModules(); - } - } - } - - private final NestedSet hdrs; - private final NestedSet textualHdrs; - private final NestedSet includes; - private final NestedSet sdkIncludes; - private final NestedSet sdkFrameworks; - private final NestedSet weakSdkFrameworks; - private final NestedSet sdkDylibs; - private final Optional packageFragment; - private final ImmutableList copts; - private final ImmutableList linkopts; - private final ImmutableList linkInputs; - private final ImmutableList defines; - private final boolean enableModules; - - private CompilationAttributes( - NestedSet hdrs, - NestedSet textualHdrs, - NestedSet includes, - NestedSet sdkIncludes, - NestedSet sdkFrameworks, - NestedSet weakSdkFrameworks, - NestedSet sdkDylibs, - Optional packageFragment, - ImmutableList copts, - ImmutableList linkopts, - ImmutableList linkInputs, - ImmutableList defines, - boolean enableModules) { - this.hdrs = hdrs; - this.textualHdrs = textualHdrs; - this.includes = includes; - this.sdkIncludes = sdkIncludes; - this.sdkFrameworks = sdkFrameworks; - this.weakSdkFrameworks = weakSdkFrameworks; - this.sdkDylibs = sdkDylibs; - this.packageFragment = packageFragment; - this.copts = copts; - this.linkopts = linkopts; - this.linkInputs = linkInputs; - this.defines = defines; - this.enableModules = enableModules; - } - - /** - * Returns the headers to be made available for dependents. - */ - public NestedSet hdrs() { - return this.hdrs; - } - - @StarlarkMethod(name = "hdrs", documented = false, structField = true) - public Depset hdrsForStarlark() { - return Depset.of(Artifact.class, hdrs()); - } - - @StarlarkMethod(name = "textual_hdrs", documented = false, structField = true) - public Depset textualHdrsForStarlark() { - return Depset.of(Artifact.class, textualHdrs()); - } - - /** - * Returns the headers that cannot be compiled individually. - */ - public NestedSet textualHdrs() { - return this.textualHdrs; - } - - /** - * Returns the include paths to be made available for compilation. - */ - public NestedSet includes() { - return this.includes; - } - - @StarlarkMethod(name = "includes", documented = false, structField = true) - public Depset includesForStarlark() { - return Depset.of( - String.class, - NestedSetBuilder.wrap( - Order.COMPILE_ORDER, - includes().toList().stream() - .map(PathFragment::getSafePathString) - .collect(ImmutableList.toImmutableList()))); - } - - @StarlarkMethod(name = "sdk_includes", documented = false, structField = true) - public Depset sdkIncludesForStarlark() { - return Depset.of( - String.class, - NestedSetBuilder.wrap( - Order.COMPILE_ORDER, - sdkIncludes().toList().stream() - .map(PathFragment::getSafePathString) - .collect(ImmutableList.toImmutableList()))); - } - - /** - * Returns the paths for SDK includes. - */ - public NestedSet sdkIncludes() { - return this.sdkIncludes; - } - - /** Returns the SDK frameworks to link against. */ - public NestedSet sdkFrameworks() { - return this.sdkFrameworks; - } - - @StarlarkMethod(name = "sdk_frameworks", documented = false, structField = true) - public Depset sdkFrameworksForStarlark() { - return Depset.of(String.class, sdkFrameworks); - } - - @StarlarkMethod(name = "weak_sdk_frameworks", documented = false, structField = true) - public Depset weakSdkFrameworksForStarlark() { - return Depset.of(String.class, weakSdkFrameworks); - } - - /** Returns the SDK frameworks to be linked weakly. */ - public NestedSet weakSdkFrameworks() { - return this.weakSdkFrameworks; - } - - @StarlarkMethod(name = "sdk_dylibs", documented = false, structField = true) - public Depset sdkDylibsForStarlark() { - return Depset.of(String.class, sdkDylibs); - } - - /** - * Returns the SDK Dylibs to link against. - */ - public NestedSet sdkDylibs() { - return this.sdkDylibs; - } - - @StarlarkMethod( - name = "header_search_paths", - documented = false, - parameters = { - @Param(name = "genfiles_dir", positional = false, named = true), - }) - public Depset headerSearchPathsForStarlark(String genfilesDir) { - return Depset.of( - String.class, - NestedSetBuilder.stableOrder() - .addAll( - headerSearchPaths(PathFragment.create(genfilesDir)).toList().stream() - .map(PathFragment::toString) - .collect(ImmutableList.toImmutableList())) - .build()); - } - - /** - * Returns the exec paths of all header search paths that should be added to this target and - * dependers on this target, obtained from the {@code includes} attribute. - */ - public NestedSet headerSearchPaths(PathFragment genfilesFragment) { - NestedSetBuilder paths = NestedSetBuilder.stableOrder(); - if (packageFragment.isPresent()) { - PathFragment packageFrag = packageFragment.get(); - PathFragment genfilesFrag = genfilesFragment.getRelative(packageFrag); - for (PathFragment include : includes().toList()) { - if (!include.isAbsolute()) { - paths.add(packageFrag.getRelative(include)); - paths.add(genfilesFrag.getRelative(include)); - } - } - } - return paths.build(); - } - - /** - * Returns the compile-time options. - */ - public ImmutableList copts() { - return this.copts; - } - - @StarlarkMethod(name = "copts", documented = false, structField = true) - public Sequence getCoptsForStarlark() { - return StarlarkList.immutableCopyOf(copts()); - } - - /** - * Returns the link-time options. - */ - public ImmutableList linkopts() { - return this.linkopts; - } - - /** Returns the additional link inputs. */ - public ImmutableList linkInputs() { - return this.linkInputs; - } - - @StarlarkMethod(name = "defines", documented = false, structField = true) - public Sequence getDefinesForStarlark() { - return StarlarkList.immutableCopyOf(defines()); - } - - /** Returns the defines. */ - public ImmutableList defines() { - return this.defines; - } - - /** - * Returns whether this target uses language features that require clang modules, such as - * {@literal @}import. - */ - @StarlarkMethod(name = "enable_modules", documented = false, structField = true) - public boolean enableModules() { - return this.enableModules; - } -} diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkInternal.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkInternal.java index ad60a8249efa37..da0bb9e0ae671e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkInternal.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkInternal.java @@ -23,7 +23,6 @@ import com.google.devtools.build.lib.analysis.Expander; import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue; import com.google.devtools.build.lib.analysis.starlark.StarlarkRuleContext; -import com.google.devtools.build.lib.packages.Types; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; import java.util.List; @@ -57,41 +56,6 @@ public static T convertFromNoneable(Object obj, @Nullable T defaultValue) { return (T) obj; } - @StarlarkMethod( - name = "create_compilation_attributes", - documented = false, - parameters = { - @Param(name = "ctx", positional = false, named = true), - }) - public CompilationAttributes createCompilationAttributes(StarlarkRuleContext starlarkRuleContext) - throws EvalException, InterruptedException { - CompilationAttributes.Builder builder = new CompilationAttributes.Builder(); - - CompilationAttributes.Builder.addHeadersFromRuleContext( - builder, starlarkRuleContext.getRuleContext()); - CompilationAttributes.Builder.addIncludesFromRuleContext( - builder, starlarkRuleContext.getRuleContext()); - CompilationAttributes.Builder.addSdkAttributesFromRuleContext( - builder, starlarkRuleContext.getRuleContext()); - if (starlarkRuleContext.getRuleContext().attributes().has("copts")) { - Sequence copts = - expandAndTokenize( - starlarkRuleContext, - "copts", - StarlarkList.immutableCopyOf( - starlarkRuleContext - .getRuleContext() - .attributes() - .get("copts", Types.STRING_LIST))); - CompilationAttributes.Builder.addCompileOptionsFromRuleContext( - builder, starlarkRuleContext.getRuleContext(), copts); - } - CompilationAttributes.Builder.addModuleOptionsFromRuleContext( - builder, starlarkRuleContext.getRuleContext()); - - return builder.build(); - } - /** * Run variable expansion and shell tokenization on a sequence of flags. * diff --git a/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl b/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl index b6802f1d1a7d26..a37dc5b7b53dca 100644 --- a/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl +++ b/src/main/starlark/builtins_bzl/common/objc/compilation_support.bzl @@ -42,6 +42,31 @@ def _build_variable_extensions(ctx, arc_enabled): return extensions +def _create_compilation_attributes(ctx): + disallow_sdk_frameworks = ctx.fragments.objc.disallow_sdk_frameworks_attributes + sdk_frameworks = getattr(ctx.attr, "sdk_frameworks", []) + weak_sdk_frameworks = getattr(ctx.attr, "weak_sdk_frameworks", []) + if disallow_sdk_frameworks: + if sdk_frameworks: + fail("sdk_frameworks attribute is disallowed. Use explicit dependencies instead.") + if weak_sdk_frameworks: + fail("weak_sdk_frameworks attribute is disallowed. Use explicit dependencies instead.") + + return struct( + hdrs = depset([artifact for artifact, _ in cc_helper.get_public_hdrs(ctx)]), + textual_hdrs = depset(getattr(ctx.files, "textual_hdrs", [])), + sdk_includes = depset(getattr(ctx.attr, "sdk_includes", [])), + includes = depset(getattr(ctx.attr, "includes", [])), + sdk_frameworks = depset(sdk_frameworks), + weak_sdk_frameworks = depset(weak_sdk_frameworks), + sdk_dylibs = depset(getattr(ctx.attr, "sdk_dylibs", [])), + linkopts = objc_internal.expand_and_tokenize(ctx = ctx, attr = "linkopts", flags = getattr(ctx.attr, "linkopts", [])), + copts = objc_internal.expand_and_tokenize(ctx = ctx, attr = "copts", flags = getattr(ctx.attr, "copts", [])), + additional_linker_inputs = getattr(ctx.files, "additional_linker_inputs", []), + defines = objc_internal.expand_and_tokenize(ctx = ctx, attr = "defines", flags = getattr(ctx.attr, "defines", [])), + enable_modules = getattr(ctx.attr, "enable_modules", False), + ) + def _build_common_variables( ctx, toolchain, @@ -55,7 +80,7 @@ def _build_common_variables( alwayslink = False, has_module_map = False, direct_cc_compilation_contexts = []): - compilation_attributes = objc_internal.create_compilation_attributes(ctx = ctx) + compilation_attributes = _create_compilation_attributes(ctx = ctx) intermediate_artifacts = create_intermediate_artifacts(ctx = ctx) if empty_compilation_artifacts: compilation_artifacts = CompilationArtifactsInfo() @@ -250,7 +275,7 @@ def _register_compile_and_archive_actions_for_j2objc( objc_compilation_context, cc_linking_contexts, extra_compile_args): - compilation_attributes = objc_internal.create_compilation_attributes(ctx = ctx) + compilation_attributes = _create_compilation_attributes(ctx = ctx) objc_linking_context = struct( cc_linking_contexts = cc_linking_contexts, diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkTest.java index baec12578d2d95..b0aeebc5410769 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkTest.java @@ -1498,9 +1498,11 @@ public void testDisallowSDKFrameworkAttribute() throws Exception { assertThat(e) .hasMessageThat() .contains( - "ERROR /workspace/examples/apple_starlark/BUILD:1:13: in sdk_frameworks attribute of" - + " objc_library rule //examples/apple_starlark:lib: sdk_frameworks attribute is" - + " disallowed. Use explicit dependencies instead."); + "ERROR /workspace/examples/apple_starlark/BUILD:1:13: " + + "in objc_library rule //examples/apple_starlark:lib:"); + + assertContainsEvent( + "sdk_frameworks attribute is disallowed. Use explicit dependencies instead."); } @Test @@ -1522,9 +1524,11 @@ public void testDisallowWeakSDKFrameworksAttribute() throws Exception { assertThat(e) .hasMessageThat() .contains( - "ERROR /workspace/examples/apple_starlark/BUILD:1:13: in weak_sdk_frameworks attribute" - + " of objc_library rule //examples/apple_starlark:lib: weak_sdk_frameworks" - + " attribute is disallowed. Use explicit dependencies instead."); + "ERROR /workspace/examples/apple_starlark/BUILD:1:13: " + + "in objc_library rule //examples/apple_starlark:lib:"); + + assertContainsEvent( + "weak_sdk_frameworks attribute is disallowed. Use explicit dependencies instead."); } @Test