diff options
author | Googler <noreply@google.com> | 2016-02-04 12:31:37 +0000 |
---|---|---|
committer | David Chen <dzc@google.com> | 2016-02-04 18:14:24 +0000 |
commit | 177ec024dc21e78948cb9fe032df36c07a632d01 (patch) | |
tree | fb196bfa9fd912d210bcbdaf864c32142eda265e /src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java | |
parent | dae6da99906e39a3ad45494f7931ef12e36eeb8b (diff) |
--
MOS_MIGRATED_REVID=113835948
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java | 12 |
1 files changed, 11 insertions, 1 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 a1673bb6f6..969955f55a 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 @@ -34,6 +34,7 @@ import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; import com.google.devtools.build.lib.analysis.Util; import com.google.devtools.build.lib.analysis.actions.SpawnAction; import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; @@ -381,7 +382,9 @@ public final class PyCommon { for (Artifact source : sources) { Artifact pycFile = createPycFile(source, pythonBinary, pythonPrecompileAttribute, hostPython2RuntimeAttribute); - pycFiles.add(pycFile); + if (pycFile != null) { + pycFiles.add(pycFile); + } } return ImmutableList.copyOf(pycFiles); } @@ -394,6 +397,13 @@ public final class PyCommon { public Artifact createPycFile( Artifact source, PathFragment pythonBinary, String pythonPrecompileAttribute, String hostPython2RuntimeAttribute) { + PackageIdentifier packageId = ruleContext.getLabel().getPackageIdentifier(); + PackageIdentifier itemPackageId = source.getOwner().getPackageIdentifier(); + if (!itemPackageId.equals(packageId)) { + // This will produce an error, so we skip this element. + return null; + } + Artifact output = ruleContext.getRelatedArtifact(source.getRootRelativePath(), ".pyc"); |