Skip to content

Commit

Permalink
Delete unused ObjcProvider keys.
Browse files Browse the repository at this point in the history
RELNOTES: Removing a few unused objc_provider keys.
PiperOrigin-RevId: 165230824
  • Loading branch information
aragos authored and iirina committed Aug 16, 2017
1 parent 1e98851 commit e29cb64
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public class AppleStaticLibrary implements RuleConfiguredTargetFactory {
ImmutableSet.<Key<?>>of(
ObjcProvider.ASSET_CATALOG,
ObjcProvider.BUNDLE_FILE,
ObjcProvider.GENERAL_RESOURCE_DIR,
ObjcProvider.GENERAL_RESOURCE_FILE,
ObjcProvider.SDK_DYLIB,
ObjcProvider.SDK_FRAMEWORK,
ObjcProvider.STORYBOARD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.ASSET_CATALOG;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BUNDLE_FILE;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.BUNDLE_IMPORT_DIR;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.CC_LIBRARY;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.DEBUG_SYMBOLS;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.DEBUG_SYMBOLS_PLIST;
Expand All @@ -27,8 +26,6 @@
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FLAG;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FORCE_LOAD_LIBRARY;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag.USES_CPP;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_DIR;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_FILE;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.HEADER;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.IMPORTED_LIBRARY;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.INCLUDE;
Expand Down Expand Up @@ -409,10 +406,6 @@ ObjcCommon build() {
new ObjcProvider.Builder()
.addAll(IMPORTED_LIBRARY, extraImportLibraries)
.addAll(BUNDLE_FILE, bundleImports)
.addAll(
BUNDLE_IMPORT_DIR,
uniqueContainers(
BundleableFile.toArtifacts(bundleImports), BUNDLE_CONTAINER_TYPE))
.addAll(SDK_FRAMEWORK, extraSdkFrameworks)
.addAll(WEAK_SDK_FRAMEWORK, extraWeakSdkFrameworks)
.addAll(SDK_DYLIB, extraSdkDylibs)
Expand Down Expand Up @@ -490,12 +483,6 @@ ObjcCommon build() {
if (resourceAttributes.isPresent()) {
ResourceAttributes attributes = resourceAttributes.get();
objcProvider
.addAll(GENERAL_RESOURCE_FILE, attributes.storyboards())
.addAll(GENERAL_RESOURCE_FILE, attributes.resources())
.addAll(GENERAL_RESOURCE_FILE, attributes.strings())
.addAll(GENERAL_RESOURCE_FILE, attributes.xibs())
.addAll(
GENERAL_RESOURCE_DIR, xcodeStructuredResourceDirs(attributes.structuredResources()))
.addAll(BUNDLE_FILE, BundleableFile.flattenedRawResourceFiles(attributes.resources()))
.addAll(
BUNDLE_FILE,
Expand All @@ -513,7 +500,6 @@ GENERAL_RESOURCE_DIR, xcodeStructuredResourceDirs(attributes.structuredResources
if (useLaunchStoryboard(context)) {
Artifact launchStoryboard =
context.getPrerequisiteArtifact("launch_storyboard", Mode.TARGET);
objcProvider.add(GENERAL_RESOURCE_FILE, launchStoryboard);
if (ObjcRuleClasses.STORYBOARD_TYPE.matches(launchStoryboard.getPath())) {
objcProvider.add(STORYBOARD, launchStoryboard);
} else {
Expand Down Expand Up @@ -707,30 +693,6 @@ static Iterable<PathFragment> uniqueContainers(
return containers.build();
}

/**
* Returns the Xcode structured resource directory paths.
*
* <p>For a checked-in source artifact "//a/b/res/sub_dir/d" included by objc rule "//a/b:c",
* "a/b/res" will be returned. For a generated source artifact "res/sub_dir/d" owned by genrule
* "//a/b:c", "bazel-out/.../genfiles/a/b/res" will be returned.
*
* <p>When XCode sees a included resource directory of "a/b/res", the entire directory structure
* up to "res" will be copied into the app bundle.
*/
static Iterable<PathFragment> xcodeStructuredResourceDirs(Iterable<Artifact> artifacts) {
ImmutableSet.Builder<PathFragment> containers = new ImmutableSet.Builder<>();
for (Artifact artifact : artifacts) {
PathFragment ownerRuleDirectory =
artifact.getArtifactOwner().getLabel().getPackageIdentifier().getSourceRoot();
String containerName =
artifact.getRootRelativePath().relativeTo(ownerRuleDirectory).getSegment(0);
PathFragment rootExecPath = artifact.getRoot().getExecPath();
containers.add(rootExecPath.getRelative(ownerRuleDirectory.getRelative(containerName)));
}

return containers.build();
}

/**
* Similar to {@link #nearestContainerMatching(FileType, Artifact)}, but returns the container
* closest to the root that matches the given type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,30 +167,8 @@ public Class<E> getType() {
new Key<>(STABLE_ORDER, "asset_catalog", Artifact.class);

/**
* Added to {@link TargetControl#getGeneralResourceFileList()} when running Xcodegen.
*/
public static final Key<Artifact> GENERAL_RESOURCE_FILE =
new Key<>(STABLE_ORDER, "general_resource_file", Artifact.class);

/**
* Resource directories added to {@link TargetControl#getGeneralResourceFileList()} when running
* Xcodegen. When copying files inside resource directories to the app bundle, XCode will preserve
* the directory structures of the copied files.
*/
public static final Key<PathFragment> GENERAL_RESOURCE_DIR =
new Key<>(STABLE_ORDER, "general_resource_dir", PathFragment.class);

/**
* Exec paths of {@code .bundle} directories corresponding to imported bundles to link.
* These are passed to Xcodegen.
*/
public static final Key<PathFragment> BUNDLE_IMPORT_DIR =
new Key<>(STABLE_ORDER, "bundle_import_dir", PathFragment.class);

/**
* Files that are plopped into the final bundle at some arbitrary bundle path. Note that these are
* not passed to Xcodegen, and these don't include information about where the file originated
* from.
* Files that are plopped into the final bundle at some arbitrary bundle path. Do not include
* information about where the file originated from.
*/
public static final Key<BundleableFile> BUNDLE_FILE =
new Key<>(STABLE_ORDER, "bundle_file", BundleableFile.class);
Expand Down Expand Up @@ -396,7 +374,6 @@ public enum Flag {
ImmutableList.<Key<?>>of(
ASSET_CATALOG,
BUNDLE_FILE,
BUNDLE_IMPORT_DIR,
DEFINE,
DYNAMIC_FRAMEWORK_DIR,
DYNAMIC_FRAMEWORK_FILE,
Expand All @@ -405,8 +382,6 @@ public enum Flag {
EXPORTED_DEBUG_ARTIFACTS,
FRAMEWORK_SEARCH_PATH_ONLY,
FORCE_LOAD_LIBRARY,
GENERAL_RESOURCE_DIR,
GENERAL_RESOURCE_FILE,
HEADER,
IMPORTED_LIBRARY,
INCLUDE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,9 @@ public void testAvoidDepsProviders() throws Exception {
")");

ObjcProvider provider = providerForTarget("//package:test");
// Do not remove SDK_FRAMEWORK or GENERAL_RESOURCE_FILE values in avoid_deps.
// Do not remove SDK_FRAMEWORK values in avoid_deps.
assertThat(provider.get(ObjcProvider.SDK_FRAMEWORK))
.containsAllOf(new SdkFramework("AvoidSDK"), new SdkFramework("BaseSDK"));
assertThat(Artifact.toRootRelativePaths(provider.get(ObjcProvider.GENERAL_RESOURCE_FILE)))
.containsExactly("package/base.png");
}

@Test
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.baseArtifactNames;
import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith;
import static com.google.devtools.build.lib.rules.objc.LegacyCompilationSupport.AUTOMATIC_SDK_FRAMEWORKS;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.GENERAL_RESOURCE_FILE;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.HEADER;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.INCLUDE;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.MODULE_MAP;
Expand Down Expand Up @@ -2123,8 +2122,6 @@ protected void checkProvidesStoryboardObjects(RuleType ruleType) throws Exceptio
getSourceArtifact("x/subdir_for_no_reason/en.lproj/loc.storyboard"),
getSourceArtifact("x/ja.lproj/loc.storyboard"));

assertThat(provider.get(GENERAL_RESOURCE_FILE))
.containsExactlyElementsIn(storyboardInputs);
assertThat(provider.get(STORYBOARD))
.containsExactlyElementsIn(storyboardInputs);
}
Expand Down

0 comments on commit e29cb64

Please sign in to comment.