From: Hiram C. <ch...@us...> - 2002-06-24 23:18:34
|
Update of /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/os390 In directory usw-pr-cvs1:/tmp/cvs-serv18517/src/net/sf/antcontrib/cpptasks/os390 Modified Files: OS390Linker.java Log Message: Started Initial support for the ICC AS/400 Compiler Added better DATASET support to the os390 compiler. You can now output modules into datasets. Index: OS390Linker.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/os390/OS390Linker.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** OS390Linker.java 20 Jun 2002 05:41:47 -0000 1.9 --- OS390Linker.java 24 Jun 2002 23:18:31 -0000 1.10 *************** *** 55,65 **** --- 55,71 ---- import java.io.File; + import java.io.FileOutputStream; + import java.io.IOException; import java.util.Vector; + import net.sf.antcontrib.cpptasks.CCTask; import net.sf.antcontrib.cpptasks.CUtil; import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker; + import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration; import net.sf.antcontrib.cpptasks.compiler.LinkType; import net.sf.antcontrib.cpptasks.compiler.Linker; import net.sf.antcontrib.cpptasks.types.LibrarySet; + import org.apache.tools.ant.BuildException; + import org.apache.tools.ant.Task; *************** *** 76,81 **** --- 82,90 ---- private static final OS390Linker dllLinker = new OS390Linker("", ".dll"); + private static final OS390Linker datasetLinker = + new OS390Linker(); private String outputPrefix; + private boolean isADatasetLinker; private OS390Linker(String outputPrefix, String outputSuffix) *************** *** 84,88 **** --- 93,107 ---- new String[] { ".dll" }, outputSuffix, false, null); this.outputPrefix = outputPrefix; + this.isADatasetLinker = false; + } + + private OS390Linker() + { + super("cxx", "/bogus", new String[] { ".o", ".a", ".lib", ".xds" }, + new String[] { ".dll", ".x" }, ".xds", false, null); + this.outputPrefix = ""; + this.isADatasetLinker = true; } + public static OS390Linker getInstance() { *************** *** 90,93 **** --- 109,117 ---- } + public static OS390Linker getDataSetInstance() { + return datasetLinker; + } + + public File[] getLibraryPath() { return CUtil.getPathFromEnvironment("LIB",";"); *************** *** 117,128 **** public Linker getLinker(LinkType linkType) { ! if(linkType.isSharedLibrary()) { return dllLinker; ! } ! /* ! if(linkType.isStaticLibrary()) { ! return OS390Librarian.getInstance(); ! } ! */ return instance; } --- 141,150 ---- public Linker getLinker(LinkType linkType) { ! if ( this == datasetLinker ) ! return datasetLinker; ! ! if(linkType.isSharedLibrary()) return dllLinker; ! return instance; } *************** *** 139,142 **** --- 161,172 ---- } + protected String[] getOutputFileSwitch(CCTask task, String outputFile) { + if( isADatasetLinker && task.getDataset() !=null ) { + String ds = task.getDataset(); + outputFile = "//'"+ds+"("+outputFile+")'"; + } + return getOutputFileSwitch(outputFile); + } + public String[] getOutputFileSwitch(String outputFile) { return new String[] { "-o", outputFile }; *************** *** 158,164 **** * @see CommandLineLinker#addLibrarySets(LibrarySet[], Vector, Vector, Vector) */ ! protected String[] addLibrarySets(LibrarySet[] libsets, Vector preargs, Vector midargs, Vector endargs) { - // // If yo want to link against a library sitting in a dataset and // not in the HFS, you can just use the //'dataset' notation --- 188,193 ---- * @see CommandLineLinker#addLibrarySets(LibrarySet[], Vector, Vector, Vector) */ ! protected String[] addLibrarySets(CCTask task, LibrarySet[] libsets, Vector preargs, Vector midargs, Vector endargs) { // If yo want to link against a library sitting in a dataset and // not in the HFS, you can just use the //'dataset' notation *************** *** 174,186 **** for( int j=0; j < libs.length; j++ ) { if( libs[j].startsWith("//") ) { ! endargs.add("-l"); ! endargs.add(libs[j]); } } } } ! return super.addLibrarySets(libsets, preargs, midargs, endargs); } } --- 203,257 ---- for( int j=0; j < libs.length; j++ ) { if( libs[j].startsWith("//") ) { ! endargs.addElement("-l"); ! endargs.addElement(libs[j]); ! } else if( libsets[i].getDataset() != null ) { ! String ds = libsets[i].getDataset(); ! endargs.addElement( "//'"+ds+"("+libs[j]+")'"); } } } } ! ! ! return super.addLibrarySets(task, libsets, preargs, midargs, endargs); ! } ! ! File outputFile; ! CCTask task; ! ! /* ! * @see CommandLineLinker#link(Task, File, String[], CommandLineLinkerConfiguration) ! */ ! public void link(CCTask task, File outputFile, String[] sourceFiles, CommandLineLinkerConfiguration config) ! throws BuildException { ! this.task = task; ! this.outputFile = outputFile; ! ! if( isADatasetLinker ) { ! int p = outputFile.getName().indexOf("."); ! if( p >= 0 ) { ! String newname = outputFile.getName().substring(0,p); ! outputFile = new File( outputFile.getParent(), newname); ! } ! } ! super.link(task, outputFile, sourceFiles, config); } + /* + * @see CommandLineLinker#runCommand(Task, File, String[]) + */ + protected int runCommand(Task task, File workingDir, String[] cmdline) throws BuildException { + int rc = super.runCommand(task, workingDir, cmdline); + // create the .xds file if everything was ok. + if( rc == 0 ) { + try { + outputFile.delete(); + new FileOutputStream( outputFile ).close(); + } catch ( IOException e ) { + throw new BuildException(e.getMessage()); + } + } + return rc; + } } |