Search in sources :

Example 46 with CxxPlatform

use of com.facebook.buck.cxx.CxxPlatform in project buck by facebook.

the class CxxLuaExtensionDescription method createBuildRule.

@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, final BuildRuleParams params, final BuildRuleResolver resolver, final A args) throws NoSuchBuildTargetException {
    // See if we're building a particular "type" of this library, and if so, extract
    // it as an enum.
    Optional<Map.Entry<Flavor, CxxPlatform>> platform = cxxPlatforms.getFlavorAndValue(params.getBuildTarget());
    // If a C/C++ platform is specified, then build an extension with it.
    if (platform.isPresent()) {
        return createExtensionBuildRule(params, resolver, platform.get().getValue(), args);
    }
    // Otherwise, we return the generic placeholder of this library, that dependents can use
    // get the real build rules via querying the action graph.
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    final SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    return new CxxLuaExtension(params) {

        @Override
        public String getModule(CxxPlatform cxxPlatform) {
            String baseModule = LuaUtil.getBaseModule(params.getBuildTarget(), args.baseModule);
            String name = getExtensionName(params.getBuildTarget(), cxxPlatform);
            return baseModule.isEmpty() ? name : baseModule + File.separator + name;
        }

        @Override
        public SourcePath getExtension(CxxPlatform cxxPlatform) throws NoSuchBuildTargetException {
            BuildRule rule = resolver.requireRule(BuildTarget.builder(getBuildTarget()).addFlavors(cxxPlatform.getFlavor()).build());
            return Preconditions.checkNotNull(rule.getSourcePathToOutput());
        }

        @Override
        public NativeLinkTargetMode getNativeLinkTargetMode(CxxPlatform cxxPlatform) {
            return NativeLinkTargetMode.library();
        }

        @Override
        public Iterable<? extends NativeLinkable> getNativeLinkTargetDeps(CxxPlatform cxxPlatform) {
            return FluentIterable.from(params.getDeclaredDeps().get()).filter(NativeLinkable.class);
        }

        @Override
        public NativeLinkableInput getNativeLinkTargetInput(CxxPlatform cxxPlatform) throws NoSuchBuildTargetException {
            return NativeLinkableInput.builder().addAllArgs(getExtensionArgs(params, resolver, pathResolver, ruleFinder, cxxPlatform, args)).addAllFrameworks(args.frameworks).build();
        }

        @Override
        public Optional<Path> getNativeLinkTargetOutputPath(CxxPlatform cxxPlatform) {
            return Optional.empty();
        }
    };
}
Also used : Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) BuildRule(com.facebook.buck.rules.BuildRule) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver)

Example 47 with CxxPlatform

use of com.facebook.buck.cxx.CxxPlatform in project buck by facebook.

the class LuaBinaryDescription method createBuildRule.

@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, final BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    CxxPlatform cxxPlatform = cxxPlatforms.getValue(params.getBuildTarget()).orElse(defaultCxxPlatform);
    PythonPlatform pythonPlatform = pythonPlatforms.getValue(params.getBuildTarget()).orElse(pythonPlatforms.getValue(args.pythonPlatform.<Flavor>map(InternalFlavor::of).orElse(pythonPlatforms.getFlavors().iterator().next())));
    LuaBinaryPackageComponents components = getPackageComponentsFromDeps(params, resolver, pathResolver, ruleFinder, cxxPlatform, pythonPlatform, args.nativeStarterLibrary.map(Optional::of).orElse(luaConfig.getNativeStarterLibrary()), args.mainModule, args.packageStyle.orElse(luaConfig.getPackageStyle()), params.getDeclaredDeps().get());
    LuaConfig.PackageStyle packageStyle = args.packageStyle.orElse(luaConfig.getPackageStyle());
    Tool binary = getBinary(params, resolver, ruleFinder, cxxPlatform, args.mainModule, components.getStarter(), components.getComponents(), packageStyle);
    return new LuaBinary(params.copyAppendingExtraDeps(binary.getDeps(ruleFinder)), ruleFinder, getOutputPath(params.getBuildTarget(), params.getProjectFilesystem()), binary, args.mainModule, components.getComponents(), luaConfig.getLua(resolver), packageStyle);
}
Also used : PythonPlatform(com.facebook.buck.python.PythonPlatform) Optional(java.util.Optional) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) Tool(com.facebook.buck.rules.Tool) CommandTool(com.facebook.buck.rules.CommandTool)

Example 48 with CxxPlatform

use of com.facebook.buck.cxx.CxxPlatform in project buck by facebook.

the class AppleTestDescription method createBuildRule.

@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
    AppleDebugFormat debugFormat = AppleDebugFormat.FLAVOR_DOMAIN.getValue(params.getBuildTarget()).orElse(appleConfig.getDefaultDebugInfoFormatForTests());
    if (params.getBuildTarget().getFlavors().contains(debugFormat.getFlavor())) {
        params = params.withoutFlavor(debugFormat.getFlavor());
    }
    boolean createBundle = Sets.intersection(params.getBuildTarget().getFlavors(), AUXILIARY_LIBRARY_FLAVORS).isEmpty();
    // Flavors pertaining to the library targets that are generated.
    Sets.SetView<Flavor> libraryFlavors = Sets.difference(params.getBuildTarget().getFlavors(), AUXILIARY_LIBRARY_FLAVORS);
    boolean addDefaultPlatform = libraryFlavors.isEmpty();
    ImmutableSet.Builder<Flavor> extraFlavorsBuilder = ImmutableSet.builder();
    if (createBundle) {
        extraFlavorsBuilder.add(LIBRARY_FLAVOR, CxxDescriptionEnhancer.MACH_O_BUNDLE_FLAVOR);
    }
    extraFlavorsBuilder.add(debugFormat.getFlavor());
    if (addDefaultPlatform) {
        extraFlavorsBuilder.add(defaultCxxPlatform.getFlavor());
    }
    Optional<MultiarchFileInfo> multiarchFileInfo = MultiarchFileInfos.create(appleCxxPlatformFlavorDomain, params.getBuildTarget());
    AppleCxxPlatform appleCxxPlatform;
    ImmutableList<CxxPlatform> cxxPlatforms;
    if (multiarchFileInfo.isPresent()) {
        ImmutableList.Builder<CxxPlatform> cxxPlatformBuilder = ImmutableList.builder();
        for (BuildTarget thinTarget : multiarchFileInfo.get().getThinTargets()) {
            cxxPlatformBuilder.add(cxxPlatformFlavorDomain.getValue(thinTarget).get());
        }
        cxxPlatforms = cxxPlatformBuilder.build();
        appleCxxPlatform = multiarchFileInfo.get().getRepresentativePlatform();
    } else {
        CxxPlatform cxxPlatform = cxxPlatformFlavorDomain.getValue(params.getBuildTarget()).orElse(defaultCxxPlatform);
        cxxPlatforms = ImmutableList.of(cxxPlatform);
        try {
            appleCxxPlatform = appleCxxPlatformFlavorDomain.getValue(cxxPlatform.getFlavor());
        } catch (FlavorDomainException e) {
            throw new HumanReadableException(e, "%s: Apple test requires an Apple platform, found '%s'", params.getBuildTarget(), cxxPlatform.getFlavor().getName());
        }
    }
    Optional<TestHostInfo> testHostInfo;
    if (args.testHostApp.isPresent()) {
        testHostInfo = Optional.of(createTestHostInfo(params, resolver, args.testHostApp.get(), debugFormat, libraryFlavors, cxxPlatforms));
    } else {
        testHostInfo = Optional.empty();
    }
    BuildTarget libraryTarget = params.getBuildTarget().withAppendedFlavors(extraFlavorsBuilder.build()).withAppendedFlavors(debugFormat.getFlavor()).withAppendedFlavors(LinkerMapMode.NO_LINKER_MAP.getFlavor());
    BuildRule library = createTestLibraryRule(targetGraph, params, resolver, args, testHostInfo.map(TestHostInfo::getTestHostAppBinarySourcePath), testHostInfo.map(TestHostInfo::getBlacklist).orElse(ImmutableSet.of()), libraryTarget);
    if (!createBundle || SwiftLibraryDescription.isSwiftTarget(libraryTarget)) {
        return library;
    }
    String platformName = appleCxxPlatform.getAppleSdk().getApplePlatform().getName();
    AppleBundle bundle = AppleDescriptions.createAppleBundle(cxxPlatformFlavorDomain, defaultCxxPlatform, appleCxxPlatformFlavorDomain, targetGraph, params.withBuildTarget(params.getBuildTarget().withAppendedFlavors(BUNDLE_FLAVOR, debugFormat.getFlavor(), LinkerMapMode.NO_LINKER_MAP.getFlavor(), AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR)).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>naturalOrder().add(library).addAll(params.getDeclaredDeps().get()).build()), params.getExtraDeps()), resolver, codeSignIdentityStore, provisioningProfileStore, library.getBuildTarget(), args.getExtension(), Optional.empty(), args.infoPlist, args.infoPlistSubstitutions, args.deps, args.tests, debugFormat, appleConfig.useDryRunCodeSigning(), appleConfig.cacheBundlesAndPackages());
    resolver.addToIndex(bundle);
    Optional<SourcePath> xctool = getXctool(params, resolver);
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    return new AppleTest(xctool, appleConfig.getXctoolStutterTimeoutMs(), appleCxxPlatform.getXctest(), appleConfig.getXctestPlatformNames().contains(platformName), platformName, appleConfig.getXctoolDefaultDestinationSpecifier(), Optional.of(args.destinationSpecifier), params.copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of(bundle)), Suppliers.ofInstance(ImmutableSortedSet.of())), bundle, testHostInfo.map(TestHostInfo::getTestHostApp), args.contacts, args.labels, args.getRunTestSeparately(), xcodeDeveloperDirectorySupplier, appleConfig.getTestLogDirectoryEnvironmentVariable(), appleConfig.getTestLogLevelEnvironmentVariable(), appleConfig.getTestLogLevel(), args.testRuleTimeoutMs.map(Optional::of).orElse(defaultTestRuleTimeoutMs), args.isUiTest(), args.snapshotReferenceImagesPath, ruleFinder);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) PathSourcePath(com.facebook.buck.rules.PathSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) ImmutableSet(com.google.common.collect.ImmutableSet) Sets(com.google.common.collect.Sets) BuildTarget(com.facebook.buck.model.BuildTarget) AbstractBuildRule(com.facebook.buck.rules.AbstractBuildRule) BuildRule(com.facebook.buck.rules.BuildRule) FlavorDomainException(com.facebook.buck.model.FlavorDomainException) Optional(java.util.Optional) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) InternalFlavor(com.facebook.buck.model.InternalFlavor) Flavor(com.facebook.buck.model.Flavor) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) HumanReadableException(com.facebook.buck.util.HumanReadableException)

Example 49 with CxxPlatform

use of com.facebook.buck.cxx.CxxPlatform in project buck by facebook.

the class RustCompileUtils method createBinaryBuildRule.

public static BinaryWrapperRule createBinaryBuildRule(BuildRuleParams params, BuildRuleResolver resolver, RustBuckConfig rustBuckConfig, FlavorDomain<CxxPlatform> cxxPlatforms, CxxPlatform defaultCxxPlatform, Optional<String> crateName, ImmutableSortedSet<String> features, Iterator<String> rustcFlags, Iterator<String> linkerFlags, Linker.LinkableDepType linkStyle, boolean rpath, ImmutableSortedSet<SourcePath> srcs, Optional<SourcePath> crateRoot, ImmutableSet<String> defaultRoots) throws NoSuchBuildTargetException {
    final BuildTarget buildTarget = params.getBuildTarget();
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    ImmutableList.Builder<String> rustcArgs = ImmutableList.builder();
    RustCompileUtils.addFeatures(buildTarget, features, rustcArgs);
    rustcArgs.addAll(rustcFlags);
    ImmutableList.Builder<String> linkerArgs = ImmutableList.builder();
    linkerArgs.addAll(linkerFlags);
    String crate = crateName.orElse(ruleToCrateName(buildTarget.getShortName()));
    CxxPlatform cxxPlatform = cxxPlatforms.getValue(params.getBuildTarget()).orElse(defaultCxxPlatform);
    Pair<SourcePath, ImmutableSortedSet<SourcePath>> rootModuleAndSources = getRootModuleAndSources(params.getBuildTarget(), resolver, pathResolver, ruleFinder, cxxPlatform, crate, crateRoot, defaultRoots, srcs);
    // The target to use for the link rule.
    BuildTarget binaryTarget = params.getBuildTarget().withAppendedFlavors(cxxPlatform.getFlavor(), RustDescriptionEnhancer.RFBIN);
    CommandTool.Builder executableBuilder = new CommandTool.Builder();
    // Special handling for dynamically linked binaries.
    if (linkStyle == Linker.LinkableDepType.SHARED) {
        // Create a symlink tree with for all native shared (NativeLinkable) libraries
        // needed by this binary.
        SymlinkTree sharedLibraries = resolver.addToIndex(CxxDescriptionEnhancer.createSharedLibrarySymlinkTree(ruleFinder, params.getBuildTarget(), params.getProjectFilesystem(), cxxPlatform, params.getDeps(), RustLinkable.class::isInstance, RustLinkable.class::isInstance));
        // Embed a origin-relative library path into the binary so it can find the shared libraries.
        // The shared libraries root is absolute. Also need an absolute path to the linkOutput
        Path absBinaryDir = params.getBuildTarget().getCellPath().resolve(RustCompileRule.getOutputDir(binaryTarget, params.getProjectFilesystem()));
        linkerArgs.addAll(Linkers.iXlinker("-rpath", String.format("%s/%s", cxxPlatform.getLd().resolve(resolver).origin(), absBinaryDir.relativize(sharedLibraries.getRoot()).toString())));
        // Add all the shared libraries and the symlink tree as inputs to the tool that represents
        // this binary, so that users can attach the proper deps.
        executableBuilder.addDep(sharedLibraries);
        executableBuilder.addInputs(sharedLibraries.getLinks().values());
        // Also add Rust shared libraries as runtime deps. We don't need these in the symlink tree
        // because rustc will include their dirs in rpath by default.
        Map<String, SourcePath> rustSharedLibraries = getTransitiveRustSharedLibraries(cxxPlatform, params.getDeps());
        executableBuilder.addInputs(rustSharedLibraries.values());
    }
    final RustCompileRule buildRule = RustCompileUtils.createBuild(binaryTarget, crate, params, resolver, pathResolver, ruleFinder, cxxPlatform, rustBuckConfig, rustcArgs.build(), linkerArgs.build(), /* linkerInputs */
    ImmutableList.of(), CrateType.BIN, linkStyle, rpath, rootModuleAndSources.getSecond(), rootModuleAndSources.getFirst());
    // Add the binary as the first argument.
    executableBuilder.addArg(SourcePathArg.of(buildRule.getSourcePathToOutput()));
    final CommandTool executable = executableBuilder.build();
    return new BinaryWrapperRule(params.copyAppendingExtraDeps(buildRule), ruleFinder) {

        @Override
        public Tool getExecutableCommand() {
            return executable;
        }

        @Override
        public SourcePath getSourcePathToOutput() {
            return new ForwardingBuildTargetSourcePath(getBuildTarget(), buildRule.getSourcePathToOutput());
        }
    };
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ForwardingBuildTargetSourcePath(com.facebook.buck.rules.ForwardingBuildTargetSourcePath) HasSourcePath(com.facebook.buck.rules.args.HasSourcePath) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) ImmutableList(com.google.common.collect.ImmutableList) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BinaryWrapperRule(com.facebook.buck.rules.BinaryWrapperRule) SourcePath(com.facebook.buck.rules.SourcePath) ForwardingBuildTargetSourcePath(com.facebook.buck.rules.ForwardingBuildTargetSourcePath) HasSourcePath(com.facebook.buck.rules.args.HasSourcePath) ForwardingBuildTargetSourcePath(com.facebook.buck.rules.ForwardingBuildTargetSourcePath) SymlinkTree(com.facebook.buck.rules.SymlinkTree) CommandTool(com.facebook.buck.rules.CommandTool) BuildTarget(com.facebook.buck.model.BuildTarget) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet)

Example 50 with CxxPlatform

use of com.facebook.buck.cxx.CxxPlatform in project buck by facebook.

the class RustLibraryDescription method createBuildRule.

@Override
public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph, BuildRuleParams params, BuildRuleResolver resolver, A args) throws NoSuchBuildTargetException {
    final BuildTarget buildTarget = params.getBuildTarget();
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    ImmutableList.Builder<String> rustcArgs = ImmutableList.builder();
    RustCompileUtils.addFeatures(buildTarget, args.features, rustcArgs);
    rustcArgs.addAll(args.rustcFlags);
    rustcArgs.addAll(rustBuckConfig.getRustLibraryFlags());
    String crate = args.crate.orElse(ruleToCrateName(params.getBuildTarget().getShortName()));
    // See if we're building a particular "type" and "platform" of this library, and if so, extract
    // them from the flavors attached to the build target.
    Optional<Map.Entry<Flavor, RustDescriptionEnhancer.Type>> type = LIBRARY_TYPE.getFlavorAndValue(buildTarget);
    Optional<CxxPlatform> cxxPlatform = cxxPlatforms.getValue(buildTarget);
    if (type.isPresent()) {
        // Uncommon case - someone explicitly invoked buck to build a specific flavor as the
        // direct target.
        CrateType crateType = type.get().getValue().getCrateType();
        Linker.LinkableDepType depType;
        if (crateType.isDynamic()) {
            depType = Linker.LinkableDepType.SHARED;
        } else {
            if (crateType.isPic()) {
                depType = Linker.LinkableDepType.STATIC_PIC;
            } else {
                depType = Linker.LinkableDepType.STATIC;
            }
        }
        return requireBuild(params, resolver, pathResolver, ruleFinder, cxxPlatform.orElse(defaultCxxPlatform), rustBuckConfig, rustcArgs.build(), /* linkerArgs */
        ImmutableList.of(), /* linkerInputs */
        ImmutableList.of(), crate, crateType, depType, args);
    }
    // Common case - we're being invoked to satisfy some other rule's dependency.
    return new RustLibrary(params) {

        // RustLinkable
        @Override
        public com.facebook.buck.rules.args.Arg getLinkerArg(boolean direct, CxxPlatform cxxPlatform, Linker.LinkableDepType depType) {
            BuildRule rule;
            CrateType crateType;
            // the use of -rpath will break with flavored paths containing ','.
            switch(args.preferredLinkage) {
                case ANY:
                default:
                    switch(depType) {
                        case SHARED:
                            crateType = CrateType.DYLIB;
                            break;
                        case STATIC_PIC:
                            crateType = CrateType.RLIB_PIC;
                            break;
                        case STATIC:
                        default:
                            crateType = CrateType.RLIB;
                            break;
                    }
                    break;
                case SHARED:
                    crateType = CrateType.DYLIB;
                    break;
                case STATIC:
                    if (depType == Linker.LinkableDepType.STATIC) {
                        crateType = CrateType.RLIB;
                    } else {
                        crateType = CrateType.RLIB_PIC;
                    }
                    break;
            }
            try {
                rule = requireBuild(params, resolver, pathResolver, ruleFinder, cxxPlatform, rustBuckConfig, rustcArgs.build(), /* linkerArgs */
                ImmutableList.of(), /* linkerInputs */
                ImmutableList.of(), crate, crateType, depType, args);
            } catch (NoSuchBuildTargetException e) {
                throw new RuntimeException(e);
            }
            SourcePath rlib = rule.getSourcePathToOutput();
            return new RustLibraryArg(pathResolver, crate, rlib, direct, params.getDeps());
        }

        @Override
        public Linkage getPreferredLinkage() {
            return args.preferredLinkage;
        }

        @Override
        public ImmutableMap<String, SourcePath> getRustSharedLibraries(CxxPlatform cxxPlatform) throws NoSuchBuildTargetException {
            ImmutableMap.Builder<String, SourcePath> libs = ImmutableMap.builder();
            String sharedLibrarySoname = CrateType.DYLIB.filenameFor(crate, cxxPlatform);
            BuildRule sharedLibraryBuildRule = requireBuild(params, resolver, pathResolver, ruleFinder, cxxPlatform, rustBuckConfig, rustcArgs.build(), /* linkerArgs */
            ImmutableList.of(), /* linkerInputs */
            ImmutableList.of(), crate, CrateType.DYLIB, Linker.LinkableDepType.SHARED, args);
            libs.put(sharedLibrarySoname, sharedLibraryBuildRule.getSourcePathToOutput());
            return libs.build();
        }

        // NativeLinkable
        @Override
        public Iterable<? extends NativeLinkable> getNativeLinkableDeps() {
            return ImmutableList.of();
        }

        @Override
        public Iterable<? extends NativeLinkable> getNativeLinkableExportedDeps() {
            return FluentIterable.from(getDeps()).filter(NativeLinkable.class);
        }

        @Override
        public NativeLinkableInput getNativeLinkableInput(CxxPlatform cxxPlatform, Linker.LinkableDepType depType) throws NoSuchBuildTargetException {
            CrateType crateType;
            switch(depType) {
                case SHARED:
                    crateType = CrateType.CDYLIB;
                    break;
                case STATIC_PIC:
                    crateType = CrateType.STATIC_PIC;
                    break;
                case STATIC:
                default:
                    crateType = CrateType.STATIC;
                    break;
            }
            BuildRule rule = requireBuild(params, resolver, pathResolver, ruleFinder, cxxPlatform, rustBuckConfig, rustcArgs.build(), /* linkerArgs */
            ImmutableList.of(), /* linkerInputs */
            ImmutableList.of(), crate, crateType, depType, args);
            SourcePath lib = rule.getSourcePathToOutput();
            SourcePathArg arg = SourcePathArg.of(lib);
            return NativeLinkableInput.builder().addArgs(arg).build();
        }

        @Override
        public Linkage getPreferredLinkage(CxxPlatform cxxPlatform) {
            return args.preferredLinkage;
        }

        @Override
        public ImmutableMap<String, SourcePath> getSharedLibraries(CxxPlatform cxxPlatform) throws NoSuchBuildTargetException {
            ImmutableMap.Builder<String, SourcePath> libs = ImmutableMap.builder();
            String sharedLibrarySoname = CxxDescriptionEnhancer.getSharedLibrarySoname(Optional.empty(), getBuildTarget(), cxxPlatform);
            BuildRule sharedLibraryBuildRule = requireBuild(params, resolver, pathResolver, ruleFinder, cxxPlatform, rustBuckConfig, rustcArgs.build(), /* linkerArgs */
            ImmutableList.of(), /* linkerInputs */
            ImmutableList.of(), crate, CrateType.CDYLIB, Linker.LinkableDepType.SHARED, args);
            libs.put(sharedLibrarySoname, sharedLibraryBuildRule.getSourcePathToOutput());
            return libs.build();
        }
    };
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) SourcePath(com.facebook.buck.rules.SourcePath) BuildTarget(com.facebook.buck.model.BuildTarget) BuildRule(com.facebook.buck.rules.BuildRule) SourcePathArg(com.facebook.buck.rules.args.SourcePathArg) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) Linker(com.facebook.buck.cxx.Linker) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) ImmutableMap(com.google.common.collect.ImmutableMap) NoSuchBuildTargetException(com.facebook.buck.parser.NoSuchBuildTargetException)

Aggregations

CxxPlatform (com.facebook.buck.cxx.CxxPlatform)52 Test (org.junit.Test)25 ImmutableMap (com.google.common.collect.ImmutableMap)24 Path (java.nio.file.Path)22 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)20 BuildTarget (com.facebook.buck.model.BuildTarget)19 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)19 SourcePath (com.facebook.buck.rules.SourcePath)17 BuildRule (com.facebook.buck.rules.BuildRule)14 ImmutableList (com.google.common.collect.ImmutableList)11 HumanReadableException (com.facebook.buck.util.HumanReadableException)9 ImmutableSet (com.google.common.collect.ImmutableSet)9 FakeExecutableFinder (com.facebook.buck.io.FakeExecutableFinder)8 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)8 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)8 Optional (java.util.Optional)8 Flavor (com.facebook.buck.model.Flavor)7 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)7 CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)6 Linker (com.facebook.buck.cxx.Linker)6