Search in sources :

Example 76 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class CxxLibraryDescription method createExportedHeaderSymlinkTreeBuildRule.

/**
   * @return a {@link HeaderSymlinkTree} for the exported headers of this C/C++ library.
   */
private <A extends Arg> HeaderSymlinkTree createExportedHeaderSymlinkTreeBuildRule(BuildRuleParams params, BuildRuleResolver resolver, CxxPreprocessables.HeaderMode mode, A args) throws NoSuchBuildTargetException {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    return CxxDescriptionEnhancer.createHeaderSymlinkTree(params, resolver, mode, CxxDescriptionEnhancer.parseExportedHeaders(params.getBuildTarget(), resolver, ruleFinder, pathResolver, Optional.empty(), args), HeaderVisibility.PUBLIC);
}
Also used : SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver)

Example 77 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class CxxLibraryDescription method createStaticLibraryBuildRule.

/**
   * Create all build rules needed to generate the static library.
   *
   * @return build rule that builds the static library version of this C/C++ library.
   */
private static BuildRule createStaticLibraryBuildRule(BuildRuleParams params, BuildRuleResolver resolver, CxxBuckConfig cxxBuckConfig, CxxPlatform cxxPlatform, Arg args, CxxSourceRuleFactory.PicType pic) throws NoSuchBuildTargetException {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver sourcePathResolver = new SourcePathResolver(ruleFinder);
    // Create rules for compiling the object files.
    ImmutableMap<CxxPreprocessAndCompile, SourcePath> objects = requireObjects(params, resolver, sourcePathResolver, ruleFinder, cxxBuckConfig, cxxPlatform, pic, args);
    // Write a build rule to create the archive for this C/C++ library.
    BuildTarget staticTarget = CxxDescriptionEnhancer.createStaticLibraryBuildTarget(params.getBuildTarget(), cxxPlatform.getFlavor(), pic);
    if (objects.isEmpty()) {
        return new NoopBuildRule(new BuildRuleParams(staticTarget, Suppliers.ofInstance(ImmutableSortedSet.of()), Suppliers.ofInstance(ImmutableSortedSet.of()), params.getProjectFilesystem(), params.getCellRoots()));
    }
    Path staticLibraryPath = CxxDescriptionEnhancer.getStaticLibraryPath(params.getProjectFilesystem(), params.getBuildTarget(), cxxPlatform.getFlavor(), pic, cxxPlatform.getStaticLibraryExtension());
    return Archive.from(staticTarget, params, ruleFinder, cxxPlatform, cxxBuckConfig.getArchiveContents(), staticLibraryPath, ImmutableList.copyOf(objects.values()));
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) SourcePath(com.facebook.buck.rules.SourcePath) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) NoopBuildRule(com.facebook.buck.rules.NoopBuildRule) BuildTarget(com.facebook.buck.model.BuildTarget) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver)

Example 78 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class CxxLibraryDescription method createHeaderSymlinkTreeBuildRule.

/**
   * @return a {@link HeaderSymlinkTree} for the headers of this C/C++ library.
   */
private <A extends Arg> HeaderSymlinkTree createHeaderSymlinkTreeBuildRule(BuildRuleParams params, BuildRuleResolver resolver, CxxPlatform cxxPlatform, A args) throws NoSuchBuildTargetException {
    boolean shouldCreatePrivateHeaderSymlinks = args.xcodePrivateHeadersSymlinks.orElse(true);
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    return CxxDescriptionEnhancer.createHeaderSymlinkTree(params, resolver, cxxPlatform, CxxDescriptionEnhancer.parseHeaders(params.getBuildTarget(), resolver, ruleFinder, pathResolver, Optional.of(cxxPlatform), args), HeaderVisibility.PRIVATE, shouldCreatePrivateHeaderSymlinks);
}
Also used : SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver)

Example 79 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class CxxLibraryDescription method createExportedPlatformHeaderSymlinkTreeBuildRule.

/**
   * @return a {@link HeaderSymlinkTree} for the exported headers of this C/C++ library.
   */
private <A extends Arg> HeaderSymlinkTree createExportedPlatformHeaderSymlinkTreeBuildRule(BuildRuleParams params, BuildRuleResolver resolver, CxxPlatform cxxPlatform, A args) throws NoSuchBuildTargetException {
    boolean shouldCreatePublicHeaderSymlinks = args.xcodePublicHeadersSymlinks.orElse(true);
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    return CxxDescriptionEnhancer.createHeaderSymlinkTree(params, resolver, cxxPlatform, CxxDescriptionEnhancer.parseExportedPlatformHeaders(params.getBuildTarget(), resolver, ruleFinder, pathResolver, cxxPlatform, args), HeaderVisibility.PUBLIC, shouldCreatePublicHeaderSymlinks);
}
Also used : SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver)

Example 80 with SourcePathResolver

use of com.facebook.buck.rules.SourcePathResolver in project buck by facebook.

the class CxxLinkableEnhancer method frameworksToLinkerArg.

@VisibleForTesting
static Arg frameworksToLinkerArg(ImmutableSortedSet<FrameworkPath> frameworkPaths) {
    return new FrameworkPathArg(frameworkPaths) {

        @Override
        public void appendToCommandLine(ImmutableCollection.Builder<String> builder, SourcePathResolver pathResolver) {
            for (FrameworkPath frameworkPath : frameworkPaths) {
                builder.add("-framework");
                builder.add(frameworkPath.getName(pathResolver::getAbsolutePath));
            }
        }
    };
}
Also used : SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)486 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)468 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)376 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)350 Test (org.junit.Test)330 BuildTarget (com.facebook.buck.model.BuildTarget)228 BuildRule (com.facebook.buck.rules.BuildRule)161 Path (java.nio.file.Path)154 SourcePath (com.facebook.buck.rules.SourcePath)148 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)138 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)126 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)119 PathSourcePath (com.facebook.buck.rules.PathSourcePath)86 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)82 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)79 TargetGraph (com.facebook.buck.rules.TargetGraph)76 RuleKey (com.facebook.buck.rules.RuleKey)72 FakeBuildRule (com.facebook.buck.rules.FakeBuildRule)70 ExecutionContext (com.facebook.buck.step.ExecutionContext)57 ImmutableList (com.google.common.collect.ImmutableList)55