Search in sources :

Example 6 with CxxBuckConfig

use of com.facebook.buck.cxx.CxxBuckConfig in project buck by facebook.

the class OCamlIntegrationTest method checkOcamlIsConfigured.

@Before
public void checkOcamlIsConfigured() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "ocaml", tmp);
    workspace.setUp();
    ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
    Config rawConfig = Configs.createDefaultConfig(filesystem.getRootPath());
    BuckConfig buckConfig = new BuckConfig(rawConfig, filesystem, Architecture.detect(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new DefaultCellPathResolver(filesystem.getRootPath(), rawConfig));
    OcamlBuckConfig ocamlBuckConfig = new OcamlBuckConfig(buckConfig, DefaultCxxPlatforms.build(Platform.detect(), filesystem, new CxxBuckConfig(buckConfig)));
    assumeTrue(ocamlBuckConfig.getOcamlCompiler().isPresent());
    assumeTrue(ocamlBuckConfig.getOcamlBytecodeCompiler().isPresent());
    assumeTrue(ocamlBuckConfig.getOcamlDepTool().isPresent());
    assumeTrue(ocamlBuckConfig.getYaccCompiler().isPresent());
    assumeTrue(ocamlBuckConfig.getLexCompiler().isPresent());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) Config(com.facebook.buck.config.Config) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) Before(org.junit.Before)

Example 7 with CxxBuckConfig

use of com.facebook.buck.cxx.CxxBuckConfig in project buck by facebook.

the class OCamlIntegrationTest method testCppLibraryDependency.

@Test
public void testCppLibraryDependency() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "ocaml", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//clib:clib");
    BuildTarget binary = createOcamlLinkTarget(target);
    BuildTarget libplus = BuildTargetFactory.newInstance(workspace.getDestPath(), "//clib:plus");
    BuildTarget libplusStatic = createStaticLibraryBuildTarget(libplus);
    BuildTarget cclib = BuildTargetFactory.newInstance(workspace.getDestPath(), "//clib:cc");
    CxxPlatform cxxPlatform = CxxPlatformUtils.build(new CxxBuckConfig(FakeBuckConfig.builder().build()));
    CxxSourceRuleFactory cxxSourceRuleFactory = CxxSourceRuleFactoryHelper.of(workspace.getDestPath(), cclib, cxxPlatform);
    BuildTarget cclibbin = CxxDescriptionEnhancer.createStaticLibraryBuildTarget(cclib, cxxPlatform.getFlavor(), CxxSourceRuleFactory.PicType.PDC);
    String sourceName = "cc/cc.cpp";
    BuildTarget ccObj = cxxSourceRuleFactory.createCompileBuildTarget(sourceName);
    BuildTarget headerSymlinkTreeTarget = CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(cclib, HeaderVisibility.PRIVATE, cxxPlatform.getFlavor());
    BuildTarget exportedHeaderSymlinkTreeTarget = CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(cclib, HeaderVisibility.PUBLIC, CxxPlatformUtils.getHeaderModeForDefaultPlatform(tmp.getRoot()).getFlavor());
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(binary.toString());
    buildLog.assertTargetBuiltLocally(libplusStatic.toString());
    buildLog.assertTargetBuiltLocally(cclibbin.toString());
    buildLog.assertTargetBuiltLocally(ccObj.toString());
    buildLog.assertTargetBuiltLocally(headerSymlinkTreeTarget.toString());
    buildLog.assertTargetBuiltLocally(exportedHeaderSymlinkTreeTarget.toString());
    workspace.resetBuildLogFile();
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetHadMatchingRuleKey(binary.toString());
    buildLog.assertTargetHadMatchingRuleKey(target.toString());
    workspace.resetBuildLogFile();
    workspace.replaceFileContents("clib/cc/cc.cpp", "Hi there", "hi there");
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(binary.toString());
    buildLog.assertTargetBuiltLocally(libplusStatic.toString());
    buildLog.assertTargetBuiltLocally(cclibbin.toString());
    buildLog.assertTargetBuiltLocally(ccObj.toString());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) CxxSourceRuleFactory(com.facebook.buck.cxx.CxxSourceRuleFactory) OcamlRuleBuilder.createStaticLibraryBuildTarget(com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget) BuildTarget(com.facebook.buck.model.BuildTarget) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) Test(org.junit.Test)

Example 8 with CxxBuckConfig

use of com.facebook.buck.cxx.CxxBuckConfig in project buck by facebook.

the class CxxPythonExtensionDescriptionTest method nativeLinkTargetDeps.

@Test
public void nativeLinkTargetDeps() throws Exception {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    CxxLibrary dep = (CxxLibrary) new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:dep")).build(resolver);
    CxxPythonExtensionBuilder builder = new CxxPythonExtensionBuilder(BuildTargetFactory.newInstance("//:rule"), FlavorDomain.of("Python Platform", PY2, PY3), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms());
    CxxPythonExtension rule = builder.setDeps(ImmutableSortedSet.of(dep.getBuildTarget())).build(resolver);
    NativeLinkTarget nativeLinkTarget = rule.getNativeLinkTarget(PY2);
    assertThat(ImmutableList.copyOf(nativeLinkTarget.getNativeLinkTargetDeps(CxxPlatformUtils.DEFAULT_PLATFORM)), Matchers.<NativeLinkable>hasItem(dep));
}
Also used : CxxLibrary(com.facebook.buck.cxx.CxxLibrary) PrebuiltCxxLibraryBuilder(com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) NativeLinkTarget(com.facebook.buck.cxx.NativeLinkTarget) Test(org.junit.Test)

Example 9 with CxxBuckConfig

use of com.facebook.buck.cxx.CxxBuckConfig in project buck by facebook.

the class CxxPythonExtensionDescriptionTest method nativeLinkTargetInput.

@Test
public void nativeLinkTargetInput() throws Exception {
    CxxPythonExtensionBuilder builder = new CxxPythonExtensionBuilder(BuildTargetFactory.newInstance("//:rule"), FlavorDomain.of("Python Platform", PY2, PY3), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms());
    builder.setLinkerFlags(ImmutableList.of(StringWithMacrosUtils.format("--flag")));
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(builder.build()), new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    CxxPythonExtension rule = builder.build(resolver);
    NativeLinkTarget nativeLinkTarget = rule.getNativeLinkTarget(PY2);
    NativeLinkableInput input = nativeLinkTarget.getNativeLinkTargetInput(CxxPlatformUtils.DEFAULT_PLATFORM);
    assertThat(Arg.stringify(input.getArgs(), pathResolver), Matchers.hasItems("--flag"));
}
Also used : NativeLinkableInput(com.facebook.buck.cxx.NativeLinkableInput) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) NativeLinkTarget(com.facebook.buck.cxx.NativeLinkTarget) Test(org.junit.Test)

Example 10 with CxxBuckConfig

use of com.facebook.buck.cxx.CxxBuckConfig in project buck by facebook.

the class CxxPythonExtensionDescriptionTest method moduleName.

@Test
public void moduleName() throws Exception {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    CxxPythonExtension cxxPythonExtension = new CxxPythonExtensionBuilder(BuildTargetFactory.newInstance("//:ext"), FlavorDomain.of("Python Platform", PY2, PY3), new CxxBuckConfig(FakeBuckConfig.builder().build()), CxxTestBuilder.createDefaultPlatforms()).setModuleName("blah").build(resolver);
    assertThat(cxxPythonExtension.getModule().toString(), Matchers.endsWith(CxxPythonExtensionDescription.getExtensionName("blah")));
}
Also used : DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Aggregations

CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)27 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)19 Test (org.junit.Test)19 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)18 BuildTarget (com.facebook.buck.model.BuildTarget)11 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)10 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)10 PrebuiltCxxLibraryBuilder (com.facebook.buck.cxx.PrebuiltCxxLibraryBuilder)9 TargetGraph (com.facebook.buck.rules.TargetGraph)8 CxxLibraryBuilder (com.facebook.buck.cxx.CxxLibraryBuilder)6 NativeLinkTarget (com.facebook.buck.cxx.NativeLinkTarget)6 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)6 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)5 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)5 ExecutableFinder (com.facebook.buck.io.ExecutableFinder)5 BuildRule (com.facebook.buck.rules.BuildRule)5 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)5 AppleConfig (com.facebook.buck.apple.AppleConfig)4