use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class AppleCxxPlatformsTest method buildAppleCxxPlatformWithSwiftToolchain.
private AppleCxxPlatform buildAppleCxxPlatformWithSwiftToolchain(boolean useDefaultSwift) throws IOException {
Path tempRoot = temp.getRoot();
AppleToolchain swiftToolchain = AppleToolchain.builder().setIdentifier("com.apple.dt.XcodeDefault").setPath(tempRoot).setVersion("1").build();
temp.newFolder("usr", "bin");
temp.newFolder("usr", "lib", "swift", "iphoneos");
temp.newFolder("usr", "lib", "swift_static", "iphoneos");
MoreFiles.makeExecutable(temp.newFile("usr/bin/swift"));
MoreFiles.makeExecutable(temp.newFile("usr/bin/swift-stdlib-tool"));
Optional<AppleToolchain> selectedSwiftToolChain = useDefaultSwift ? Optional.empty() : Optional.of(swiftToolchain);
final ImmutableSet<Path> knownPaths = ImmutableSet.<Path>builder().addAll(COMMON_KNOWN_PATHS).add(Paths.get("Platforms/iPhoneOS.platform/Developer/usr/bin/libtool")).add(Paths.get("Platforms/iPhoneOS.platform/Developer/usr/bin/ar")).add(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/swift")).add(Paths.get("Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-stdlib-tool")).build();
return AppleCxxPlatforms.buildWithExecutableChecker(projectFilesystem, FakeAppleRuleDescriptions.DEFAULT_IPHONEOS_SDK, "7.0", "i386", FakeAppleRuleDescriptions.DEFAULT_IPHONEOS_SDK_PATHS, FakeBuckConfig.builder().build(), new FakeAppleConfig(), new ExecutableFinder() {
@Override
public Optional<Path> getOptionalExecutable(Path suggestedPath, ImmutableCollection<Path> searchPath, ImmutableCollection<String> fileSuffixes) {
Optional<Path> realPath = super.getOptionalExecutable(suggestedPath, searchPath, fileSuffixes);
if (realPath.isPresent()) {
return realPath;
}
for (Path path : knownPaths) {
if (suggestedPath.equals(path.getFileName())) {
return Optional.of(path);
}
}
return Optional.empty();
}
}, Optional.of(FakeAppleRuleDescriptions.PROCESS_EXECUTOR), selectedSwiftToolChain);
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class LuaBinaryIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
// We don't currently support windows.
assumeThat(Platform.detect(), Matchers.not(Platform.WINDOWS));
// Verify that a Lua interpreter is available on the system.
LuaBuckConfig fakeConfig = new LuaBuckConfig(FakeBuckConfig.builder().build(), new ExecutableFinder());
Optional<Path> luaOptional = fakeConfig.getSystemLua();
assumeTrue(luaOptional.isPresent());
lua = luaOptional.get();
// Try to detect if a Lua devel package is available, which is needed to C/C++ support.
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
CxxPlatform cxxPlatform = DefaultCxxPlatforms.build(Platform.detect(), new FakeProjectFilesystem(), new CxxBuckConfig(FakeBuckConfig.builder().build()));
ProcessExecutorParams params = ProcessExecutorParams.builder().setCommand(ImmutableList.<String>builder().addAll(cxxPlatform.getCc().resolve(resolver).getCommandPrefix(new SourcePathResolver(new SourcePathRuleFinder(resolver)))).add("-includelua.h", "-E", "-").build()).setRedirectInput(ProcessBuilder.Redirect.PIPE).build();
ProcessExecutor executor = new DefaultProcessExecutor(Console.createNullConsole());
ProcessExecutor.LaunchedProcess launchedProcess = executor.launchProcess(params);
launchedProcess.getOutputStream().close();
int exitCode = executor.waitForLaunchedProcess(launchedProcess).getExitCode();
luaDevel = exitCode == 0;
if (starterType == LuaBinaryDescription.StarterType.NATIVE) {
assumeTrue("Lua devel package required for native starter", luaDevel);
}
// Setup the workspace.
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "lua_binary", tmp);
workspace.setUp();
workspace.writeContentsToPath(Joiner.on(System.lineSeparator()).join(ImmutableList.of("[lua]", " starter_type = " + starterType.toString().toLowerCase(), " native_link_strategy = " + nativeLinkStrategy.toString().toLowerCase(), "[cxx]", " sandbox_sources =" + sandboxSources)), ".buckconfig");
LuaBuckConfig config = getLuaBuckConfig();
assertThat(config.getStarterType(), Matchers.equalTo(Optional.of(starterType)));
assertThat(config.getNativeLinkStrategy(), Matchers.equalTo(nativeLinkStrategy));
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class OCamlIntegrationTest method getOcamlVersion.
private String getOcamlVersion(ProjectWorkspace workspace) throws IOException, InterruptedException {
Path ocamlc = new ExecutableFinder(Platform.detect()).getExecutable(Paths.get("ocamlc"), ImmutableMap.copyOf(System.getenv()));
ProcessExecutor.Result result = workspace.runCommand(ocamlc.toString(), "-version");
assertEquals(0, result.getExitCode());
return result.getStdout().get();
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class ResolverIntegrationTest method createParser.
@BeforeClass
public static void createParser() {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuckConfig buckConfig = FakeBuckConfig.builder().build();
ParserConfig parserConfig = buckConfig.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(buckConfig, new ExecutableFinder());
ImmutableSet<Description<?>> descriptions = ImmutableSet.of(new RemoteFileDescription(new ExplodingDownloader()), new PrebuiltJarDescription());
DefaultProjectBuildFileParserFactory parserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(filesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(filesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(descriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
buildFileParser = parserFactory.createParser(new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), new TestConsole(), ImmutableMap.of(), BuckEventBusFactory.newInstance(), /* ignoreBuckAutodepsFiles */
false);
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class NdkBuildStep method getShellCommandInternal.
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
Optional<Path> ndkRoot = context.getAndroidPlatformTarget().getNdkDirectory();
if (!ndkRoot.isPresent()) {
throw new HumanReadableException("Must set ANDROID_NDK to point to the absolute path of your Android NDK directory.");
}
Optional<Path> ndkBuild = new ExecutableFinder().getOptionalExecutable(Paths.get("ndk-build"), ndkRoot.get());
if (!ndkBuild.isPresent()) {
throw new HumanReadableException("Unable to find ndk-build");
}
ConcurrencyLimit concurrencyLimit = context.getConcurrencyLimit();
ImmutableList.Builder<String> builder = ImmutableList.builder();
builder.add(ndkBuild.get().toAbsolutePath().toString(), "-j", // coordinate job concurrency.
Integer.toString(concurrencyLimit.threadLimit), "-C", this.root.toString());
if (concurrencyLimit.loadLimit < Double.POSITIVE_INFINITY) {
builder.add("--load-average", Double.toString(concurrencyLimit.loadLimit));
}
Iterable<String> flags = Iterables.transform(this.flags, macroExpander);
builder.addAll(flags);
// We want relative, not absolute, paths in the debug-info for binaries we build using
// ndk_library. Absolute paths are machine-specific, but relative ones should be the
// same everywhere.
Path relativePathToProject = filesystem.resolve(root).relativize(filesystem.getRootPath());
builder.add("APP_PROJECT_PATH=" + filesystem.resolve(buildArtifactsDirectory) + File.separatorChar, "APP_BUILD_SCRIPT=" + filesystem.resolve(makefile), "NDK_OUT=" + filesystem.resolve(buildArtifactsDirectory) + File.separatorChar, "NDK_LIBS_OUT=" + filesystem.resolve(binDirectory), "BUCK_PROJECT_DIR=" + relativePathToProject);
// Suppress the custom build step messages (e.g. "Compile++ ...").
if (Platform.detect() == Platform.WINDOWS) {
builder.add("host-echo-build-step=@REM");
} else {
builder.add("host-echo-build-step=@#");
}
// If we're running verbosely, force all the subcommands from the ndk build to be printed out.
if (context.getVerbosity().shouldPrintCommand()) {
builder.add("V=1");
// Otherwise, suppress everything, including the "make: entering directory..." messages.
} else {
builder.add("--silent");
}
return builder.build();
}
Aggregations