Search in sources :

Example 36 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class ParserConfigTest method whenParserPythonIsExecutableFileThenItIsUsed.

@Test
public void whenParserPythonIsExecutableFileThenItIsUsed() throws IOException {
    Path configPythonFile = temporaryFolder.newExecutableFile("python");
    ParserConfig parserConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("parser", ImmutableMap.of("python_interpreter", configPythonFile.toAbsolutePath().toString()))).build().getView(ParserConfig.class);
    assertEquals("Should return path to temp file.", configPythonFile.toAbsolutePath().toString(), parserConfig.getPythonInterpreter(new ExecutableFinder()));
}
Also used : Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) Test(org.junit.Test)

Example 37 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class MissingSymbolsHandler method create.

public static MissingSymbolsHandler create(ProjectFilesystem projectFilesystem, ImmutableSet<Description<?>> descriptions, BuckConfig config, BuckEventBus buckEventBus, Console console, JavacOptions javacOptions, ImmutableMap<String, String> environment) {
    SrcRootsFinder srcRootsFinder = new SrcRootsFinder(projectFilesystem);
    ParserConfig parserConfig = config.getView(ParserConfig.class);
    PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(config, new ExecutableFinder());
    ProjectBuildFileParserFactory projectBuildFileParserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(projectFilesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(projectFilesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setAutodepsFilesHaveSignatures(config.getIncludeAutodepsSignature()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(descriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
    JavaSymbolFinder javaSymbolFinder = new JavaSymbolFinder(projectFilesystem, srcRootsFinder, javacOptions, new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), projectBuildFileParserFactory, config, buckEventBus, console, environment);
    return new MissingSymbolsHandler(console, javaSymbolFinder, parserConfig.getBuildFileName());
}
Also used : PythonBuckConfig(com.facebook.buck.python.PythonBuckConfig) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) ProjectBuildFileParserFactory(com.facebook.buck.json.ProjectBuildFileParserFactory) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) DefaultProjectBuildFileParserFactory(com.facebook.buck.json.DefaultProjectBuildFileParserFactory) JavaSymbolFinder(com.facebook.buck.jvm.java.JavaSymbolFinder) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) ParserConfig(com.facebook.buck.parser.ParserConfig) SrcRootsFinder(com.facebook.buck.jvm.java.SrcRootsFinder)

Example 38 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class CsharpLibraryCompile method getShellCommandInternal.

@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
    Path csc = new ExecutableFinder().getExecutable(CSC, context.getEnvironment());
    DotnetFramework netFramework = DotnetFramework.resolveFramework(context.getEnvironment(), version);
    ImmutableList.Builder<String> args = ImmutableList.builder();
    args.add(csc.toAbsolutePath().toString()).add("/target:library").add("/out:" + output.toString());
    for (Either<Path, String> ref : references) {
        args.add("/reference:" + resolveReference(netFramework, ref));
    }
    for (Path resource : resources.keySet()) {
        for (String name : resources.get(resource)) {
            args.add("/resource:" + Escaper.escapeAsShellString(resource.toString()) + "," + name);
        }
    }
    args.addAll(srcs.stream().map(input -> Escaper.escapeAsShellString(input.toAbsolutePath().toString())).collect(MoreCollectors.toImmutableSet()));
    return args.build();
}
Also used : Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) ImmutableList(com.google.common.collect.ImmutableList)

Example 39 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class ElfExtractSectionsStepTest method assumeObjcopy.

private Path assumeObjcopy() {
    assumeThat(Platform.detect(), Matchers.oneOf(Platform.LINUX, Platform.MACOS));
    ExecutableFinder finder = new ExecutableFinder();
    Optional<Path> objcopy = Optional.empty();
    for (String name : OBJCOPY_NAMES) {
        objcopy = finder.getOptionalExecutable(tmp.getRoot().getFileSystem().getPath(name), ImmutableMap.copyOf(System.getenv()));
        if (objcopy.isPresent()) {
            break;
        }
    }
    assumeTrue(objcopy.isPresent());
    return objcopy.get();
}
Also used : Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder)

Example 40 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class PythonBuckConfigTest method whenPython2OnPathThenItIsUsed.

@Test
public void whenPython2OnPathThenItIsUsed() throws IOException {
    temporaryFolder.newExecutableFile("python");
    Path python2 = temporaryFolder.newExecutableFile("python2");
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setEnvironment(ImmutableMap.<String, String>builder().put("PATH", temporaryFolder.getRoot().toAbsolutePath().toString()).put("PATHEXT", "").build()).build(), new ExecutableFinder());
    assertEquals("Should return path to python2.", python2.toAbsolutePath().toString(), config.getPythonInterpreter());
}
Also used : Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Aggregations

ExecutableFinder (com.facebook.buck.io.ExecutableFinder)47 Path (java.nio.file.Path)28 Test (org.junit.Test)20 AlwaysFoundExecutableFinder (com.facebook.buck.io.AlwaysFoundExecutableFinder)13 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)9 PythonBuckConfig (com.facebook.buck.python.PythonBuckConfig)6 HumanReadableException (com.facebook.buck.util.HumanReadableException)6 CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)5 BuildTarget (com.facebook.buck.model.BuildTarget)5 ParserConfig (com.facebook.buck.parser.ParserConfig)5 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)5 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)5 BuckConfig (com.facebook.buck.cli.BuckConfig)4 DefaultProjectBuildFileParserFactory (com.facebook.buck.json.DefaultProjectBuildFileParserFactory)4 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)4 TestConsole (com.facebook.buck.testutil.TestConsole)4 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)4 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)3 Config (com.facebook.buck.config.Config)3 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)3