Use <condition> in the ant build.xml scripts rather than
variable substitution in WebAppCreator.  This makes the
scripts more portable and defers the choice of whether
to include -d32 to runtime.

Include the -d32 flag in all Mac Eclipse launch scripts;
this may fail on some older OS versions that only support
64 bits, but will enable the samples to run in Snow Leopard
without needed additional configuration.

Review by: TBR



git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.7@6180 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/tools/WebAppCreator.java b/user/src/com/google/gwt/user/tools/WebAppCreator.java
index ddb8da1..b6757e4 100644
--- a/user/src/com/google/gwt/user/tools/WebAppCreator.java
+++ b/user/src/com/google/gwt/user/tools/WebAppCreator.java
@@ -229,7 +229,6 @@
     // Figure out what platform we're on
     boolean isMacOsX = gwtDevPath.substring(gwtDevPath.lastIndexOf('/') + 1).indexOf(
         "mac") >= 0;
-    boolean is64BitVm = "64".equals(System.getProperty("sun.arch.data.model"));
 
     // Compute module package and name.
     int pos = moduleName.lastIndexOf('.');
@@ -261,21 +260,18 @@
     replacements.put("@compileClass", Compiler.class.getName());
     replacements.put("@startupUrl", moduleShortName + ".html");
 
-    String antVmargs = "";
-    if (isMacOsX) {
-	antVmargs = "\n      <jvmarg value=\"-XstartOnFirstThread\"/>";
-	if (is64BitVm) {
-	    antVmargs += "\n      <jvmarg value=\"-d32\"/>";
-	}
-    }
-    replacements.put("@antVmargs", antVmargs);
-
     String vmargs = "";
     if (isMacOsX) {
-	vmargs = "&#10;-XstartOnFirstThread";
-	if (is64BitVm) {
-	    vmargs += "&#10;-d32";
-	}
+        vmargs = "&#10;-XstartOnFirstThread";
+        /*
+         * For Eclipse launch scripts, include the -d32 flag.  Note
+         * that some older Mac JVMs that supported only 64-bit mode
+         * may not understand this argument; however, since there is
+         * no way to make the argument conditional, we choose to fail
+         * on these older VMs in order to make newer VMs work without
+         * the need for additional configuration.
+         */
+        vmargs += "&#10;-d32";
     }
     replacements.put("@vmargs", vmargs);
 
diff --git a/user/src/com/google/gwt/user/tools/project.ant.xmlsrc b/user/src/com/google/gwt/user/tools/project.ant.xmlsrc
index 8b3ef42..7a62c81 100644
--- a/user/src/com/google/gwt/user/tools/project.ant.xmlsrc
+++ b/user/src/com/google/gwt/user/tools/project.ant.xmlsrc
@@ -3,6 +3,20 @@
   <!-- Configure path to GWT SDK -->
   <property name="gwt.sdk" location="@gwtSdk" />
 
+  <!-- SWT on Mac requires the -XstartOFirstThreadFlag. -->
+  <condition property="XstartOnFirstThreadFlag" value="-XstartOnFirstThread"
+    else="-Dgwt.dummy.arg1=">
+    <os family="mac"/>
+  </condition>
+
+  <!-- SWT on Mac requires the -d32 flag if the VM is 64-bit. -->
+  <condition property="d32Flag" value="-d32" else="-Dgwt.dummy.arg2=">
+    <and>
+      <os family="mac"/>
+      <equals arg1="${sun.arch.data.model}" arg2="64"/>
+    </and>
+  </condition>
+
   <path id="project.class.path">
     <pathelement location="war/WEB-INF/classes"/>
     <pathelement location="${gwt.sdk}/gwt-user.jar"/>
@@ -37,7 +51,9 @@
         <path refid="project.class.path"/>
       </classpath>
       <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
-      <jvmarg value="-Xmx256M"/>@antVmargs
+      <jvmarg value="-Xmx256M"/>
+      <jvmarg value="${XstartOnFirstThreadFlag}"/>
+      <jvmarg value="${d32Flag}"/>
       <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
       <arg value="@moduleName"/>
     </java>
@@ -49,7 +65,9 @@
         <pathelement location="src"/>
         <path refid="project.class.path"/>
       </classpath>
-      <jvmarg value="-Xmx256M"/>@antVmargs
+      <jvmarg value="-Xmx256M"/>
+      <jvmarg value="${XstartOnFirstThreadFlag}"/>
+      <jvmarg value="${d32Flag}"/>
       <arg value="-startupUrl"/>
       <arg value="@startupUrl"/>
       <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->