use ArchNameTask to configure darwin sdk

This commit is contained in:
Doug MacEachern 2009-02-25 21:35:54 -08:00
parent 839010d6c9
commit 1bd4f0e074
2 changed files with 34 additions and 6 deletions

View File

@ -25,7 +25,6 @@ USA.
<property name="jni.src.java" value="src"/>
<property name="jni.libprefix" value="java"/>
<property name="jni.libversion" value=""/>
<property name="uni.sdk.version" value="4u"/>
<property name="osx.min" value="-mmacosx-version-min=10.3"/>
<property name="cpptasks.jar" location="lib/cpptasks.jar"/>
@ -195,11 +194,6 @@ USA.
<property name="jni.objdir" value="${build}/obj/${jni.libarch}"/>
<condition property="uni.sdk"
value="/Developer/SDKs/MacOSX10.${uni.sdk.version}.sdk">
<istrue value="${darwin}"/>
</condition>
<condition property="jni.cc" value="uni-cc">
<isset property="darwin"/>
</condition>

View File

@ -18,6 +18,11 @@
package org.hyperic.jni;
import java.io.File;
import java.io.FileFilter;
import java.util.Arrays;
import java.util.Comparator;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
@ -72,5 +77,34 @@ public class ArchNameTask extends Task {
}
}
}
if (ArchLoader.IS_DARWIN) {
//default to most recent SDK
//MacOSX10.3.9.sdk, MacOSX10.4u.sdk, MacOSX10.5.sdk,etc.
File[] sdks =
new File("/Developer/SDKs").listFiles(new FileFilter() {
public boolean accept(File file) {
String name = file.getName();
return
name.startsWith("MacOSX10.") &&
name.endsWith(".sdk");
}
});
if (sdks != null) {
Arrays.sort(sdks, new Comparator() {
public int compare(Object s1, Object s2) {
return (int)(((File)s2).lastModified() -
((File)s1).lastModified());
}
});
final String prop = "uni.sdk";
String sdk = getProject().getProperty(prop);
if (sdk == null) {
sdk = sdks[0].getPath();
getProject().setProperty(prop, sdk);
}
System.out.println("Using SDK=" + sdk);
}
}
}
}