Skip to content

Commit

Permalink
Merge branch 'hpux'
Browse files Browse the repository at this point in the history
  • Loading branch information
dougm committed Feb 14, 2009
2 parents 14be0b9 + 04c9f43 commit 0ac6619
Show file tree
Hide file tree
Showing 4 changed files with 318 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/net/sf/antcontrib/cpptasks/CompilerEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
import net.sf.antcontrib.cpptasks.gcc.WindresResourceCompiler;
import net.sf.antcontrib.cpptasks.hp.aCCCompiler;
import net.sf.antcontrib.cpptasks.hp.HPCompiler;
import net.sf.antcontrib.cpptasks.ibm.VisualAgeCCompiler;
import net.sf.antcontrib.cpptasks.intel.IntelLinux32CCompiler;
import net.sf.antcontrib.cpptasks.intel.IntelLinux64CCompiler;
Expand Down Expand Up @@ -216,6 +217,7 @@ public class CompilerEnum extends EnumeratedAttribute {
new ProcessorEnumValue("armcpp", ADSCCompiler.getArmCpp()),
new ProcessorEnumValue("tcc", ADSCCompiler.getThumbCC()),
new ProcessorEnumValue("tcpp", ADSCCompiler.getThumbCpp()),
new ProcessorEnumValue("hp", HPCompiler.getInstance()),
// GCC Cross Compilers
new ProcessorEnumValue(
"sparc-sun-solaris2-gcc",
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/sf/antcontrib/cpptasks/LinkerEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.sf.antcontrib.cpptasks.gcc.GppLinker;
import net.sf.antcontrib.cpptasks.gcc.LdLinker;
import net.sf.antcontrib.cpptasks.hp.aCCLinker;
import net.sf.antcontrib.cpptasks.hp.HPLinker;
import net.sf.antcontrib.cpptasks.ibm.VisualAgeLinker;
import net.sf.antcontrib.cpptasks.intel.IntelLinux32Linker;
import net.sf.antcontrib.cpptasks.intel.IntelLinux64Linker;
Expand Down Expand Up @@ -72,6 +73,7 @@ public class LinkerEnum extends EnumeratedAttribute {
new ProcessorEnumValue("armcpp", ADSLinker.getInstance()),
new ProcessorEnumValue("tcc", ADSLinker.getInstance()),
new ProcessorEnumValue("tcpp", ADSLinker.getInstance()),
new ProcessorEnumValue("hp", HPLinker.getInstance()),
// gcc cross compilers
new ProcessorEnumValue(
"sparc-sun-solaris2-gcc",
Expand Down
161 changes: 161 additions & 0 deletions src/main/java/net/sf/antcontrib/cpptasks/hp/HPCompiler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Ant-Contrib project. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package net.sf.antcontrib.cpptasks.hp;

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.GccCompatibleCCompiler;
import org.apache.tools.ant.types.Environment;

/**
* Adapter for the HP compiler
*
* @author Curt Arnold
*/
public final class HPCompiler extends GccCompatibleCCompiler {

private String identifier;
private File[] includePath;
private static final HPCompiler instance =
new HPCompiler("cc", false, null);

/**
* Private constructor. Use GccCCompiler.getInstance() to get
* singleton instance of this class.
*/
private HPCompiler(
String command,
boolean newEnvironment,
Environment env) {
super(command, "-help", false, null, newEnvironment, env);
}

public int getMaximumCommandLength() {
return Integer.MAX_VALUE;
}

/**
* Gets singleton instance of this class
*/
public static HPCompiler getInstance() {
return instance;
}

public File[] getEnvironmentIncludePath() {
if (includePath == null) {
File ccLoc = CUtil.getExecutableLocation("cc");
if (ccLoc != null) {
File compilerIncludeDir =
new File(new File(ccLoc, "../include").getAbsolutePath());
if (compilerIncludeDir.exists()) {
includePath = new File[2];
includePath[0] = compilerIncludeDir;
}
}
if (includePath == null) {
includePath = new File[1];
}
includePath[includePath.length - 1] = new File("/usr/include");
}
return includePath;
}

public void addImpliedArgs(
Vector args,
boolean debug,
boolean multithreaded,
boolean exceptions,
LinkType linkType) {
args.addElement("-c");
if (debug) {
args.addElement("-g");
}
/*
if (multithreaded) {
args.addElement("-mt");
}
*/
if (linkType.isSharedLibrary()) {
args.addElement("+z");
}
}

public void addWarningSwitch(Vector args, int level) {
switch (level) {
case 0 :
args.addElement("-w");
break;

case 1 :
case 2 :
args.addElement("+w");
break;
/*
case 3:
case 4:
case 5:
args.addElement("+w2");
break;
*/
}
}

public Linker getLinker(LinkType linkType) {
return HPLinker.getInstance().getLinker(linkType);
}
}
153 changes: 153 additions & 0 deletions src/main/java/net/sf/antcontrib/cpptasks/hp/HPLinker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Ant-Contrib project. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package net.sf.antcontrib.cpptasks.hp;

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 HP linker
*
* @author Curt Arnold
*/
public final class HPLinker extends AbstractLdLinker
{
private static final String[] objFiles = new String[]
{ ".o", ".a", ".lib", ".dll", ".so", ".sl" };
private static final String[] discardFiles = new String[0];

private static final HPLinker instance =
new HPLinker("ld", objFiles, discardFiles, "", "");
private static final HPLinker dllLinker =
new HPLinker("ld", objFiles, discardFiles, "lib", ".sl");
private static final HPLinker arLinker =
new HPLinker("ld", objFiles, discardFiles, "", ".a");

private File[] libDirs;

private HPLinker(String command, String[] extensions,
String[] ignoredExtensions, String outputPrefix,
String outputSuffix) {
super(command, "-help", extensions, ignoredExtensions,
outputPrefix, outputSuffix,false,null);
}

public static HPLinker getInstance() {
return instance;
}

/**
* Returns library path.
*
*/
public File[] getLibraryPath() {
if(libDirs == null) {
File CCloc = CUtil.getExecutableLocation("ld");
if(CCloc != null) {
File compilerLib = new File(
new File(CCloc, "../lib").getAbsolutePath());
if (compilerLib.exists()) {
libDirs = new File[2];
libDirs[0] = compilerLib;
}
}
if (libDirs == null) {
libDirs = new File[1];
}
}
libDirs[libDirs.length-1] = new File("/usr/lib");
return libDirs;
}

public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
/* if(linkType.isStaticRuntime()) {
args.addElement("-static");
}
*/
if(linkType.isSharedLibrary()) {
args.addElement("-b");
}
/*
if (linkType.isStaticLibrary()) {
args.addElement("-Wl,-noshared");
}
*/
}


public Linker getLinker(LinkType type) {
if(type.isStaticLibrary()) {
return arLinker;
}
if(type.isSharedLibrary()) {
return dllLinker;
}
return instance;
}

public void addIncremental(boolean incremental, Vector args) {
/*
if (incremental) {
args.addElement("-xidlon");
} else {
args.addElement("-xidloff");
}
*/
}
}

0 comments on commit 0ac6619

Please sign in to comment.