Search in sources :

Example 11 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class CxxPrecompiledHeaderTemplate method getPreprocessDeps.

private ImmutableSortedSet<BuildRule> getPreprocessDeps(CxxPlatform cxxPlatform) {
    ImmutableSortedSet.Builder<BuildRule> builder = ImmutableSortedSet.naturalOrder();
    for (CxxPreprocessorInput input : getCxxPreprocessorInputs(cxxPlatform)) {
        builder.addAll(input.getDeps(ruleResolver, ruleFinder));
    }
    for (CxxHeaders cxxHeaders : getIncludes(cxxPlatform)) {
        builder.addAll(cxxHeaders.getDeps(ruleFinder));
    }
    for (FrameworkPath frameworkPath : getFrameworks(cxxPlatform)) {
        builder.addAll(frameworkPath.getDeps(ruleFinder));
    }
    builder.addAll(getDeps());
    builder.addAll(getExportedDeps());
    return builder.build();
}
Also used : ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) BuildRule(com.facebook.buck.rules.BuildRule) NoopBuildRule(com.facebook.buck.rules.NoopBuildRule) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath)

Example 12 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class CxxLibraryDescriptionTest method sharedLibraryShouldLinkOwnRequiredLibrariesForCxxLibrary.

@Test
public void sharedLibraryShouldLinkOwnRequiredLibrariesForCxxLibrary() throws Exception {
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    CxxPlatform platform = CxxLibraryBuilder.createDefaultPlatform();
    ImmutableSortedSet<FrameworkPath> libraries = ImmutableSortedSet.of(FrameworkPath.ofSourcePath(new FakeSourcePath("/some/path/libs.dylib")), FrameworkPath.ofSourcePath(new FakeSourcePath("/another/path/liba.dylib")));
    CxxLibraryBuilder libraryBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:foo"), cxxBuckConfig);
    libraryBuilder.setLibraries(libraries).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo.c"))));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(libraryBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    CxxLibrary library = (CxxLibrary) libraryBuilder.build(resolver, filesystem, targetGraph);
    assertThat(library.getNativeLinkTargetInput(platform).getLibraries(), equalTo(libraries));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 13 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class FrameworkPathArgTest method testGetDeps.

@Test
public void testGetDeps() throws Exception {
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
    BuildTarget genruleTarget = BuildTargetFactory.newInstance("//:genrule");
    Genrule genrule = GenruleBuilder.newGenruleBuilder(genruleTarget).setOut("foo/bar.o").build(ruleResolver, filesystem);
    FrameworkPath sourcePathFrameworkPath = FrameworkPath.ofSourcePath(genrule.getSourcePathToOutput());
    FrameworkPathArg sourcePathFrameworkPathArg = new TestFrameworkPathArg(sourcePathFrameworkPath);
    assertThat(sourcePathFrameworkPathArg.getDeps(ruleFinder), Matchers.contains(genrule));
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Genrule(com.facebook.buck.shell.Genrule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) Test(org.junit.Test)

Example 14 with FrameworkPath

use of com.facebook.buck.rules.coercer.FrameworkPath in project buck by facebook.

the class NewNativeTargetProjectMutator method addFrameworksBuildPhase.

private void addFrameworksBuildPhase(PBXProject project, PBXNativeTarget target) {
    if (frameworks.isEmpty() && archives.isEmpty()) {
        return;
    }
    PBXGroup sharedFrameworksGroup = project.getMainGroup().getOrCreateChildGroupByName("Frameworks");
    PBXFrameworksBuildPhase frameworksBuildPhase = new PBXFrameworksBuildPhase();
    target.getBuildPhases().add(frameworksBuildPhase);
    for (FrameworkPath framework : frameworks) {
        SourceTreePath sourceTreePath;
        if (framework.getSourceTreePath().isPresent()) {
            sourceTreePath = framework.getSourceTreePath().get();
        } else if (framework.getSourcePath().isPresent()) {
            sourceTreePath = new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputPathToSourcePath(framework.getSourcePath().get()), Optional.empty());
        } else {
            throw new RuntimeException();
        }
        PBXFileReference fileReference = sharedFrameworksGroup.getOrCreateFileReferenceBySourceTreePath(sourceTreePath);
        frameworksBuildPhase.getFiles().add(new PBXBuildFile(fileReference));
    }
    for (PBXFileReference archive : archives) {
        frameworksBuildPhase.getFiles().add(new PBXBuildFile(archive));
    }
}
Also used : SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) PBXGroup(com.facebook.buck.apple.xcode.xcodeproj.PBXGroup) PBXFrameworksBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXFrameworksBuildPhase) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) PBXFileReference(com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)

Aggregations

FrameworkPath (com.facebook.buck.rules.coercer.FrameworkPath)14 BuildTarget (com.facebook.buck.model.BuildTarget)6 ImmutableList (com.google.common.collect.ImmutableList)6 SourcePath (com.facebook.buck.rules.SourcePath)5 Path (java.nio.file.Path)5 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)4 BuildRule (com.facebook.buck.rules.BuildRule)4 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)4 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)4 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)4 Test (org.junit.Test)4 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)3 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)3 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)3 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)3 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)3 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)2 PBXGroup (com.facebook.buck.apple.xcode.xcodeproj.PBXGroup)2 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)2 LinkerMapMode (com.facebook.buck.cxx.LinkerMapMode)2