From 254c4886d58979eebd0e352f4d16e391736f2a33 Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Thu, 5 Nov 2009 23:27:33 +0100 Subject: Reorganized source directories in line with cpptasks-1.0b5, for easier tracking --- .../gcc/cross/sparc_sun_solaris2/GccCCompiler.java | 244 ----------------- .../gcc/cross/sparc_sun_solaris2/GccLibrarian.java | 43 --- .../gcc/cross/sparc_sun_solaris2/GccLinker.java | 215 --------------- .../gcc/cross/sparc_sun_solaris2/GccProcessor.java | 305 --------------------- .../gcc/cross/sparc_sun_solaris2/GppLinker.java | 210 -------------- .../gcc/cross/sparc_sun_solaris2/LdLinker.java | 60 ---- 6 files changed, 1077 deletions(-) delete mode 100644 src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccCCompiler.java delete mode 100644 src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLibrarian.java delete mode 100644 src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLinker.java delete mode 100644 src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java delete mode 100644 src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GppLinker.java delete mode 100644 src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/LdLinker.java (limited to 'src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2') diff --git a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccCCompiler.java b/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccCCompiler.java deleted file mode 100644 index 44dd968..0000000 --- a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccCCompiler.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * - * Copyright 2001-2004 The Ant-Contrib project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2; -import java.io.File; -import java.util.Vector; - -import net.sf.antcontrib.cpptasks.CUtil; -import net.sf.antcontrib.cpptasks.compiler.LinkType; -import net.sf.antcontrib.cpptasks.compiler.Linker; -import net.sf.antcontrib.cpptasks.compiler.Processor; -import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler; -import net.sf.antcontrib.cpptasks.parser.CParser; -import net.sf.antcontrib.cpptasks.parser.FortranParser; -import net.sf.antcontrib.cpptasks.parser.Parser; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.Environment; -import net.sf.antcontrib.cpptasks.OptimizationEnum; - -/** - * Adapter for the GCC C/C++ compiler - * - * @author Adam Murdoch - */ -public final class GccCCompiler extends GccCompatibleCCompiler { - private final static String[] sourceExtensions = new String[]{".c", /* C */ - ".cc", /* C++ */ - ".cpp", /* C++ */ - ".cxx", /* C++ */ - ".c++", /* C++ */ - ".i", /* preprocessed C */ - ".ii", /* preprocessed C++ */ - ".f", /* FORTRAN */ - ".for", /* FORTRAN */ - ".m", /* Objective-C */ - ".mm", /* Objected-C++ */ - ".s" /* Assembly */ - }; - private final static String[] headerExtensions = new String[]{".h", ".hpp", - ".inl"}; - public static final String CMD_PREFIX = "sparc-sun-solaris2-"; - private static final GccCCompiler cppInstance = new GccCCompiler(CMD_PREFIX - + "c++", sourceExtensions, headerExtensions, false, - new GccCCompiler(CMD_PREFIX + "c++", sourceExtensions, - headerExtensions, true, null, false, null), false, null); - private static final GccCCompiler g77Instance = new GccCCompiler(CMD_PREFIX - + "g77", sourceExtensions, headerExtensions, false, - new GccCCompiler(CMD_PREFIX + "g77", sourceExtensions, - headerExtensions, true, null, false, null), false, null); - private static final GccCCompiler gppInstance = new GccCCompiler(CMD_PREFIX - + "g++", sourceExtensions, headerExtensions, false, - new GccCCompiler(CMD_PREFIX + "g++", sourceExtensions, - headerExtensions, true, null, false, null), false, null); - private static final GccCCompiler instance = new GccCCompiler(CMD_PREFIX - + "gcc", sourceExtensions, headerExtensions, false, - new GccCCompiler(CMD_PREFIX + "gcc", sourceExtensions, - headerExtensions, true, null, false, null), false, null); - /** - * Gets c++ adapter - */ - public static GccCCompiler getCppInstance() { - return cppInstance; - } - /** - * Gets g77 adapter - */ - public static GccCCompiler getG77Instance() { - return g77Instance; - } - /** - * Gets gpp adapter - */ - public static GccCCompiler getGppInstance() { - return gppInstance; - } - /** - * Gets gcc adapter - */ - public static GccCCompiler getInstance() { - return instance; - } - private String identifier; - private File[] includePath; - private boolean isPICMeaningful = true; - /** - * Private constructor. Use GccCCompiler.getInstance() to get singleton - * instance of this class. - */ - private GccCCompiler(String command, String[] sourceExtensions, - String[] headerExtensions, boolean isLibtool, - GccCCompiler libtoolCompiler, boolean newEnvironment, - Environment env) { - super(command, null, sourceExtensions, headerExtensions, isLibtool, - libtoolCompiler, newEnvironment, env); - isPICMeaningful = System.getProperty("os.name").indexOf("Windows") < 0; - } - public void addImpliedArgs(final Vector args, - final boolean debug, - final boolean multithreaded, - final boolean exceptions, - final LinkType linkType, - final Boolean rtti, - final OptimizationEnum optimization) { - super.addImpliedArgs(args, debug, multithreaded, - exceptions, linkType, rtti, optimization); - if (isPICMeaningful && linkType.isSharedLibrary()) { - args.addElement("-fPIC"); - } - } - public Processor changeEnvironment(boolean newEnvironment, Environment env) { - if (newEnvironment || env != null) { - return new GccCCompiler(getCommand(), this.getSourceExtensions(), - this.getHeaderExtensions(), this.getLibtool(), - (GccCCompiler) this.getLibtoolCompiler(), newEnvironment, - env); - } - return this; - } - /** - * Create parser to determine dependencies. - * - * Will create appropriate parser (C++, FORTRAN) based on file extension. - * - */ - protected Parser createParser(File source) { - if (source != null) { - String sourceName = source.getName(); - int lastDot = sourceName.lastIndexOf('.'); - if (lastDot >= 0 && lastDot + 1 < sourceName.length()) { - char afterDot = sourceName.charAt(lastDot + 1); - if (afterDot == 'f' || afterDot == 'F') { - return new FortranParser(); - } - } - } - return new CParser(); - } - public File[] getEnvironmentIncludePath() { - if (includePath == null) { - // - // construct default include path from machine id and version id - // - String[] defaultInclude = new String[1]; - StringBuffer buf = new StringBuffer("/lib/"); - buf.append(GccProcessor.getMachine()); - buf.append('/'); - buf.append(GccProcessor.getVersion()); - buf.append("/include"); - defaultInclude[0] = buf.toString(); - // - // read specs file and look for -istart and -idirafter - // - String[] specs = GccProcessor.getSpecs(); - String[][] optionValues = GccProcessor.parseSpecs(specs, "*cpp:", - new String[]{"-isystem ", "-idirafter "}); - // - // if no entries were found, then use a default path - // - if (optionValues[0].length == 0 && optionValues[1].length == 0) { - optionValues[0] = new String[]{"/usr/local/include", - "/usr/include", "/usr/include/win32api"}; - } - // - // remove mingw entries. - // For MinGW compiles this will mean the - // location of the sys includes will be - // wrong in dependencies.xml - // but that should have no significant effect - for (int i = 0; i < optionValues.length; i++) { - for (int j = 0; j < optionValues[i].length; j++) { - if (optionValues[i][j].indexOf("mingw") > 0) { - optionValues[i][j] = null; - } - } - } - // - // if cygwin then - // we have to prepend location of gcc32 - // and .. to start of absolute filenames to - // have something that will exist in the - // windows filesystem - if (GccProcessor.isCygwin()) { - GccProcessor.convertCygwinFilenames(optionValues[0]); - GccProcessor.convertCygwinFilenames(optionValues[1]); - GccProcessor.convertCygwinFilenames(defaultInclude); - } - int count = CUtil.checkDirectoryArray(optionValues[0]); - count += CUtil.checkDirectoryArray(optionValues[1]); - count += CUtil.checkDirectoryArray(defaultInclude); - includePath = new File[count]; - int index = 0; - for (int i = 0; i < optionValues.length; i++) { - for (int j = 0; j < optionValues[i].length; j++) { - if (optionValues[i][j] != null) { - includePath[index++] = new File(optionValues[i][j]); - } - } - } - for (int i = 0; i < defaultInclude.length; i++) { - if (defaultInclude[i] != null) { - includePath[index++] = new File(defaultInclude[i]); - } - } - } - return (File[]) includePath.clone(); - } - public String getIdentifier() throws BuildException { - if (identifier == null) { - StringBuffer buf; - if (getLibtool()) { - buf = new StringBuffer("libtool "); - } else { - buf = new StringBuffer(' '); - } - buf.append(getCommand()); - buf.append(' '); - buf.append(GccProcessor.getVersion()); - buf.append(' '); - buf.append(GccProcessor.getMachine()); - identifier = buf.toString(); - } - return identifier; - } - public Linker getLinker(LinkType linkType) { - return GccLinker.getInstance().getLinker(linkType); - } - public int getMaximumCommandLength() { - return Integer.MAX_VALUE; - } -} diff --git a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLibrarian.java b/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLibrarian.java deleted file mode 100644 index 779fb3d..0000000 --- a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLibrarian.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Copyright 2002-2004 The Ant-Contrib project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2; -import net.sf.antcontrib.cpptasks.compiler.LinkType; -import net.sf.antcontrib.cpptasks.compiler.Linker; -import net.sf.antcontrib.cpptasks.gcc.AbstractArLibrarian; -/** - * Adapter for the 'ar' archiver - * - * @author Adam Murdoch - */ -public final class GccLibrarian extends AbstractArLibrarian { - private static String[] objFileExtensions = new String[]{".o"}; - private static GccLibrarian instance = new GccLibrarian( - GccCCompiler.CMD_PREFIX + "ar", objFileExtensions, false, - new GccLibrarian(GccCCompiler.CMD_PREFIX + "ar", objFileExtensions, - true, null)); - public static GccLibrarian getInstance() { - return instance; - } - private GccLibrarian(String command, String[] inputExtensions, - boolean isLibtool, GccLibrarian libtoolLibrarian) { - super(command, "V", inputExtensions, new String[0], "lib", ".a", - isLibtool, libtoolLibrarian); - } - public Linker getLinker(LinkType type) { - return GccLinker.getInstance().getLinker(type); - } -} diff --git a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLinker.java b/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLinker.java deleted file mode 100644 index d7dd3db..0000000 --- a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccLinker.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * - * Copyright 2001-2004 The Ant-Contrib project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2; -import java.io.File; -import java.util.Vector; - -import net.sf.antcontrib.cpptasks.CUtil; -import net.sf.antcontrib.cpptasks.compiler.LinkType; -import net.sf.antcontrib.cpptasks.compiler.Linker; -import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker; -/** - * Adapter for the GCC linker - * - * @author Adam Murdoch - */ -public class GccLinker extends AbstractLdLinker { - private static final String[] discardFiles = new String[0]; - private static final String[] objFiles = new String[]{".o", ".a", ".lib", - ".dll", ".so", ".sl"}; - private static final String[] libtoolObjFiles = new String[]{".fo", ".a", - ".lib", ".dll", ".so", ".sl"}; - private static String[] linkerOptions = new String[]{"-bundle", - "-dynamiclib", "-nostartfiles", "-nostdlib", "-prebind", "-s", - "-static", "-shared", "-symbolic", "-Xlinker", - "--export-all-symbols", "-static-libgcc",}; - private static final GccLinker dllLinker = new GccLinker( - GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib", - ".so", false, new GccLinker(GccCCompiler.CMD_PREFIX + "gcc", - objFiles, discardFiles, "lib", ".so", true, null)); - private static final GccLinker instance = new GccLinker( - GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "", "", - false, null); - private static final GccLinker machBundleLinker = new GccLinker( - GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib", - ".bundle", false, null); - private static final GccLinker machDllLinker = new GccLinker( - GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib", - ".dylib", false, null); - public static GccLinker getInstance() { - return instance; - } - private File[] libDirs; - protected GccLinker(String command, String[] extensions, - String[] ignoredExtensions, String outputPrefix, - String outputSuffix, boolean isLibtool, GccLinker libtoolLinker) { - super(command, "-dumpversion", extensions, ignoredExtensions, - outputPrefix, outputSuffix, isLibtool, libtoolLinker); - } - protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) { - super.addImpliedArgs(debug, linkType, args); - if (getIdentifier().indexOf("mingw") >= 0) { - if (linkType.isSubsystemConsole()) { - args.addElement("-mconsole"); - } - if (linkType.isSubsystemGUI()) { - args.addElement("-mwindows"); - } - } - } - /** - * Allows drived linker to decorate linker option. Override by GccLinker to - * prepend a "-Wl," to pass option to through gcc to linker. - * - * @param buf - * buffer that may be used and abused in the decoration process, - * must not be null. - * @param arg - * linker argument - */ - public String decorateLinkerOption(StringBuffer buf, String arg) { - String decoratedArg = arg; - if (arg.length() > 1 && arg.charAt(0) == '-') { - switch (arg.charAt(1)) { - // - // passed automatically by GCC - // - case 'g' : - case 'f' : - case 'F' : - /* Darwin */ - case 'm' : - case 'O' : - case 'W' : - case 'l' : - case 'L' : - case 'u' : - case 'v' : - break; - default : - boolean known = false; - for (int i = 0; i < linkerOptions.length; i++) { - if (linkerOptions[i].equals(arg)) { - known = true; - break; - } - } - if (!known) { - buf.setLength(0); - buf.append("-Wl,"); - buf.append(arg); - decoratedArg = buf.toString(); - } - break; - } - } - return decoratedArg; - } - /** - * Returns library path. - * - */ - public File[] getLibraryPath() { - if (libDirs == null) { - // - // construct gcc lib path from machine and version - // - StringBuffer buf = new StringBuffer("/lib/gcc-lib/"); - buf.append(GccProcessor.getMachine()); - buf.append('/'); - buf.append(GccProcessor.getVersion()); - // - // build default path from gcc and system /lib and /lib/w32api - // - String[] impliedLibPath = new String[]{buf.toString(), - "/lib/w32api", "/lib"}; - // - // read gcc specs file for other library paths - // - String[] specs = GccProcessor.getSpecs(); - String[][] libpaths = GccProcessor.parseSpecs(specs, "*link:", - new String[]{"%q"}); - String[] libpath; - if (libpaths[0].length > 0) { - libpath = new String[libpaths[0].length + 3]; - int i = 0; - for (; i < libpaths[0].length; i++) { - libpath[i] = libpaths[0][i]; - } - libpath[i++] = buf.toString(); - libpath[i++] = "/lib/w32api"; - libpath[i++] = "/lib"; - } else { - // - // if a failure to find any matches then - // use some default values for lib path entries - libpath = new String[]{"/usr/local/lib/mingw", - "/usr/local/lib", "/usr/lib/w32api", "/usr/lib/mingw", - "/usr/lib", buf.toString(), "/lib/w32api", "/lib"}; - } - for (int i = 0; i < libpath.length; i++) { - if (libpath[i].indexOf("mingw") >= 0) { - libpath[i] = null; - } - } - // - // if cygwin then - // we have to prepend location of gcc32 - // and .. to start of absolute filenames to - // have something that will exist in the - // windows filesystem - if (GccProcessor.isCygwin()) { - GccProcessor.convertCygwinFilenames(libpath); - } - // - // check that remaining entries are actual directories - // - int count = CUtil.checkDirectoryArray(libpath); - // - // populate return array with remaining entries - // - libDirs = new File[count]; - int index = 0; - for (int i = 0; i < libpath.length; i++) { - if (libpath[i] != null) { - libDirs[index++] = new File(libpath[i]); - } - } - } - return libDirs; - } - public Linker getLinker(LinkType type) { - if (type.isStaticLibrary()) { - return GccLibrarian.getInstance(); - } - if (type.isPluginModule()) { - if (isDarwin()) { - return machBundleLinker; - } else { - return dllLinker; - } - } - if (type.isSharedLibrary()) { - if (isDarwin()) { - return machDllLinker; - } else { - return dllLinker; - } - } - return instance; - } -} diff --git a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java b/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java deleted file mode 100644 index 8a7a26e..0000000 --- a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GccProcessor.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * - * Copyright 2002-2004 The Ant-Contrib project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.Vector; - -import net.sf.antcontrib.cpptasks.CUtil; -import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler; -import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum; - -/** - * A add-in class for Gcc processors - * - * - */ -public class GccProcessor { - // the results from gcc -dumpmachine - private static String machine; - private static String[] specs; - // the results from gcc -dumpversion - private static String version; - private static int addLibraryPatterns(String[] libnames, StringBuffer buf, - String prefix, String extension, String[] patterns, int offset) { - for (int i = 0; i < libnames.length; i++) { - buf.setLength(0); - buf.append(prefix); - buf.append(libnames[i]); - buf.append(extension); - patterns[offset + i] = buf.toString(); - } - return offset + libnames.length; - } - /** - * Converts absolute Cygwin file or directory names to the corresponding - * Win32 name. - * - * @param names - * array of names, some elements may be null, will be changed in - * place. - */ - public static void convertCygwinFilenames(String[] names) { - if (names == null) { - throw new NullPointerException("names"); - } - File gccDir = CUtil.getExecutableLocation(GccCCompiler.CMD_PREFIX - + "gcc.exe"); - if (gccDir != null) { - String prefix = gccDir.getAbsolutePath() + "/.."; - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < names.length; i++) { - String name = names[i]; - if (name != null && name.length() > 1 && name.charAt(0) == '/') { - buf.setLength(0); - buf.append(prefix); - buf.append(name); - names[i] = buf.toString(); - } - } - } - } - public static String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) { - StringBuffer buf = new StringBuffer(); - String[] patterns = new String[libnames.length * 2]; - int offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0); - if (isHPUX()) { - offset = addLibraryPatterns(libnames, buf, "lib", ".sl", patterns, - offset); - } else { - offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns, - offset); - } - return patterns; - } - public static String getMachine() { - if (machine == null) { - String[] args = new String[]{GccCCompiler.CMD_PREFIX + "gcc", - "-dumpmachine"}; - String[] cmdout = CaptureStreamHandler.run(args); - if (cmdout.length == 0) { - machine = "nomachine"; - } else { - machine = cmdout[0]; - } - } - return machine; - } - public static String[] getOutputFileSwitch(String letter, String outputFile) { - StringBuffer buf = new StringBuffer(); - if (outputFile.indexOf(' ') >= 0) { - buf.append('"'); - buf.append(outputFile.replace('\\', '/')); - buf.append('"'); - } else { - buf.append(outputFile.replace('\\', '/')); - } - String[] retval = new String[]{letter, buf.toString()}; - return retval; - } - /** - * Returns the contents of the gcc specs file. - * - * The implementation locates gcc.exe in the executable path and then - * builds a relative path name from the results of -dumpmachine and - * -dumpversion. Attempts to use gcc -dumpspecs to provide this information - * resulted in stalling on the Execute.run - * - * @returns contents of the specs file - */ - public static String[] getSpecs() { - if (specs == null) { - File gccParent = CUtil - .getExecutableLocation(GccCCompiler.CMD_PREFIX + "gcc.exe"); - if (gccParent != null) { - // - // build a relative path like - // ../lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs - // - StringBuffer buf = new StringBuffer("../lib/gcc-lib/"); - buf.append(getMachine()); - buf.append('/'); - buf.append(getVersion()); - buf.append("/specs"); - // - // resolve it relative to the location of gcc.exe - // - String relativePath = buf.toString(); - File specsFile = new File(gccParent, relativePath); - // - // found the specs file - // - try { - // - // read the lines in the file - // - BufferedReader reader = new BufferedReader(new FileReader( - specsFile)); - Vector lines = new Vector(100); - String line = reader.readLine(); - while (line != null) { - lines.addElement(line); - line = reader.readLine(); - } - specs = new String[lines.size()]; - lines.copyInto(specs); - } catch (IOException ex) { - } - } - } - if (specs == null) { - specs = new String[0]; - } - return specs; - } - public static String getVersion() { - if (version == null) { - String[] args = new String[]{GccCCompiler.CMD_PREFIX + "gcc", - "-dumpversion"}; - String[] cmdout = CaptureStreamHandler.run(args); - if (cmdout.length == 0) { - version = "noversion"; - } else { - version = cmdout[0]; - } - } - return version; - } - public static boolean isCaseSensitive() { - return true; - } - /** - * Determines if task is running with cygwin - * - * @return true if cygwin was detected - */ - public static boolean isCygwin() { - return getMachine().indexOf("cygwin") > 0; - } - private static boolean isHPUX() { - String osname = System.getProperty("os.name").toLowerCase(); - if (osname.indexOf("hp") >= 0 && osname.indexOf("ux") >= 0) { - return true; - } - return false; - } - /** - * - * Parses the results of the specs file for a specific processor and - * options - * - * @param specsContent - * Contents of specs file as returned from getSpecs - * @param specSectionStart - * start of spec section, for example "*cpp:" - * @param options - * command line switches such as "-istart" - */ - public static String[][] parseSpecs(String[] specsContent, - String specSectionStart, String[] options) { - if (specsContent == null) { - throw new NullPointerException("specsContent"); - } - if (specSectionStart == null) { - throw new NullPointerException("specSectionStart"); - } - if (options == null) { - throw new NullPointerException("option"); - } - String[][] optionValues = new String[options.length][]; - StringBuffer optionValue = new StringBuffer(40); - for (int i = 0; i < specsContent.length; i++) { - String specLine = specsContent[i]; - // - // if start of section then start paying attention - // - if (specLine.startsWith(specSectionStart)) { - Vector[] optionVectors = new Vector[options.length]; - for (int j = 0; j < options.length; j++) { - optionVectors[j] = new Vector(10); - } - // - // go to next line and examine contents - // and repeat until end of file - // - for (i++; i < specsContent.length; i++) { - specLine = specsContent[i]; - for (int j = 0; j < options.length; j++) { - int optionStart = specLine.indexOf(options[j]); - while (optionStart >= 0) { - optionValue.setLength(0); - // - // walk rest of line looking for first non - // whitespace - // and then next space - boolean hasNonBlank = false; - int k = optionStart + options[j].length(); - for (; k < specLine.length(); k++) { - // - // either a blank or a "}" (close of - // conditional) - // section will end the path - // - if (specLine.charAt(k) == ' ' - || specLine.charAt(k) == '}') { - if (hasNonBlank) { - break; - } - } else { - hasNonBlank = true; - optionValue.append(specLine.charAt(k)); - } - } - // - // transition back to whitespace - // value is over, add it to vector - if (hasNonBlank) { - optionVectors[j].addElement(optionValue - .toString()); - } - // - // find next occurance on line - // - optionStart = specLine.indexOf(options[j], k); - } - } - } - // - // copy vectors over to option arrays - // - for (int j = 0; j < options.length; j++) { - optionValues[j] = new String[optionVectors[j].size()]; - optionVectors[j].copyInto(optionValues[j]); - } - } - } - // - // fill in any missing option values with - // a zero-length string array - for (int i = 0; i < optionValues.length; i++) { - String[] zeroLenArray = new String[0]; - if (optionValues[i] == null) { - optionValues[i] = zeroLenArray; - } - } - return optionValues; - } - private GccProcessor() { - } -} diff --git a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GppLinker.java b/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GppLinker.java deleted file mode 100644 index 45bbea9..0000000 --- a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/GppLinker.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * - * Copyright 2003-2004 The Ant-Contrib project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2; -import java.io.File; -import java.util.Vector; - -import net.sf.antcontrib.cpptasks.CCTask; -import net.sf.antcontrib.cpptasks.CUtil; -import net.sf.antcontrib.cpptasks.compiler.CaptureStreamHandler; -import net.sf.antcontrib.cpptasks.compiler.LinkType; -import net.sf.antcontrib.cpptasks.compiler.Linker; -import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker; -import net.sf.antcontrib.cpptasks.types.LibrarySet; -/** - * Adapter for the g++ variant of the GCC linker - * - * @author Stephen M. Webb - */ -public class GppLinker extends AbstractLdLinker { - protected static final String[] discardFiles = new String[0]; - protected static final String[] objFiles = new String[]{".o", ".a", ".lib", - ".dll", ".so", ".sl"}; - private final static String libPrefix = "libraries: ="; - protected static final String[] libtoolObjFiles = new String[]{".fo", ".a", - ".lib", ".dll", ".so", ".sl"}; - private static String[] linkerOptions = new String[]{"-bundle", "-dylib", - "-dynamic", "-dynamiclib", "-nostartfiles", "-nostdlib", - "-prebind", "-s", "-static", "-shared", "-symbolic", "-Xlinker"}; - private static final GppLinker dllLinker = new GppLinker( - GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib", - ".so", false, new GppLinker(GccCCompiler.CMD_PREFIX + "gcc", - objFiles, discardFiles, "lib", ".so", true, null)); - private static final GppLinker instance = new GppLinker( - GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "", "", - false, null); - private static final GppLinker machDllLinker = new GppLinker( - GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib", - ".dylib", false, null); - private static final GppLinker machPluginLinker = new GppLinker( - GccCCompiler.CMD_PREFIX + "gcc", objFiles, discardFiles, "lib", - ".bundle", false, null); - public static GppLinker getInstance() { - return instance; - } - private File[] libDirs; - private String runtimeLibrary; - protected GppLinker(String command, String[] extensions, - String[] ignoredExtensions, String outputPrefix, - String outputSuffix, boolean isLibtool, GppLinker libtoolLinker) { - super(command, "-dumpversion", extensions, ignoredExtensions, - outputPrefix, outputSuffix, isLibtool, libtoolLinker); - } - protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args) { - super.addImpliedArgs(debug, linkType, args); - if (getIdentifier().indexOf("mingw") >= 0) { - if (linkType.isSubsystemConsole()) { - args.addElement("-mconsole"); - } - if (linkType.isSubsystemGUI()) { - args.addElement("-mwindows"); - } - } - if (linkType.isStaticRuntime()) { - String[] cmdin = new String[]{GccCCompiler.CMD_PREFIX + "g++", - "-print-file-name=libstdc++.a"}; - String[] cmdout = CaptureStreamHandler.run(cmdin); - if (cmdout.length > 0) { - runtimeLibrary = cmdout[0]; - } else { - runtimeLibrary = null; - } - } else { - runtimeLibrary = "-lstdc++"; - } - } - public String[] addLibrarySets(CCTask task, LibrarySet[] libsets, - Vector preargs, Vector midargs, Vector endargs) { - String[] rs = super.addLibrarySets(task, libsets, preargs, midargs, - endargs); - if (runtimeLibrary != null) { - endargs.addElement(runtimeLibrary); - } - return rs; - } - /** - * Allows drived linker to decorate linker option. Override by GppLinker to - * prepend a "-Wl," to pass option to through gcc to linker. - * - * @param buf - * buffer that may be used and abused in the decoration process, - * must not be null. - * @param arg - * linker argument - */ - public String decorateLinkerOption(StringBuffer buf, String arg) { - String decoratedArg = arg; - if (arg.length() > 1 && arg.charAt(0) == '-') { - switch (arg.charAt(1)) { - // - // passed automatically by GCC - // - case 'g' : - case 'f' : - case 'F' : - /* Darwin */ - case 'm' : - case 'O' : - case 'W' : - case 'l' : - case 'L' : - case 'u' : - break; - default : - boolean known = false; - for (int i = 0; i < linkerOptions.length; i++) { - if (linkerOptions[i].equals(arg)) { - known = true; - break; - } - } - if (!known) { - buf.setLength(0); - buf.append("-Wl,"); - buf.append(arg); - decoratedArg = buf.toString(); - } - break; - } - } - return decoratedArg; - } - /** - * Returns library path. - * - */ - public File[] getLibraryPath() { - if (libDirs == null) { - Vector dirs = new Vector(); - // Ask GCC where it will look for its libraries. - String[] args = new String[]{GccCCompiler.CMD_PREFIX + "g++", - "-print-search-dirs"}; - String[] cmdout = CaptureStreamHandler.run(args); - for (int i = 0; i < cmdout.length; ++i) { - int prefixIndex = cmdout[i].indexOf(libPrefix); - if (prefixIndex >= 0) { - // Special case DOS-type GCCs like MinGW or Cygwin - int s = prefixIndex + libPrefix.length(); - int t = cmdout[i].indexOf(';', s); - while (t > 0) { - dirs.addElement(cmdout[i].substring(s, t)); - s = t + 1; - t = cmdout[i].indexOf(';', s); - } - dirs.addElement(cmdout[i].substring(s)); - ++i; - for (; i < cmdout.length; ++i) { - dirs.addElement(cmdout[i]); - } - } - } - // Eliminate all but actual directories. - String[] libpath = new String[dirs.size()]; - dirs.copyInto(libpath); - int count = CUtil.checkDirectoryArray(libpath); - // Build return array. - libDirs = new File[count]; - int index = 0; - for (int i = 0; i < libpath.length; ++i) { - if (libpath[i] != null) { - libDirs[index++] = new File(libpath[i]); - } - } - } - return libDirs; - } - public Linker getLinker(LinkType type) { - if (type.isStaticLibrary()) { - return GccLibrarian.getInstance(); - } - if (type.isPluginModule()) { - if (GccProcessor.getMachine().indexOf("darwin") >= 0) { - return machPluginLinker; - } else { - return dllLinker; - } - } - if (type.isSharedLibrary()) { - if (GccProcessor.getMachine().indexOf("darwin") >= 0) { - return machDllLinker; - } else { - return dllLinker; - } - } - return instance; - } -} diff --git a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/LdLinker.java b/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/LdLinker.java deleted file mode 100644 index 0cc5fbf..0000000 --- a/src/net/sf/antcontrib/cpptasks/gcc/cross/sparc_sun_solaris2/LdLinker.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Copyright 2001-2004 The Ant-Contrib project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.sf.antcontrib.cpptasks.gcc.cross.sparc_sun_solaris2; -import java.io.File; - -import net.sf.antcontrib.cpptasks.compiler.LinkType; -import net.sf.antcontrib.cpptasks.compiler.Linker; -import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker; -/** - * Adapter for the 'ld' linker - * - * @author Curt Arnold - */ -public final class LdLinker extends AbstractLdLinker { - private static final String[] discardFiles = new String[0]; - private static final String[] libtoolObjFiles = new String[]{".fo", ".a", - ".lib", ".dll", ".so", ".sl"}; - private static final String[] objFiles = new String[]{".o", ".a", ".lib", - ".dll", ".so", ".sl"}; - private static final LdLinker dllLinker = new LdLinker( - GccCCompiler.CMD_PREFIX + "ld", objFiles, discardFiles, "lib", - ".so", false, new LdLinker(GccCCompiler.CMD_PREFIX + "ld", - objFiles, discardFiles, "lib", ".so", true, null)); - private static final LdLinker instance = new LdLinker( - GccCCompiler.CMD_PREFIX + "ld", objFiles, discardFiles, "", "", - false, null); - public static LdLinker getInstance() { - return instance; - } - private File[] libDirs; - private LdLinker(String command, String[] extensions, - String[] ignoredExtensions, String outputPrefix, - String outputSuffix, boolean isLibtool, LdLinker libtoolLinker) { - super(command, "-version", extensions, ignoredExtensions, outputPrefix, - outputSuffix, isLibtool, libtoolLinker); - } - public Linker getLinker(LinkType type) { - if (type.isStaticLibrary()) { - return GccLibrarian.getInstance(); - } - if (type.isSharedLibrary()) { - return dllLinker; - } - return instance; - } -} -- cgit v1.2.3