diff options
author | Benoit Foucher <benoit@zeroc.com> | 2008-01-29 17:36:34 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2008-01-29 17:36:34 +0100 |
commit | 77a5dcc6c3aaf568a390b13097bdd8619eb7f51e (patch) | |
tree | 5a5207f86284410ac440a5973bb4e49b07ffeff9 /java/ant/SliceTask.java | |
parent | Fixed couplr of Ice-E compile problems (diff) | |
download | ice-77a5dcc6c3aaf568a390b13097bdd8619eb7f51e.tar.bz2 ice-77a5dcc6c3aaf568a390b13097bdd8619eb7f51e.tar.xz ice-77a5dcc6c3aaf568a390b13097bdd8619eb7f51e.zip |
Many build system fixes to not require ICE_HOME anymore when building a source distribution
Diffstat (limited to 'java/ant/SliceTask.java')
-rw-r--r-- | java/ant/SliceTask.java | 129 |
1 files changed, 114 insertions, 15 deletions
diff --git a/java/ant/SliceTask.java b/java/ant/SliceTask.java index e8319b41499..48da90adc7b 100644 --- a/java/ant/SliceTask.java +++ b/java/ant/SliceTask.java @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.ExecTask; import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.taskdefs.PumpStreamHandler; import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Environment; import org.apache.tools.ant.types.Commandline.Argument; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; @@ -312,7 +313,102 @@ public class SliceTask extends org.apache.tools.ant.Task return dependencies; } - + + protected String + getDefaultTranslator(String name) + { + String iceInstall = getIceHome(); + if(iceInstall != null) + { + return new File(iceInstall + File.separator + "bin" + File.separator + name).toString(); + } + else + { + // + // If the location of the Ice install is not known, we + // rely on a path search to find the translator. + // + return name; + } + } + + protected void + addLdLibraryPath(ExecTask task) + { + String iceInstall = getIceHome(); + if(iceInstall != null) + { + String ldLibPathEnv = null; + String ldLib64PathEnv = null; + String libPath = new File(iceInstall + File.separator + "lib").toString(); + String lib64Path = null; + + String os = System.getProperty("os.name"); + if(os.equals("Mac OS X")) + { + ldLibPathEnv = "DYLD_LIBRARY_PATH"; + } + else if(os.equals("AIX")) + { + ldLibPathEnv = "LIBPATH"; + } + else if(os.equals("HP-UX")) + { + ldLibPathEnv = "SHLIB_PATH"; + ldLib64PathEnv = "LD_LIBRARY_PATH"; + lib64Path = new File(iceInstall + File.separator + "lib" + File.separator + "pa20_64").toString(); + } + else if(os.startsWith("Windows")) + { + // + // No need to change the PATH environment variable on Windows, the DLLs should be found + // in the translator local directory. + // + //ldLibPathEnv = "PATH"; + } + else if(os.equals("SunOS")) + { + ldLibPathEnv = "LD_LIBRARY_PATH"; + ldLib64PathEnv = "LD_LIBRARY_PATH_64"; + lib64Path = new File(iceInstall + File.separator + "lib" + File.separator + "sparcv9").toString(); + } + else + { + ldLibPathEnv = "LD_LIBRARY_PATH"; + ldLib64PathEnv = "LD_LIBRARY_PATH_64"; + lib64Path = new File(iceInstall + File.separator + "lib64").toString(); + } + + if(ldLibPathEnv != null) + { + String envLibPath = getEnvironment(ldLibPathEnv); + if(envLibPath != null) + { + libPath = libPath + File.pathSeparator + envLibPath; + } + + Environment.Variable v = new Environment.Variable(); + v.setKey(ldLibPathEnv); + v.setValue(libPath); + task.addEnv(v); + } + + if(ldLib64PathEnv != null) + { + String envLib64Path = getEnvironment(ldLib64PathEnv); + if(envLib64Path != null) + { + lib64Path = lib64Path + File.pathSeparator + envLib64Path; + } + + Environment.Variable v = new Environment.Variable(); + v.setKey(ldLib64PathEnv); + v.setValue(lib64Path); + task.addEnv(v); + } + } + } + // // Query for the location of the Ice install. The Ice install // location may be indicated in one of two ways: @@ -335,20 +431,7 @@ public class SliceTask extends org.apache.tools.ant.Task } else { - // - // Check for the presence of the ICE_HOME environment variable. - // - java.util.Vector env = Execute.getProcEnvironment(); - java.util.Enumeration e = env.elements(); - while(e.hasMoreElements()) - { - String entry = (String)e.nextElement(); - if(entry.startsWith("ICE_HOME=")) - { - _iceHome = entry.substring(entry.indexOf('=') + 1); - break; - } - } + _iceHome = getEnvironment("ICE_HOME"); } } return _iceHome; @@ -401,6 +484,22 @@ public class SliceTask extends org.apache.tools.ant.Task public long _timeStamp; } + private String + getEnvironment(String key) + { + java.util.Vector env = Execute.getProcEnvironment(); + java.util.Enumeration e = env.elements(); + while(e.hasMoreElements()) + { + String entry = (String)e.nextElement(); + if(entry.startsWith(key + "=")) + { + return entry.substring(entry.indexOf('=') + 1); + } + } + return null; + } + protected File _dependencyFile; protected File _outputDir; protected String _outputDirString; |