Skip to content

Commit

Permalink
Delete system framework paths from blaze
Browse files Browse the repository at this point in the history
    This has been moved to crosstool.

    RELNOTES: None.
    PiperOrigin-RevId: 253647421
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent 433af7b commit 672e960
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@
import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
import com.google.devtools.build.lib.rules.apple.AppleCommandLineOptions.AppleBitcodeMode;
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;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.apple.XcodeConfig;
import com.google.devtools.build.lib.rules.apple.XcodeConfigProvider;
import com.google.devtools.build.lib.rules.cpp.CcCommon;
Expand Down Expand Up @@ -673,28 +670,11 @@ static CompilationArtifacts compilationArtifacts(
.build();
}

/** Add framework search paths common to both headers and libraries. */
private static void addCommonFrameworkSearchPaths(
ImmutableList.Builder<String> paths,
RuleContext ruleContext,
BuildConfiguration buildConfiguration) {

ApplePlatform platform =
buildConfiguration.getFragment(AppleConfiguration.class).getSingleArchPlatform();
paths.add(
AppleToolchain.sdkFrameworkDir(platform, XcodeConfig.getXcodeConfigProvider(ruleContext)));
// As of sdk8.1, XCTest is in a base Framework dir.
if (platform.getType() != PlatformType.WATCHOS) { // WatchOS does not have this directory.
paths.add(AppleToolchain.platformDeveloperFrameworkDir(platform));
}
}

/** Returns a list of framework search paths for clang actions for pre-cleanup mode. */
static ImmutableList<String> preCleanupFrameworkSearchPaths(
ObjcProvider provider, RuleContext ruleContext, BuildConfiguration buildConfiguration) {

ImmutableList.Builder<String> frameworkNames = new ImmutableList.Builder<String>();
addCommonFrameworkSearchPaths(frameworkNames, ruleContext, buildConfiguration);
ImmutableList.Builder<String> frameworkNames = new ImmutableList.Builder<>();
return frameworkNames
// Add custom (non-SDK) framework search paths. For each framework foo/bar.framework,
// include "foo" as a search path.
Expand Down Expand Up @@ -723,7 +703,6 @@ static ImmutableList<String> frameworkHeaderSearchPaths(
return preCleanupFrameworkSearchPaths(provider, ruleContext, buildConfiguration);
}
ImmutableList.Builder<String> searchPaths = new ImmutableList.Builder<String>();
addCommonFrameworkSearchPaths(searchPaths, ruleContext, buildConfiguration);
return searchPaths
// Add header search paths corresponding to custom (non-SDK) frameworks. For each framework
// foo/bar.framework, include "foo" as a search path.
Expand All @@ -744,7 +723,6 @@ static ImmutableList<String> frameworkLibrarySearchPaths(
return preCleanupFrameworkSearchPaths(provider, ruleContext, buildConfiguration);
}
ImmutableList.Builder<String> searchPaths = new ImmutableList.Builder<String>();
addCommonFrameworkSearchPaths(searchPaths, ruleContext, buildConfiguration);
return searchPaths
// Add library search paths corresponding to custom (non-SDK) frameworks. For each framework
// foo/bar.framework, include "foo" as a search path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
import com.google.devtools.build.lib.packages.SkylarkProvider;
import com.google.devtools.build.lib.packages.StructImpl;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher;
import com.google.devtools.build.lib.rules.apple.ApplePlatform;
import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.objc.AppleBinary.BinaryType;
import com.google.devtools.build.lib.rules.objc.CompilationSupport.ExtraLinkArgs;
import com.google.devtools.build.lib.syntax.SkylarkDict;
Expand Down Expand Up @@ -1518,33 +1515,6 @@ public void testMinimumOsDifferentTargets() throws Exception {
checkMinimumOsDifferentTargets(getRuleType(), "_lipobin", "_bin");
}

@Test
public void testMacosFrameworkDirectories() throws Exception {
scratch.file(
"test/BUILD",
"apple_binary(",
" name = 'test',",
" deps = [':lib'],",
" platform_type = 'macos',",
")",
"objc_library(",
" name = 'lib',",
" srcs = ['a.m'],",
")");

CommandAction linkAction = linkAction("//test:test");
ImmutableList<String> expectedCommandLineFragments =
ImmutableList.<String>builder()
.add(AppleToolchain.sdkDir() + AppleToolchain.SYSTEM_FRAMEWORK_PATH)
.add(frameworkDir(ApplePlatform.forTarget(PlatformType.MACOS, "x86_64")))
.build();

String linkArgs = Joiner.on(" ").join(linkAction.getArguments());
for (String expectedCommandLineFragment : expectedCommandLineFragments) {
assertThat(linkArgs).contains(expectedCommandLineFragment);
}
}

@Test
public void testDrops32BitArchitecture() throws Exception {
verifyDrops32BitArchitecture(getRuleType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.packages.NativeAspectClass;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.apple.DottedVersion;
Expand Down Expand Up @@ -1212,8 +1211,6 @@ public void testCompileActionTemplateFromGenJar() throws Exception {
String genfilesFragment =
getConfiguration(j2objcLibraryTarget).getGenfilesFragment().toString();
String binFragment = getConfiguration(j2objcLibraryTarget).getBinFragment().toString();
AppleConfiguration appleConfiguration =
getConfiguration(j2objcLibraryTarget).getFragment(AppleConfiguration.class);

String commandLine = Joiner.on(" ").join(compileAction.getArguments());
ImmutableList<String> expectedArgs =
Expand All @@ -1228,12 +1225,6 @@ public void testCompileActionTemplateFromGenJar() throws Exception {
.add("-arch", "i386")
.add("-isysroot")
.add(AppleToolchain.sdkDir())
.add("-F")
.add(AppleToolchain.sdkDir() + "/Developer/Library/Frameworks")
.add("-F")
.add(
AppleToolchain.platformDeveloperFrameworkDir(
appleConfiguration.getSingleArchPlatform()))
.add("-O0")
.add("-DDEBUG=1")
.add("-iquote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import com.google.devtools.build.lib.analysis.util.ScratchAttributeWriter;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.util.MockObjcSupport;
import com.google.devtools.build.lib.rules.apple.ApplePlatform;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.cpp.CppCompileAction;
import com.google.devtools.build.lib.rules.cpp.CppModuleMap;
Expand All @@ -58,7 +57,6 @@
import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.common.options.OptionsParsingException;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.junit.Ignore;
Expand Down Expand Up @@ -434,12 +432,6 @@ public void testCompilationActions_simulator() throws Exception {
assertThat(compileActionA.getArguments())
.containsAtLeast("-isysroot", AppleToolchain.sdkDir())
.inOrder();
assertThat(Collections.frequency(compileActionA.getArguments(),
"-F" + AppleToolchain.sdkDir() + "/Developer/Library/Frameworks")).isEqualTo(1);
assertThat(
Collections.frequency(
compileActionA.getArguments(), "-F" + frameworkDir(ApplePlatform.IOS_SIMULATOR)))
.isEqualTo(1);
assertThat(compileActionA.getArguments())
.containsAtLeastElementsIn(AppleToolchain.DEFAULT_WARNINGS.values());
assertThat(compileActionA.getArguments())
Expand Down Expand Up @@ -484,12 +476,6 @@ public void testCompilationActions_device() throws Exception {
assertThat(compileActionA.getArguments())
.containsAtLeast("-isysroot", AppleToolchain.sdkDir())
.inOrder();
assertThat(Collections.frequency(compileActionA.getArguments(),
"-F" + AppleToolchain.sdkDir() + "/Developer/Library/Frameworks")).isEqualTo(1);
assertThat(
Collections.frequency(
compileActionA.getArguments(), "-F" + frameworkDir(ApplePlatform.IOS_DEVICE)))
.isEqualTo(1);
assertThat(compileActionA.getArguments())
.containsAtLeastElementsIn(AppleToolchain.DEFAULT_WARNINGS.values());
assertThat(compileActionA.getArguments())
Expand Down Expand Up @@ -1308,29 +1294,9 @@ public void testSdkIncludesUsedInCompileAction() throws Exception {
checkSdkIncludesUsedInCompileAction(RULE_TYPE);
}

// Test with ios device SDK version 9.0. Framework path differs from previous versions.
@Test
public void testCompilationActions_deviceSdk9() throws Exception {
useConfiguration("--cpu=ios_armv7", "--ios_minimum_os=1.0", "--ios_sdk_version=9.0");

createLibraryTargetWriter("//objc:lib")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
.setAndCreateFiles("hdrs", "c.h")
.write();

CommandAction compileAction = compileAction("//objc:lib", "a.o");

// We remove spaces, since the crosstool rules do not use spaces in command line args.

String compileArgs = Joiner.on("").join(compileAction.getArguments()).replace(" ", "");
assertThat(compileArgs)
.contains("-F" + AppleToolchain.sdkDir() + AppleToolchain.SYSTEM_FRAMEWORK_PATH);
}

@Test
public void testCompilationActionsWithPch() throws Exception {
useConfiguration("--apple_platform_type=ios");
ApplePlatform platform = ApplePlatform.IOS_SIMULATOR;
scratch.file("objc/foo.pch");
createLibraryTargetWriter("//objc:lib")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
Expand All @@ -1352,8 +1318,6 @@ public void testCompilationActionsWithPch() throws Exception {
.add("-mios-simulator-version-min=" + DEFAULT_IOS_SDK_VERSION)
.add("-arch x86_64")
.add("-isysroot", AppleToolchain.sdkDir())
.add("-F" + AppleToolchain.sdkDir() + "/Developer/Library/Frameworks")
.add("-F" + frameworkDir(platform))
.addAll(FASTBUILD_COPTS)
.addAll(
iquoteArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.util.MockObjcSupport;
import com.google.devtools.build.lib.packages.util.MockProtoSupport;
import com.google.devtools.build.lib.rules.apple.ApplePlatform;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.cpp.CppModuleMapAction;
import com.google.devtools.build.lib.testutil.TestConstants;
Expand Down Expand Up @@ -464,7 +463,6 @@ public void testModuleMapActionFiltersHeaders() throws Exception {
@Test
public void testCompilationAction() throws Exception {
useConfiguration("--apple_platform_type=ios", "--cpu=ios_i386");
ApplePlatform platform = ApplePlatform.IOS_SIMULATOR;

// Because protos are linked/compiled within the apple_binary context, we need to traverse the
// action graph to find the linked protos (.a) and compiled protos (.o).
Expand Down Expand Up @@ -506,8 +504,6 @@ public void testCompilationAction() throws Exception {
.add("-mios-simulator-version-min=" + DEFAULT_IOS_SDK_VERSION)
.add("-arch", "i386")
.add("-isysroot", AppleToolchain.sdkDir())
.add("-F", AppleToolchain.sdkDir() + AppleToolchain.DEVELOPER_FRAMEWORK_PATH)
.add("-F", frameworkDir(platform))
.addAll(FASTBUILD_COPTS)
.addAll(
ObjcLibraryTest.iquoteArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import com.google.devtools.build.lib.packages.util.MockProtoSupport;
import com.google.devtools.build.lib.rules.apple.AppleCommandLineOptions;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher;
import com.google.devtools.build.lib.rules.apple.ApplePlatform;
import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.apple.DottedVersion;
Expand Down Expand Up @@ -217,11 +216,6 @@ public void initializeMockClient() throws IOException {
MockProtoSupport.setup(mockToolsConfig);
}

protected static String frameworkDir(ApplePlatform platform) {
return AppleToolchain.platformDir(
platform.getNameInPlist()) + AppleToolchain.DEVELOPER_FRAMEWORK_PATH;
}

/**
* Creates an {@code objc_library} target writer for the label indicated by the given String.
*/
Expand Down Expand Up @@ -364,8 +358,6 @@ protected void verifyLinkAction(
.add("-mios-simulator-version-min=" + DEFAULT_IOS_SDK_VERSION)
.add("-arch " + arch)
.add("-isysroot " + AppleToolchain.sdkDir())
.add(AppleToolchain.sdkDir() + AppleToolchain.DEVELOPER_FRAMEWORK_PATH)
.add(frameworkDir(ApplePlatform.forTarget(PlatformType.IOS, arch)))
.addAll(frameworkPathFragmentParents.build())
.add("-Xlinker -objc_abi_version -Xlinker 2")
.add("-fobjc-link-runtime")
Expand Down

0 comments on commit 672e960

Please sign in to comment.