Search in sources :

Example 6 with ConstantToolProvider

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

the class BuckConfig method getToolProvider.

/**
   * @return a {@link Tool} identified by a @{link BuildTarget} or {@link Path} reference
   *     by the given section:field, if set.
   */
public Optional<ToolProvider> getToolProvider(String section, String field) {
    Optional<String> value = getValue(section, field);
    if (!value.isPresent()) {
        return Optional.empty();
    }
    Optional<BuildTarget> target = getMaybeBuildTarget(section, field);
    if (target.isPresent()) {
        return Optional.of(new BinaryBuildRuleToolProvider(target.get(), String.format("[%s] %s", section, field)));
    } else {
        checkPathExists(value.get(), String.format("Overridden %s:%s path not found: ", section, field));
        return Optional.of(new ConstantToolProvider(new HashedFileTool(getPathFromVfs(value.get()))));
    }
}
Also used : ConstantToolProvider(com.facebook.buck.rules.ConstantToolProvider) BinaryBuildRuleToolProvider(com.facebook.buck.rules.BinaryBuildRuleToolProvider) HashedFileTool(com.facebook.buck.rules.HashedFileTool) BuildTarget(com.facebook.buck.model.BuildTarget)

Example 7 with ConstantToolProvider

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

the class AppleConfig method getCodesignProvider.

public ToolProvider getCodesignProvider() {
    final String codesignField = "codesign";
    Optional<BuildTarget> target = delegate.getMaybeBuildTarget(APPLE_SECTION, codesignField);
    String source = String.format("[%s] %s", APPLE_SECTION, codesignField);
    if (target.isPresent()) {
        return new BinaryBuildRuleToolProvider(target.get(), source);
    } else {
        Optional<Path> codesignPath = delegate.getPath(APPLE_SECTION, codesignField);
        Path defaultCodesignPath = Paths.get("/usr/bin/codesign");
        HashedFileTool codesign = new HashedFileTool(codesignPath.orElse(defaultCodesignPath));
        return new ConstantToolProvider(codesign);
    }
}
Also used : Path(java.nio.file.Path) ConstantToolProvider(com.facebook.buck.rules.ConstantToolProvider) BinaryBuildRuleToolProvider(com.facebook.buck.rules.BinaryBuildRuleToolProvider) HashedFileTool(com.facebook.buck.rules.HashedFileTool) BuildTarget(com.facebook.buck.model.BuildTarget)

Example 8 with ConstantToolProvider

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

the class HaskellBuckConfig method getPackager.

@Override
public ToolProvider getPackager() {
    Optional<ToolProvider> configuredPackager = delegate.getToolProvider(SECTION, "packager");
    if (configuredPackager.isPresent()) {
        return configuredPackager.get();
    }
    Optional<Path> systemPackager = getSystemPackager();
    if (systemPackager.isPresent()) {
        return new ConstantToolProvider(new HashedFileTool(systemPackager.get()));
    }
    throw new HumanReadableException("No Haskell packager found in .buckconfig (%s.compiler) or on system", SECTION);
}
Also used : ToolProvider(com.facebook.buck.rules.ToolProvider) ConstantToolProvider(com.facebook.buck.rules.ConstantToolProvider) Path(java.nio.file.Path) ConstantToolProvider(com.facebook.buck.rules.ConstantToolProvider) HashedFileTool(com.facebook.buck.rules.HashedFileTool) HumanReadableException(com.facebook.buck.util.HumanReadableException)

Example 9 with ConstantToolProvider

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

the class HaskellBuckConfig method getLinker.

@Override
public ToolProvider getLinker() {
    Optional<ToolProvider> configuredLinker = delegate.getToolProvider(SECTION, "linker");
    if (configuredLinker.isPresent()) {
        return configuredLinker.get();
    }
    Optional<Path> systemLinker = getSystemCompiler();
    if (systemLinker.isPresent()) {
        return new ConstantToolProvider(new HashedFileTool(systemLinker.get()));
    }
    throw new HumanReadableException("No Haskell linker found in .buckconfig (%s.compiler) or on system", SECTION);
}
Also used : ToolProvider(com.facebook.buck.rules.ToolProvider) ConstantToolProvider(com.facebook.buck.rules.ConstantToolProvider) Path(java.nio.file.Path) ConstantToolProvider(com.facebook.buck.rules.ConstantToolProvider) HashedFileTool(com.facebook.buck.rules.HashedFileTool) HumanReadableException(com.facebook.buck.util.HumanReadableException)

Aggregations

ConstantToolProvider (com.facebook.buck.rules.ConstantToolProvider)9 HashedFileTool (com.facebook.buck.rules.HashedFileTool)7 Path (java.nio.file.Path)7 ToolProvider (com.facebook.buck.rules.ToolProvider)4 HumanReadableException (com.facebook.buck.util.HumanReadableException)4 CompilerProvider (com.facebook.buck.cxx.CompilerProvider)2 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)2 DefaultLinkerProvider (com.facebook.buck.cxx.DefaultLinkerProvider)2 HeaderVerification (com.facebook.buck.cxx.HeaderVerification)2 MungingDebugPathSanitizer (com.facebook.buck.cxx.MungingDebugPathSanitizer)2 PosixNmSymbolNameTool (com.facebook.buck.cxx.PosixNmSymbolNameTool)2 PrefixMapDebugPathSanitizer (com.facebook.buck.cxx.PrefixMapDebugPathSanitizer)2 PreprocessorProvider (com.facebook.buck.cxx.PreprocessorProvider)2 BuildTarget (com.facebook.buck.model.BuildTarget)2 BinaryBuildRuleToolProvider (com.facebook.buck.rules.BinaryBuildRuleToolProvider)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 IOException (java.io.IOException)2 NSDictionary (com.dd.plist.NSDictionary)1