Search in sources :

Example 6 with FakeExecutableFinder

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

the class AppleCxxPlatformsTest method iphoneOSSdkPathsBuiltFromDirectory.

@Test
public void iphoneOSSdkPathsBuiltFromDirectory() 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();
    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();
    ImmutableSet<Path> paths = ImmutableSet.<Path>builder().addAll(COMMON_KNOWN_PATHS).add(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate")).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();
    AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "7.0", "armv7", 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("Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"), appleCxxPlatform.getCodesignAllocate().get().getCommandPrefix(resolver));
    assertEquals(ImmutableList.of("usr/bin/xctest"), appleCxxPlatform.getXctest().getCommandPrefix(resolver));
    assertEquals(InternalFlavor.of("iphoneos8.0-armv7"), 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/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk").toString()));
    assertThat(cxxPlatform.getCflags(), hasConsecutiveItems("-arch", "armv7"));
    assertThat(cxxPlatform.getAsflags(), hasConsecutiveItems("-arch", "armv7"));
    assertThat(cxxPlatform.getCflags(), hasConsecutiveItems("-mios-version-min=7.0"));
    assertThat(cxxPlatform.getLdflags(), hasConsecutiveItems("-Wl,-sdk_version", "-Wl,8.0"));
    assertEquals(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++").toString(), cxxPlatform.getCxx().resolve(ruleResolver).getCommandPrefix(resolver).get(0));
    assertEquals(Paths.get("Platforms/iPhoneOS.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 7 with FakeExecutableFinder

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

the class AppleCxxPlatformsTest method iphoneOSSimulatorPlatformSetsLinkerFlags.

@Test
public void iphoneOSSimulatorPlatformSetsLinkerFlags() 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/iPhoneSimulator8.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")).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.IPHONESIMULATOR).setName("iphonesimulator8.0").setVersion("8.0").setToolchains(ImmutableList.of(toolchain)).build();
    AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "7.0", "armv7", appleSdkPaths, FakeBuckConfig.builder().build(), new FakeAppleConfig(), new FakeExecutableFinder(paths), Optional.empty(), Optional.empty());
    CxxPlatform cxxPlatform = appleCxxPlatform.getCxxPlatform();
    assertThat(cxxPlatform.getCflags(), hasItem("-mios-simulator-version-min=7.0"));
    assertThat(cxxPlatform.getLdflags(), hasItem("-mios-simulator-version-min=7.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 8 with FakeExecutableFinder

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

the class LuaBinaryIntegrationTest method getLuaBuckConfig.

private LuaBuckConfig getLuaBuckConfig() throws IOException {
    Config rawConfig = Configs.createDefaultConfig(tmp.getRoot());
    BuckConfig buckConfig = new BuckConfig(rawConfig, new ProjectFilesystem(tmp.getRoot()), Architecture.detect(), Platform.detect(), ImmutableMap.of(), new DefaultCellPathResolver(tmp.getRoot(), rawConfig));
    return new LuaBuckConfig(buckConfig, new FakeExecutableFinder(ImmutableList.of()));
}
Also used : DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) BuckConfig(com.facebook.buck.cli.BuckConfig) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) Config(com.facebook.buck.config.Config) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) FakeExecutableFinder(com.facebook.buck.io.FakeExecutableFinder) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Example 9 with FakeExecutableFinder

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

the class AppleCxxPlatformsTest method appleTVOSSimulatorPlatformSetsLinkerFlags.

@Test
public void appleTVOSSimulatorPlatformSetsLinkerFlags() throws Exception {
    AppleSdkPaths appleSdkPaths = AppleSdkPaths.builder().setDeveloperPath(Paths.get(".")).addToolchainPaths(Paths.get("Toolchains/XcodeDefault.xctoolchain")).setPlatformPath(Paths.get("Platforms/AppleTVSimulator.platform")).setSdkPath(Paths.get("Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator9.1.sdk")).build();
    ImmutableSet<Path> paths = ImmutableSet.<Path>builder().addAll(COMMON_KNOWN_PATHS).add(Paths.get("Platforms/AppleTVSimulator.platform/Developer/usr/bin/libtool")).add(Paths.get("Platforms/AppleTVSimulator.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.APPLETVSIMULATOR).setName("appletvsimulator9.1").setVersion("9.1").setToolchains(ImmutableList.of(toolchain)).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();
    assertThat(cxxPlatform.getCflags(), hasItem("-mtvos-simulator-version-min=9.1"));
    assertThat(cxxPlatform.getLdflags(), hasItem("-mtvos-simulator-version-min=9.1"));
}
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 10 with FakeExecutableFinder

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

the class AppleCxxPlatformsTest method invalidFlavorCharactersInSdkAreEscaped.

@Test
public void invalidFlavorCharactersInSdkAreEscaped() 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("_(in)+va|id_").setVersion("8.0").setToolchains(ImmutableList.of(toolchain)).build();
    AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, targetSdk, "7.0", "cha+rs", appleSdkPaths, FakeBuckConfig.builder().build(), new FakeAppleConfig(), new FakeExecutableFinder(paths), Optional.empty(), Optional.empty());
    assertEquals(InternalFlavor.of("__in__va_id_-cha_rs"), appleCxxPlatform.getCxxPlatform().getFlavor());
}
Also used : Path(java.nio.file.Path) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) 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