summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcarnold <[email protected]>2007-08-04 02:34:12 +0000
committercarnold <[email protected]>2007-08-04 02:34:12 +0000
commit14f23e25571a56646659a70caff73b8e36dda88d (patch)
tree08bd63f4d03119cf1d21362b05545a450dd6a943
parent8079f2276bb6cf7227a943258a73dc991d9a349e (diff)
Bug 980130: XCode continued, dylibs recognized
git-svn-id: file:///home/sven/projects/JOGL/temp/ant-contrib/svn/ant-contrib-code/cpptasks/trunk@137 32d7a393-a5a9-423c-abd3-5d954feb1f2f
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java14
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/apple/XcodeProjectWriter.java38
2 files changed, 38 insertions, 14 deletions
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java b/src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java
index 20b4c1b..207d52f 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/apple/PropertyListSerialization.java
@@ -22,12 +22,16 @@ import org.xml.sax.helpers.AttributesImpl;
import javax.xml.transform.Result;
import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.io.File;
+import java.io.IOException;
+import java.io.FileOutputStream;
/**
* Static class that provides methods to serialize
@@ -45,16 +49,20 @@ public final class PropertyListSerialization {
/**
* Serializes a property list into a Cocoa XML Property List document.
* @param propertyList property list.
- * @param result destination.
+ * @param file destination.
* @throws SAXException if exception during serialization.
* @throws TransformerConfigurationException if exception creating serializer.
*/
public static void serialize(final Map propertyList,
- final Result result)
- throws SAXException, TransformerConfigurationException {
+ final File file)
+ throws IOException, SAXException,
+ TransformerConfigurationException {
SAXTransformerFactory sf = (SAXTransformerFactory)
SAXTransformerFactory.newInstance();
TransformerHandler handler = sf.newTransformerHandler();
+
+ FileOutputStream os = new FileOutputStream(file);
+ StreamResult result = new StreamResult(os);
handler.setResult(result);
handler.startDocument();
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/apple/XcodeProjectWriter.java b/src/main/java/net/sf/antcontrib/cpptasks/apple/XcodeProjectWriter.java
index 48a91df..bbd96f3 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/apple/XcodeProjectWriter.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/apple/XcodeProjectWriter.java
@@ -17,20 +17,18 @@
package net.sf.antcontrib.cpptasks.apple;
import net.sf.antcontrib.cpptasks.CCTask;
-import net.sf.antcontrib.cpptasks.TargetInfo;
import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.TargetInfo;
import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
-import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;
import net.sf.antcontrib.cpptasks.gcc.GccCCompiler;
import net.sf.antcontrib.cpptasks.ide.ProjectDef;
import net.sf.antcontrib.cpptasks.ide.ProjectWriter;
import org.apache.tools.ant.BuildException;
import org.xml.sax.SAXException;
-import javax.xml.transform.Result;
import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.IOException;
import java.text.NumberFormat;
@@ -186,10 +184,8 @@ public final class XcodeProjectWriter
//
// write property list out to XML file
//
- Result result = new StreamResult(xcodeProj);
-
try {
- PropertyListSerialization.serialize(propertyList, result);
+ PropertyListSerialization.serialize(propertyList, xcodeProj);
} catch (TransformerConfigurationException ex) {
throw new IOException(ex.toString());
} catch (SAXException ex) {
@@ -236,6 +232,8 @@ public final class XcodeProjectWriter
String fileType = "compiled.mach-o.executable";
if (isStaticLibrary(linkTarget)) {
fileType = "archive.ar";
+ } else if (isDylibLibrary(linkTarget)) {
+ fileType = "compiled.mach-o.dylib";
}
executableProperties.put("explicitFileType", fileType);
executableProperties.put("includeInIndex", "0");
@@ -334,6 +332,7 @@ public final class XcodeProjectWriter
/**
* Add project configuration list.
* @param objects map of objects.
+ * @param baseDir base directory.
* @param compilerConfig compiler configuration.
* @param linkerConfig linker configuration.
* @return project configuration object.
@@ -368,7 +367,7 @@ public final class XcodeProjectWriter
PBXObjectRef configurationList = createXCConfigurationList(configurations);
Map projectConfigurationListProperties = configurationList.getProperties();
projectConfigurationListProperties.put("defaultConfigurationIsVisible", "0");
- projectConfigurationListProperties.put("defaultConfigurationName", "Release");
+ projectConfigurationListProperties.put("defaultConfigurationName", "Debug");
objects.put(configurationList.getID(), configurationList.getProperties());
//
@@ -409,9 +408,12 @@ public final class XcodeProjectWriter
String[] linkerArgs = linkerConfig.getPreArguments();
List librarySearchPaths = new ArrayList();
+ List libNames = new ArrayList();
for (int i = 0; i < linkerArgs.length; i++) {
if (linkerArgs[i].startsWith("-L")) {
librarySearchPaths.add(linkerArgs[i].substring(2));
+ } else if (linkerArgs[i].startsWith("-l")) {
+ libNames.add(linkerArgs[i]);
}
}
if (librarySearchPaths.size() > 0) {
@@ -419,9 +421,11 @@ public final class XcodeProjectWriter
debugSettings.put("LIBRARY_SEARCH_PATHS", librarySearchPaths);
releaseSettings.put("LIBRARY_SEARCH_PATHS", librarySearchPaths);
}
-
-
-
+ if (libNames.size() > 0) {
+ libNames.add("$(inherited)");
+ debugSettings.put("OTHER_LDFLAGS", libNames);
+ releaseSettings.put("OTHER_LDFLAGS", libNames);
+ }
return configurationList;
}
@@ -484,6 +488,8 @@ public final class XcodeProjectWriter
String productType = "com.apple.product-type.tool";
if (isStaticLibrary(linkTarget)) {
productType = "com.apple.product-type.library.static";
+ } else if (isDylibLibrary(linkTarget)) {
+ productType = "com.apple.product-type.library.dynamic";
}
PBXObjectRef nativeTarget = createPBXNativeTarget(projectName,
@@ -504,6 +510,16 @@ public final class XcodeProjectWriter
return (outPath.lastIndexOf(".a") == outPath.length() - 2);
}
+ /**
+ * Determines if linked target is a static library.
+ * @param linkTarget link target
+ * @return true if a static library
+ */
+ private static boolean isDylibLibrary(final TargetInfo linkTarget) {
+ String outPath = linkTarget.getOutput().getPath();
+ return (outPath.lastIndexOf(".dylib") == outPath.length() - 6 &&
+ outPath.length() > 6);
+ }
/**
* Create PBXFileReference.