Search in sources :

Example 1 with FakeExecutableFinder

use of com.facebook.buck.io.FakeExecutableFinder in project buck by facebook.

the class AppleCxxPlatformsTest method watchOSSdkPathsBuiltFromDirectory.

@Test
public void watchOSSdkPathsBuiltFromDirectory() throws Exception {
    AppleSdkPaths appleSdkPaths = AppleSdkPaths.builder().setDeveloperPath(Paths.get(".")).addToolchainPaths(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(Paths.get("Platforms/WatchOS.platform")).setSdkPath(Paths.get("Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.0.sdk")).build();
    AppleToolchain toolchain = AppleToolchain.builder().setIdentifier("com.apple.dt.XcodeDefault").setPath(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setVersion("1").build();
    AppleSdk targetSdk = AppleSdk.builder().setApplePlatform(ApplePlatform.WATCHOS).setName("watchos2.0").setVersion("2.0").setToolchains(ImmutableList.of(toolchain)).build();
    ImmutableSet<Path> paths = ImmutableSet.<Path>builder().addAll(COMMON_KNOWN_PATHS).add(Paths.get("Platforms/WatchOS.platform/Developer/usr/bin/libtool")).add(Paths.get("Platforms/WatchOS.platform/Developer/usr/bin/ar")).build();
    AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "2.0", "armv7k", appleSdkPaths, FakeBuckConfig.builder().build(), new FakeAppleConfig(), new FakeExecutableFinder(paths), Optional.empty(), Optional.empty());
    CxxPlatform cxxPlatform = appleCxxPlatform.getCxxPlatform();
    BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(ruleResolver));
    assertEquals(ImmutableList.of("usr/bin/actool"), appleCxxPlatform.getActool().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("usr/bin/ibtool"), appleCxxPlatform.getIbtool().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("usr/bin/lldb"), appleCxxPlatform.getLldb().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil"), appleCxxPlatform.getDsymutil().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("usr/bin/xctest"), appleCxxPlatform.getXctest().getCommandPrefix(resolver));
    assertEquals(InternalFlavor.of("watchos2.0-armv7k"), cxxPlatform.getFlavor());
    assertEquals(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/clang").toString(), cxxPlatform.getCc().resolve(ruleResolver).getCommandPrefix(resolver).get(0));
    assertThat(ImmutableList.<String>builder().addAll(cxxPlatform.getCc().resolve(ruleResolver).getCommandPrefix(resolver)).addAll(cxxPlatform.getCflags()).build(), hasConsecutiveItems("-isysroot", Paths.get("Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.0.sdk").toString()));
    assertThat(cxxPlatform.getCflags(), hasConsecutiveItems("-arch", "armv7k"));
    assertThat(cxxPlatform.getCflags(), hasConsecutiveItems("-mwatchos-version-min=2.0"));
    assertThat(cxxPlatform.getLdflags(), hasConsecutiveItems("-Wl,-sdk_version", "-Wl,2.0"));
    assertEquals(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++").toString(), cxxPlatform.getCxx().resolve(ruleResolver).getCommandPrefix(resolver).get(0));
    assertEquals(Paths.get("Platforms/WatchOS.platform/Developer/usr/bin/ar").toString(), cxxPlatform.getAr().getCommandPrefix(resolver).get(0));
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) Matchers.containsString(org.hamcrest.Matchers.containsString) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeExecutableFinder(com.facebook.buck.io.FakeExecutableFinder) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 2 with FakeExecutableFinder

use of com.facebook.buck.io.FakeExecutableFinder in project buck by facebook.

the class AppleCxxPlatformsTest method appleTVOSSdkPathsBuiltFromDirectory.

@Test
public void appleTVOSSdkPathsBuiltFromDirectory() throws Exception {
    AppleSdkPaths appleSdkPaths = AppleSdkPaths.builder().setDeveloperPath(Paths.get(".")).addToolchainPaths(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(Paths.get("Platforms/AppleTVOS.platform")).setSdkPath(Paths.get("Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk")).build();
    AppleToolchain toolchain = AppleToolchain.builder().setIdentifier("com.apple.dt.XcodeDefault").setPath(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setVersion("1").build();
    AppleSdk targetSdk = AppleSdk.builder().setApplePlatform(ApplePlatform.APPLETVOS).setName("appletvos9.1").setVersion("9.1").setToolchains(ImmutableList.of(toolchain)).build();
    ImmutableSet<Path> paths = ImmutableSet.<Path>builder().addAll(COMMON_KNOWN_PATHS).add(Paths.get("Platforms/AppleTVOS.platform/Developer/usr/bin/libtool")).add(Paths.get("Platforms/AppleTVOS.platform/Developer/usr/bin/ar")).build();
    AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "9.1", "arm64", appleSdkPaths, FakeBuckConfig.builder().build(), new FakeAppleConfig(), new FakeExecutableFinder(paths), Optional.empty(), Optional.empty());
    CxxPlatform cxxPlatform = appleCxxPlatform.getCxxPlatform();
    BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
    SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
    assertEquals(ImmutableList.of("usr/bin/actool"), appleCxxPlatform.getActool().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("usr/bin/ibtool"), appleCxxPlatform.getIbtool().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("usr/bin/lldb"), appleCxxPlatform.getLldb().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil"), appleCxxPlatform.getDsymutil().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("usr/bin/xctest"), appleCxxPlatform.getXctest().getCommandPrefix(resolver));
    assertEquals(InternalFlavor.of("appletvos9.1-arm64"), cxxPlatform.getFlavor());
    assertEquals(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/clang").toString(), cxxPlatform.getCc().resolve(ruleResolver).getCommandPrefix(resolver).get(0));
    assertThat(ImmutableList.<String>builder().addAll(cxxPlatform.getCc().resolve(ruleResolver).getCommandPrefix(resolver)).addAll(cxxPlatform.getCflags()).build(), hasConsecutiveItems("-isysroot", Paths.get("Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk").toString()));
    assertThat(cxxPlatform.getCflags(), hasConsecutiveItems("-arch", "arm64"));
    assertThat(cxxPlatform.getCflags(), hasConsecutiveItems("-mtvos-version-min=9.1"));
    assertThat(cxxPlatform.getLdflags(), hasConsecutiveItems("-Wl,-sdk_version", "-Wl,9.1"));
    assertEquals(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++").toString(), cxxPlatform.getCxx().resolve(ruleResolver).getCommandPrefix(resolver).get(0));
    assertEquals(Paths.get("Platforms/AppleTVOS.platform/Developer/usr/bin/ar").toString(), cxxPlatform.getAr().getCommandPrefix(resolver).get(0));
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) Matchers.containsString(org.hamcrest.Matchers.containsString) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FakeExecutableFinder(com.facebook.buck.io.FakeExecutableFinder) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 3 with FakeExecutableFinder

use of com.facebook.buck.io.FakeExecutableFinder in project buck by facebook.

the class AppleCxxPlatformsTest method watchOSSimulatorPlatformSetsLinkerFlags.

@Test
public void watchOSSimulatorPlatformSetsLinkerFlags() throws Exception {
    AppleSdkPaths appleSdkPaths = AppleSdkPaths.builder().setDeveloperPath(Paths.get(".")).addToolchainPaths(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(Paths.get("Platforms/WatchSimulator.platform")).setSdkPath(Paths.get("Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator2.0.sdk")).build();
    ImmutableSet<Path> paths = ImmutableSet.<Path>builder().addAll(COMMON_KNOWN_PATHS).add(Paths.get("Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool")).add(Paths.get("Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar")).build();
    AppleToolchain toolchain = AppleToolchain.builder().setIdentifier("com.apple.dt.XcodeDefault").setPath(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setVersion("1").build();
    AppleSdk targetSdk = AppleSdk.builder().setApplePlatform(ApplePlatform.WATCHSIMULATOR).setName("watchsimulator2.0").setVersion("2.0").setToolchains(ImmutableList.of(toolchain)).build();
    AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "2.0", "armv7k", appleSdkPaths, FakeBuckConfig.builder().build(), new FakeAppleConfig(), new FakeExecutableFinder(paths), Optional.empty(), Optional.empty());
    CxxPlatform cxxPlatform = appleCxxPlatform.getCxxPlatform();
    assertThat(cxxPlatform.getCflags(), hasItem("-mwatchos-simulator-version-min=2.0"));
    assertThat(cxxPlatform.getLdflags(), hasItem("-mwatchos-simulator-version-min=2.0"));
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) FakeExecutableFinder(com.facebook.buck.io.FakeExecutableFinder) Test(org.junit.Test)

Example 4 with FakeExecutableFinder

use of com.facebook.buck.io.FakeExecutableFinder in project buck by facebook.

the class AppleCxxPlatformsTest method cxxToolParamsReadFromBuckConfig.

@Test
public void cxxToolParamsReadFromBuckConfig() throws Exception {
    AppleSdkPaths appleSdkPaths = AppleSdkPaths.builder().setDeveloperPath(Paths.get(".")).addToolchainPaths(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(Paths.get("Platforms/iPhoneOS.platform")).setSdkPath(Paths.get("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk")).build();
    ImmutableSet<Path> paths = ImmutableSet.<Path>builder().addAll(COMMON_KNOWN_PATHS).add(Paths.get("Platforms/iPhoneOS.platform/Developer/usr/bin/libtool")).add(Paths.get("Platforms/iPhoneOS.platform/Developer/usr/bin/ar")).add(Paths.get("Tools/otest")).build();
    AppleToolchain toolchain = AppleToolchain.builder().setIdentifier("com.apple.dt.XcodeDefault").setPath(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setVersion("1").build();
    AppleSdk targetSdk = AppleSdk.builder().setApplePlatform(ApplePlatform.IPHONEOS).setName("iphoneos8.0").setVersion("8.0").setToolchains(ImmutableList.of(toolchain)).build();
    AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "7.0", "armv7", appleSdkPaths, FakeBuckConfig.builder().setSections(ImmutableMap.of("cxx", ImmutableMap.of("cflags", "-std=gnu11", "cppflags", "-DCTHING", "cxxflags", "-std=c++11", "cxxppflags", "-DCXXTHING"))).build(), new FakeAppleConfig(), new FakeExecutableFinder(paths), Optional.empty(), Optional.empty());
    CxxPlatform cxxPlatform = appleCxxPlatform.getCxxPlatform();
    assertThat(cxxPlatform.getCflags(), hasItem("-std=gnu11"));
    assertThat(cxxPlatform.getCppflags(), hasItems("-DCTHING"));
    assertThat(cxxPlatform.getCxxflags(), hasItem("-std=c++11"));
    assertThat(cxxPlatform.getCxxppflags(), hasItems("-DCXXTHING"));
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) FakeExecutableFinder(com.facebook.buck.io.FakeExecutableFinder) Test(org.junit.Test)

Example 5 with FakeExecutableFinder

use of com.facebook.buck.io.FakeExecutableFinder in project buck by facebook.

the class AppleCxxPlatformsTest method pathNotFoundThrows.

@Test
public void pathNotFoundThrows() throws Exception {
    thrown.expect(HumanReadableException.class);
    thrown.expectMessage(containsString("Cannot find tool"));
    AppleSdkPaths appleSdkPaths = AppleSdkPaths.builder().setDeveloperPath(Paths.get(".")).addToolchainPaths(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(Paths.get("Platforms/iPhoneOS.platform")).setSdkPath(Paths.get("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk")).build();
    AppleToolchain toolchain = AppleToolchain.builder().setIdentifier("com.apple.dt.XcodeDefault").setPath(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setVersion("1").build();
    AppleSdk targetSdk = AppleSdk.builder().setApplePlatform(ApplePlatform.IPHONEOS).setName("iphoneos8.0").setVersion("8.0").setToolchains(ImmutableList.of(toolchain)).build();
    AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "7.0", "armv7", appleSdkPaths, FakeBuckConfig.builder().build(), new FakeAppleConfig(), new FakeExecutableFinder(ImmutableSet.of()), Optional.empty(), Optional.empty());
}
Also used : FakeExecutableFinder(com.facebook.buck.io.FakeExecutableFinder) Test(org.junit.Test)

Aggregations

FakeExecutableFinder (com.facebook.buck.io.FakeExecutableFinder)10 Test (org.junit.Test)9 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)8 Path (java.nio.file.Path)8 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)7 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)3 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)3 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)3 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 BuckConfig (com.facebook.buck.cli.BuckConfig)1 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)1 Config (com.facebook.buck.config.Config)1 CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)1 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 DefaultCellPathResolver (com.facebook.buck.rules.DefaultCellPathResolver)1 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)1