Do not hardcode the path to genrule-setup.sh in the implementation of genrule.
I don't know why it was implemented like that in the first place.
--
MOS_MIGRATED_REVID=103934038
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRule.java
index 1b6284c..3f931e2 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/GenRule.java
@@ -50,9 +50,6 @@
*/
public class GenRule implements RuleConfiguredTargetFactory {
- public static final String GENRULE_SETUP_CMD =
- "source tools/genrule/genrule-setup.sh; ";
-
private Artifact getExecutable(RuleContext ruleContext, NestedSet<Artifact> filesToBuild) {
if (Iterables.size(filesToBuild) == 1) {
Artifact out = Iterables.getOnlyElement(filesToBuild);
@@ -99,7 +96,9 @@
ruleContext.attributes().get("heuristic_label_expansion", Type.BOOLEAN), false);
// Adds the genrule environment setup script before the actual shell command
- String command = GENRULE_SETUP_CMD + baseCommand;
+ String command = String.format("source %s; %s",
+ ruleContext.getPrerequisiteArtifact("$genrule_setup", Mode.HOST).getExecPath(),
+ baseCommand);
command = resolveCommand(ruleContext, command, resolvedSrcs, filesToBuild);