Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add buildwrapper location to path if not present

  • Loading branch information...
commit 1c6fe2f5187880b914a6065a03eff24b118e1927 1 parent a81fe77
@JPMoresmau authored
View
27 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
@@ -342,6 +342,7 @@ private void addEditorStanza(IFile file,List<String> command){
pb.directory(workingDir);
pb.redirectErrorStream(true);
pb.command(command);
+ addBuildWrapperPath(pb);
if (ow!=null && BuildWrapperPlugin.logAnswers) {
ow.addMessage(LangUtil.join(command, " "));
}
@@ -1089,7 +1090,29 @@ private CabalPackage parsePackage(JSONObject obj){
return null;
}
-
+ /**
+ * flag caching if we need to add the path
+ */
+ private Boolean needPath=null;
+ /**
+ * add the buildwrapper location to the path so that other executables can be found
+ * @param pb
+ */
+ private synchronized void addBuildWrapperPath(ProcessBuilder pb){
+ if (needPath==null || needPath.booleanValue()){
+ needPath=false;
+ String path=new File(bwPath).getParent();
+ if (path!=null){
+ Map<String,String> env=pb.environment();
+ String pathValue=env.get("PATH");
+ if (Boolean.TRUE.equals(needPath) || !pathValue.contains(path)){
+ pathValue+=File.pathSeparator+path;
+ env.put("PATH",pathValue);
+ needPath=true;
+ }
+ }
+ }
+ }
private <T> T run(LinkedList<String> args,JSONFactory<T> f){
return run(args,f,true);
@@ -1118,6 +1141,7 @@ private CabalPackage parsePackage(JSONObject obj){
pb.directory(workingDir);
pb.redirectErrorStream(true);
pb.command(args);
+ addBuildWrapperPath(pb);
if (ow!=null && BuildWrapperPlugin.logAnswers) {
ow.addMessage(LangUtil.join(args, " "));
}
@@ -1272,6 +1296,7 @@ public String getBwPath() {
public void setBwPath(String bwPath) {
this.bwPath = bwPath;
+ needPath=null;
}
private static interface JSONFactory<T>{
Please sign in to comment.
Something went wrong with that request. Please try again.