diff options
author | Carmi Grushko <carmi@google.com> | 2016-05-25 14:18:15 +0000 |
---|---|---|
committer | Yue Gan <yueg@google.com> | 2016-05-27 08:43:55 +0000 |
commit | 472be687fb942233caba87edcba5ed65471c4ce1 (patch) | |
tree | 299b30b4d8211e4aebfd66a110564557917fdd5d /src/main/java/com/google/devtools/build/lib | |
parent | 32ad74234fcb9f4b628d844297576c5e2290783a (diff) |
--
MOS_MIGRATED_REVID=123210708
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java index 15e27985e3..ae43116519 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java @@ -138,20 +138,39 @@ public final class PyCommon { public void addCommonTransitiveInfoProviders(RuleConfiguredTargetBuilder builder, PythonSemantics semantics, NestedSet<Artifact> filesToBuild) { - SkylarkClassObject sourcesProvider = - new SkylarkClassObject(ImmutableMap.<String, Object>of( - TRANSITIVE_PYTHON_SRCS, SkylarkNestedSet.of(Artifact.class, transitivePythonSources), - IS_USING_SHARED_LIBRARY, usesSharedLibraries()), "No such attribute '%s'"); builder - .add(InstrumentedFilesProvider.class, InstrumentedFilesCollector.collect(ruleContext, - semantics.getCoverageInstrumentationSpec(), METADATA_COLLECTOR, filesToBuild)) - .addSkylarkTransitiveInfo(PYTHON_SKYLARK_PROVIDER_NAME, sourcesProvider) + .add( + InstrumentedFilesProvider.class, + InstrumentedFilesCollector.collect( + ruleContext, + semantics.getCoverageInstrumentationSpec(), + METADATA_COLLECTOR, + filesToBuild)) + .addSkylarkTransitiveInfo( + PYTHON_SKYLARK_PROVIDER_NAME, + createSourceProvider(this.transitivePythonSources, usesSharedLibraries())) // Python targets are not really compilable. The best we can do is make sure that all // generated source files are ready. .addOutputGroup(OutputGroupProvider.FILES_TO_COMPILE, transitivePythonSources) .addOutputGroup(OutputGroupProvider.COMPILATION_PREREQUISITES, transitivePythonSources); } + /** + * Returns a Skylark struct for exposing transitive Python sources: + * + * addSkylarkTransitiveInfo(PYTHON_SKYLARK_PROVIDER_NAME, createSourceProvider(...)) + */ + public static SkylarkClassObject createSourceProvider( + NestedSet<Artifact> transitivePythonSources, boolean isUsingSharedLibrary) { + return new SkylarkClassObject( + ImmutableMap.<String, Object>of( + TRANSITIVE_PYTHON_SRCS, + SkylarkNestedSet.of(Artifact.class, transitivePythonSources), + IS_USING_SHARED_LIBRARY, + isUsingSharedLibrary), + "No such attribute '%s'"); + } + public PythonVersion getDefaultPythonVersion() { return ruleContext.getRule() .isAttrDefined("default_python_version", Type.STRING) |