diff options
author | Mark Spruiell <mes@zeroc.com> | 2008-03-03 14:56:50 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2008-03-03 14:56:50 -0800 |
commit | 52ad04cf152145a1ba62f1816233e307bd05e1ba (patch) | |
tree | 0975ef8476c22e74c0414a229dac7aeaad5b9ae5 | |
parent | New icestormmigrate exe (diff) | |
download | ice-52ad04cf152145a1ba62f1816233e307bd05e1ba.tar.bz2 ice-52ad04cf152145a1ba62f1816233e307bd05e1ba.tar.xz ice-52ad04cf152145a1ba62f1816233e307bd05e1ba.zip |
bug 2724, 2725, 2744 - Java fixes
-rw-r--r-- | java/build.xml | 137 | ||||
-rw-r--r-- | java/config/build.properties | 5 | ||||
-rw-r--r-- | java/config/common.xml | 113 | ||||
-rw-r--r-- | java/src/ant/Slice2FreezeJTask.java | 663 | ||||
-rw-r--r-- | java/src/ant/Slice2JavaTask.java | 387 | ||||
-rw-r--r-- | java/src/ant/SliceDefine.java | 40 | ||||
-rw-r--r-- | java/src/ant/SliceMeta.java | 25 | ||||
-rw-r--r-- | java/src/ant/SliceTask.java | 513 |
8 files changed, 1775 insertions, 108 deletions
diff --git a/java/build.xml b/java/build.xml index 3b69cc1185f..30ff543901a 100644 --- a/java/build.xml +++ b/java/build.xml @@ -21,11 +21,28 @@ <property name="lib.dir" value="lib${build.suffix}"/> <property name="cache.dir" value="depcache${build.suffix}"/> - <target name="generate" depends="init"> + <!-- This target cannot depend on init because the tasks may not be compiled yet --> + <target name="tasks" depends="config-init"> + <mkdir dir="${lib.dir}/ant"/> + <javac srcdir="${src.dir}/ant" destdir="${lib.dir}/ant" + source="1.5" + includes="**" + deprecation="on"> + <compilerarg value="${javac.lint}"/> + </javac> + <jar jarfile="${lib.dir}/ant-ice.jar" basedir="${lib.dir}/ant"> + <include name="*.class"/> + <manifest> + <attribute name="Built-By" value="ZeroC, Inc."/> + </manifest> + </jar> + </target> + + <target name="generate" depends="tasks, task-init"> <!-- Create the output directory for generated code --> <mkdir dir="${generated.dir}"/> <slice2java ice="on" stream="on" outputdir="${generated.dir}" dependencyfile="${generated.dir}/.depend.Ice"> - <meta value="${java2metadata}"/> + <meta value="${java2metadata}"/> <includepath> <pathelement path="${slice.dir}" /> </includepath> @@ -34,7 +51,7 @@ </fileset> </slice2java> <slice2java ice="on" outputdir="${generated.dir}" dependencyfile="${generated.dir}/.depend.Ice"> - <meta value="${java2metadata}"/> + <meta value="${java2metadata}"/> <includepath> <pathelement path="${slice.dir}" /> </includepath> @@ -43,7 +60,7 @@ <include name="Current.ice" /> <include name="Endpoint.ice" /> <include name="FacetMap.ice" /> - <include name="ImplicitContext.ice" /> + <include name="ImplicitContext.ice" /> <include name="Identity.ice" /> <include name="LocalException.ice" /> <include name="Locator.ice" /> @@ -76,7 +93,7 @@ </slice2java> <slice2freezej outputdir="${generated.dir}" dependencyfile="${generated.dir}/.depend.Freeze"> - <meta value="${java2metadata}"/> + <meta value="${java2metadata}"/> <includepath> <pathelement path="${slice.dir}" /> </includepath> @@ -85,7 +102,7 @@ </slice2freezej> <slice2freezej ice="on" outputdir="${generated.dir}" dependencyfile="${generated.dir}/.depend.Freeze"> - <meta value="${java2metadata}"/> + <meta value="${java2metadata}"/> <includepath> <pathelement path="${slice.dir}" /> </includepath> @@ -97,7 +114,7 @@ <slice2java ice="on" outputdir="${generated.dir}" checksum="Glacier2.SliceChecksums" dependencyfile="${generated.dir}/.depend.Glacier2"> - <meta value="${java2metadata}"/> + <meta value="${java2metadata}"/> <includepath> <pathelement path="${slice.dir}" /> </includepath> @@ -111,7 +128,7 @@ <slice2java ice="on" outputdir="${generated.dir}" checksum="IceBox.SliceChecksums" dependencyfile="${generated.dir}/.depend.IceBox"> - <meta value="${java2metadata}"/> + <meta value="${java2metadata}"/> <includepath> <pathelement path="${slice.dir}" /> </includepath> @@ -122,7 +139,7 @@ <slice2java ice="on" outputdir="${generated.dir}" checksum="IceGrid.SliceChecksums" dependencyfile="${generated.dir}/.depend.IceGrid"> - <meta value="${java2metadata}"/> + <meta value="${java2metadata}"/> <includepath> <pathelement path="${slice.dir}" /> </includepath> @@ -142,7 +159,7 @@ <slice2java ice="on" outputdir="${generated.dir}" checksum="IceStorm.SliceChecksums" dependencyfile="${generated.dir}/.depend.IceStorm"> - <meta value="${java2metadata}"/> + <meta value="${java2metadata}"/> <includepath> <pathelement path="${slice.dir}" /> </includepath> @@ -155,58 +172,60 @@ <target name="ice-compile" depends="generate"> <mkdir dir="${lib.dir}"/> <mkdir dir="${cache.dir}"/> - <depend srcdir="${generated.dir}:${src.dir}" destdir="${lib.dir}" cache="${cache.dir}"/> - <javac srcdir="${generated.dir}:${src.dir}" destdir="${lib.dir}" - source="1.5" debug="${debug}" - excludes="IceGridGUI/**" - includes="**" - deprecation="on"> - <compilerarg value="${javac.lint}"/> - </javac> + <depend srcdir="${generated.dir}:${src.dir}" destdir="${lib.dir}" cache="${cache.dir}"/> + <javac srcdir="${generated.dir}:${src.dir}" destdir="${lib.dir}" + source="1.5" debug="${debug}" + excludes="IceGridGUI/**" + includes="**" + deprecation="on"> + <compilerarg value="${javac.lint}"/> + </javac> </target> <target name="ice-jar" depends="ice-compile"> - <jar jarfile="${lib.dir}/Ice.jar" basedir="${lib.dir}"> - <include name="**/*.class"/> + <jar jarfile="${lib.dir}/Ice.jar" basedir="${lib.dir}"> + <include name="**/*.class"/> <exclude name="IceGridGUI/**"/> - <exclude name="*.jar"/> + <exclude name="ant/**"/> + <exclude name="*.jar"/> <manifest> <attribute name="Built-By" value="ZeroC, Inc."/> - <attribute name="Class-Path" value="db.jar /usr/share/java/db46/db.jar ../db.jar"/> + <attribute name="Class-Path" value="db.jar /usr/share/java/db-${db.version}.jar ../db.jar"/> </manifest> - </jar> + </jar> </target> <target name="icegridadmin-compile" depends="ice-compile" unless="java2"> <javac srcdir="${src.dir}" destdir="${lib.dir}" - source="1.5" debug="${debug}" - includes="IceGridGUI/**" - deprecation="on"/> + source="1.5" debug="${debug}" + includes="IceGridGUI/**" + classpath="${jgoodies.looks}:${jgoodies.forms}" + deprecation="on"/> </target> <condition property="build-icegridadmin-pro-jar"> - <and> + <and> <available classname="proguard.ant.ProGuardTask" classpath="${env.CLASSPATH}" /> - <available file="${jgoodies.looks}" /> - <available file="${jgoodies.forms}" /> + <available file="${jgoodies.looks}" /> + <available file="${jgoodies.forms}" /> <not><isset property="java2"/></not> - </and> + </and> </condition> <condition property="build-icegridadmin-plain-jar"> - <and> + <and> <not><isset property="build-icegridadmin-pro-jar"/></not> <not><isset property="java2"/></not> - </and> + </and> </condition> <target name="icegridadmin-plain-jar" depends="icegridadmin-compile" if="build-icegridadmin-plain-jar"> - <manifest file="${lib.dir}/icegridgui.mf"> - <attribute name="Class-Path" value="Ice.jar ../resources/"/> - </manifest> + <manifest file="${lib.dir}/icegridgui.mf"> + <attribute name="Class-Path" value="Ice.jar ../resources/"/> + </manifest> <jar jarfile="${lib.dir}/IceGridGUI.jar" manifest="${lib.dir}/icegridgui.mf" basedir="${lib.dir}"> - <include name="IceGridGUI/**"/> - </jar> + <include name="IceGridGUI/**"/> + </jar> <delete file="${lib.dir}/icegridgui.mf" /> </target> @@ -218,18 +237,18 @@ <os family="mac"/> </condition> - <manifest file="${lib.dir}/icegridgui.mf"> - <attribute name="Main-Class" value="IceGridGUI.Main"/> - <attribute name="Class-Path" value="../help/ ../resources/ ../../share/doc/Ice-${ice.version}/ ../../share/doc/packages/Ice-${ice.version}/"/> - </manifest> - <jar jarfile="${lib.dir}/IceGridGUItemp.jar" manifest="${lib.dir}/icegridgui.mf" basedir="${lib.dir}"> - <include name="IceGridGUI/**"/> - </jar> - <jar jarfile="${lib.dir}/IceGridGUItemp.jar" manifest="${lib.dir}/icegridgui.mf" basedir="resources" - update="true"> - <include name="icons/**"/> - </jar> - <delete file="${lib.dir}/icegridgui.mf" /> + <manifest file="${lib.dir}/icegridgui.mf"> + <attribute name="Main-Class" value="IceGridGUI.Main"/> + <attribute name="Class-Path" value="../help/ ../resources/ ../../share/doc/Ice-${ice.version}/ ../../share/doc/packages/Ice-${ice.version}/"/> + </manifest> + <jar jarfile="${lib.dir}/IceGridGUItemp.jar" manifest="${lib.dir}/icegridgui.mf" basedir="${lib.dir}"> + <include name="IceGridGUI/**"/> + </jar> + <jar jarfile="${lib.dir}/IceGridGUItemp.jar" manifest="${lib.dir}/icegridgui.mf" basedir="resources" + update="true"> + <include name="icons/**"/> + </jar> + <delete file="${lib.dir}/icegridgui.mf" /> <taskdef resource="proguard/ant/task.properties"/> <proguard> @@ -242,7 +261,7 @@ -libraryjars ${jsse.jar} -include config/icegridgui.pro </proguard> - <delete file="${lib.dir}/IceGridGUItemp.jar" /> + <delete file="${lib.dir}/IceGridGUItemp.jar" /> </target> <target name="compile" depends="ice-compile, icegridadmin-compile"> @@ -258,20 +277,14 @@ <target name="install-common"> <mkdir dir="${prefix}"/> <mkdir dir="${prefix}/lib"/> - <mkdir dir="${prefix}/ant"/> <copy file="${ice.dir}/LICENSE" todir="${prefix}"/> <copy file="${ice.dir}/ICE_LICENSE" todir="${prefix}"/> - <copy todir="${prefix}/ant"> - <fileset dir="${ant.task.dir}"> - <include name="*.class"/> - </fileset> - </copy> </target> <condition property="slice-installed"> - <and> + <and> <available file="${prefix}/slice/Ice/Communicator.ice"/> - </and> + </and> </condition> <target name="install-slice" unless="slice-installed"> @@ -280,7 +293,7 @@ <fileset dir="../slice" includes="**"/> </copy> </target> - + <target name="install-icegridgui-jar" unless="java2"> <mkdir dir="${prefix}/help"/> <copy file="${lib.dir}/IceGridGUI.jar" todir="${prefix}/lib"/> @@ -298,7 +311,11 @@ <copy file="${lib.dir}/Ice.jar" todir="${prefix}/lib/java2"/> </target> - <target name="install" depends="jar, install-common, install-jar, install-java2-jar, install-icegridgui-jar, install-slice"> + <target name="install-tasks"> + <copy file="${lib.dir}/ant-ice.jar" todir="${prefix}/lib"/> + </target> + + <target name="install" depends="jar, install-common, install-jar, install-java2-jar, install-icegridgui-jar, install-tasks, install-slice"> </target> <target name="clean" depends="config-init"> diff --git a/java/config/build.properties b/java/config/build.properties index 09b53452b62..684043304c8 100644 --- a/java/config/build.properties +++ b/java/config/build.properties @@ -8,6 +8,7 @@ # ********************************************************************** ice.version = 3.3.0 +db.version = 4.6.21 # # Select an installation base directory. The directory will be created @@ -35,7 +36,7 @@ debug = on # These properties only need to be set if you want to build the # standalone jar for the IceGrid GUI. # -jgoodies.forms = /usr/share/java/forms-1.1.0.jar +jgoodies.forms = /usr/share/java/forms-1.2.0.jar jgoodies.looks = /usr/share/java/looks-2.1.4.jar -#jgoodies.forms = C:/Ice-3.3.0-ThirdParty-VC80/lib/forms-1.1.0.jar +#jgoodies.forms = C:/Ice-3.3.0-ThirdParty-VC80/lib/forms-1.2.0.jar #jgoodies.looks = C:/Ice-3.3.0-ThirdParty-VC80/lib/looks-2.1.4.jar diff --git a/java/config/common.xml b/java/config/common.xml index 670ca77257c..96227adf3e5 100644 --- a/java/config/common.xml +++ b/java/config/common.xml @@ -13,7 +13,7 @@ <property environment="env"/> - <target name="init" depends="config-init"> + <target name="init" depends="config-init, task-init"> <!-- Create the time stamp --> <tstamp/> </target> @@ -34,12 +34,12 @@ </condition> </fail> <condition property="java2"> - <equals arg1="${ice.mapping}" arg2="java2"/> + <equals arg1="${ice.mapping}" arg2="java2"/> </condition> <!-- Use the global metadata "java:java2" when using java2 mapping --> <condition property="java2metadata" value="java:java2" else=""> - <isset property="java2"/> + <isset property="java2"/> </condition> <!-- Use -Xlint when requested --> @@ -51,7 +51,7 @@ scripts to build the jars and classes file in other directories than the default one. This is useful to build both the Java2 and Java5 mapping with the same source tree. - --> + --> <property name="build.suffix" value=""/> <!-- Commonly needed properties --> @@ -99,7 +99,7 @@ <and> <available file="${ice.top.dir}/../java"/> <not><isset property="ice.bin.dist"/></not> - </and> + </and> </condition> <!-- When building a source distribution, we allow using either the translators from a binary distribution or the local translators, --> @@ -200,58 +200,79 @@ <target name="config-init" depends="config-init-warn"> <!-- Set slice.dir to the directory containing the Slice files. --> - <condition property="slice.dir" value="/usr/share/Ice-${ice.version}/slice" else="${ice.dir}/slice"> - <equals arg1="${ice.dir}" arg2="/usr"/> - </condition> - - <!-- Set ant.task.dir to the directory containing the Slice ant tasks. --> - <condition property="ant.task.dir" value="${ice.dir}/java/ant"> - <isset property="ice.src.dist"/> - </condition> - <condition property="ant.task.dir" value="${ice.dir}/ant"> + <condition property="slice.dir" value="/usr/share/Ice-${ice.version}/slice" else="${ice.dir}/slice"> + <equals arg1="${ice.dir}" arg2="/usr"/> + </condition> + + <!-- Set ice.classpath with the distribution Ice.jar file --> + <condition property="dist.lib.dir" value="${ice.dir}/java/lib"> + <isset property="ice.src.dist"/> + </condition> + <condition property="dist.lib.dir" value="${ice.dir}/lib"> <and> - <isset property="ice.bin.dist"/> + <isset property="ice.bin.dist"/> <not><equals arg1="${ice.dir}" arg2="/usr"/></not> </and> - </condition> - <condition property="ant.task.dir" value="/usr/lib/Ice-${ice.version}/ant"> + </condition> + <condition property="dist.lib.dir" value="/usr/share/java"> <and> - <isset property="ice.bin.dist"/> + <isset property="ice.bin.dist"/> <equals arg1="${ice.dir}" arg2="/usr"/> </and> - </condition> + </condition> - <taskdef name="slice2java" classpath="${ant.task.dir}" classname="Slice2JavaTask"/> - <taskdef name="slice2freezej" classpath="${ant.task.dir}" classname="Slice2FreezeJTask" /> + <condition property="dist.jar.file" value="${dist.lib.dir}/Ice-java2-${ice.version}.jar"> + <and> + <available file="${dist.lib.dir}/Ice-java2-${ice.version}.jar"/> + <isset property="java2"/> + </and> + </condition> - <!-- Set ice.classpath with the distribution Ice.jar file --> - <condition property="dist.lib.dir" value="${ice.dir}/java/lib"> - <isset property="ice.src.dist"/> - </condition> - <condition property="dist.lib.dir" value="${ice.dir}/lib"> + <condition property="dist.jar.file" value="${dist.lib.dir}/java2/Ice.jar"> <and> - <isset property="ice.bin.dist"/> - <not><equals arg1="${ice.dir}" arg2="/usr"/></not> + <not><isset property="dist.jar.file"/></not> + <available file="${dist.lib.dir}/java2/Ice.jar"/> + <isset property="java2"/> </and> - </condition> - <condition property="dist.lib.dir" value="/usr/lib/Ice-${ice.version}"> + </condition> + + <condition property="dist.jar.file" value="${dist.lib.dir}/Ice-${ice.version}.jar"> <and> - <isset property="ice.bin.dist"/> - <equals arg1="${ice.dir}" arg2="/usr"/> + <not><isset property="dist.jar.file"/></not> + <available file="${dist.lib.dir}/Ice-${ice.version}.jar"/> </and> - </condition> - - <condition property="dist.jar.file" value="${dist.lib.dir}/java2/Ice.jar" else="${dist.lib.dir}/Ice.jar"> - <and> - <available file="${dist.lib.dir}/java2/Ice.jar"/> - <isset property="java2"/> - </and> - </condition> - - <path id="ice.classpath"> - <fileset file="${dist.jar.file}"/> - </path> - + </condition> + + <condition property="dist.jar.file" value="${dist.lib.dir}/Ice.jar"> + <and> + <not><isset property="dist.jar.file"/></not> + <available file="${dist.lib.dir}/Ice.jar"/> + </and> + </condition> + + <path id="ice.classpath"> + <fileset file="${dist.jar.file}"/> + </path> + </target> - + + <!-- Install the Slice ant tasks. --> + <target name="task-init"> + + <condition property="task.jar.file" value="${dist.lib.dir}/ant-ice-${ice.version}.jar"> + <available file="${dist.lib.dir}/ant-ice-${ice.version}.jar"/> + </condition> + + <condition property="task.jar.file" value="${dist.lib.dir}/ant-ice.jar"> + <and> + <not><isset property="task.jar.file"/></not> + <available file="${dist.lib.dir}/ant-ice.jar"/> + </and> + </condition> + + <taskdef name="slice2java" classpath="${task.jar.file}" classname="Slice2JavaTask"/> + <taskdef name="slice2freezej" classpath="${task.jar.file}" classname="Slice2FreezeJTask" /> + + </target> + </project> diff --git a/java/src/ant/Slice2FreezeJTask.java b/java/src/ant/Slice2FreezeJTask.java new file mode 100644 index 00000000000..92509e79814 --- /dev/null +++ b/java/src/ant/Slice2FreezeJTask.java @@ -0,0 +1,663 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +//package Ice.Ant; + +import org.apache.tools.ant.Task; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.taskdefs.ExecTask; +import org.apache.tools.ant.types.Commandline.Argument; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Reference; + +import java.io.File; +import java.io.FileOutputStream; + +/** + * An ant task for slice2freezej. This task extends the abstract + * SliceTask class which takes care of attributes common to all slice + * translators (see SliceTask.java for details on these attributes). + * + * Attributes: + * + * Nested elements: + * + * define - defines a preprocessor symbol + * dict - contains the NAME, KEY TYPE, and VALUE TYPE of a Freeze map. + * index - contains the NAME, CLASS TYPE, MEMBER NAME and optional + * case sensitivity of a Freeze Evictor index. + * dictindex - contains the NAME and optional member name and case + * sensitivity of a Freeze Map index. + * + * Example: + * + * <project ...> + * <taskdef name="slice2freezej" classname="Slice2FreezeJTask" /> + * <property name="slice.dir" value="../include/slice"/> + * <target name="generate"> + * <mkdir dir="tags" /> + * <slice2freezej tagdir="tags" outputdir="out" output="CharIntMap"> + * <define name="SYMBOL" value="VALUE"/> + * <includepath> + * <pathelement path="${slice.dir}" /> + * </includepath> + * <fileset dir="${slice.dir}"> + * <include name="*.ice" /> + * </fileset> + * <dict name="CharIntMap" key="char" value="int"/> + * <index name="NameIndex" type="Foo" member="name" casesensitive="false"/> + * </slice2freezej> + * </target> + * </project> + * + * The <taskdef> element installs the slice2freezej task. + */ +public class Slice2FreezeJTask extends SliceTask +{ + public + Slice2FreezeJTask() + { + } + + public void + setTranslator(File prog) + { + _translator = prog; + } + + public Dict + createDict() + { + Dict d = new Dict(); + _dicts.add(d); + return d; + } + + public Index + createIndex() + { + Index i = new Index(); + _indices.add(i); + return i; + } + + public Dictindex + createDictindex() + { + Dictindex i = new Dictindex(); + _dictIndices.add(i); + return i; + } + + public void + execute() + throws BuildException + { + if(_dicts.isEmpty() && _indices.isEmpty()) + { + throw new BuildException("No dictionary or index specified"); + } + + // + // Read the set of dependencies for this task. + // + java.util.HashMap dependencies = readDependencies(); + + // + // Check if the set of slice files changed. If it changed we + // need to rebuild all the dictionnaries and indices. + // + boolean build = false; + java.util.List sliceFiles = new java.util.LinkedList(); + + java.util.Iterator p = _fileSets.iterator(); + while(p.hasNext()) + { + FileSet fileset = (FileSet)p.next(); + + DirectoryScanner scanner = fileset.getDirectoryScanner(getProject()); + String[] files = scanner.getIncludedFiles(); + + for(int i = 0; i < files.length; i++) + { + File slice = new File(fileset.getDir(getProject()), files[i]); + sliceFiles.add(slice); + + if(!build) + { + // + // The dictionnaries need to be re-created since + // on dependency changed. + // + SliceDependency depend = (SliceDependency)dependencies.get(getSliceTargetKey(slice.toString())); + if(depend == null || !depend.isUpToDate()) + { + build = true; + } + } + } + } + + if(!build) + { + // + // Check that each dictionary has been built at least + // once. + // + p = _dicts.iterator(); + while(p.hasNext()) + { + SliceDependency depend = (SliceDependency)dependencies.get(getDictTargetKey((Dict)p.next())); + if(depend == null) + { + build = true; + break; + } + } + + // + // Likewise for indices + // + p = _indices.iterator(); + while(p.hasNext()) + { + SliceDependency depend = (SliceDependency)dependencies.get(getIndexTargetKey((Index)p.next())); + if(depend == null) + { + build = true; + break; + } + } + } + + // + // Add the --dict options. + // + p = _dicts.iterator(); + StringBuffer dictString = new StringBuffer(); + while(p.hasNext()) + { + Dict d = (Dict)p.next(); + + dictString.append(" --dict "); + dictString.append(d.getName() + "," + d.getKey() + "," + d.getValue()); + } + + // + // Add the --dict-index options. + // + p = _dictIndices.iterator(); + StringBuffer dictIndexString = new StringBuffer(); + while(p.hasNext()) + { + Dictindex d = (Dictindex)p.next(); + + dictIndexString.append(" --dict-index "); + dictIndexString.append(d.getName()); + if(d.getMember() != null) + { + dictIndexString.append("," + d.getMember()); + } + if(d.getCasesensitive() == false) + { + dictIndexString.append("," + "case-insensitive"); + } + } + + // + // Add the --index options. + // + p = _indices.iterator(); + StringBuffer indexString = new StringBuffer(); + while(p.hasNext()) + { + Index i = (Index)p.next(); + + indexString.append(" --index "); + indexString.append(i.getName() + "," + i.getType() + "," + i.getMember()); + if(i.getCasesensitive() == false) + { + indexString.append("," + "case-insensitive"); + } + } + + if(!build) + { + log("skipping" + dictString + indexString); + return; + } + + // + // Run the translator + // + StringBuffer cmd = new StringBuffer(); + + // + // Add --ice + // + if(_ice) + { + cmd.append(" --ice"); + } + + // + // Add --output-dir + // + if(_outputDir != null) + { + cmd.append(" --output-dir "); + cmd.append(_outputDirString); + } + + // + // Add --case-sensitive + // + if(_caseSensitive) + { + cmd.append(" --case-sensitive"); + } + + // + // Add include directives + // + if(_includePath != null) + { + String[] dirs = _includePath.list(); + for(int i = 0; i < dirs.length; i++) + { + cmd.append(" -I"); + if(dirs[i].indexOf(' ') != -1) + { + cmd.append('"' + dirs[i] + '"'); + } + else + { + cmd.append(dirs[i]); + } + } + } + + // + // Add defines + // + if(!_defines.isEmpty()) + { + java.util.Iterator i = _defines.iterator(); + while(i.hasNext()) + { + SliceDefine define = (SliceDefine)i.next(); + cmd.append(" -D"); + cmd.append(define.getName()); + String value = define.getValue(); + if(value != null) + { + cmd.append("="); + cmd.append(value); + } + } + } + + // + // Add the --dict options. + // + cmd.append(dictString); + + // + // Add the --dict-index options. + // + cmd.append(dictIndexString); + + // + // Add the --index options. + // + cmd.append(indexString); + + // + // Add the --meta options. + // + if(!_meta.isEmpty()) + { + java.util.Iterator i = _meta.iterator(); + while(i.hasNext()) + { + SliceMeta m = (SliceMeta)i.next(); + cmd.append(" --meta " + m.getValue()); + } + } + + // + // Add the slice files. + // + p = sliceFiles.iterator(); + while(p.hasNext()) + { + File f = (File)p.next(); + cmd.append(" "); + String s = f.toString(); + if(s.indexOf(' ') != -1) + { + cmd.append('"' + s + '"'); + } + else + { + cmd.append(s); + } + } + + String translator; + if(_translator == null) + { + translator = getDefaultTranslator("slice2freezej"); + } + else + { + translator = _translator.toString(); + } + + // + // Execute. + // + log(translator + " " + cmd); + ExecTask task = (ExecTask)getProject().createTask("exec"); + addLdLibraryPath(task); + task.setFailonerror(true); + Argument arg = task.createArg(); + arg.setLine(cmd.toString()); + task.setExecutable(translator); + task.execute(); + + // + // Update the dependencies. + // + if(!sliceFiles.isEmpty()) + { + cmd = new StringBuffer("--depend"); + + // + // Add include directives + // + if(_includePath != null) + { + String[] dirs = _includePath.list(); + for(int i = 0; i < dirs.length; i++) + { + cmd.append(" -I"); + if(dirs[i].indexOf(' ') != -1) + { + cmd.append('"' + dirs[i] + '"'); + } + else + { + cmd.append(dirs[i]); + } + } + } + + // + // Add the --dict options. + // + cmd.append(dictString); + + // + // Add the --dict-index options. + // + cmd.append(dictIndexString); + + // + // Add the --index options. + // + cmd.append(indexString); + + // + // Add the slice files. + // + p = sliceFiles.iterator(); + while(p.hasNext()) + { + File f = (File)p.next(); + cmd.append(" "); + String s = f.toString(); + if(s.indexOf(' ') != -1) + { + cmd.append('"' + s + '"'); + } + else + { + cmd.append(s); + } + } + + + // + // It's not possible anymore to re-use the same output property since Ant 1.5.x. so we use a + // unique property name here. Perhaps we should output the dependencies to a file instead. + // + final String outputProperty = "slice2freezej.depend." + System.currentTimeMillis(); + + task = (ExecTask)getProject().createTask("exec"); + addLdLibraryPath(task); + task.setFailonerror(true); + arg = task.createArg(); + arg.setLine(cmd.toString()); + task.setExecutable(translator); + task.setOutputproperty(outputProperty); + task.execute(); + + // + // Update dependency file. + // + java.util.List newDependencies = parseDependencies(getProject().getProperty(outputProperty)); + p = newDependencies.iterator(); + while(p.hasNext()) + { + SliceDependency dep = (SliceDependency)p.next(); + dependencies.put(getSliceTargetKey(dep._dependencies[0]), dep); + } + } + + p = _dicts.iterator(); + while(p.hasNext()) + { + dependencies.put(getDictTargetKey((Dict)p.next()), new SliceDependency()); + } + + p = _indices.iterator(); + while(p.hasNext()) + { + dependencies.put(getIndexTargetKey((Index)p.next()), new SliceDependency()); + } + + writeDependencies(dependencies); + } + + private String + getSliceTargetKey(String slice) + { + // + // Since the dependency file can be shared by several slice + // tasks we need to make sure that each dependency has a + // unique key. We use the name of the task, the output + // directory, the first dictionary or index name and the name of the + // slice file to be compiled. + // + String name; + if(_dicts.size() > 0) + { + name = ((Dict)_dicts.get(0)).getName(); + } + else + { + name = ((Index)_indices.get(0)).getName(); + } + return "slice2freezej " + _outputDir.toString() + name + slice; + } + + private String + getDictTargetKey(Dict d) + { + return "slice2freezej " + _outputDir.toString() + d.getName(); + } + + private String + getIndexTargetKey(Index i) + { + return "slice2freezej " + _outputDir.toString() + i.getName(); + } + + private File _translator = null; + + public class Dict + { + private String _name; + private String _key; + private String _value; + + public void + setName(String name) + { + _name = name; + } + + public String + getName() + { + return _name; + } + + public void + setKey(String key) + { + _key = key; + } + + public String + getKey() + { + return _key; + } + + public void + setValue(String value) + { + _value = value; + } + + public String + getValue() + { + return _value; + } + } + + public class Dictindex + { + private String _name; + private String _member; + private boolean _caseSensitive = true; + + public void + setName(String name) + { + _name = name; + } + + public String + getName() + { + return _name; + } + + public void + setMember(String member) + { + _member = member; + } + + public String + getMember() + { + return _member; + } + + public void + setCasesensitive(boolean caseSensitive) + { + _caseSensitive = caseSensitive; + } + + public boolean + getCasesensitive() + { + return _caseSensitive; + } + } + + + public class Index + { + private String _name; + private String _type; + private String _member; + private boolean _caseSensitive = true; + + public void + setName(String name) + { + _name = name; + } + + public String + getName() + { + return _name; + } + + public void + setType(String type) + { + _type = type; + } + + public String + getType() + { + return _type; + } + + public void + setMember(String member) + { + _member = member; + } + + public String + getMember() + { + return _member; + } + + public void + setCasesensitive(boolean caseSensitive) + { + _caseSensitive = caseSensitive; + } + + public boolean + getCasesensitive() + { + return _caseSensitive; + } + } + + private java.util.List _dicts = new java.util.LinkedList(); + private java.util.List _dictIndices = new java.util.LinkedList(); + private java.util.List _indices = new java.util.LinkedList(); +} diff --git a/java/src/ant/Slice2JavaTask.java b/java/src/ant/Slice2JavaTask.java new file mode 100644 index 00000000000..34dc7e4ca8a --- /dev/null +++ b/java/src/ant/Slice2JavaTask.java @@ -0,0 +1,387 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +//package Ice.Ant; + +import org.apache.tools.ant.Task; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.types.FileSet; +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.Commandline.Argument; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Reference; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.StringReader; +import java.io.BufferedReader; +import java.io.BufferedWriter; + +/** + * An ant task for slice2java. This task extends the abstract + * SliceTask class which takes care of attributes common to all slice + * translators (see SliceTask.java for details on these attributes). + * + * Attributes specific to slice2java: + * + * translator - The pathname of the translator (default: "slice2java"). + * tie - The value for the --tie translator option. + * checksum - The value for the --checksum translator option. + * stream - The value for the --stream translator option. + * + * Example: + * + * <project ...> + * <taskdef name="slice2java" classname="Slice2JavaTask" /> + * <property name="slice.dir" value="../include/slice"/> + * <target name="generate"> + * <mkdir dir="tags" /> + * <slice2java tagdir="tags" outputdir="out"> + * <define name="SYMBOL" value="VALUE"/> + * <includepath> + * <pathelement path="${slice.dir}" /> + * </includepath> + * <fileset dir="${slice.dir}"> + * <include name="*.ice" /> + * </fileset> + * </slice2java> + * </target> + * </project> + * + * The <taskdef> element installs the slice2java task. + */ +public class Slice2JavaTask extends SliceTask +{ + public + Slice2JavaTask() + { + _translator = null; + _tie = false; + _checksum = null; + } + + public void + setTranslator(File prog) + { + _translator = prog; + } + + public void + setTie(boolean tie) + { + _tie = tie; + } + + public void + setChecksum(String checksum) + { + _checksum = checksum; + } + + public void + setStream(boolean stream) + { + _stream = stream; + } + + public void + execute() + throws BuildException + { + if(_fileSets.isEmpty()) + { + throw new BuildException("No fileset specified"); + } + + // + // Read the set of dependencies for this task. + // + java.util.HashMap dependencies = readDependencies(); + + // + // Compose a list of the files that need to be translated. A + // file needs to translated if we can't find a dependency in + // the dependency table or if its dependency is not up-to-date + // anymore (the slice file changed since the dependency was + // last updated or a slice file it depends on changed). + // + java.util.Vector buildList = new java.util.Vector(); + java.util.Iterator p = _fileSets.iterator(); + while(p.hasNext()) + { + FileSet fileset = (FileSet)p.next(); + + DirectoryScanner scanner = fileset.getDirectoryScanner(getProject()); + scanner.scan(); + String[] files = scanner.getIncludedFiles(); + for(int i = 0; i < files.length; i++) + { + File slice = new File(fileset.getDir(getProject()), files[i]); + + SliceDependency depend = (SliceDependency)dependencies.get(getTargetKey(slice.toString())); + if(depend == null || !depend.isUpToDate()) + { + buildList.addElement(slice); + } + else + { + log("skipping " + files[i]); + } + } + } + + // + // Run the translator + // + if(!buildList.isEmpty()) + { + String translator; + if(_translator == null) + { + translator = getDefaultTranslator("slice2java"); + } + else + { + translator = _translator.toString(); + } + + StringBuffer cmd = new StringBuffer(); + + // + // Add --output-dir + // + if(_outputDir != null) + { + cmd.append(" --output-dir "); + cmd.append(_outputDirString); + } + + // + // Add include directives + // + if(_includePath != null) + { + String[] dirs = _includePath.list(); + for(int i = 0; i < dirs.length; i++) + { + cmd.append(" -I"); + if(dirs[i].indexOf(' ') != -1) + { + cmd.append('"' + dirs[i] + '"'); + } + else + { + cmd.append(dirs[i]); + } + } + } + + // + // Add defines + // + if(!_defines.isEmpty()) + { + java.util.Iterator i = _defines.iterator(); + while(i.hasNext()) + { + SliceDefine define = (SliceDefine)i.next(); + cmd.append(" -D"); + cmd.append(define.getName()); + String value = define.getValue(); + if(value != null) + { + cmd.append("="); + cmd.append(value); + } + } + } + + // + // Add --tie + // + if(_tie) + { + cmd.append(" --tie"); + } + + // + // Add --checksum + // + if(_checksum != null && _checksum.length() > 0) + { + cmd.append(" --checksum " + _checksum); + } + + // + // Add --stream + // + if(_stream) + { + cmd.append(" --stream"); + } + + // + // Add --meta + // + if(!_meta.isEmpty()) + { + java.util.Iterator i = _meta.iterator(); + while(i.hasNext()) + { + SliceMeta m = (SliceMeta)i.next(); + cmd.append(" --meta " + m.getValue()); + } + } + + // + // Add --ice + // + if(_ice) + { + cmd.append(" --ice"); + } + + // + // Add --case-sensitive + // + if(_caseSensitive) + { + cmd.append(" --case-sensitive"); + } + + // + // Add files to be translated + // + for(int i = 0; i < buildList.size(); i++) + { + File f = (File)buildList.elementAt(i); + cmd.append(" "); + String s = f.toString(); + if(s.indexOf(' ') != -1) + { + cmd.append('"' + s + '"'); + } + else + { + cmd.append(s); + } + } + + // + // Execute + // + log(translator + " " + cmd); + ExecTask task = (ExecTask)getProject().createTask("exec"); + addLdLibraryPath(task); + task.setFailonerror(true); + Argument arg = task.createArg(); + arg.setLine(cmd.toString()); + task.setExecutable(translator); + task.execute(); + + // + // Update the dependencies. + // + cmd = new StringBuffer("--depend"); + + // + // Add include directives + // + if(_includePath != null) + { + String[] dirs = _includePath.list(); + for(int i = 0; i < dirs.length; i++) + { + cmd.append(" -I"); + if(dirs[i].indexOf(' ') != -1) + { + cmd.append('"' + dirs[i] + '"'); + } + else + { + cmd.append(dirs[i]); + } + } + } + + // + // Add files for which we need to check dependencies. + // + for(int i = 0; i < buildList.size(); i++) + { + File f = (File)buildList.elementAt(i); + cmd.append(" "); + String s = f.toString(); + if(s.indexOf(' ') != -1) + { + cmd.append('"' + s + '"'); + } + else + { + cmd.append(s); + } + } + + // + // It's not possible anymore to re-use the same output property since Ant 1.5.x. so we use a + // unique property name here. Perhaps we should output the dependencies to a file instead. + // + final String outputProperty = "slice2java.depend." + System.currentTimeMillis(); + + task = (ExecTask)getProject().createTask("exec"); + addLdLibraryPath(task); + task.setFailonerror(true); + arg = task.createArg(); + arg.setLine(cmd.toString()); + task.setExecutable(translator); + task.setOutputproperty(outputProperty); + task.execute(); + + // + // Update dependency file. + // + java.util.List newDependencies = parseDependencies(getProject().getProperty(outputProperty)); + p = newDependencies.iterator(); + while(p.hasNext()) + { + SliceDependency dep = (SliceDependency)p.next(); + dependencies.put(getTargetKey(dep._dependencies[0]), dep); + } + + writeDependencies(dependencies); + } + } + + private String + getTargetKey(String slice) + { + // + // Since the dependency file can be shared by several slice + // tasks we need to make sure that each dependency has a + // unique key. We use the name of the task, the output + // directory and the name of the slice file to be compiled. + // + // If there's two slice2java tasks using the same dependency + // file, with the same output dir and which compiles the same + // slice file they'll use the same dependency. + // + return "slice2java " + _outputDir.toString() + " " + slice; + } + + private File _translator; + private boolean _tie; + private String _checksum; + private boolean _stream; +} diff --git a/java/src/ant/SliceDefine.java b/java/src/ant/SliceDefine.java new file mode 100644 index 00000000000..e9e423da46a --- /dev/null +++ b/java/src/ant/SliceDefine.java @@ -0,0 +1,40 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +//package Ice.Ant; + +public class SliceDefine +{ + public void + setName(String name) + { + _name = name; + } + + public String + getName() + { + return _name; + } + + public void + setValue(String value) + { + _value = value; + } + + public String + getValue() + { + return _value; + } + + private String _name; + private String _value; +} diff --git a/java/src/ant/SliceMeta.java b/java/src/ant/SliceMeta.java new file mode 100644 index 00000000000..878dad75218 --- /dev/null +++ b/java/src/ant/SliceMeta.java @@ -0,0 +1,25 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +public class SliceMeta +{ + public void + setValue(String value) + { + _value = value; + } + + public String + getValue() + { + return _value; + } + + private String _value; +} diff --git a/java/src/ant/SliceTask.java b/java/src/ant/SliceTask.java new file mode 100644 index 00000000000..48da90adc7b --- /dev/null +++ b/java/src/ant/SliceTask.java @@ -0,0 +1,513 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +//package Ice.Ant; + +import org.apache.tools.ant.Task; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.types.FileSet; +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; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.StringReader; +import java.io.BufferedReader; +import java.io.BufferedWriter; + +/** + * An abstract ant task for slice translators. The task minimizes + * regeneration by checking the dependencies between slice files. + * + * Attributes: + * + * dependencyfile - The file in which dependencies are stored (default: ".depend"). + * outputdir - The value for the --output-dir translator option. + * casesensitive - Enables the --case-sensitive translator option. + * ice - Enables the --ice translator option. + * + * Nested elements: + * + * includepath - The directories in which to search for Slice files. + * These are converted into -I directives for the translator. + * define - Defines a preprocessor symbol. The "name" attribute + * specifies the symbol name, and the optional "value" attribute + * specifies the symbol's value. + * fileset - The set of Slice files which contain relevent types. + * + */ +public class SliceTask extends org.apache.tools.ant.Task +{ + public + SliceTask() + { + _dependencyFile = null; + _outputDir = null; + _outputDirString = null; + _caseSensitive = false; + _ice = false; + _includePath = null; + } + + public void + setDependencyFile(File file) + { + _dependencyFile = file; + } + + public void + setOutputdir(File dir) + { + _outputDir = dir; + _outputDirString = _outputDir.toString(); + if(_outputDirString.indexOf(' ') != -1) + { + _outputDirString = '"' + _outputDirString + '"'; + } + } + + public void + setCaseSensitive(boolean c) + { + _caseSensitive = c; + } + + public void + setIce(boolean ice) + { + _ice = ice; + } + + public Path + createIncludePath() + { + if(_includePath == null) + { + _includePath = new Path(getProject()); + } + return _includePath.createPath(); + } + + public void + setIncludePathRef(Reference ref) + { + createIncludePath().setRefid(ref); + } + + public void + setIncludePath(Path includePath) + { + if(_includePath == null) + { + _includePath = includePath; + } + else + { + _includePath.append(includePath); + } + } + + public FileSet + createFileset() + { + FileSet fileset = new FileSet(); + _fileSets.add(fileset); + + return fileset; + } + + public void + addConfiguredDefine(SliceDefine define) + throws BuildException + { + if(define.getName() == null) + { + throw new BuildException("The name attribute must be supplied in a <define> element"); + } + + _defines.add(define); + } + + public void + addConfiguredMeta(SliceMeta meta) + { + if(meta.getValue().length() > 0) + { + _meta.add(meta); + } + } + + // + // Read the dependency file. + // + protected java.util.HashMap + readDependencies() + { + if(_dependencyFile == null) + { + if(_outputDir != null) + { + _dependencyFile = new File(_outputDir, ".depend"); + } + else + { + _dependencyFile = new File(".depend"); + } + } + + try + { + java.io.ObjectInputStream in = new java.io.ObjectInputStream(new java.io.FileInputStream(_dependencyFile)); + java.util.HashMap dependencies = (java.util.HashMap)in.readObject(); + in.close(); + return dependencies; + } + catch(java.io.IOException ex) + { + } + catch(java.lang.ClassNotFoundException ex) + { + } + + return new java.util.HashMap(); + } + + protected void + writeDependencies(java.util.HashMap dependencies) + { + try + { + java.io.ObjectOutputStream out = new java.io.ObjectOutputStream(new FileOutputStream(_dependencyFile)); + out.writeObject(dependencies); + out.close(); + } + catch(java.io.IOException ex) + { + throw new BuildException("Unable to write dependencies in file " + _dependencyFile.getPath() + ": " + ex); + } + } + + // + // Parse dependencies returned by the slice translator (Makefile + // dependencies). + // + protected java.util.List + parseDependencies(String allDependencies) + { + java.util.List dependencies = new java.util.LinkedList(); + try + { + BufferedReader in = new BufferedReader(new StringReader(allDependencies)); + StringBuffer depline = new StringBuffer(); + String line; + + while((line = in.readLine()) != null) + { + if(line.length() == 0) + { + continue; + } + else if(line.endsWith("\\")) + { + depline.append(line.substring(0, line.length() - 1)); + } + else + { + depline.append(line); + + // + // It's easier to split up the filenames if we first convert Windows + // path separators into Unix path separators. + // + char[] chars = depline.toString().toCharArray(); + int pos = 0; + while(pos < chars.length) + { + if(chars[pos] == '\\') + { + if(pos + 1 < chars.length) + { + // + // Only convert the backslash if it's not an escape. + // + if(chars[pos + 1] != ' ' && chars[pos + 1] != ':' && chars[pos + 1] != '\r' && + chars[pos + 1] != '\n') + { + chars[pos] = '/'; + } + } + } + ++pos; + } + + // + // Split the dependencies up into filenames. Note that filenames containing + // spaces are escaped and the initial file may have escaped colons + // (e.g., "C\:/Program\ Files/..."). + // + java.util.ArrayList l = new java.util.ArrayList(); + StringBuffer file = new StringBuffer(); + pos = 0; + while(pos < chars.length) + { + if(Character.isWhitespace(chars[pos])) + { + if(file.length() > 0) + { + l.add(file.toString()); + file = new StringBuffer(); + } + } + else if(chars[pos] != '\\') // Skip backslash of an escaped character. + { + file.append(chars[pos]); + } + ++pos; + } + if(file.length() > 0) + { + l.add(file.toString()); + } + + // + // Create SliceDependency. We need to remove the trailing colon from the first file. + // We also normalize the pathname for this platform. + // + SliceDependency depend = new SliceDependency(); + depend._dependencies = new String[l.size()]; + l.toArray(depend._dependencies); + depend._timeStamp = new java.util.Date().getTime(); + pos = depend._dependencies[0].lastIndexOf(':'); + assert(pos == depend._dependencies[0].length() - 1); + depend._dependencies[0] = depend._dependencies[0].substring(0, pos); + for(int i = 0; i < depend._dependencies.length; ++i) + { + depend._dependencies[i] = new File(depend._dependencies[i]).toString(); + } + dependencies.add(depend); + + depline = new StringBuffer(); + } + } + } + catch(java.io.IOException ex) + { + throw new BuildException("Unable to read dependencies from slice translator: " + ex); + } + + 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: + // + // 1. Through the ice.home property + // 2. Through the ICE_HOME environment variable. + // + // If both the property and environment variable is specified, the + // property takes precedence. If neither is available, getIceHome() + // returns null. + // + protected String + getIceHome() + { + if(_iceHome == null) + { + if(getProject().getProperties().containsKey("ice.home")) + { + _iceHome = (String)getProject().getProperties().get("ice.home"); + } + else + { + _iceHome = getEnvironment("ICE_HOME"); + } + } + return _iceHome; + } + + // + // A slice dependency. + // + // * the _timeStamp attribute contains the last time the slice + // file was compiled. + // + // * the _dependencies attribute contains an array with all the + // files this slice file depends on. + // + // This dependency represents the dependencies for the slice file + // _dependencies[0]. + // + protected class SliceDependency implements java.io.Serializable + { + private void writeObject(java.io.ObjectOutputStream out) + throws java.io.IOException + { + out.writeObject(_dependencies); + out.writeLong(_timeStamp); + } + + private void readObject(java.io.ObjectInputStream in) + throws java.io.IOException, java.lang.ClassNotFoundException + { + _dependencies = (String[])in.readObject(); + _timeStamp = in.readLong(); + } + + public boolean + isUpToDate() + { + for(int i = 0; i < _dependencies.length; ++i) + { + File dep = new File(_dependencies[i]); + if(!dep.exists() || _timeStamp < dep.lastModified()) + { + return false; + } + } + + return true; + } + + public String[] _dependencies; + 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; + protected boolean _caseSensitive; + protected boolean _ice; + protected Path _includePath; + protected java.util.List _fileSets = new java.util.LinkedList(); + protected java.util.List _defines = new java.util.LinkedList(); + protected java.util.List _meta = new java.util.LinkedList(); + private String _iceHome; +} |