Search in sources :

Example 1 with NoSuchBuildTargetException

use of com.facebook.buck.parser.NoSuchBuildTargetException in project buck by facebook.

the class ProjectGenerator method getPublicCxxHeaders.

private ImmutableSortedMap<Path, SourcePath> getPublicCxxHeaders(TargetNode<? extends CxxLibraryDescription.Arg, ?> targetNode) {
    CxxLibraryDescription.Arg arg = targetNode.getConstructorArg();
    if (arg instanceof AppleNativeTargetDescriptionArg) {
        Path headerPathPrefix = AppleDescriptions.getHeaderPathPrefix((AppleNativeTargetDescriptionArg) arg, targetNode.getBuildTarget());
        ImmutableSortedMap<String, SourcePath> cxxHeaders = AppleDescriptions.convertAppleHeadersToPublicCxxHeaders(this::resolveSourcePath, headerPathPrefix, arg);
        return convertMapKeysToPaths(cxxHeaders);
    } else {
        BuildRuleResolver resolver = buildRuleResolverForNode.apply(targetNode);
        SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
        SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
        try {
            return ImmutableSortedMap.copyOf(CxxDescriptionEnhancer.parseExportedHeaders(targetNode.getBuildTarget(), resolver, ruleFinder, pathResolver, Optional.empty(), arg));
        } catch (NoSuchBuildTargetException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) BuildTargetSourcePath(com.facebook.buck.rules.BuildTargetSourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) SourcePath(com.facebook.buck.rules.SourcePath) BuildTargetSourcePath(com.facebook.buck.rules.BuildTargetSourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) CxxLibraryDescription(com.facebook.buck.cxx.CxxLibraryDescription) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) AppleNativeTargetDescriptionArg(com.facebook.buck.apple.AppleNativeTargetDescriptionArg) NSString(com.dd.plist.NSString) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver)

Example 2 with NoSuchBuildTargetException

use of com.facebook.buck.parser.NoSuchBuildTargetException in project buck by facebook.

the class CxxGenruleDescription method getMacroHandler.

@Override
protected <A extends Arg> MacroHandler getMacroHandler(BuildTarget buildTarget, ProjectFilesystem filesystem, BuildRuleResolver resolver, TargetGraph targetGraph, A args) {
    CxxPlatform cxxPlatform = cxxPlatforms.getRequiredValue(buildTarget);
    ImmutableMap.Builder<String, MacroExpander> macros = ImmutableMap.builder();
    macros.put("exe", new ExecutableMacroExpander());
    macros.put("location", new CxxLocationMacroExpander(cxxPlatform));
    macros.put("platform-name", new StringExpander(cxxPlatform.getFlavor().toString()));
    macros.put("location-platform", new LocationMacroExpander() {

        @Override
        protected BuildRule resolve(BuildRuleResolver resolver, LocationMacro input) throws MacroException {
            try {
                return resolver.requireRule(input.getTarget().withAppendedFlavors(cxxPlatform.getFlavor()));
            } catch (NoSuchBuildTargetException e) {
                throw new MacroException(e.getHumanReadableErrorMessage());
            }
        }
    });
    macros.put("cc", new ToolExpander(cxxPlatform.getCc().resolve(resolver)));
    macros.put("cxx", new ToolExpander(cxxPlatform.getCxx().resolve(resolver)));
    ImmutableList<String> asflags = cxxPlatform.getAsflags();
    ImmutableList<String> cflags = cxxPlatform.getCflags();
    ImmutableList<String> cxxflags = cxxPlatform.getCxxflags();
    macros.put("cflags", new StringExpander(shquoteJoin(Iterables.concat(cflags, asflags))));
    macros.put("cxxflags", new StringExpander(shquoteJoin(Iterables.concat(cxxflags, asflags))));
    macros.put("cppflags", new CxxPreprocessorFlagsExpander(cxxPlatform, CxxSource.Type.C));
    macros.put("cxxppflags", new CxxPreprocessorFlagsExpander(cxxPlatform, CxxSource.Type.CXX));
    macros.put("ld", new ToolExpander(cxxPlatform.getLd().resolve(resolver)));
    for (Linker.LinkableDepType depType : Linker.LinkableDepType.values()) {
        for (Filter filter : Filter.values()) {
            macros.put(String.format("ldflags-%s%s", depType.toString().toLowerCase().replace('_', '-'), filter == Filter.PARAM ? "-filter" : ""), new CxxLinkerFlagsExpander(buildTarget, filesystem, cxxPlatform, depType, args.out, filter));
        }
    }
    return new MacroHandler(macros.build());
}
Also used : ExecutableMacroExpander(com.facebook.buck.rules.macros.ExecutableMacroExpander) ExecutableMacroExpander(com.facebook.buck.rules.macros.ExecutableMacroExpander) AbstractMacroExpander(com.facebook.buck.rules.macros.AbstractMacroExpander) MacroExpander(com.facebook.buck.rules.macros.MacroExpander) LocationMacroExpander(com.facebook.buck.rules.macros.LocationMacroExpander) MacroHandler(com.facebook.buck.rules.macros.MacroHandler) ImmutableMap(com.google.common.collect.ImmutableMap) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) StringExpander(com.facebook.buck.rules.macros.StringExpander) LocationMacroExpander(com.facebook.buck.rules.macros.LocationMacroExpander) LocationMacro(com.facebook.buck.rules.macros.LocationMacro) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) BuildRule(com.facebook.buck.rules.BuildRule) MacroException(com.facebook.buck.model.MacroException)

Example 3 with NoSuchBuildTargetException

use of com.facebook.buck.parser.NoSuchBuildTargetException in project buck by facebook.

the class CxxDescriptionEnhancer method parseOnlyPlatformHeaders.

static ImmutableMap<String, SourcePath> parseOnlyPlatformHeaders(BuildTarget buildTarget, BuildRuleResolver resolver, SourcePathRuleFinder ruleFinder, SourcePathResolver sourcePathResolver, CxxPlatform cxxPlatform, String headersParameterName, SourceList headers, String platformHeadersParameterName, PatternMatchedCollection<SourceList> platformHeaders) throws NoSuchBuildTargetException {
    ImmutableMap.Builder<String, SourcePath> parsed = ImmutableMap.builder();
    java.util.function.Function<SourcePath, SourcePath> fixup = path -> {
        try {
            return CxxGenruleDescription.fixupSourcePath(resolver, ruleFinder, cxxPlatform, path);
        } catch (NoSuchBuildTargetException e) {
            throw new RuntimeException(e);
        }
    };
    // Include all normal exported headers that are generated by `cxx_genrule`.
    parsed.putAll(headers.toNameMap(buildTarget, sourcePathResolver, headersParameterName, path -> CxxGenruleDescription.wrapsCxxGenrule(ruleFinder, path), fixup));
    // Include all platform specific headers.
    for (SourceList sourceList : platformHeaders.getMatchingValues(cxxPlatform.getFlavor().toString())) {
        parsed.putAll(sourceList.toNameMap(buildTarget, sourcePathResolver, platformHeadersParameterName, path -> true, fixup));
    }
    return parsed.build();
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) PatternMatchedCollection(com.facebook.buck.rules.coercer.PatternMatchedCollection) ImmutableCollection(com.google.common.collect.ImmutableCollection) RichStream(com.facebook.buck.util.RichStream) InternalFlavor(com.facebook.buck.model.InternalFlavor) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) SymlinkTree(com.facebook.buck.rules.SymlinkTree) FlavorDomain(com.facebook.buck.model.FlavorDomain) Matcher(java.util.regex.Matcher) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) StringArg(com.facebook.buck.rules.args.StringArg) Map(java.util.Map) SourceList(com.facebook.buck.rules.coercer.SourceList) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) RuleKeyObjectSink(com.facebook.buck.rules.RuleKeyObjectSink) Path(java.nio.file.Path) JsonConcatenate(com.facebook.buck.json.JsonConcatenate) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) TargetGraph(com.facebook.buck.rules.TargetGraph) BuildTarget(com.facebook.buck.model.BuildTarget) RuleKeyAppendableFunction(com.facebook.buck.rules.args.RuleKeyAppendableFunction) SourceWithFlags(com.facebook.buck.rules.SourceWithFlags) Predicate(com.google.common.base.Predicate) Optional(java.util.Optional) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Pattern(java.util.regex.Pattern) Joiner(com.google.common.base.Joiner) CellPathResolver(com.facebook.buck.rules.CellPathResolver) SourcePathArg(com.facebook.buck.rules.args.SourcePathArg) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) SourcePath(com.facebook.buck.rules.SourcePath) HashMap(java.util.HashMap) BuildRule(com.facebook.buck.rules.BuildRule) ImmutableList(com.google.common.collect.ImmutableList) Files(com.google.common.io.Files) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) Suppliers(com.google.common.base.Suppliers) StreamSupport(java.util.stream.StreamSupport) StringWithMacros(com.facebook.buck.rules.macros.StringWithMacros) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) MoreCollectors(com.facebook.buck.util.MoreCollectors) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) Logger(com.facebook.buck.log.Logger) Functions(com.google.common.base.Functions) FileListableLinkerInputArg(com.facebook.buck.rules.args.FileListableLinkerInputArg) HumanReadableException(com.facebook.buck.util.HumanReadableException) QueryUtils(com.facebook.buck.rules.query.QueryUtils) Arg(com.facebook.buck.rules.args.Arg) Paths(java.nio.file.Paths) CommandTool(com.facebook.buck.rules.CommandTool) StringWithMacrosArg(com.facebook.buck.rules.args.StringWithMacrosArg) LocationMacroExpander(com.facebook.buck.rules.macros.LocationMacroExpander) Preconditions(com.google.common.base.Preconditions) Flavor(com.facebook.buck.model.Flavor) MacroHandler(com.facebook.buck.rules.macros.MacroHandler) VisibleForTesting(com.google.common.annotations.VisibleForTesting) BuildTargets(com.facebook.buck.model.BuildTargets) SourceList(com.facebook.buck.rules.coercer.SourceList) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 4 with NoSuchBuildTargetException

use of com.facebook.buck.parser.NoSuchBuildTargetException in project buck by facebook.

the class HaskellDescriptionUtils method createCompileRule.

/**
   * Create a Haskell compile rule that compiles all the given haskell sources in one step and
   * pulls interface files from all transitive haskell dependencies.
   */
private static HaskellCompileRule createCompileRule(BuildTarget target, final BuildRuleParams baseParams, final BuildRuleResolver resolver, SourcePathRuleFinder ruleFinder, ImmutableSet<BuildRule> deps, final CxxPlatform cxxPlatform, HaskellConfig haskellConfig, final Linker.LinkableDepType depType, Optional<String> main, Optional<HaskellPackageInfo> packageInfo, ImmutableList<String> flags, HaskellSources sources) throws NoSuchBuildTargetException {
    final Map<BuildTarget, ImmutableList<String>> depFlags = new TreeMap<>();
    final Map<BuildTarget, ImmutableList<SourcePath>> depIncludes = new TreeMap<>();
    final ImmutableSortedMap.Builder<String, HaskellPackage> exposedPackagesBuilder = ImmutableSortedMap.naturalOrder();
    final ImmutableSortedMap.Builder<String, HaskellPackage> packagesBuilder = ImmutableSortedMap.naturalOrder();
    new AbstractBreadthFirstThrowingTraversal<BuildRule, NoSuchBuildTargetException>(deps) {

        private final ImmutableSet<BuildRule> empty = ImmutableSet.of();

        @Override
        public Iterable<BuildRule> visit(BuildRule rule) throws NoSuchBuildTargetException {
            ImmutableSet<BuildRule> ruleDeps = empty;
            if (rule instanceof HaskellCompileDep) {
                ruleDeps = rule.getDeps();
                HaskellCompileInput compileInput = ((HaskellCompileDep) rule).getCompileInput(cxxPlatform, depType);
                depFlags.put(rule.getBuildTarget(), compileInput.getFlags());
                depIncludes.put(rule.getBuildTarget(), compileInput.getIncludes());
                // We add packages from first-order deps as expose modules, and transitively included
                // packages as hidden ones.
                boolean firstOrderDep = deps.contains(rule);
                for (HaskellPackage pkg : compileInput.getPackages()) {
                    if (firstOrderDep) {
                        exposedPackagesBuilder.put(pkg.getInfo().getIdentifier(), pkg);
                    } else {
                        packagesBuilder.put(pkg.getInfo().getIdentifier(), pkg);
                    }
                }
            }
            return ruleDeps;
        }
    }.start();
    Collection<CxxPreprocessorInput> cxxPreprocessorInputs = CxxPreprocessables.getTransitiveCxxPreprocessorInput(cxxPlatform, deps);
    ExplicitCxxToolFlags.Builder toolFlagsBuilder = CxxToolFlags.explicitBuilder();
    PreprocessorFlags.Builder ppFlagsBuilder = PreprocessorFlags.builder();
    toolFlagsBuilder.setPlatformFlags(CxxSourceTypes.getPlatformPreprocessFlags(cxxPlatform, CxxSource.Type.C));
    for (CxxPreprocessorInput input : cxxPreprocessorInputs) {
        ppFlagsBuilder.addAllIncludes(input.getIncludes());
        ppFlagsBuilder.addAllFrameworkPaths(input.getFrameworks());
        toolFlagsBuilder.addAllRuleFlags(input.getPreprocessorFlags().get(CxxSource.Type.C));
    }
    ppFlagsBuilder.setOtherFlags(toolFlagsBuilder.build());
    PreprocessorFlags ppFlags = ppFlagsBuilder.build();
    ImmutableList<String> compileFlags = ImmutableList.<String>builder().addAll(haskellConfig.getCompilerFlags()).addAll(flags).addAll(Iterables.concat(depFlags.values())).build();
    ImmutableList<SourcePath> includes = ImmutableList.copyOf(Iterables.concat(depIncludes.values()));
    ImmutableSortedMap<String, HaskellPackage> exposedPackages = exposedPackagesBuilder.build();
    ImmutableSortedMap<String, HaskellPackage> packages = packagesBuilder.build();
    return HaskellCompileRule.from(target, baseParams, ruleFinder, haskellConfig.getCompiler().resolve(resolver), haskellConfig.getHaskellVersion(), compileFlags, ppFlags, cxxPlatform, depType == Linker.LinkableDepType.STATIC ? CxxSourceRuleFactory.PicType.PDC : CxxSourceRuleFactory.PicType.PIC, main, packageInfo, includes, exposedPackages, packages, sources, CxxSourceTypes.getPreprocessor(cxxPlatform, CxxSource.Type.C).resolve(resolver));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) SourcePath(com.facebook.buck.rules.SourcePath) ImmutableSet(com.google.common.collect.ImmutableSet) BuildTarget(com.facebook.buck.model.BuildTarget) BuildRule(com.facebook.buck.rules.BuildRule) PreprocessorFlags(com.facebook.buck.cxx.PreprocessorFlags) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) TreeMap(java.util.TreeMap) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) CxxPreprocessorInput(com.facebook.buck.cxx.CxxPreprocessorInput) ExplicitCxxToolFlags(com.facebook.buck.cxx.ExplicitCxxToolFlags)

Example 5 with NoSuchBuildTargetException

use of com.facebook.buck.parser.NoSuchBuildTargetException in project buck by facebook.

the class LuaBinaryDescription method getPackageComponentsFromDeps.

private LuaBinaryPackageComponents getPackageComponentsFromDeps(BuildRuleParams baseParams, BuildRuleResolver ruleResolver, SourcePathResolver pathResolver, SourcePathRuleFinder ruleFinder, final CxxPlatform cxxPlatform, final PythonPlatform pythonPlatform, Optional<BuildTarget> nativeStarterLibrary, String mainModule, LuaConfig.PackageStyle packageStyle, Iterable<BuildRule> deps) throws NoSuchBuildTargetException {
    final LuaPackageComponents.Builder builder = LuaPackageComponents.builder();
    final OmnibusRoots.Builder omnibusRoots = OmnibusRoots.builder(cxxPlatform, ImmutableSet.of());
    final Map<BuildTarget, NativeLinkable> nativeLinkableRoots = new LinkedHashMap<>();
    final Map<BuildTarget, CxxLuaExtension> luaExtensions = new LinkedHashMap<>();
    final Map<BuildTarget, CxxPythonExtension> pythonExtensions = new LinkedHashMap<>();
    // Walk the deps to find all Lua packageables and native linkables.
    new AbstractBreadthFirstThrowingTraversal<BuildRule, NoSuchBuildTargetException>(deps) {

        private final ImmutableSet<BuildRule> empty = ImmutableSet.of();

        @Override
        public ImmutableSet<BuildRule> visit(BuildRule rule) throws NoSuchBuildTargetException {
            ImmutableSet<BuildRule> deps = empty;
            if (rule instanceof LuaPackageable) {
                LuaPackageable packageable = (LuaPackageable) rule;
                LuaPackageComponents components = packageable.getLuaPackageComponents();
                LuaPackageComponents.addComponents(builder, components);
                if (components.hasNativeCode(cxxPlatform)) {
                    for (BuildRule dep : rule.getDeps()) {
                        if (dep instanceof NativeLinkable) {
                            NativeLinkable linkable = (NativeLinkable) dep;
                            nativeLinkableRoots.put(linkable.getBuildTarget(), linkable);
                            omnibusRoots.addExcludedRoot(linkable);
                        }
                    }
                }
                deps = rule.getDeps();
            } else if (rule instanceof CxxPythonExtension) {
                CxxPythonExtension extension = (CxxPythonExtension) rule;
                NativeLinkTarget target = extension.getNativeLinkTarget(pythonPlatform);
                pythonExtensions.put(target.getBuildTarget(), (CxxPythonExtension) rule);
                omnibusRoots.addIncludedRoot(target);
            } else if (rule instanceof PythonPackagable) {
                PythonPackagable packageable = (PythonPackagable) rule;
                PythonPackageComponents components = packageable.getPythonPackageComponents(pythonPlatform, cxxPlatform);
                builder.putAllPythonModules(MoreMaps.transformKeys(components.getModules(), Object::toString));
                builder.putAllNativeLibraries(MoreMaps.transformKeys(components.getNativeLibraries(), Object::toString));
                if (components.hasNativeCode(cxxPlatform)) {
                    for (BuildRule dep : rule.getDeps()) {
                        if (dep instanceof NativeLinkable) {
                            NativeLinkable linkable = (NativeLinkable) dep;
                            nativeLinkableRoots.put(linkable.getBuildTarget(), linkable);
                            omnibusRoots.addExcludedRoot(linkable);
                        }
                    }
                }
                deps = rule.getDeps();
            } else if (rule instanceof CxxLuaExtension) {
                CxxLuaExtension extension = (CxxLuaExtension) rule;
                luaExtensions.put(extension.getBuildTarget(), extension);
                omnibusRoots.addIncludedRoot(extension);
            } else if (rule instanceof NativeLinkable) {
                NativeLinkable linkable = (NativeLinkable) rule;
                nativeLinkableRoots.put(linkable.getBuildTarget(), linkable);
                omnibusRoots.addPotentialRoot(linkable);
            }
            return deps;
        }
    }.start();
    // Build the starter.
    Starter starter = createStarter(baseParams, ruleResolver, pathResolver, ruleFinder, cxxPlatform, nativeStarterLibrary, mainModule, packageStyle, !nativeLinkableRoots.isEmpty() || !omnibusRoots.isEmpty());
    SourcePath starterPath = null;
    if (luaConfig.getNativeLinkStrategy() == NativeLinkStrategy.MERGED) {
        // If we're using a native starter, include it in omnibus linking.
        if (starter instanceof NativeExecutableStarter) {
            NativeExecutableStarter nativeStarter = (NativeExecutableStarter) starter;
            omnibusRoots.addIncludedRoot(nativeStarter);
        }
        // Build the omnibus libraries.
        OmnibusRoots roots = omnibusRoots.build();
        OmnibusLibraries libraries = Omnibus.getSharedLibraries(baseParams, ruleResolver, ruleFinder, cxxBuckConfig, cxxPlatform, ImmutableList.of(), roots.getIncludedRoots().values(), roots.getExcludedRoots().values());
        // Add all the roots from the omnibus link.  If it's an extension, add it as a module.
        for (Map.Entry<BuildTarget, OmnibusRoot> root : libraries.getRoots().entrySet()) {
            // If it's a Lua extension add it as a module.
            CxxLuaExtension luaExtension = luaExtensions.get(root.getKey());
            if (luaExtension != null) {
                builder.putModules(luaExtension.getModule(cxxPlatform), root.getValue().getPath());
                continue;
            }
            // If it's a Python extension, add it as a python module.
            CxxPythonExtension pythonExtension = pythonExtensions.get(root.getKey());
            if (pythonExtension != null) {
                builder.putPythonModules(pythonExtension.getModule().toString(), root.getValue().getPath());
                continue;
            }
            // A root named after the top-level target is our native starter.
            if (root.getKey().equals(baseParams.getBuildTarget())) {
                starterPath = root.getValue().getPath();
                continue;
            }
            // Otherwise, add it as a native library.
            NativeLinkTarget target = Preconditions.checkNotNull(roots.getIncludedRoots().get(root.getKey()), "%s: linked unexpected omnibus root: %s", baseParams.getBuildTarget(), root.getKey());
            NativeLinkTargetMode mode = target.getNativeLinkTargetMode(cxxPlatform);
            String soname = Preconditions.checkNotNull(mode.getLibraryName().orElse(null), "%s: omnibus library for %s was built without soname", baseParams.getBuildTarget(), root.getKey());
            builder.putNativeLibraries(soname, root.getValue().getPath());
        }
        // Add all remaining libraries as native libraries.
        for (OmnibusLibrary library : libraries.getLibraries()) {
            builder.putNativeLibraries(library.getSoname(), library.getPath());
        }
    } else {
        // roots.
        for (Map.Entry<BuildTarget, CxxLuaExtension> entry : luaExtensions.entrySet()) {
            CxxLuaExtension extension = entry.getValue();
            builder.putModules(extension.getModule(cxxPlatform), extension.getExtension(cxxPlatform));
            nativeLinkableRoots.putAll(Maps.uniqueIndex(extension.getNativeLinkTargetDeps(cxxPlatform), NativeLinkable::getBuildTarget));
        }
        // Add in native executable deps.
        if (starter instanceof NativeExecutableStarter) {
            NativeExecutableStarter executableStarter = (NativeExecutableStarter) starter;
            nativeLinkableRoots.putAll(Maps.uniqueIndex(executableStarter.getNativeStarterDeps(), NativeLinkable::getBuildTarget));
        }
        // python-platform specific deps to the native linkables.
        for (Map.Entry<BuildTarget, CxxPythonExtension> entry : pythonExtensions.entrySet()) {
            PythonPackageComponents components = entry.getValue().getPythonPackageComponents(pythonPlatform, cxxPlatform);
            builder.putAllPythonModules(MoreMaps.transformKeys(components.getModules(), Object::toString));
            builder.putAllNativeLibraries(MoreMaps.transformKeys(components.getNativeLibraries(), Object::toString));
            nativeLinkableRoots.putAll(Maps.uniqueIndex(entry.getValue().getNativeLinkTarget(pythonPlatform).getNativeLinkTargetDeps(cxxPlatform), NativeLinkable::getBuildTarget));
        }
        // Add shared libraries from all native linkables.
        for (NativeLinkable nativeLinkable : NativeLinkables.getTransitiveNativeLinkables(cxxPlatform, nativeLinkableRoots.values()).values()) {
            NativeLinkable.Linkage linkage = nativeLinkable.getPreferredLinkage(cxxPlatform);
            if (linkage != NativeLinkable.Linkage.STATIC) {
                builder.putAllNativeLibraries(nativeLinkable.getSharedLibraries(cxxPlatform));
            }
        }
    }
    // building one directly from the starter.
    if (starterPath == null) {
        starterPath = starter.build();
    }
    return LuaBinaryPackageComponents.of(starterPath, builder.build());
}
Also used : CxxPythonExtension(com.facebook.buck.python.CxxPythonExtension) NativeLinkable(com.facebook.buck.cxx.NativeLinkable) NativeLinkTargetMode(com.facebook.buck.cxx.NativeLinkTargetMode) OmnibusRoot(com.facebook.buck.cxx.OmnibusRoot) LinkedHashMap(java.util.LinkedHashMap) SourcePath(com.facebook.buck.rules.SourcePath) OmnibusLibraries(com.facebook.buck.cxx.OmnibusLibraries) ImmutableSet(com.google.common.collect.ImmutableSet) BuildTarget(com.facebook.buck.model.BuildTarget) OmnibusRoots(com.facebook.buck.cxx.OmnibusRoots) BuildRule(com.facebook.buck.rules.BuildRule) PythonPackageComponents(com.facebook.buck.python.PythonPackageComponents) OmnibusLibrary(com.facebook.buck.cxx.OmnibusLibrary) PythonPackagable(com.facebook.buck.python.PythonPackagable) NativeLinkTarget(com.facebook.buck.cxx.NativeLinkTarget) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap)

Aggregations

NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)34 BuildTarget (com.facebook.buck.model.BuildTarget)26 BuildRule (com.facebook.buck.rules.BuildRule)25 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)22 SourcePath (com.facebook.buck.rules.SourcePath)21 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)20 ImmutableList (com.google.common.collect.ImmutableList)19 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)18 ImmutableSet (com.google.common.collect.ImmutableSet)18 HumanReadableException (com.facebook.buck.util.HumanReadableException)17 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)14 ImmutableMap (com.google.common.collect.ImmutableMap)14 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)14 Path (java.nio.file.Path)13 Optional (java.util.Optional)13 Flavor (com.facebook.buck.model.Flavor)11 TargetGraph (com.facebook.buck.rules.TargetGraph)11 Map (java.util.Map)11 MoreCollectors (com.facebook.buck.util.MoreCollectors)10 InternalFlavor (com.facebook.buck.model.InternalFlavor)9