Search in sources :

Example 26 with NestedSetBuilder

use of com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder in project bazel by bazelbuild.

the class Watch2ExtensionSupport method createBundle.

/**
   * Registers actions to create a watchOS2 extension bundle and zip it into an {@code .ipa}.
   *
   * @param ipaArtifact an .ipa artifact containing to extension bundle; this is the output artifact
   *     of the bundling
   */
void createBundle(Artifact ipaArtifact, NestedSetBuilder<Artifact> extensionFilesToBuild, ObjcProvider.Builder exposedObjcProviderBuilder) throws InterruptedException {
    ObjcProvider.Builder releaseBundlingObjcProviderBuilder = new ObjcProvider.Builder();
    releaseBundlingObjcProviderBuilder.addTransitiveAndPropagate(attributes.binaryDependencies());
    releaseBundlingObjcProviderBuilder.addAll(GENERAL_RESOURCE_FILE, attributes.resources()).addAll(GENERAL_RESOURCE_FILE, attributes.strings()).addAll(GENERAL_RESOURCE_DIR, ObjcCommon.xcodeStructuredResourceDirs(attributes.structuredResources())).addAll(BUNDLE_FILE, BundleableFile.flattenedRawResourceFiles(attributes.resources())).addAll(BUNDLE_FILE, BundleableFile.structuredRawResourceFiles(attributes.structuredResources())).addAll(STRINGS, attributes.strings());
    ObjcProvider releaseBundlingObjcProvider = releaseBundlingObjcProviderBuilder.build();
    ReleaseBundling.Builder releaseBundling = new ReleaseBundling.Builder().setIpaArtifact(ipaArtifact).setBundleId(attributes.bundleId()).setProvisioningProfile(attributes.provisioningProfile()).setProvisioningProfileAttributeName(WATCH_EXT_PROVISIONING_PROFILE_ATTR).setTargetDeviceFamilies(ImmutableSet.of(TargetDeviceFamily.WATCH)).setIntermediateArtifacts(intermediateArtifacts).setInfoPlistsFromRule(attributes.infoPlists()).setEntitlements(attributes.entitlements());
    if (attributes.isBundleIdExplicitySpecified()) {
        releaseBundling.setPrimaryBundleId(attributes.bundleId());
    } else {
        releaseBundling.setFallbackBundleId(attributes.bundleId());
    }
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    ReleaseBundlingSupport releaseBundlingSupport = new ReleaseBundlingSupport(ruleContext, releaseBundlingObjcProvider, LinkedBinary.DEPENDENCIES_ONLY, ReleaseBundlingSupport.EXTENSION_BUNDLE_DIR_FORMAT, bundleName, appleConfiguration.getMinimumOsForPlatformType(PlatformType.WATCHOS), releaseBundling.build(), appleConfiguration.getMultiArchPlatform(PlatformType.WATCHOS));
    releaseBundlingSupport.registerActions(DsymOutputType.APP).addFilesToBuild(extensionFilesToBuild, Optional.of(DsymOutputType.APP)).validateResources().validateAttributes().addExportedDebugArtifacts(exposedObjcProviderBuilder, DsymOutputType.APP);
}
Also used : NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration)

Example 27 with NestedSetBuilder

use of com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder in project bazel by bazelbuild.

the class WatchApplicationSupport method createBundle.

private void createBundle(Optional<XcodeProvider.Builder> xcodeProviderBuilder, ObjcProvider depsObjcProvider, NestedSetBuilder<Artifact> filesToBuild) throws InterruptedException {
    registerActions();
    ReleaseBundling.Builder releaseBundling = new ReleaseBundling.Builder().setIpaArtifact(ipaArtifact).setBundleId(attributes.bundleId()).setAppIcon(attributes.appIcon()).setProvisioningProfile(attributes.provisioningProfile()).setProvisioningProfileAttributeName(WATCH_APP_PROVISIONING_PROFILE_ATTR).setTargetDeviceFamilies(families()).setIntermediateArtifacts(intermediateArtifacts).setInfoPlistsFromRule(attributes.infoPlists()).setArtifactPrefix(artifactPrefix).setEntitlements(attributes.entitlements());
    if (attributes.isBundleIdExplicitySpecified()) {
        releaseBundling.setPrimaryBundleId(attributes.bundleId());
    } else {
        releaseBundling.setFallbackBundleId(attributes.bundleId());
    }
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    PlatformType appPlatformType = watchOSVersion == WatchOSVersion.OS1 ? PlatformType.IOS : PlatformType.WATCHOS;
    DottedVersion minimumOsVersion = appPlatformType == PlatformType.IOS ? WatchUtils.determineMinimumIosVersion(appleConfiguration.getMinimumOsForPlatformType(PlatformType.IOS)) : appleConfiguration.getMinimumOsForPlatformType(PlatformType.WATCHOS);
    ReleaseBundlingSupport releaseBundlingSupport = new ReleaseBundlingSupport(ruleContext, depsObjcProvider, LinkedBinary.DEPENDENCIES_ONLY, watchOSVersion.getApplicationBundleDirFormat(), bundleName, minimumOsVersion, releaseBundling.build(), appleConfiguration.getMultiArchPlatform(appPlatformType)).registerActions(DsymOutputType.APP);
    if (xcodeProviderBuilder.isPresent()) {
        releaseBundlingSupport.addXcodeSettings(xcodeProviderBuilder.get());
    }
    releaseBundlingSupport.addFilesToBuild(filesToBuild, Optional.<DsymOutputType>absent()).validateResources().validateAttributes();
}
Also used : DottedVersion(com.google.devtools.build.lib.rules.apple.DottedVersion) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration) PlatformType(com.google.devtools.build.lib.rules.apple.Platform.PlatformType)

Example 28 with NestedSetBuilder

use of com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder in project bazel by bazelbuild.

the class BuildView method getDirectPrerequisiteDependenciesForTesting.

@VisibleForTesting
public OrderedSetMultimap<Attribute, Dependency> getDirectPrerequisiteDependenciesForTesting(final ExtendedEventHandler eventHandler, final ConfiguredTarget ct, BuildConfigurationCollection configurations) throws EvalException, InvalidConfigurationException, InterruptedException, InconsistentAspectOrderException {
    if (!(ct.getTarget() instanceof Rule)) {
        return OrderedSetMultimap.create();
    }
    class SilentDependencyResolver extends DependencyResolver {

        @Override
        protected void invalidVisibilityReferenceHook(TargetAndConfiguration node, Label label) {
            throw new RuntimeException("bad visibility on " + label + " during testing unexpected");
        }

        @Override
        protected void invalidPackageGroupReferenceHook(TargetAndConfiguration node, Label label) {
            throw new RuntimeException("bad package group on " + label + " during testing unexpected");
        }

        @Override
        protected void missingEdgeHook(Target from, Label to, NoSuchThingException e) {
            throw new RuntimeException("missing dependency from " + from.getLabel() + " to " + to + ": " + e.getMessage(), e);
        }

        @Override
        protected Target getTarget(Target from, Label label, NestedSetBuilder<Label> rootCauses) throws InterruptedException {
            try {
                return skyframeExecutor.getPackageManager().getTarget(eventHandler, label);
            } catch (NoSuchThingException e) {
                throw new IllegalStateException(e);
            }
        }

        @Override
        protected List<BuildConfiguration> getConfigurations(Set<Class<? extends BuildConfiguration.Fragment>> fragments, Iterable<BuildOptions> buildOptions) {
            Preconditions.checkArgument(ct.getConfiguration().fragmentClasses().equals(fragments));
            Dependency asDep = Dependency.withTransitionAndAspects(ct.getLabel(), Attribute.ConfigurationTransition.NONE, AspectCollection.EMPTY);
            ImmutableList.Builder<BuildConfiguration> builder = ImmutableList.builder();
            for (BuildOptions options : buildOptions) {
                builder.add(Iterables.getOnlyElement(skyframeExecutor.getConfigurations(eventHandler, options, ImmutableList.<Dependency>of(asDep)).values()));
            }
            return builder.build();
        }
    }
    DependencyResolver dependencyResolver = new SilentDependencyResolver();
    TargetAndConfiguration ctgNode = new TargetAndConfiguration(ct.getTarget(), ct.getConfiguration());
    return dependencyResolver.dependentNodeMap(ctgNode, configurations.getHostConfiguration(), /*aspect=*/
    null, getConfigurableAttributeKeysForTesting(eventHandler, ctgNode));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) NestedSet(com.google.devtools.build.lib.collect.nestedset.NestedSet) ImmutableList(com.google.common.collect.ImmutableList) Label(com.google.devtools.build.lib.cmdline.Label) BuildConfiguration(com.google.devtools.build.lib.analysis.config.BuildConfiguration) Target(com.google.devtools.build.lib.packages.Target) NoSuchThingException(com.google.devtools.build.lib.packages.NoSuchThingException) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) BuildOptions(com.google.devtools.build.lib.analysis.config.BuildOptions) Rule(com.google.devtools.build.lib.packages.Rule) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)28 Artifact (com.google.devtools.build.lib.actions.Artifact)24 RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)18 TransitiveInfoCollection (com.google.devtools.build.lib.analysis.TransitiveInfoCollection)8 AppleConfiguration (com.google.devtools.build.lib.rules.apple.AppleConfiguration)8 Runfiles (com.google.devtools.build.lib.analysis.Runfiles)6 RunfilesProvider (com.google.devtools.build.lib.analysis.RunfilesProvider)6 ImmutableList (com.google.common.collect.ImmutableList)4 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)4 FileProvider (com.google.devtools.build.lib.analysis.FileProvider)3 RunfilesSupport (com.google.devtools.build.lib.analysis.RunfilesSupport)3 ParameterFileWriteAction (com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction)3 SpawnAction (com.google.devtools.build.lib.analysis.actions.SpawnAction)3 Label (com.google.devtools.build.lib.cmdline.Label)3 PlatformType (com.google.devtools.build.lib.rules.apple.Platform.PlatformType)3 CcLinkParamsProvider (com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider)3 JavaRuleOutputJarsProvider (com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider)3 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)3 ArrayList (java.util.ArrayList)3 ImmutableSet (com.google.common.collect.ImmutableSet)2