diff options
author | Carmi Grushko <carmi@google.com> | 2015-10-27 00:14:49 +0000 |
---|---|---|
committer | Florian Weikert <fwe@google.com> | 2015-10-27 11:51:02 +0000 |
commit | 317ebd534057f85950931784514377a103473afe (patch) | |
tree | 10d890175bd379d991c47d8de2c305ffc2d50d29 /src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java | |
parent | 4835caa1138954eb5700a0055d636b405a8d1482 (diff) |
Un-hardcode the names of some Python implicit attributes ($python_precompile, etc.)
--
MOS_MIGRATED_REVID=106352835
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 | 15 |
1 files changed, 10 insertions, 5 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 bf67b4f7aa..75360fff8c 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 @@ -374,10 +374,12 @@ public final class PyCommon { * Utility function to compile multiple .py files to .pyc files. */ public Collection<Artifact> createPycFiles( - Iterable<Artifact> sources, PathFragment pythonBinary) { + Iterable<Artifact> sources, PathFragment pythonBinary, + String pythonPrecompileAttribute, String hostPython2RuntimeAttribute) { List<Artifact> pycFiles = new ArrayList<>(); for (Artifact source : sources) { - Artifact pycFile = createPycFile(source, pythonBinary); + Artifact pycFile = createPycFile(source, pythonBinary, pythonPrecompileAttribute, + hostPython2RuntimeAttribute); pycFiles.add(pycFile); } return ImmutableList.copyOf(pycFiles); @@ -385,9 +387,12 @@ public final class PyCommon { /** * Given a single .py source artifact generate a .pyc file. + * @param pythonPrecompileAttribute e.g., "$python_precompile". + * @param hostPython2RuntimeAttribute e.g., ":host_python2_runtime". */ public Artifact createPycFile( - Artifact source, PathFragment pythonBinary) { + Artifact source, PathFragment pythonBinary, + String pythonPrecompileAttribute, String hostPython2RuntimeAttribute) { Artifact output = ruleContext.getRelatedArtifact(source.getRootRelativePath(), ".pyc"); @@ -399,11 +404,11 @@ public final class PyCommon { .setExecutable(pythonBinary) .setProgressMessage("Compiling Python") .addInputArgument( - ruleContext.getPrerequisiteArtifact("$python_precompile", Mode.HOST)) + ruleContext.getPrerequisiteArtifact(pythonPrecompileAttribute, Mode.HOST)) .setMnemonic("PyCompile"); TransitiveInfoCollection pythonTarget = - ruleContext.getPrerequisite(":host_python2_runtime", Mode.HOST); + ruleContext.getPrerequisite(hostPython2RuntimeAttribute, Mode.HOST); if (pythonTarget != null) { builder.addInputs(pythonTarget .getProvider(FileProvider.class) |