From 6500952e5bcd36776421c10800de664bcc8f80bb Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 25 Feb 2009 21:35:54 -0800 Subject: [PATCH] use ArchNameTask to configure darwin sdk --- bindings/java/hyperic_jni/jni-build.xml | 6 ---- .../src/org/hyperic/jni/ArchNameTask.java | 34 +++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/bindings/java/hyperic_jni/jni-build.xml b/bindings/java/hyperic_jni/jni-build.xml index 7c0d0631..034ec21f 100644 --- a/bindings/java/hyperic_jni/jni-build.xml +++ b/bindings/java/hyperic_jni/jni-build.xml @@ -25,7 +25,6 @@ USA. - @@ -195,11 +194,6 @@ USA. - - - - diff --git a/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchNameTask.java b/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchNameTask.java index 4041b134..e1c275d3 100644 --- a/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchNameTask.java +++ b/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchNameTask.java @@ -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; @@ -78,5 +83,34 @@ public class ArchNameTask extends Task { getProject().setProperty("jni.gccm", "-m31"); } } + + 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); + } + } } }