diff --git a/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java b/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java index 619db4aec1537b..4a5ff482d0e9c2 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java +++ b/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java @@ -557,18 +557,6 @@ public class BuildLanguageOptions extends OptionsBase implements Serializable { + "instead of linkopts to cc_toolchain_config") public boolean incompatibleLinkoptsToLinklibs; - @Option( - name = "incompatible_objc_provider_remove_compile_info", - defaultValue = "true", - documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS, - effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS}, - metadataTags = { - OptionMetadataTag.INCOMPATIBLE_CHANGE, - OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES - }, - help = "If set to true, the ObjcProvider's APIs for compile info/merge_zip will be removed.") - public boolean incompatibleObjcProviderRemoveCompileInfo; - @Option( name = "incompatible_java_common_parameters", defaultValue = "false", @@ -660,9 +648,6 @@ public StarlarkSemantics toStarlarkSemantics() { .setBool(INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API, incompatibleRequireLinkerInputCcApi) .setBool(INCOMPATIBLE_RESTRICT_STRING_ESCAPES, incompatibleRestrictStringEscapes) .setBool(INCOMPATIBLE_LINKOPTS_TO_LINKLIBS, incompatibleLinkoptsToLinklibs) - .setBool( - INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO, - incompatibleObjcProviderRemoveCompileInfo) .set(MAX_COMPUTATION_STEPS, maxComputationSteps) .build(); return INTERNER.intern(semantics); @@ -722,8 +707,6 @@ public StarlarkSemantics toStarlarkSemantics() { "-incompatible_no_implicit_file_export"; public static final String INCOMPATIBLE_NO_RULE_OUTPUTS_PARAM = "-incompatible_no_rule_outputs_param"; - public static final String INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO = - "+incompatible_objc_provider_remove_compile_info"; public static final String INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API = "+incompatible_require_linker_input_cc_api"; public static final String INCOMPATIBLE_RESTRICT_STRING_ESCAPES = diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStarlarkCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStarlarkCommon.java index 39fa8e5b988f84..fad0237256f07f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStarlarkCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleStarlarkCommon.java @@ -32,7 +32,6 @@ import com.google.devtools.build.lib.packages.StarlarkAspect; import com.google.devtools.build.lib.packages.StarlarkInfo; import com.google.devtools.build.lib.packages.StructImpl; -import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.ApplePlatform; import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType; @@ -50,7 +49,6 @@ import net.starlark.java.eval.Sequence; import net.starlark.java.eval.Starlark; import net.starlark.java.eval.StarlarkInt; -import net.starlark.java.eval.StarlarkSemantics; import net.starlark.java.eval.StarlarkThread; import net.starlark.java.eval.StarlarkValue; import net.starlark.java.syntax.Location; @@ -69,19 +67,9 @@ public class AppleStarlarkCommon public static final String DEPRECATED_KEY_ERROR = "Key '%s' no longer supported in ObjcProvider (use CcInfo instead)."; - @VisibleForTesting - public static final String BAD_DIRECT_DEP_PROVIDERS_ERROR = - "Argument 'direct_dep_providers' no longer supported. Please use 'strict_include' field " - + "in ObjcProvider."; - @VisibleForTesting public static final String BAD_KEY_ERROR = - "Argument %s not a recognized key," - + " 'strict_include', 'providers', or 'direct_dep_providers'."; - - @VisibleForTesting - public static final String BAD_FRAMEWORK_PATH_ERROR = - "Value for key framework_search_paths must end in .framework; instead found %s."; + "Argument %s not a recognized key, 'strict_include', or 'providers'."; @VisibleForTesting public static final String BAD_PROVIDERS_ITER_ERROR = @@ -92,16 +80,9 @@ public class AppleStarlarkCommon "Value for argument 'providers' must be a list of ObjcProvider instances, instead found " + "iterable with %s."; - @VisibleForTesting - public static final String BAD_DIRECT_DEPENDENCY_KEY_ERROR = - "Key %s not allowed to be in direct_dep_provider."; - @VisibleForTesting public static final String NOT_SET_ERROR = "Value for key %s must be a set, instead found %s."; - @VisibleForTesting - public static final String MISSING_KEY_ERROR = "No value for required key %s was present."; - @Nullable private StructImpl platformType; @Nullable private StructImpl platform; @@ -200,8 +181,8 @@ public SplitTransitionProviderApi getMultiArchSplitProvider() { // This method is registered statically for Starlark, and never called directly. public ObjcProvider newObjcProvider( Boolean usesSwift, Dict kwargs, StarlarkThread thread) throws EvalException { - StarlarkSemantics semantics = thread.getSemantics(); - ObjcProvider.StarlarkBuilder resultBuilder = new ObjcProvider.StarlarkBuilder(semantics); + ObjcProvider.StarlarkBuilder resultBuilder = + new ObjcProvider.StarlarkBuilder(thread.getSemantics()); if (usesSwift) { resultBuilder.add(ObjcProvider.FLAG, ObjcProvider.Flag.USES_SWIFT); } @@ -213,12 +194,6 @@ public ObjcProvider newObjcProvider( resultBuilder.addStrictIncludeFromStarlark(entry.getValue()); } else if (entry.getKey().equals("providers")) { resultBuilder.addProvidersFromStarlark(entry.getValue()); - } else if (entry.getKey().equals("direct_dep_providers")) { - if (semantics.getBool( - BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO)) { - throw new EvalException(BAD_DIRECT_DEP_PROVIDERS_ERROR); - } - resultBuilder.addDirectDepProvidersFromStarlark(entry.getValue()); } else { throw Starlark.errorf(BAD_KEY_ERROR, entry.getKey()); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java index 34ce90c5bf1419..1c663295a1a6ea 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java @@ -316,10 +316,6 @@ ObjcCommon build() { objcProvider.addAllDirect(HEADER, headerProvider.getDeclaredIncludeSrcs().toList()); } - for (ObjcProvider provider : runtimeDepObjcProviders) { - objcProvider.addTransitiveAndPropagate(ObjcProvider.MERGE_ZIP, provider); - } - for (CcLinkingContext linkProvider : depCcLinkProviders) { ImmutableList linkOpts = linkProvider.getFlattenedUserLinkFlags(); ImmutableSet.Builder frameworkLinkOpts = new ImmutableSet.Builder<>(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java index bb3ed116f6f9a4..481821e3359b65 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java @@ -35,7 +35,6 @@ import com.google.devtools.build.lib.packages.BuiltinProvider; import com.google.devtools.build.lib.packages.BuiltinProvider.WithLegacyStarlarkName; import com.google.devtools.build.lib.packages.Info; -import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions; import com.google.devtools.build.lib.rules.cpp.CcCompilationContext; import com.google.devtools.build.lib.rules.cpp.CcLinkingContext; import com.google.devtools.build.lib.rules.cpp.CppModuleMap; @@ -160,30 +159,11 @@ public Class getType() { public static final Key SOURCE = new Key<>(STABLE_ORDER, "source", Artifact.class); /** - * Include search paths specified with {@code -I} on the command line. Also known as header search - * paths (and distinct from user header search paths). + * Include search paths {@code -I} that are stored specially in their own field, and not + * propagated transitively. */ - public static final Key INCLUDE = - new Key<>(LINK_ORDER, "include", PathFragment.class); - - /** - * Include search paths specified with {@code -iquote} on the command line. Also known as user - * header search paths. - */ - public static final Key IQUOTE = - new Key<>(LINK_ORDER, "iquote", PathFragment.class); - - /** - * Include search paths specified with {@code -isystem} on the command line. - */ - public static final Key INCLUDE_SYSTEM = - new Key<>(LINK_ORDER, "include_system", PathFragment.class); - - /** - * Key for values in {@code defines} attributes. These are passed as {@code -D} flags to all - * invocations of the compiler for this target and all depending targets. - */ - public static final Key DEFINE = new Key<>(STABLE_ORDER, "define", String.class); + public static final Key STRICT_INCLUDE = + new Key<>(LINK_ORDER, "strict_include", PathFragment.class); public static final Key SDK_DYLIB = new Key<>(STABLE_ORDER, "sdk_dylib", String.class); public static final Key SDK_FRAMEWORK = @@ -214,23 +194,6 @@ public Class getType() { public static final Key TOP_LEVEL_MODULE_MAP = new Key<>(STABLE_ORDER, "top_level_module_map", CppModuleMap.class); - /** - * Merge zips to include in the bundle. The entries of these zip files are included in the final - * bundle with the same path. The entries in the merge zips should not include the bundle root - * path (e.g. {@code Foo.app}). - */ - public static final Key MERGE_ZIP = - new Key<>(STABLE_ORDER, "merge_zip", Artifact.class); - - /** - * Exec paths of {@code .framework} directories corresponding to frameworks to include in search - * paths, but not to link. These cause -F arguments (framework search paths) to be added to each - * compile action, but do not cause -framework (link framework) arguments to be added to link - * actions. - */ - public static final Key FRAMEWORK_SEARCH_PATHS = - new Key<>(LINK_ORDER, "framework_search_paths", PathFragment.class); - /** The static library files of user-specified static frameworks. */ public static final Key STATIC_FRAMEWORK_FILE = new Key<>(STABLE_ORDER, "static_framework_file", Artifact.class); @@ -319,27 +282,14 @@ public enum Flag { private final CcCompilationContext ccCompilationContext; - /** - * Keys that are deprecated and will be removed. These include compile information that has been - * migrated to CcCompilationContext, plus MERGE_ZIP. - */ - static final ImmutableSet> DEPRECATED_KEYS = - ImmutableSet.>of( - DEFINE, FRAMEWORK_SEARCH_PATHS, HEADER, INCLUDE, INCLUDE_SYSTEM, IQUOTE, MERGE_ZIP); - /** All keys in ObjcProvider that will be passed in the corresponding Starlark provider. */ static final ImmutableList> KEYS_FOR_STARLARK = ImmutableList.>of( - DEFINE, DYNAMIC_FRAMEWORK_FILE, EXPORTED_DEBUG_ARTIFACTS, - FRAMEWORK_SEARCH_PATHS, FORCE_LOAD_LIBRARY, HEADER, IMPORTED_LIBRARY, - INCLUDE, - INCLUDE_SYSTEM, - IQUOTE, J2OBJC_LIBRARY, JRE_LIBRARY, LIBRARY, @@ -347,7 +297,6 @@ public enum Flag { LINKED_BINARY, LINKMAP_FILE, LINKOPT, - MERGE_ZIP, MODULE_MAP, MULTI_ARCH_DYNAMIC_LIBRARIES, MULTI_ARCH_LINKED_ARCHIVES, @@ -375,15 +324,13 @@ public enum Flag { static final ImmutableSet> KEYS_FOR_DIRECT = ImmutableSet.>of(HEADER, MODULE_MAP, SOURCE); + /** Keys that are only used for direct fields, and nothing else. */ + static final ImmutableSet> KEYS_FOR_DIRECT_ONLY = ImmutableSet.>of(HEADER); + public ImmutableList getStrictDependencyIncludes() { return strictDependencyIncludes; } - @Override - public Depset /**/ defineForStarlark() { - return getCcCompilationContext().getStarlarkDefines(); - } - public NestedSet define() { return getCcCompilationContext().getDefines(); } @@ -402,21 +349,6 @@ NestedSet dynamicFrameworkFile() { return Depset.of(Artifact.TYPE, get(EXPORTED_DEBUG_ARTIFACTS)); } - @Override - public Depset frameworkIncludeForStarlark() { - // Starlark code expects the framework path to include the ".framework" directory, which is then - // stripped to get the actual framework search path. CcCompilationContext only stores the - // framework search path, so the best we can do is to append a fake ".framework" directory. - // This at least preserves the behavior when the field is used for its intended purpose. - return Depset.of( - Depset.ElementType.STRING, - NestedSetBuilder.wrap( - Order.STABLE_ORDER, - frameworkInclude().stream() - .map(x -> x.getChild("fake.framework").getSafePathString()) - .collect(ImmutableList.toImmutableList()))); - } - public ImmutableList frameworkInclude() { return getCcCompilationContext().getFrameworkIncludeDirs(); } @@ -426,11 +358,6 @@ public ImmutableList frameworkInclude() { return Depset.of(Artifact.TYPE, get(FORCE_LOAD_LIBRARY)); } - @Override - public Depset /**/ headerForStarlark() { - return Depset.of(Artifact.TYPE, header()); - } - public NestedSet header() { return getCcCompilationContext().getDeclaredIncludeSrcs(); } @@ -445,17 +372,6 @@ public Sequence directHeaders() { return Depset.of(Artifact.TYPE, get(IMPORTED_LIBRARY)); } - @Override - public Depset /**/ includeForStarlark() { - return Depset.of( - Depset.ElementType.STRING, - NestedSetBuilder.wrap( - Order.STABLE_ORDER, - include().stream() - .map(PathFragment::getSafePathString) - .collect(ImmutableList.toImmutableList()))); - } - public ImmutableList include() { ImmutableList.Builder listBuilder = ImmutableList.builder(); return listBuilder @@ -475,20 +391,10 @@ public ImmutableList include() { .collect(ImmutableList.toImmutableList()))); } - @Override - public Depset systemIncludeForStarlark() { - return getCcCompilationContext().getStarlarkSystemIncludeDirs(); - } - public ImmutableList systemInclude() { return getCcCompilationContext().getSystemIncludeDirs(); } - @Override - public Depset quoteIncludeForStarlark() { - return getCcCompilationContext().getStarlarkQuoteIncludeDirs(); - } - public ImmutableList quoteInclude() { return getCcCompilationContext().getQuoteIncludeDirs(); } @@ -528,11 +434,6 @@ public ImmutableList quoteInclude() { return Depset.of(Depset.ElementType.STRING, get(LINKOPT)); } - @Override - public Depset /**/ mergeZip() { - return Depset.of(Artifact.TYPE, get(MERGE_ZIP)); - } - @Override public Depset /**/ moduleMap() { return Depset.of(Artifact.TYPE, get(MODULE_MAP)); @@ -604,7 +505,6 @@ public Depset weakSdkFramework() { WEAK_SDK_FRAMEWORK, get(WEAK_SDK_FRAMEWORK)); } - @Override public CcCompilationContext getCcCompilationContext() { return ccCompilationContext; } @@ -623,7 +523,9 @@ public CcCompilationContext getCcCompilationContext() { // Flag enum is not exposed to Starlark. FLAG, // CppModuleMap is not exposed to Starlark. - TOP_LEVEL_MODULE_MAP); + TOP_LEVEL_MODULE_MAP, + // Strict include is handled specially. + STRICT_INCLUDE); /** * Set of {@link ObjcProvider} whose values are not subtracted via {@link #subtractSubtrees}. @@ -636,15 +538,8 @@ public CcCompilationContext getCcCompilationContext() { */ private static final ImmutableSet> NON_SUBTRACTABLE_KEYS = ImmutableSet.>of( - DEFINE, DYNAMIC_FRAMEWORK_FILE, FLAG, - MERGE_ZIP, - FRAMEWORK_SEARCH_PATHS, - HEADER, - INCLUDE, - INCLUDE_SYSTEM, - IQUOTE, LINKOPT, LINK_INPUTS, SDK_DYLIB, @@ -994,10 +889,6 @@ public Builder(StarlarkSemantics semantics) { this.starlarkSemantics = semantics; } - public StarlarkSemantics getStarlarkSemantics() { - return starlarkSemantics; - } - private static void maybeAddEmptyBuilder(Map, NestedSetBuilder> set, Key key) { set.computeIfAbsent(key, k -> new NestedSetBuilder<>(k.order)); } @@ -1061,44 +952,6 @@ public Builder addTransitiveAndPropagate(Key key, NestedSet items) { return this; } - /** Return an EvalException for having a bad key in the direct dependency provider. */ - private static EvalException badDirectDependencyKeyError(Key key) { - return Starlark.errorf( - AppleStarlarkCommon.BAD_DIRECT_DEPENDENCY_KEY_ERROR, key.getStarlarkKeyName()); - } - - /** - * Propagate keys and values from the given provider to direct dependers of this ObjcProvider. - * We no longer support this generically -- the only remaining use case we support is for - * includes. - */ - public Builder addAsDirectDeps(ObjcProvider provider) throws EvalException { - CcCompilationContext providerCcCompilationContext = provider.getCcCompilationContext(); - - strictDependencyIncludes.addAll(providerCcCompilationContext.getIncludeDirs()); - - // Emit an error if we find any other information in the provider. - for (Key key : provider.items.keySet()) { - throw badDirectDependencyKeyError(key); - } - if (!provider.define().isEmpty()) { - throw badDirectDependencyKeyError(DEFINE); - } - if (!provider.header().isEmpty()) { - throw badDirectDependencyKeyError(HEADER); - } - if (!providerCcCompilationContext.getFrameworkIncludeDirs().isEmpty()) { - throw badDirectDependencyKeyError(FRAMEWORK_SEARCH_PATHS); - } - if (!providerCcCompilationContext.getSystemIncludeDirs().isEmpty()) { - throw badDirectDependencyKeyError(INCLUDE_SYSTEM); - } - if (!providerCcCompilationContext.getQuoteIncludeDirs().isEmpty()) { - throw badDirectDependencyKeyError(IQUOTE); - } - return this; - } - /** * Add element, and propagate it to any (transitive) dependers on this ObjcProvider. */ @@ -1191,19 +1044,7 @@ public StarlarkBuilder(StarlarkSemantics semantics) { */ void addElementsFromStarlark(Key key, Object starlarkToAdd) throws EvalException { NestedSet toAdd = ObjcProviderStarlarkConverters.convertToJava(key, starlarkToAdd); - if (DEPRECATED_KEYS.contains(key)) { - if (getStarlarkSemantics() - .getBool(BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO)) { - if (!KEYS_FOR_DIRECT.contains(key)) { - throw Starlark.errorf( - AppleStarlarkCommon.DEPRECATED_KEY_ERROR, key.getStarlarkKeyName()); - } - } else { - if (!addCompileElementsFromStarlark(key, starlarkToAdd)) { - uncheckedAddTransitive(key, toAdd); - } - } - } else { + if (!KEYS_FOR_DIRECT_ONLY.contains(key)) { uncheckedAddTransitive(key, toAdd); } @@ -1212,63 +1053,6 @@ void addElementsFromStarlark(Key key, Object starlarkToAdd) throws EvalExcept } } - private boolean addCompileElementsFromStarlark(Key key, Object starlarkToAdd) - throws EvalException { - String keyName = key.getStarlarkKeyName(); - - if (key == DEFINE) { - ccCompilationContextBuilder.addDefines( - Depset.noneableCast(starlarkToAdd, String.class, keyName)); - return true; - } else if (key == FRAMEWORK_SEARCH_PATHS) { - // Due to legacy reasons, There is a mismatch between the starlark interface for the - // framework search path, and the internal representation. The interface specifies that - // framework_search_paths include the framework directories, but internally we only store - // their parents. We will eventually clean up the interface, but for now we need to do - // this ugly conversion. - - ImmutableList frameworks = - Depset.noneableCast(starlarkToAdd, String.class, keyName).toList().stream() - .map(PathFragment::create) - .collect(ImmutableList.toImmutableList()); - - ImmutableList.Builder frameworkSearchPaths = ImmutableList.builder(); - for (PathFragment framework : frameworks) { - if (!framework.getSafePathString().endsWith(FRAMEWORK_SUFFIX)) { - throw Starlark.errorf(AppleStarlarkCommon.BAD_FRAMEWORK_PATH_ERROR, framework); - } - frameworkSearchPaths.add(framework.getParentDirectory()); - } - ccCompilationContextBuilder.addFrameworkIncludeDirs(frameworkSearchPaths.build()); - return true; - } else if (key == HEADER) { - ImmutableList hdrs = - Depset.noneableCast(starlarkToAdd, Artifact.class, keyName).toList(); - ccCompilationContextBuilder.addDeclaredIncludeSrcs(hdrs); - ccCompilationContextBuilder.addTextualHdrs(hdrs); - return true; - } else if (key == INCLUDE) { - ccCompilationContextBuilder.addIncludeDirs( - Depset.noneableCast(starlarkToAdd, String.class, keyName).toList().stream() - .map(PathFragment::create) - .collect(ImmutableList.toImmutableList())); - return true; - } else if (key == INCLUDE_SYSTEM) { - ccCompilationContextBuilder.addSystemIncludeDirs( - Depset.noneableCast(starlarkToAdd, String.class, keyName).toList().stream() - .map(PathFragment::create) - .collect(ImmutableList.toImmutableList())); - return true; - } else if (key == IQUOTE) { - ccCompilationContextBuilder.addQuoteIncludeDirs( - Depset.noneableCast(starlarkToAdd, String.class, keyName).toList().stream() - .map(PathFragment::create) - .collect(ImmutableList.toImmutableList())); - return true; - } - return false; - } - /** * Adds the given providers from Starlark. An error is thrown if toAdd is not an iterable of * ObjcProvider instances. @@ -1293,27 +1077,6 @@ void addProvidersFromStarlark(Object toAdd) throws EvalException { } } - /** - * Adds the given providers from Starlark, but propagate any normally-propagated items only to - * direct dependers. An error is thrown if toAdd is not an iterable of ObjcProvider instances. - */ - @SuppressWarnings("unchecked") - void addDirectDepProvidersFromStarlark(Object toAdd) throws EvalException { - if (!(toAdd instanceof Iterable)) { - throw Starlark.errorf(AppleStarlarkCommon.BAD_PROVIDERS_ITER_ERROR, Starlark.type(toAdd)); - } else { - Iterable toAddIterable = (Iterable) toAdd; - for (Object toAddObject : toAddIterable) { - if (!(toAddObject instanceof ObjcProvider)) { - throw Starlark.errorf( - AppleStarlarkCommon.BAD_PROVIDERS_ELEM_ERROR, Starlark.type(toAddObject)); - } else { - this.addAsDirectDeps((ObjcProvider) toAddObject); - } - } - } - } - /** * Adds the given strict include paths from Starlark. An error is thrown if starlarkToAdd is not * an appropriate Depset. @@ -1322,7 +1085,7 @@ void addDirectDepProvidersFromStarlark(Object toAdd) throws EvalException { void addStrictIncludeFromStarlark(Object starlarkToAdd) throws EvalException { NestedSet toAdd = (NestedSet) - ObjcProviderStarlarkConverters.convertToJava(INCLUDE, starlarkToAdd); + ObjcProviderStarlarkConverters.convertToJava(STRICT_INCLUDE, starlarkToAdd); addStrictDependencyIncludes(toAdd.toList()); } diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ObjcProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ObjcProviderApi.java index d413c5ca20f0ee..5aba78bf934915 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ObjcProviderApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ObjcProviderApi.java @@ -16,9 +16,7 @@ import com.google.devtools.build.docgen.annot.DocCategory; import com.google.devtools.build.lib.collect.nestedset.Depset; -import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions; import com.google.devtools.build.lib.starlarkbuildapi.FileApi; -import com.google.devtools.build.lib.starlarkbuildapi.cpp.CcCompilationContextApi; import net.starlark.java.annot.StarlarkBuiltin; import net.starlark.java.annot.StarlarkMethod; import net.starlark.java.eval.Sequence; @@ -34,15 +32,6 @@ doc = "A provider for compilation and linking of objc.") public interface ObjcProviderApi extends StarlarkValue { - @StarlarkMethod( - name = "define", - structField = true, - doc = - "A set of strings from 'defines' attributes. These are to be passed as '-D' flags to " - + "all invocations of the compiler for this target and all depending targets.", - disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO) - Depset /**/ defineForStarlark(); - @StarlarkMethod( name = "dynamic_framework_file", structField = true, @@ -57,28 +46,12 @@ public interface ObjcProviderApi extends StarlarkValue doc = "Debug files that should be exported by the top-level target.") Depset /**/ exportedDebugArtifacts(); - @StarlarkMethod( - name = "framework_search_path_only", - structField = true, - doc = - "Exec paths of .framework directories corresponding to frameworks to include " - + "in search paths, but not to link.", - disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO) - Depset /**/ frameworkIncludeForStarlark(); - @StarlarkMethod( name = "force_load_library", structField = true, doc = "Libraries to load with -force_load.") Depset /**/ forceLoadLibrary(); - @StarlarkMethod( - name = "header", - structField = true, - doc = "All header files. These may be either public or private headers.", - disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO) - Depset /**/ headerForStarlark(); - @StarlarkMethod( name = "direct_headers", structField = true, @@ -93,15 +66,6 @@ public interface ObjcProviderApi extends StarlarkValue doc = "Imported precompiled static libraries (.a files) to be linked into the binary.") Depset /**/ importedLibrary(); - @StarlarkMethod( - name = "include", - structField = true, - doc = - "Include search paths specified with '-I' on the command line. Also known as " - + "header search paths (and distinct from user header search paths).", - disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO) - Depset includeForStarlark(); - @StarlarkMethod( name = "strict_include", structField = true, @@ -110,20 +74,6 @@ public interface ObjcProviderApi extends StarlarkValue + "as header search paths (and distinct from user header search paths).") Depset strictIncludeForStarlark(); - @StarlarkMethod( - name = "include_system", - structField = true, - doc = "System include search paths (typically specified with -isystem).", - disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO) - Depset systemIncludeForStarlark(); - - @StarlarkMethod( - name = "iquote", - structField = true, - doc = "User header search paths (typically specified with -iquote).", - disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO) - Depset quoteIncludeForStarlark(); - @StarlarkMethod( name = "j2objc_library", structField = true, @@ -169,16 +119,6 @@ public interface ObjcProviderApi extends StarlarkValue @StarlarkMethod(name = "linkopt", structField = true, doc = "Linking options.") Depset /**/ linkopt(); - @StarlarkMethod( - name = "merge_zip", - structField = true, - doc = - "Merge zips to include in the bundle. The entries of these zip files are included " - + "in the final bundle with the same path. The entries in the merge zips should not " - + "include the bundle root path (e.g. 'Foo.app').", - disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO) - Depset /**/ mergeZip(); - @StarlarkMethod( name = "module_map", structField = true, @@ -280,13 +220,4 @@ public interface ObjcProviderApi extends StarlarkValue structField = true, doc = "Returns all framework paths to static frameworks in this provider.") Depset /**/ staticFrameworkPathsForStarlark(); - - @StarlarkMethod( - name = "compilation_context", - doc = - "Returns the embedded CcCompilationContext that contains the" - + "provider's compilation information.", - structField = true, - disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO) - CcCompilationContextApi getCcCompilationContext(); } diff --git a/src/main/java/com/google/devtools/build/skydoc/fakebuildapi/apple/FakeObjcProvider.java b/src/main/java/com/google/devtools/build/skydoc/fakebuildapi/apple/FakeObjcProvider.java index 171200422fef9d..c4118740a2cea3 100644 --- a/src/main/java/com/google/devtools/build/skydoc/fakebuildapi/apple/FakeObjcProvider.java +++ b/src/main/java/com/google/devtools/build/skydoc/fakebuildapi/apple/FakeObjcProvider.java @@ -17,7 +17,6 @@ import com.google.devtools.build.lib.collect.nestedset.Depset; import com.google.devtools.build.lib.starlarkbuildapi.FileApi; import com.google.devtools.build.lib.starlarkbuildapi.apple.ObjcProviderApi; -import com.google.devtools.build.lib.starlarkbuildapi.cpp.CcCompilationContextApi; import net.starlark.java.eval.Printer; import net.starlark.java.eval.Sequence; @@ -26,11 +25,6 @@ */ public class FakeObjcProvider implements ObjcProviderApi { - @Override - public Depset /**/ defineForStarlark() { - return null; - } - @Override public Depset /**/ dynamicFrameworkFileForStarlark() { return null; @@ -41,21 +35,11 @@ public class FakeObjcProvider implements ObjcProviderApi { return null; } - @Override - public Depset frameworkIncludeForStarlark() { - return null; - } - @Override public Depset /**/ forceLoadLibrary() { return null; } - @Override - public Depset /**/ headerForStarlark() { - return null; - } - @Override public Sequence directHeaders() { return null; @@ -66,26 +50,11 @@ public Sequence directHeaders() { return null; } - @Override - public Depset includeForStarlark() { - return null; - } - @Override public Depset /**/ strictIncludeForStarlark() { return null; } - @Override - public Depset systemIncludeForStarlark() { - return null; - } - - @Override - public Depset quoteIncludeForStarlark() { - return null; - } - @Override public Depset /**/ j2objcLibrary() { return null; @@ -121,11 +90,6 @@ public Depset quoteIncludeForStarlark() { return null; } - @Override - public Depset /**/ mergeZip() { - return null; - } - @Override public Depset /**/ moduleMap() { return null; @@ -186,11 +150,6 @@ public Depset weakSdkFramework() { return null; } - @Override - public CcCompilationContextApi getCcCompilationContext() { - return null; - } - @Override public Depset /**/ dynamicFrameworkNamesForStarlark() { return null; diff --git a/src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java index 68e212f90e4d30..79124ce7a73e12 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java @@ -149,7 +149,6 @@ private static BuildLanguageOptions buildRandomOptions(Random rand) throws Excep "--incompatible_no_attr_license=" + rand.nextBoolean(), "--incompatible_no_implicit_file_export=" + rand.nextBoolean(), "--incompatible_no_rule_outputs_param=" + rand.nextBoolean(), - "--incompatible_objc_provider_remove_compile_info=" + rand.nextBoolean(), "--incompatible_run_shell_command_string=" + rand.nextBoolean(), "--incompatible_struct_has_no_methods=" + rand.nextBoolean(), "--incompatible_visibility_private_attributes_at_definition=" + rand.nextBoolean(), @@ -205,8 +204,6 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) { .setBool(BuildLanguageOptions.INCOMPATIBLE_NO_ATTR_LICENSE, rand.nextBoolean()) .setBool(BuildLanguageOptions.INCOMPATIBLE_NO_IMPLICIT_FILE_EXPORT, rand.nextBoolean()) .setBool(BuildLanguageOptions.INCOMPATIBLE_NO_RULE_OUTPUTS_PARAM, rand.nextBoolean()) - .setBool( - BuildLanguageOptions.INCOMPATIBLE_OBJC_PROVIDER_REMOVE_COMPILE_INFO, rand.nextBoolean()) .setBool(BuildLanguageOptions.INCOMPATIBLE_RUN_SHELL_COMMAND_STRING, rand.nextBoolean()) .setBool(BuildLanguageOptions.INCOMPATIBLE_STRUCT_HAS_NO_METHODS, rand.nextBoolean()) .setBool( 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 457ea32d53b110..ce0ea0964caa1e 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 @@ -962,7 +962,8 @@ public void testStarlarkCanCreateObjcProviderWithLinkopts() throws Exception { assertThat(foundLinkopts).containsExactly("opt1", "opt2", "opt3"); } - private void testStarlarkCanCreateObjcProviderWithHeaders() throws Exception { + @Test + public void testStarlarkCanCreateObjcProviderWithHeaders() throws Exception { ConfiguredTarget starlarkTarget = createObjcProviderStarlarkTarget( " hdr1 = ctx.actions.declare_file('hdr1')", @@ -982,256 +983,8 @@ private void testStarlarkCanCreateObjcProviderWithHeaders() throws Exception { assertThat(ActionsTestUtil.baseArtifactNames(directHeaders)).containsExactly("hdr1", "hdr2"); } - @Test - public void testStarlarkCanCreateObjcProviderWithHeadersPreAPIRemoval() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - testStarlarkCanCreateObjcProviderWithHeaders(); - } - - @Test - public void testStarlarkCanCreateObjcProviderWithHeadersPostAPIRemoval() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=true"); - testStarlarkCanCreateObjcProviderWithHeaders(); - } - - @Test - public void testStarlarkCanCreateObjcProviderWithIncludePathFragmentsPreAPIRemoval() - throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - ConfiguredTarget starlarkTarget = - createObjcProviderStarlarkTarget( - " includes = depset(['path1', 'path_dir/path2', 'path_dir1/path_dir2/path3'])", - " created_provider = apple_common.new_objc_provider\\", - "(include=includes)", - " return [created_provider]"); - - Iterable foundIncludes = - starlarkTarget.get(ObjcProvider.STARLARK_CONSTRUCTOR).include(); - - assertThat(foundIncludes) - .containsExactly( - PathFragment.create("path1"), - PathFragment.create("path_dir/path2"), - PathFragment.create("path_dir1/path_dir2/path3")); - } - - @Test - public void testStarlarkCanCreateObjcProviderWithFrameworkIncludesPreAPIRemoval() - throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - ConfiguredTarget starlarkTarget = - createObjcProviderStarlarkTarget( - " includes = depset(['path1/foo.framework', 'path_dir/path2/bar.framework'])", - " created_provider = apple_common.new_objc_provider\\", - "(framework_search_paths=includes)", - " return [created_provider]"); - - Iterable foundIncludes = - starlarkTarget.get(ObjcProvider.STARLARK_CONSTRUCTOR).frameworkInclude(); - - assertThat(foundIncludes) - .containsExactly(PathFragment.create("path1"), PathFragment.create("path_dir/path2")); - } - - @Test - public void testStarlarkCanCreateObjcProviderWithSystemIncludesPreAPIRemoval() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - ConfiguredTarget starlarkTarget = - createObjcProviderStarlarkTarget( - " includes = depset(['path1', 'path_dir/path2', 'path_dir1/path_dir2/path3'])", - " created_provider = apple_common.new_objc_provider\\", - "(include_system=includes)", - " return [created_provider]"); - - Iterable foundIncludes = - starlarkTarget.get(ObjcProvider.STARLARK_CONSTRUCTOR).systemInclude(); - - assertThat(foundIncludes) - .containsExactly( - PathFragment.create("path1"), - PathFragment.create("path_dir/path2"), - PathFragment.create("path_dir1/path_dir2/path3")); - } - - @Test - public void testStarlarkCanCreateObjcProviderWithQuoteIncludesPreAPIRemoval() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - ConfiguredTarget starlarkTarget = - createObjcProviderStarlarkTarget( - " includes = depset(['path1', 'path_dir/path2', 'path_dir1/path_dir2/path3'])", - " created_provider = apple_common.new_objc_provider\\", - "(iquote=includes)", - " return [created_provider]"); - - Iterable foundIncludes = - starlarkTarget.get(ObjcProvider.STARLARK_CONSTRUCTOR).quoteInclude(); - - assertThat(foundIncludes) - .containsExactly( - PathFragment.create("path1"), - PathFragment.create("path_dir/path2"), - PathFragment.create("path_dir1/path_dir2/path3")); - } - - @Test - public void testStarlarkCannotCreateObjcProviderWithIncludePathFragmentsPostAPIRemoval() - throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=true"); - AssertionError e = - assertThrows( - AssertionError.class, - () -> - createObjcProviderStarlarkTarget( - " includes = depset(['path'])", - " created_provider = apple_common.new_objc_provider\\", - "(include=includes)", - " return [created_provider]")); - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleStarlarkCommon.DEPRECATED_KEY_ERROR, "include")); - } - - @Test - public void testStarlarkCannotCreateObjcProviderWithDefinePostAPIRemoval() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=true"); - AssertionError e = - assertThrows( - AssertionError.class, - () -> - createObjcProviderStarlarkTarget( - " define = depset(['def'])", - " created_provider = apple_common.new_objc_provider\\", - "(define=define)", - " return [created_provider]")); - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleStarlarkCommon.DEPRECATED_KEY_ERROR, "define")); - } - - @Test - public void testStarlarkCannotCreateObjcProviderWithFrameworkIncludesPostAPIRemoval() - throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=true"); - AssertionError e = - assertThrows( - AssertionError.class, - () -> - createObjcProviderStarlarkTarget( - " includes = depset(['path1/foo.framework'])", - " created_provider = apple_common.new_objc_provider\\", - "(framework_search_paths=includes)", - " return [created_provider]")); - assertThat(e) - .hasMessageThat() - .contains( - String.format(AppleStarlarkCommon.DEPRECATED_KEY_ERROR, "framework_search_paths")); - } - - @Test - public void testStarlarkCannotCreateObjcProviderWithSystemIncludesPostAPIRemoval() - throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=true"); - AssertionError e = - assertThrows( - AssertionError.class, - () -> - createObjcProviderStarlarkTarget( - " includes = depset(['path1'])", - " created_provider = apple_common.new_objc_provider\\", - "(include_system=includes)", - " return [created_provider]")); - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleStarlarkCommon.DEPRECATED_KEY_ERROR, "include_system")); - } - - @Test - public void testStarlarkCannotCreateObjcProviderWithQuoteIncludesPostAPIRemoval() - throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=true"); - AssertionError e = - assertThrows( - AssertionError.class, - () -> - createObjcProviderStarlarkTarget( - " includes = depset(['path1'])", - " created_provider = apple_common.new_objc_provider\\", - "(iquote=includes)", - " return [created_provider]")); - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleStarlarkCommon.DEPRECATED_KEY_ERROR, "iquote")); - } - - @Test - public void testStarlarkCanCreateObjcProviderWithMergeZipsPreAPIRemoval() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - ConfiguredTarget starlarkTarget = - createObjcProviderStarlarkTarget( - " file = ctx.actions.declare_file('file')", - " ctx.actions.run_shell(outputs=[file], command='echo')", - " created_provider = apple_common.new_objc_provider\\", - "(merge_zip = depset([file]))", - " return [created_provider]"); - - Iterable foundMergeZips = - starlarkTarget.get(ObjcProvider.STARLARK_CONSTRUCTOR).get(ObjcProvider.MERGE_ZIP).toList(); - - assertThat(ActionsTestUtil.baseArtifactNames(foundMergeZips)).containsExactly("file"); - } - - @Test - public void testStarlarkCannotCreateObjcProviderWithMergeZipsPostAPIRemoval() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=true"); - AssertionError e = - assertThrows( - AssertionError.class, - () -> - createObjcProviderStarlarkTarget( - " file = ctx.actions.declare_file('file')", - " ctx.actions.run_shell(outputs=[file], command='echo')", - " created_provider = apple_common.new_objc_provider\\", - "(merge_zip = depset([file]))", - " return [created_provider]")); - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleStarlarkCommon.DEPRECATED_KEY_ERROR, "merge_zip")); - } - @Test public void testStarlarkCanCreateObjcProviderWithStrictDeps() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - ConfiguredTarget starlarkTarget = - createObjcProviderStarlarkTarget( - " strict_includes = depset(['path1'])", - " propagated_includes = depset(['path2'])", - " strict_provider = apple_common.new_objc_provider\\", - "(include=strict_includes)", - " created_provider = apple_common.new_objc_provider\\", - "(include=propagated_includes, direct_dep_providers=[strict_provider])", - " return [created_provider]"); - - ObjcProvider starlarkProvider = starlarkTarget.get(ObjcProvider.STARLARK_CONSTRUCTOR); - assertThat(starlarkProvider.include()) - .containsExactly(PathFragment.create("path1"), PathFragment.create("path2")); - assertThat(starlarkProvider.getStrictDependencyIncludes()) - .containsExactly(PathFragment.create("path1")); - - scratch.file( - "examples/objc_starlark2/BUILD", - "objc_library(", - " name = 'direct_dep',", - " deps = ['//examples/objc_starlark:my_target']", - ")"); - - ObjcProvider starlarkProviderDirectDepender = - getConfiguredTarget("//examples/objc_starlark2:direct_dep") - .get(ObjcProvider.STARLARK_CONSTRUCTOR); - assertThat(starlarkProviderDirectDepender.include()).isEmpty(); - } - - @Test - public void testStarlarkCanCreateObjcProviderWithStrictDepsDirectly() throws Exception { ConfiguredTarget starlarkTarget = createObjcProviderStarlarkTarget( " strict_includes = depset(['path'])", @@ -1256,44 +1009,6 @@ public void testStarlarkCanCreateObjcProviderWithStrictDepsDirectly() throws Exc assertThat(starlarkProviderDirectDepender.getStrictDependencyIncludes()).isEmpty(); } - @Test - public void testStarlarkStrictDepsDoesNotSupportDefine() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - AssertionError e = - assertThrows( - AssertionError.class, - () -> - createObjcProviderStarlarkTarget( - " strict_defines = depset(['def1'])", - " strict_provider = apple_common.new_objc_provider\\", - "(define=strict_defines)", - " created_provider = apple_common.new_objc_provider\\", - "(direct_dep_providers=[strict_provider])", - " return [created_provider]")); - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleStarlarkCommon.BAD_DIRECT_DEPENDENCY_KEY_ERROR, "define")); - } - - @Test - public void testStarlarkStrictDepsDoesNotSupportLinkopt() throws Exception { - setBuildLanguageOptions("--incompatible_objc_provider_remove_compile_info=false"); - AssertionError e = - assertThrows( - AssertionError.class, - () -> - createObjcProviderStarlarkTarget( - " strict_linkopts = depset(['opt1'])", - " strict_provider = apple_common.new_objc_provider\\", - "(linkopt=strict_linkopts)", - " created_provider = apple_common.new_objc_provider\\", - "(direct_dep_providers=[strict_provider])", - " return [created_provider]")); - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleStarlarkCommon.BAD_DIRECT_DEPENDENCY_KEY_ERROR, "linkopt")); - } - @Test public void testStarlarkCanCreateObjcProviderFromObjcProvider() throws Exception { ConfiguredTarget starlarkTarget =