Search in sources :

Example 1 with HashedFileTool

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

the class HaskellBuckConfig method getCompiler.

@Override
public ToolProvider getCompiler() {
    Optional<ToolProvider> configuredCompiler = delegate.getToolProvider(SECTION, "compiler");
    if (configuredCompiler.isPresent()) {
        return configuredCompiler.get();
    }
    Optional<Path> systemCompiler = getSystemCompiler();
    if (systemCompiler.isPresent()) {
        return new ConstantToolProvider(new HashedFileTool(systemCompiler.get()));
    }
    throw new HumanReadableException("No Haskell compiler 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 2 with HashedFileTool

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

the class GoBuckConfig method getGoTool.

private Tool getGoTool(final String configName, final String toolName, final String extraFlagsConfigKey) {
    Optional<Path> toolPath = delegate.getPath(SECTION, configName);
    if (!toolPath.isPresent()) {
        toolPath = Optional.of(goToolDirSupplier.get().resolve(toolName));
    }
    CommandTool.Builder builder = new CommandTool.Builder(new HashedFileTool(toolPath.get()));
    if (!extraFlagsConfigKey.isEmpty()) {
        for (String arg : getFlags(extraFlagsConfigKey)) {
            builder.addArg(arg);
        }
    }
    builder.addEnv("GOROOT", goRootSupplier.get().toString());
    return builder.build();
}
Also used : Path(java.nio.file.Path) CommandTool(com.facebook.buck.rules.CommandTool) HashedFileTool(com.facebook.buck.rules.HashedFileTool)

Example 3 with HashedFileTool

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

the class GroovyBuckConfig method getGroovyCompiler.

Supplier<Tool> getGroovyCompiler() {
    Optional<Path> path = delegate.getPath("groovy", "groovy_home");
    final Path groovyHomePath;
    if (path.isPresent()) {
        groovyHomePath = path.get();
    } else {
        String defaultGroovyHome = delegate.getEnvironment().get("GROOVY_HOME");
        if (defaultGroovyHome == null) {
            throw new HumanReadableException("Unable to locate groovy compiler:" + " GROOVY_HOME is not set, and groovy.groovy_home was not provided");
        } else {
            groovyHomePath = Paths.get(defaultGroovyHome);
        }
    }
    Path compiler = new ExecutableFinder().getExecutable(groovyHomePath.resolve("bin/groovyc"), delegate.getEnvironment());
    return Suppliers.ofInstance(new HashedFileTool(compiler));
}
Also used : Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) HashedFileTool(com.facebook.buck.rules.HashedFileTool) HumanReadableException(com.facebook.buck.util.HumanReadableException)

Example 4 with HashedFileTool

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

the class KotlinBuckConfig method getKotlinCompiler.

/**
   * Get the Tool instance for the Kotlin compiler.
   * @return the Kotlin compiler Tool
   */
public Supplier<Tool> getKotlinCompiler() {
    Path compilerPath = getKotlinHome().resolve("kotlinc");
    if (!Files.isExecutable(compilerPath)) {
        compilerPath = getKotlinHome().resolve(Paths.get("bin", "kotlinc"));
        if (!Files.isExecutable(compilerPath)) {
            throw new HumanReadableException("Could not resolve kotlinc location.");
        }
    }
    Path compiler = new ExecutableFinder().getExecutable(compilerPath, delegate.getEnvironment());
    return Suppliers.ofInstance(new HashedFileTool(compiler));
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) HashedFileTool(com.facebook.buck.rules.HashedFileTool) HumanReadableException(com.facebook.buck.util.HumanReadableException)

Example 5 with HashedFileTool

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

the class ScalaBuckConfig method findScalac.

private Tool findScalac(BuildRuleResolver resolver) {
    Optional<Tool> configScalac = delegate.getTool(SECTION, "compiler", resolver);
    if (configScalac.isPresent()) {
        return configScalac.get();
    }
    Optional<Path> externalScalac = new ExecutableFinder().getOptionalExecutable(Paths.get("scalac"), delegate.getEnvironment());
    if (externalScalac.isPresent()) {
        return new HashedFileTool(externalScalac.get());
    }
    String scalaHome = delegate.getEnvironment().get("SCALA_HOME");
    if (scalaHome != null) {
        Path scalacInHomePath = Paths.get(scalaHome, "bin", "scalac");
        if (scalacInHomePath.toFile().exists()) {
            return new HashedFileTool(scalacInHomePath);
        }
        throw new HumanReadableException("Could not find scalac at $SCALA_HOME/bin/scalac.");
    }
    throw new HumanReadableException("Could not find scalac. Consider setting scala.compiler or $SCALA_HOME.");
}
Also used : Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) HashedFileTool(com.facebook.buck.rules.HashedFileTool) HumanReadableException(com.facebook.buck.util.HumanReadableException) HashedFileTool(com.facebook.buck.rules.HashedFileTool) Tool(com.facebook.buck.rules.Tool) CommandTool(com.facebook.buck.rules.CommandTool)

Aggregations

HashedFileTool (com.facebook.buck.rules.HashedFileTool)17 Path (java.nio.file.Path)11 BuildTarget (com.facebook.buck.model.BuildTarget)7 ConstantToolProvider (com.facebook.buck.rules.ConstantToolProvider)7 HumanReadableException (com.facebook.buck.util.HumanReadableException)6 Test (org.junit.Test)6 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)5 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)5 FakeBuildRuleParamsBuilder (com.facebook.buck.rules.FakeBuildRuleParamsBuilder)5 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)5 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)5 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)5 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)4 ExecutableFinder (com.facebook.buck.io.ExecutableFinder)3 CommandTool (com.facebook.buck.rules.CommandTool)3 RuleKey (com.facebook.buck.rules.RuleKey)3 ToolProvider (com.facebook.buck.rules.ToolProvider)3 DefaultRuleKeyFactory (com.facebook.buck.rules.keys.DefaultRuleKeyFactory)3 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)3 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2