summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorcarnold <[email protected]>2008-02-22 16:48:34 +0000
committercarnold <[email protected]>2008-02-22 16:48:34 +0000
commit7919095f38d9536f02f1a9505d8fa55b69bd9c02 (patch)
tree6859adeb398973b32b129a3125a59a7b0fdc118d /src
parent212c1db014944a850167ee2988b24815bdfa0fd8 (diff)
Fix outtype detection for Xcode gen on non-Mac platforms
git-svn-id: file:///home/sven/projects/JOGL/temp/ant-contrib/svn/ant-contrib-code/cpptasks/trunk@158 32d7a393-a5a9-423c-abd3-5d954feb1f2f
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/sf/antcontrib/cpptasks/apple/XcodeProjectWriter.java65
1 files changed, 37 insertions, 28 deletions
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 e339638..f901b4d 100644
--- a/src/main/java/net/sf/antcontrib/cpptasks/apple/XcodeProjectWriter.java
+++ b/src/main/java/net/sf/antcontrib/cpptasks/apple/XcodeProjectWriter.java
@@ -317,12 +317,7 @@ public final class XcodeProjectWriter
linkTarget.getOutput());
Map executableProperties = executable.getProperties();
- String fileType = "compiled.mach-o.executable";
- if (isStaticLibrary(linkTarget)) {
- fileType = "archive.ar";
- } else if (isDylibLibrary(linkTarget)) {
- fileType = "compiled.mach-o.dylib";
- }
+ String fileType = getFileType(linkTarget);
executableProperties.put("explicitFileType", fileType);
executableProperties.put("includeInIndex", "0");
objects.put(executable.getID(), executableProperties);
@@ -615,12 +610,7 @@ public final class XcodeProjectWriter
String productInstallPath = "$(HOME)/bin";
- 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";
- }
+ String productType = getProductType(linkTarget);
PBXObjectRef nativeTarget = createPBXNativeTarget(projectName,
buildConfigurations, buildPhases, buildRules, dependencies,
@@ -630,27 +620,46 @@ public final class XcodeProjectWriter
return nativeTarget;
}
- /**
- * Determines if linked target is a static library.
- * @param linkTarget link target
- * @return true if a static library
- */
- private static boolean isStaticLibrary(final TargetInfo linkTarget) {
+ private int getProductTypeIndex(final TargetInfo linkTarget) {
String outPath = linkTarget.getOutput().getPath();
- return (outPath.lastIndexOf(".a") == outPath.length() - 2);
+ String outExtension = null;
+ int lastDot = outPath.lastIndexOf('.');
+ if (lastDot != -1) {
+ outExtension = outPath.substring(lastDot);
+ }
+ if (".a".equalsIgnoreCase(outExtension) || ".lib".equalsIgnoreCase(outExtension)) {
+ return 1;
+ } else if (".dylib".equalsIgnoreCase(outExtension) ||
+ ".so".equalsIgnoreCase(outExtension) ||
+ ".dll".equalsIgnoreCase(outExtension)) {
+ return 2;
+ }
+ return 0;
}
- /**
- * 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);
+ private String getProductType(final TargetInfo linkTarget) {
+ switch(getProductTypeIndex(linkTarget)) {
+ case 1:
+ return "com.apple.product-type.library.static";
+ case 2:
+ return "com.apple.product-type.library.dynamic";
+ default:
+ return "com.apple.product-type.tool";
+ }
}
+ private String getFileType(final TargetInfo linkTarget) {
+ switch(getProductTypeIndex(linkTarget)) {
+ case 1:
+ return "archive.ar";
+ case 2:
+ return "compiled.mach-o.dylib";
+ default:
+ return "compiled.mach-o.executable";
+ }
+ }
+
+
/**
* Create PBXFileReference.
* @param sourceTree source tree.