use of com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider 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();
}
Aggregations