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());
}
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());
}
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));
}
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"));
}
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")));
}
Aggregations