Search in sources :

Example 46 with RuleConfiguredTargetBuilder

use of com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder in project bazel by bazelbuild.

the class ReleaseBundlingTargetFactory method create.

@Override
public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException {
    validateAttributes(ruleContext);
    ObjcCommon common = common(ruleContext);
    XcodeProvider.Builder xcodeProviderBuilder = new XcodeProvider.Builder();
    NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.stableOrder();
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    ReleaseBundlingSupport releaseBundlingSupport = new ReleaseBundlingSupport(ruleContext, common.getObjcProvider(), LinkedBinary.DEPENDENCIES_ONLY, bundleDirFormat, bundleName(ruleContext), bundleMinimumOsVersion(ruleContext), appleConfiguration.getMultiArchPlatform(PlatformType.IOS));
    releaseBundlingSupport.registerActions(DsymOutputType.APP).addXcodeSettings(xcodeProviderBuilder).addFilesToBuild(filesToBuild, Optional.of(DsymOutputType.APP)).validateResources().validateAttributes();
    XcodeSupport xcodeSupport = new XcodeSupport(ruleContext).addFilesToBuild(filesToBuild).addXcodeSettings(xcodeProviderBuilder, common.getObjcProvider(), xcodeProductType, ruleContext.getFragment(AppleConfiguration.class).getDependencySingleArchitecture(), configurationDistinguisher).addDummySource(xcodeProviderBuilder);
    for (Attribute attribute : dependencyAttributes) {
        xcodeSupport.addDependencies(xcodeProviderBuilder, attribute);
    }
    xcodeSupport.registerActions(xcodeProviderBuilder.build());
    RuleConfiguredTargetBuilder targetBuilder = ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build()).addProvider(XcTestAppProvider.class, releaseBundlingSupport.xcTestAppProvider()).addProvider(XcodeProvider.class, xcodeProviderBuilder.build()).addProvider(InstrumentedFilesProvider.class, InstrumentedFilesCollector.forward(ruleContext, "binary"));
    ObjcProvider exposedObjcProvider = exposedObjcProvider(ruleContext, releaseBundlingSupport);
    if (exposedObjcProvider != null) {
        targetBuilder.addProvider(ObjcProvider.class, exposedObjcProvider);
    }
    configureTarget(targetBuilder, ruleContext, releaseBundlingSupport);
    return targetBuilder.build();
}
Also used : NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration) Artifact(com.google.devtools.build.lib.actions.Artifact)

Example 47 with RuleConfiguredTargetBuilder

use of com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder in project bazel by bazelbuild.

the class PyLibrary method create.

@Override
public ConfiguredTarget create(final RuleContext ruleContext) throws RuleErrorException {
    PythonSemantics semantics = createSemantics();
    PyCommon common = new PyCommon(ruleContext);
    common.initCommon(common.getDefaultPythonVersion());
    common.validatePackageName();
    semantics.validate(ruleContext, common);
    List<Artifact> srcs = common.validateSrcs();
    List<Artifact> allOutputs = new ArrayList<>(semantics.precompiledPythonFiles(ruleContext, srcs, common));
    if (ruleContext.hasErrors()) {
        return null;
    }
    NestedSet<Artifact> filesToBuild = NestedSetBuilder.wrap(Order.STABLE_ORDER, allOutputs);
    common.addPyExtraActionPseudoAction();
    CcLinkParamsStore ccLinkParamsStore = new CcLinkParamsStore() {

        @Override
        protected void collect(CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) {
            builder.addTransitiveTargets(ruleContext.getPrerequisites("deps", Mode.TARGET), PyCcLinkParamsProvider.TO_LINK_PARAMS, CcLinkParamsProvider.TO_LINK_PARAMS);
        }
    };
    NestedSet<PathFragment> imports = common.collectImports(ruleContext, semantics);
    if (ruleContext.hasErrors()) {
        return null;
    }
    Runfiles.Builder runfilesBuilder = new Runfiles.Builder(ruleContext.getWorkspaceName(), ruleContext.getConfiguration().legacyExternalRunfiles());
    if (common.getConvertedFiles() != null) {
        runfilesBuilder.addSymlinks(common.getConvertedFiles());
    } else {
        runfilesBuilder.addTransitiveArtifacts(filesToBuild);
    }
    runfilesBuilder.setEmptyFilesSupplier(PythonUtils.GET_INIT_PY_FILES);
    runfilesBuilder.add(ruleContext, PythonRunfilesProvider.TO_RUNFILES);
    runfilesBuilder.addRunfiles(ruleContext, RunfilesProvider.DEFAULT_RUNFILES);
    RuleConfiguredTargetBuilder builder = new RuleConfiguredTargetBuilder(ruleContext);
    common.addCommonTransitiveInfoProviders(builder, semantics, filesToBuild);
    return builder.setFilesToBuild(filesToBuild).add(RunfilesProvider.class, RunfilesProvider.simple(runfilesBuilder.build())).add(CcLinkParamsProvider.class, new CcLinkParamsProvider(ccLinkParamsStore)).add(PythonImportsProvider.class, new PythonImportsProvider(imports)).build();
}
Also used : NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) CcLinkParamsProvider(com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider) ArrayList(java.util.ArrayList) CcLinkParamsStore(com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RunfilesProvider(com.google.devtools.build.lib.analysis.RunfilesProvider) Artifact(com.google.devtools.build.lib.actions.Artifact) Runfiles(com.google.devtools.build.lib.analysis.Runfiles) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)

Example 48 with RuleConfiguredTargetBuilder

use of com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder in project bazel by bazelbuild.

the class PyBinary method create.

@Override
public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException {
    PyCommon common = new PyCommon(ruleContext);
    common.initCommon(common.getDefaultPythonVersion());
    RuleConfiguredTargetBuilder builder = init(ruleContext, createSemantics(), common);
    if (builder == null) {
        return null;
    }
    return builder.build();
}
Also used : RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)

Aggregations

RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)48 Artifact (com.google.devtools.build.lib.actions.Artifact)36 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)21 RunfilesProvider (com.google.devtools.build.lib.analysis.RunfilesProvider)19 Runfiles (com.google.devtools.build.lib.analysis.Runfiles)17 TransitiveInfoCollection (com.google.devtools.build.lib.analysis.TransitiveInfoCollection)11 RunfilesSupport (com.google.devtools.build.lib.analysis.RunfilesSupport)7 AppleConfiguration (com.google.devtools.build.lib.rules.apple.AppleConfiguration)6 CcLinkParamsProvider (com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider)5 ArrayList (java.util.ArrayList)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 FileProvider (com.google.devtools.build.lib.analysis.FileProvider)4 FilesToRunProvider (com.google.devtools.build.lib.analysis.FilesToRunProvider)4 Label (com.google.devtools.build.lib.cmdline.Label)4 CcLinkParamsStore (com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore)4 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)4 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)3 JavaRuleOutputJarsProvider (com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider)3 CompositeRunfilesSupplier (com.google.devtools.build.lib.actions.CompositeRunfilesSupplier)2 CommandHelper (com.google.devtools.build.lib.analysis.CommandHelper)2