use of com.facebook.buck.rules.SymlinkTree in project buck by facebook.
the class PythonBinaryDescription method createInPlaceBinaryRule.
private PythonInPlaceBinary createInPlaceBinaryRule(BuildRuleParams params, BuildRuleResolver resolver, SourcePathRuleFinder ruleFinder, PythonPlatform pythonPlatform, CxxPlatform cxxPlatform, String mainModule, Optional<String> extension, PythonPackageComponents components, ImmutableSet<String> preloadLibraries) {
// We don't currently support targeting Windows.
if (cxxPlatform.getLd().resolve(resolver) instanceof WindowsLinker) {
throw new HumanReadableException("%s: cannot build in-place python binaries for Windows (%s)", params.getBuildTarget(), cxxPlatform.getFlavor());
}
// Add in any missing init modules into the python components.
SourcePath emptyInit = createEmptyInitModule(params, resolver);
components = components.withModules(addMissingInitModules(components.getModules(), emptyInit));
BuildTarget linkTreeTarget = params.getBuildTarget().withAppendedFlavors(InternalFlavor.of("link-tree"));
Path linkTreeRoot = BuildTargets.getGenPath(params.getProjectFilesystem(), linkTreeTarget, "%s");
SymlinkTree linkTree = resolver.addToIndex(new SymlinkTree(linkTreeTarget, params.getProjectFilesystem(), linkTreeRoot, ImmutableMap.<Path, SourcePath>builder().putAll(components.getModules()).putAll(components.getResources()).putAll(components.getNativeLibraries()).build(), ruleFinder));
return PythonInPlaceBinary.from(params, resolver, cxxPlatform, pythonPlatform, mainModule, components, extension.orElse(pythonBuckConfig.getPexExtension()), preloadLibraries, pythonBuckConfig.legacyOutputPath(), ruleFinder, linkTree, pythonPlatform.getEnvironment());
}
use of com.facebook.buck.rules.SymlinkTree in project buck by facebook.
the class LuaBinaryDescriptionTest method versionLessNativeLibraryExtension.
@Test
public void versionLessNativeLibraryExtension() throws Exception {
CxxLibraryBuilder cxxLibraryBuilder = new CxxLibraryBuilder(BuildTargetFactory.newInstance("//:lib")).setSoname("libfoo.so.1.0").setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("hello.c"))));
LuaBinaryBuilder binaryBuilder = new LuaBinaryBuilder(BuildTargetFactory.newInstance("//:rule"), FakeLuaConfig.DEFAULT.withPackageStyle(LuaConfig.PackageStyle.INPLACE)).setMainModule("main").setDeps(ImmutableSortedSet.of(cxxLibraryBuilder.getTarget()));
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraphFactory.newInstance(cxxLibraryBuilder.build(), binaryBuilder.build()), new DefaultTargetNodeToBuildRuleTransformer());
cxxLibraryBuilder.build(resolver);
binaryBuilder.build(resolver);
SymlinkTree tree = resolver.getRuleWithType(LuaBinaryDescription.getNativeLibsSymlinkTreeTarget(binaryBuilder.getTarget()), SymlinkTree.class);
assertThat(tree.getLinks().keySet(), Matchers.hasItem(tree.getProjectFilesystem().getPath("libfoo.so")));
}
use of com.facebook.buck.rules.SymlinkTree in project buck by facebook.
the class AbstractCxxSourceRuleFactory method getSandboxedCxxSource.
private CxxSource getSandboxedCxxSource(CxxSource source) {
if (getSandboxTree().isPresent()) {
SymlinkTree sandboxTree = getSandboxTree().get();
Path sourcePath = Paths.get(getPathResolver().getSourcePathName(getParams().getBuildTarget(), source.getPath()));
Path sandboxPath = BuildTargets.getGenPath(getParams().getProjectFilesystem(), sandboxTree.getBuildTarget(), "%s");
ExplicitBuildTargetSourcePath path = new ExplicitBuildTargetSourcePath(sandboxTree.getBuildTarget(), sandboxPath.resolve(sourcePath));
source = CxxSource.copyOf(source).withPath(path);
}
return source;
}
use of com.facebook.buck.rules.SymlinkTree in project buck by facebook.
the class AbstractCxxSourceRuleFactory method getPreprocessDeps.
private ImmutableSortedSet<BuildRule> getPreprocessDeps() {
ImmutableSortedSet.Builder<BuildRule> builder = ImmutableSortedSet.naturalOrder();
for (CxxPreprocessorInput input : getCxxPreprocessorInput()) {
builder.addAll(input.getDeps(getResolver(), getRuleFinder()));
}
if (getPrefixHeader().isPresent()) {
builder.addAll(getRuleFinder().filterBuildRuleInputs(getPrefixHeader().get()));
}
if (getPrecompiledHeader().isPresent()) {
builder.addAll(getRuleFinder().filterBuildRuleInputs(getPrecompiledHeader().get()));
}
if (getSandboxTree().isPresent()) {
SymlinkTree tree = getSandboxTree().get();
builder.add(tree);
builder.addAll(getRuleFinder().filterBuildRuleInputs(tree.getLinks().values()));
}
return builder.build();
}
use of com.facebook.buck.rules.SymlinkTree in project buck by facebook.
the class AndroidResourceDescription method collectInputSourcePaths.
private static Pair<Optional<SymlinkTree>, Optional<SourcePath>> collectInputSourcePaths(BuildRuleResolver ruleResolver, BuildTarget resourceRuleTarget, Flavor symlinkTreeFlavor, Optional<Either<SourcePath, ImmutableSortedMap<String, SourcePath>>> attribute) {
if (!attribute.isPresent()) {
return new Pair<>(Optional.empty(), Optional.empty());
}
if (attribute.get().isLeft()) {
SourcePath inputSourcePath = attribute.get().getLeft();
if (!(inputSourcePath instanceof PathSourcePath)) {
// in advance to create a symlink tree. Instead, we have to pass the source path as is.
return new Pair<>(Optional.empty(), Optional.of(inputSourcePath));
}
}
BuildTarget symlinkTreeTarget = resourceRuleTarget.withAppendedFlavors(symlinkTreeFlavor);
SymlinkTree symlinkTree;
try {
symlinkTree = (SymlinkTree) ruleResolver.requireRule(symlinkTreeTarget);
} catch (NoSuchBuildTargetException e) {
throw new RuntimeException(e);
}
return new Pair<>(Optional.of(symlinkTree), Optional.of(symlinkTree.getSourcePathToOutput()));
}
Aggregations