flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject svn commit: r1333232 [21/34] - in /incubator/flex/trunk: ./ frameworks/tests/ frameworks/tests/basicTests/ frameworks/tests/basicTests/dmv/ frameworks/tests/basicTests/dmv/scripts/ frameworks/tests/basicTests/dmv/views/ frameworks/tests/basicTests/fxg/...
Date Wed, 02 May 2012 22:45:08 GMT
Propchange: incubator/flex/trunk/mustella/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/mustella/clobber.awk
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/mustella/clobber.awk?rev=1333232&view=auto
==============================================================================
--- incubator/flex/trunk/mustella/clobber.awk (added)
+++ incubator/flex/trunk/mustella/clobber.awk Wed May  2 22:44:38 2012
@@ -0,0 +1,85 @@
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+BEGIN { FS="," 
+
+	MYLINE=""
+
+	while ( (getline line < "local.properties") > 0) {
+		if (index(line, "extra_includes") == 1) {
+			MYLINE=	substr(line, index(line, "=")+1)
+		}
+	}
+
+	## treat the entry as an array
+	n = split(MYLINE, arr)
+
+	for (z in arr)
+		print "myline: "  arr[z]
+
+}
+{
+
+reg=0;app=0;
+
+if ( (reg=index($1, "sdk.mustella.excludes")) > 0 || (app=index($1, "apollo_only_excludes")) > 0) {
+
+	# print "found reg or app in " $1 "reg:"reg" app:" app;
+
+	## operate on this line
+	# clip $1
+
+	resultLine=""
+
+	for (i=1;i<=NF;i++) {
+		
+		field=$i
+
+		if (i==1)
+			field = substr($i, index($i, "=")+1)
+
+
+		## loop through our list of extra_includes for a match. 
+		sawmatch=0;
+		for (j in arr) {
+			if (field==arr[j])  {
+				sawmatch=1;
+			}
+		}
+
+		if (!sawmatch)
+			resultLine=sprintf("%s,%s", field, resultLine);
+
+
+	}
+
+
+
+}
+}
+
+END { 
+
+
+	if (resultLine != "" && reg)
+		print "sdk.mustella.excludes="resultLine
+	if (resultLine != "" && app)
+		print "apollo_only_excludes="resultLine
+
+}
+

Propchange: incubator/flex/trunk/mustella/clobber.awk
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/mustella/java/src/build.xml
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/mustella/java/src/build.xml?rev=1333232&view=auto
==============================================================================
--- incubator/flex/trunk/mustella/java/src/build.xml (added)
+++ incubator/flex/trunk/mustella/java/src/build.xml Wed May  2 22:44:38 2012
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<project name="Flex Mustella Source" default="main" basedir="../..">
+	<property environment="env"/>
+    <property name="ant-contrib.jar" location="${env.ANT_HOME}/lib/ant-contrib-1.0b2.jar"/>
+	<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${ant-contrib.jar}"/>
+
+    <property name="mustella.dir" value="${basedir}"/>
+    <property file="${mustella.dir}/local.properties"/>
+    <property file="${mustella.dir}/build.properties"/>
+    <property name="sdk.dir" value="$.."/>
+
+	<property name="src.dir" value="${mustella.dir}/java/src"/>
+    <property name="build.dir" value="${mustella.dir}/classes"/>
+
+	<!-- You can use Ant-based dependency-tracking for faster compiling. -->
+	<!-- Add the following property to your build.properties to turn this on: -->
+	<!-- src.depend=true -->
+	<!-- these may be overridden by specifying in build.properties -->
+	<property name="src.debug" value="on"/>
+
+    <path id="flex.mustella.lib.classpath">
+	<pathelement location="${mustella.dir}/classes"/>
+        <fileset dir="${mustella.dir}/lib">
+            <include name="*.jar"/>
+        </fileset>
+    </path>
+
+    <path id="ant.lib.classpath">
+        <fileset dir="${env.ANT_HOME}/lib">
+            <include name="*.jar"/>
+        </fileset>
+    </path>
+
+	<path id="sdk.lib.classpath">
+		<fileset dir="${sdk.dir}/lib">
+			<include name="*.jar"/>
+		</fileset>
+	</path>
+
+    <path id="swfutils.classpath">
+        <fileset dir="${sdk.dir}/lib">
+            <include name="swfutils.jar"/>
+            <include name="xalan.jar"/>
+        </fileset>
+    </path>
+
+
+	<target name="main" depends="compile,jar"/>
+
+	<target name="prepare">
+		<echo message="Creating build directory..."/>
+		<mkdir dir="${build.dir}"/>
+	</target>
+
+	<target name="compile-mustella" depends="prepare">
+		<echo message="Compiling mustella source code..."/>		
+		<javac  destdir="${build.dir}" debug="${src.debug}" nowarn="true" source="1.4" srcdir="${src.dir}" includes="mustella/**/*.java,utils/**/*.java">
+			<classpath>
+                <!--<path refid="flex.mustella.lib.classpath"/>-->
+                <path refid="ant.lib.classpath"/>
+                <path refid="swfutils.classpath"/>
+				<path refid="sdk.lib.classpath"/>
+			</classpath>
+		</javac>
+
+	</target>
+
+
+	<target name="compile" depends="prepare">
+		<echo message="Compiling source code..."/>
+		<javac srcdir="${src.dir}" destdir="${build.dir}" debug="${src.debug}" nowarn="true" source="1.4">
+			<classpath>
+                <!--<path refid="flex.mustella.lib.classpath"/>-->
+                <path refid="ant.lib.classpath"/>
+                <path refid="swfutils.classpath"/>
+			</classpath>
+		</javac>
+	</target>
+
+	<target name="jar" depends="compile">
+        <echo message="Building jars..."/>
+        <jar file="${mustella.dir}/lib/testRunner.jar" basedir="${mustella.dir}/classes"
+             includes="**/*.class">
+          <manifest>
+            <attribute name="Main-Class" value="tools.TestRunner" />
+          </manifest>
+        </jar>
+        <jar file="${mustella.dir}/lib/mxmlRunner.jar" basedir="${mustella.dir}/classes"
+             includes="**/*.class">
+          <manifest>
+            <attribute name="Main-Class" value="tools.MxmlRunner" />
+          </manifest>
+        </jar>
+	</target>
+	
+	<target name="jar-browserServer" depends="compile">
+        <echo message="Building browserServer jar..."/>
+        <jar file="${mustella.dir}/lib/browserServer.jar" basedir="${mustella.dir}/classes"
+             includes="tools/browserServer/**/*.class">
+          <manifest>
+            <attribute name="Main-Class" value="tools.browserServer.Server" />
+          </manifest>
+        </jar>      
+	</target>
+
+	<target name="compileBuildInfo" depends="prepare">
+		<echo message="Compiling BuildInfo source code..."/>
+
+		<javac srcdir="${src.dir}" destdir="${build.dir}" debug="${src.debug}" nowarn="true" includes="**/BuildInfo/**/*.java">
+			<classpath>
+                <path refid="flex.mustella.lib.classpath"/>
+                <path refid="ant.lib.classpath"/>
+                <path refid="swfutils.classpath"/>
+			</classpath>
+		</javac>
+	</target>
+
+	<target name="jarBuildInfo" depends="compileBuildInfo">
+        <echo message="Building BuildInfo jar..."/>
+        <jar file="${mustella.dir}/lib/BuildInfo.jar" basedir="${mustella.dir}/classes"
+             includes="**/*.class">
+        </jar>
+	</target>
+
+	<target name="clean">
+		<echo message="Removing classes..."/>
+		<delete dir="${build.dir}"/>
+	</target>
+
+</project>

Propchange: incubator/flex/trunk/mustella/java/src/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/mustella/java/src/mustella/ApolloAdjuster.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/mustella/java/src/mustella/ApolloAdjuster.java?rev=1333232&view=auto
==============================================================================
--- incubator/flex/trunk/mustella/java/src/mustella/ApolloAdjuster.java (added)
+++ incubator/flex/trunk/mustella/java/src/mustella/ApolloAdjuster.java Wed May  2 22:44:38 2012
@@ -0,0 +1,405 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package mustella;
+import java.io.*;
+
+import javax.xml.parsers.*;
+import javax.xml.transform.*;
+import org.w3c.dom.*;
+import javax.xml.transform.dom.*;
+import javax.xml.transform.stream.StreamResult;
+
+import utils.*;
+
+/**
+
+Writes application descriptor files for AIR
+
+
+*/
+public class ApolloAdjuster {
+
+
+	static String swffile = null;
+	static String xmlfile = null;
+	static String xmlfile2 = null;
+	static String delete_file = null;
+	static String deviceName = "";
+
+	/// the template file.
+	static String template_location = "/templates/air/descriptor-template.xml";
+	static String model_file = System.getProperty ("sdk.dir") +  template_location;
+
+
+	static String xmlnsVal = "http://ns.adobe.com/air/application/1.0";
+
+	static {
+
+		try {
+			if (System.getProperty ("air_xmlns") != null)
+				xmlnsVal = System.getProperty ("air_xmlns");
+		} catch (Exception e) {
+
+			/// leave it
+
+		}
+
+
+		try {
+			deviceName = System.getProperty( "device_name" );
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		
+	}
+
+
+	/**
+	 * use the template that's part of the distribution to create the
+	 * application descriptor file.
+	 * See code comments for details.
+	 */
+	public static String xmlTransformFromTemplate ( boolean includeSwfParent ) throws Exception {
+
+		DocumentBuilder docb = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+		Document doc = docb.parse (new File(model_file));
+
+		NodeList nl = null;
+
+		String justSwf = getSwfName ( swffile, false );
+		String appid = justSwf.substring( 0, justSwf.indexOf( ".swf" ) ).replace( "_", "" );
+		String content = getSwfName ( swffile, includeSwfParent );
+
+		/// modify the pieces we need to: content:
+		nl = doc.getElementsByTagName("content");
+
+		if ( nl.item(0).getFirstChild() == null)  {
+			Text t = doc.createTextNode (content);
+			nl.item(0).appendChild(t);
+		} else
+			nl.item(0).getFirstChild().setNodeValue(content);
+
+		/// modify the pieces we need to: filename
+		//  Note: The adt tool doesn't like filename to be exactly the same as the name of the swf.
+		nl = doc.getElementsByTagName("filename");
+
+		if ( nl.item(0).getFirstChild() == null)  {
+			Text ft = doc.createTextNode (appid);
+			nl.item(0).appendChild (ft);
+		} else {
+			nl.item(0).getFirstChild().setNodeValue(appid);
+		}
+
+
+		/// modify the pieces we need to: id
+		nl = doc.getElementsByTagName("id");
+		if ( nl.item(0).getFirstChild() == null)  {
+			Text it = doc.createTextNode (appid);
+			nl.item(0).appendChild (it);
+		} else
+			nl.item(0).getFirstChild().setNodeValue(appid);
+
+		nl = doc.getElementsByTagName("versionNumber");
+		if ( nl != null && nl.item(0) != null )  {
+			if (nl.item(0).getFirstChild() == null)  {
+				Text vit = doc.createTextNode ("1.0.0");
+				nl.item(0).appendChild (vit);
+			} else { 
+				nl.item(0).getFirstChild().setNodeValue("1.0.0");
+			}
+		}
+
+		/// modify the pieces we need to: android
+		if( deviceName != null ){
+			if( MobileUtil.getOSForDevice( deviceName ).compareToIgnoreCase( MobileUtil.ANDROID_OS ) == 0 ){
+				nl = doc.getElementsByTagName("application");
+				Element el = doc.createElement("android");
+				
+				Node el2 = el.appendChild( doc.createElement("manifestAdditions") );
+				el2.appendChild( doc.createCDATASection("\n\t<manifest>" +
+														"\n\t\t<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />" +
+														"\n\t\t<uses-permission android:name=\"android.permission.INTERNET\" />" +
+														"\n\t\t<uses-permission android:name=\"android.permission.WAKE_LOCK\" />" +
+														"\n\t\t<uses-permission android:name=\"android.permission.DISABLE_KEYGUARD\" />" +
+														"\n\t\t<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" />" +
+														"\n\t\t<uses-permission android:name=\"android.permission.READ_PHONE_STATE\" />" +
+														"\n\t\t<uses-permission android:name=\"android.permission.CAMERA\" />" +
+														"\n\t\t<uses-permission android:name=\"android.permission.RECORD_AUDIO\" />" +
+														"\n\t</manifest>\n"));
+				nl.item(0).appendChild(el);
+				
+				// For namespace 3.1 and after, use 16 bit color for Android due to performance issues.
+				Element colorDepth = doc.createElement("colorDepth");
+				Text colorDepthVal = doc.createTextNode ("16bit");
+				colorDepth.appendChild(colorDepthVal);
+				el.appendChild(colorDepth);
+				
+				// Set the softKeyboardBehavior in initialWindow.  This is only supported in Android right now, and
+				// this code can just be moved if it ends up being supported for other devices.
+				Element softKeyboardBehavior = doc.createElement("softKeyboardBehavior");
+				Text softKeyboardBehaviorVal = doc.createTextNode ("none");
+				softKeyboardBehavior.appendChild(softKeyboardBehaviorVal);
+				nl = doc.getElementsByTagName ("initialWindow");
+				nl.item(0).appendChild (softKeyboardBehavior);
+			}
+		}
+
+		/// modify the pieces we need to: iOS
+		if( deviceName != null ){
+			if( MobileUtil.getOSForDevice( deviceName ).compareToIgnoreCase( MobileUtil.IOS ) == 0 ){
+
+				// Add fullScreen, autoOrients, aspectRatio, and renderMode to initialWindow.  I'm not sure which of these
+				// are absolutely needed, but I do know that the file which works contains these items in addition to the above.
+				Element fullScreen = doc.createElement("fullScreen");
+				Text fullScreenVal = doc.createTextNode ("true");
+				fullScreen.appendChild (fullScreenVal);
+
+				Element autoOrients = doc.createElement("autoOrients");
+				Text autoOrientsVal = doc.createTextNode ("true");
+				autoOrients.appendChild (autoOrientsVal);
+
+				Element aspectRatio = doc.createElement("aspectRatio");
+				Text aspectRatioVal = doc.createTextNode ("portrait");
+				aspectRatio.appendChild (aspectRatioVal);
+
+				Element renderMode = doc.createElement("renderMode");
+				Text renderModeVal = doc.createTextNode ("cpu");
+				renderMode.appendChild (renderModeVal);
+				
+				nl = doc.getElementsByTagName ("initialWindow");
+				nl.item(0).appendChild(fullScreen);
+				nl.item(0).appendChild(autoOrients);
+				nl.item(0).appendChild(aspectRatio);
+				nl.item(0).appendChild(renderMode);
+				
+				// Run iOS tests in high resolution mode.  Add these to the application node.
+				nl = doc.getElementsByTagName("application");
+				Element el = doc.createElement("iPhone");
+				Node el2 = el.appendChild( doc.createElement("InfoAdditions") );
+				el2.appendChild( doc.createCDATASection("\n\t<key>UIDeviceFamily</key>" +
+														"\n\t\t<array>" +
+														"\n\t\t\t<string>1</string>" +
+														"\n\t\t\t<string>2</string>" +
+														"\n\t\t</array>" +
+														"\n\t\t<key>UIStatusBarStyle</key>" +
+														"\n\t\t<string>UIStatusBarStyleBlackOpaque</string>" +
+														"\n\t\t<key>UIRequiresPersistentWiFi</key>" +
+														"\n\t\t<string>YES</string>"));
+				nl.item(0).appendChild(el);
+				
+				nl = doc.getElementsByTagName("iPhone");
+				Element reqDisplayRes = doc.createElement("requestedDisplayResolution");
+				Text reqDisplayResVal = doc.createTextNode ("high");
+				reqDisplayRes.appendChild(reqDisplayResVal);
+				nl.item(0).appendChild(reqDisplayRes);				
+			}
+		}
+
+		// modify the pieces we need to: name.  Be sure it's no more than 25 characters (QNX restriction).
+		if( deviceName != null ){
+			if( MobileUtil.getOSForDevice( deviceName ).compareToIgnoreCase( MobileUtil.QNX ) == 0 ){
+				
+				String appName = appid;
+				if( appName.length() > 25 ){
+					appName = appName.substring( 0, 25 );
+				}
+				
+				nl = doc.getElementsByTagName( "name" );
+				if ( nl.item(0).getFirstChild() == null )  {
+					Text nameNode = doc.createTextNode ( appName );
+					nl.item(0).appendChild ( nameNode );
+				} else
+					nl.item(0).getFirstChild().setNodeValue( appName );
+			}
+		}
+				
+		/// modify the pieces we need to: systemChrome (we like 'none')
+		/// this is commented out in the template, so we just add it
+		Element sysChrome = doc.createElement("systemChrome");
+		Text chrome = doc.createTextNode ("none");
+		sysChrome.appendChild (chrome);
+
+		/// modify the pieces we need to: transparent (we like 'true')
+		/// this is commented out in the template, so we just add it
+		Element trans = doc.createElement("transparent");
+		Text transt = doc.createTextNode ("true");
+		trans.appendChild (transt);
+
+		/// modify the pieces we need to: visible (we like 'true')
+		/// this is commented out in the template, so we just add it
+		Element viz = doc.createElement("visible");
+		Text transv = doc.createTextNode ("true");
+		viz.appendChild (transv);
+
+		/// put them in the InitialWindow section
+		nl = doc.getElementsByTagName ("initialWindow");
+		nl.item(0).appendChild(sysChrome);
+		nl.item(0).appendChild(trans);
+		nl.item(0).appendChild(viz);
+
+		/// output the result
+		Transformer transformer = TransformerFactory.newInstance().newTransformer();
+		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+		//initialize StreamResult with File object to save to file
+		StreamResult result = new StreamResult(new StringWriter());
+		DOMSource source = new DOMSource(doc);
+		transformer.transform(source, result);
+		String xmlString = result.getWriter().toString();
+
+		return xmlString;
+	}
+
+
+	public static String xmlWriter (String file) {
+		return xmlWriter (file, true);
+
+	}
+	public static String xmlWriter (String file, boolean deleteIt) {
+		return xmlWriter (file, deleteIt, false);
+	}
+
+	public static String xmlWriter (String file, boolean deleteIt, boolean includeSwfParent) {
+
+		System.out.println ("apollo adj with : " + file);
+
+		if (file.indexOf (".swf") != -1) {
+
+			System.out.println ("apollo adj thinks it's a swf");
+			swffile = file;
+			// builder's generated name
+			xmlfile = file.substring (0, file.indexOf (".swf")) + ".xml";
+			if (deleteIt)
+				delete_file = file.substring (0, file.indexOf (".swf")) + ".delete";
+			else
+				delete_file = null;
+
+		} else if (file.indexOf (".xml") != -1) {
+
+			xmlfile = file;
+			swffile = file.substring (0, file.indexOf (".xml")) + ".swf";
+			if (deleteIt)
+				delete_file = file.substring (0, file.indexOf (".xml")) + ".delete";
+			else
+				delete_file = null;
+		}
+
+		/// check if it exists.
+
+		if (new File(xmlfile).exists() && (delete_file == null || !new File(delete_file).exists()))   {
+			System.out.println ("not writing Apollo file");
+			return xmlfile;
+		} else  {
+			System.out.println ("writing Apollo file!");
+			createFile( includeSwfParent );
+		}
+
+		return xmlfile;
+	}
+
+
+	public static boolean didWrite () {
+		try {
+			return new File(delete_file).exists();
+		} catch (Exception e) {
+			return false;
+		}
+	}
+
+
+	public static void delete () {
+
+		System.out.println ("removing the xml app file");
+		new File(delete_file).delete();
+		new File(xmlfile).delete();
+
+	}
+
+	public static String getSwfName (String file, boolean includeSwfParent) {
+		String ret = null;
+		String left = null;
+		String right = null;
+
+		if (includeSwfParent){
+			right = file.substring( file.lastIndexOf( File.separator ) + 1 );	// ButtonMain.swf
+			right = "/" + right;												// /ButtonMain.swf, must be a /, cannot be a \.
+			left = file.substring( 0, file.lastIndexOf( File.separator ) );		// blah/blah/Button/swfs
+			left = left.substring( left.lastIndexOf( File.separator ) +1 );		// swfs
+			ret = left + right;													// swfs/ButtonMain.swf
+		}else{
+			if (file.indexOf("/") != -1) {
+				ret = file.substring (file.lastIndexOf("/")+1);
+			} else if (file.indexOf(File.separator) != -1) {
+				ret = file.substring (file.lastIndexOf(File.separator)+1);
+			} else {
+				ret = file;
+			}
+		}
+
+		return ret;
+	}
+
+	public static void createFile ( boolean includeSwfParent ) {
+
+		System.out.println ("full swf is " + swffile);
+
+		FileOutputStream bos = null;
+		FileOutputStream bos2 = null;
+
+		try {
+			/// get the contents we'll write:
+			String xmlString = xmlTransformFromTemplate( includeSwfParent );
+
+			/// write a marker to delete the file we'll write
+			if (delete_file != null) {
+				bos2 = new FileOutputStream (delete_file);
+				bos2.write ("0".getBytes(), 0, 1);
+				bos2.flush();
+				bos2.close();
+			}
+
+			/// write the xml file
+			bos = new FileOutputStream (xmlfile);
+
+			bos.write (xmlString.getBytes(), 0, xmlString.length());
+
+			bos.flush();
+			bos.close();
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			try {
+			bos.close();
+			bos2.close();
+			} catch (Exception e2) {
+			}
+		}
+	}
+
+
+
+	public static void main (String [] args) throws Exception {
+
+		xmlWriter (args[0]);
+
+
+
+	}
+
+
+}

Propchange: incubator/flex/trunk/mustella/java/src/mustella/ApolloAdjuster.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/mustella/java/src/mustella/ApolloAppToWindow.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/mustella/java/src/mustella/ApolloAppToWindow.java?rev=1333232&view=auto
==============================================================================
--- incubator/flex/trunk/mustella/java/src/mustella/ApolloAppToWindow.java (added)
+++ incubator/flex/trunk/mustella/java/src/mustella/ApolloAppToWindow.java Wed May  2 22:44:38 2012
@@ -0,0 +1,382 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package mustella;
+import java.io.*;
+
+import javax.xml.parsers.*;
+import javax.xml.transform.*;
+import org.w3c.dom.*;
+import javax.xml.transform.dom.*;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+
+
+/**
+
+Utility for transforming a mustella test to apollo, by which is meant, 
+changing the test_swf from Application to Window, and popping that window up 
+from a WindowedApplication (provided as a template). 
+
+
+
+*/
+public class ApolloAppToWindow { 
+
+
+	/**
+	 * given the mxml arg, get the testSwf's className
+	public static String getTestSwfName (String mxml) {
+
+		return mxml;
+	}
+	 */
+
+
+
+	/**
+	 * return what will be the transformed name, given a test_swf filename
+ 	 * and a directory
+	 */
+	public static String getNewMxmlName (String dir, String mxml, String transform_prefix) { 
+
+		if (mxml.indexOf ("\\apollo\\") != -1  || mxml.indexOf ("/apollo/") != -1)
+			return mxml;
+
+		// System.out.println ("This is the getNewMxmlName with mxml="+ mxml);
+
+		String className = getSwfClassName(mxml);
+		// System.out.println ("This is the getNewMxmlName className: " +className);
+
+		// String subDir = getSwfSubDir(mxml);
+		// System.out.println ("This is the getNewMxmlName swf subdir: " +subDir);
+
+		String newName = transform_prefix + className + ".mxml";
+		// System.out.println ("This is the getNewMxmlName returning: " +dir+ "/" + newName);
+		return dir + "/" + newName;
+		
+
+	}
+
+
+	/**
+	 * The normal compile has a test_swf, and a bunch of args 
+	 * The Air transform introduces a new test_swf, based on a template. 
+	 * so we shift the args a bit: 
+	 * we make the test_swf an include and add its source path
+	 * dir is the same as targetDir below
+	 */
+	public static String adjustArgList (String args, String mxml, String dir, String prefix) {
+
+		String className = getSwfClassName (mxml);
+
+		args += " -source-path="+dir;
+		args += " -includes="+prefix+className;
+		
+		return args;
+
+	}
+
+	public static final String app_string = "<mx:Application";
+	public static final String app_string2 = "</mx:Application";
+	public static final String replace_string = "<mx:Window";
+	public static final String replace_string2 = "</mx:Window";
+
+	/** 
+	 * The main transformation is to take our test_swf and turn it into an AIR window
+	 * write that into a new file.
+	 */
+	public static void transformTestSwfToWindow (String fileName, String dir, String prefix2) {
+
+		String fileContents = readFileIntoString (fileName);
+
+		String height = getAttribute (fileName, "mx:Application", "height");
+		String width = getAttribute (fileName,  "mx:Application", "width");
+
+		String addString = "";
+
+		if (height == null || height.length()==0) 
+			addString = addString+" height=\"375\"";
+		if (width == null || width.length()==0) 
+			addString = addString+" width=\"500\"";
+		
+		// System.out.println ("This is the applicaton decl w/h: " + height + " " + width);
+
+		fileContents = fileContents.replaceAll (app_string,  replace_string + addString);
+		fileContents = fileContents.replaceAll (app_string2,  replace_string2);
+
+
+		String newFilename = getNewMxmlName (dir, fileName, prefix2);
+
+		try { 
+			writeStringToFile (fileContents, newFilename);
+		} catch (java.io.FileNotFoundException  fnf) { 
+			try { 
+				new File (newFilename).delete();
+				writeStringToFile (fileContents, newFilename);
+			} catch (Exception  fnf2) { 
+				fnf2.printStackTrace();
+			}
+		} catch (Exception ee) {
+			ee.printStackTrace();
+		}
+
+	}
+
+	/**
+	 * in case we need stuff from the test_swf moved into the Main app 
+	 * this is provided as a convenience. 
+	 * one known item that needs to get written in the WindowedApplication is 
+	 * the mx:Style block
+	 */
+	public static String getAttribute(String fileName, String element, String attr) {
+
+		File file = null;
+		StringBuffer sb = new StringBuffer();
+		try { 
+
+			file = new File(fileName);
+  			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+  			DocumentBuilder db = dbf.newDocumentBuilder();
+  			Document doc = db.parse(file);
+ 			// System.out.println("Root element " + doc.getDocumentElement().getNodeName());
+  			NodeList nodeLst = doc.getElementsByTagName(element);
+
+			// sort of a hack:
+			Element el = (Element) nodeLst.item(0);
+
+			return el.getAttribute (attr);
+
+
+		} catch (Exception e) { 
+
+			e.printStackTrace();
+
+
+		}
+		return sb.toString();
+	}
+
+
+	/**
+	 * in case we need stuff from the test_swf moved into the Main app 
+	 * this is provided as a convenience. 
+	 * one known item that needs to get written in the WindowedApplication is 
+	 * the mx:Style block
+	 */
+	public static String getBlockFromTestSwf(String fileName, String nodeName) {
+
+		File file = null;
+		StringBuffer sb = new StringBuffer();
+		try { 
+
+			file = new File(fileName);
+  			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+  			DocumentBuilder db = dbf.newDocumentBuilder();
+  			Document doc = db.parse(file);
+  			doc.getDocumentElement().normalize();
+ 			// System.out.println("Root element " + doc.getDocumentElement().getNodeName());
+  			NodeList nodeLst = doc.getElementsByTagName(nodeName);
+
+		      	TransformerFactory transfac = TransformerFactory.newInstance();
+
+      			Transformer trans = transfac.newTransformer();
+      			trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+      			trans.setOutputProperty(OutputKeys.INDENT, "yes");
+
+      			// Print the DOM node
+
+      			StringWriter sw = new StringWriter();
+      			StreamResult result = new StreamResult(sw);
+
+			for (int s = 0; s < nodeLst.getLength(); s++) {
+
+    				Node aNode = nodeLst.item(s);
+
+      				DOMSource source = new DOMSource(aNode);
+      				trans.transform(source, result);
+      				String xmlString = sw.toString();
+
+				// System.out.println ("adding styles: " + xmlString);
+				sb.append (xmlString);
+
+			}
+
+
+
+
+
+		} catch (Exception e) { 
+
+			e.printStackTrace();
+
+
+		}
+
+		return sb.toString();
+
+
+	}
+
+	public static String getSwfSubDir(String swfString) {
+
+		String tmp = "";
+		if (swfString.indexOf (File.separator)!= -1) {
+
+			tmp = swfString.substring (0, swfString.lastIndexOf (File.separator));
+
+		}
+		return  tmp;
+
+	}
+
+
+	/// given an mxml
+	public static String getSwfClassName(String swfString) {
+
+		String tmp = null;
+		if (swfString.indexOf (File.separator)!= -1) {
+
+			tmp = swfString.substring (swfString.lastIndexOf (File.separator)+1, swfString.indexOf (".mxml"));
+
+		}
+		return  tmp;
+
+	}
+
+
+	public static final String stock_string = "CLASS_NAME";
+	public static final String script_start = "<mx:Script";
+
+
+	public static void transformDummyAndCopy (String prefix, String prefix2, String mxml, String templateFile, String swfDir, String insertBlock) {
+
+
+		String className = getSwfClassName (mxml);
+
+		String fileContents = readFileIntoString (templateFile);
+
+		int insertPoint = -1;
+
+		fileContents = fileContents.replaceAll (stock_string, prefix2+className);
+
+		if (insertBlock.length() > 0) {
+			insertPoint = fileContents.indexOf (script_start);
+
+			StringBuffer sb = new StringBuffer(fileContents);
+			sb.insert ( (insertPoint-1), insertBlock);
+
+			fileContents = sb.toString();
+		}
+
+		try { 	
+		writeStringToFile (fileContents, getNewMxmlName(swfDir, mxml, prefix));
+		} catch (Exception e) { 
+			e.printStackTrace();
+		}
+		
+	}
+
+
+
+	public static String doAll (String args, String prefix, String prefix2, String mxml, String templateFile, String targetDir) {
+
+
+		if (mxml.indexOf ("\\apollo\\") != -1  || mxml.indexOf ("/apollo/") != -1)
+			return args;
+
+
+		// System.out.println ("here is the dir AApp got; " + targetDir);
+
+		/// need more from the Test swf
+		String insertBlock = getBlockFromTestSwf (mxml, "mx:Style");	
+
+		/// do all, then return the adjusted Arg
+		transformDummyAndCopy (prefix, prefix2, mxml, templateFile, targetDir, insertBlock);
+	
+		transformTestSwfToWindow (mxml, targetDir, prefix2);
+
+
+		args += " -includes=WaitForWindow";
+		return adjustArgList(args, mxml, targetDir, prefix2);
+	}
+
+	private static void writeStringToFile (String str, String fileName) throws Exception {
+
+		BufferedOutputStream bos = new BufferedOutputStream (new FileOutputStream (fileName));
+
+		bos.write (str.getBytes(), 0, str.length());
+		bos.flush();
+		bos.close();
+
+
+    	}
+
+
+	public static String readFileIntoString (String mxml) {
+
+	
+		try { 
+		BufferedInputStream bis = new BufferedInputStream (new FileInputStream (mxml));
+
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+		int av = 0;
+		byte [] b = null;
+		
+		String contents = null;
+
+		while ((av = bis.available()) > 0) { 
+			b = new byte[av];
+			bis.read (b, 0, av);
+			bos.write (b, 0, av);
+
+		}
+
+
+		bis.close();
+
+		return bos.toString();	
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+		return (String)null;
+
+    	}
+
+
+
+
+
+	public static void main (String [] args) { 
+
+
+	}	
+
+
+
+}

Propchange: incubator/flex/trunk/mustella/java/src/mustella/ApolloAppToWindow.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/mustella/java/src/mustella/BaselineServer.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/mustella/java/src/mustella/BaselineServer.java?rev=1333232&view=auto
==============================================================================
--- incubator/flex/trunk/mustella/java/src/mustella/BaselineServer.java (added)
+++ incubator/flex/trunk/mustella/java/src/mustella/BaselineServer.java Wed May  2 22:44:38 2012
@@ -0,0 +1,127 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+package mustella;
+
+import java.net.*;
+import java.util.Date;
+import java.util.ArrayList;
+
+/** 
+ * BaselineServer
+ *
+ * Serve a given port, spawn BaselineWriters on whoever writes to it
+ */
+public class BaselineServer extends Thread { 
+
+
+	int port = 9998;
+
+
+	public BaselineServer (int port) { 
+		this.port = port;
+	}
+
+
+	public String dir = null;
+
+
+	/// this should be 1 above the swf
+	public void setDir (String dir) {
+		this.dir = dir.replaceAll("\\\\", "/");
+	}
+
+
+	public static ArrayList threads = new ArrayList();
+
+
+	ServerSocket ss = null; 
+
+	public void run () {
+
+		System.out.println ("starting the baseline server: " + new Date());
+
+		/// launch server, dispatch sockets on new inlines
+
+		try  { 
+	
+			ss = new ServerSocket (port);
+
+			while (running) { 
+
+				try { 
+
+				Socket s = ss.accept ();
+				BaselineWriter bw = null;
+				if (dir != null)
+					bw = new BaselineWriter (s, dir);
+				else
+					bw = new BaselineWriter (s);
+				threads.add (bw);
+				bw.start();
+
+				} catch (Exception e) { 
+					// System.out.println ("broke out of the socket loop");
+					return;
+				}
+
+			}
+
+		} catch (Exception e) {
+
+			e.printStackTrace ();
+
+		}
+	
+	}
+
+
+	boolean running = true;
+
+	public void end() { 
+		running = false;
+		BaselineWriter bw = null;
+		for (int i=0;i<threads.size();i++) { 
+			bw = (BaselineWriter)threads.get(i);
+			if (bw.isAlive())
+				bw.clobbered = true;
+			threads.remove (i);
+		}
+
+	} 
+
+	public void destroy() { 
+		try { 
+			ss.close();
+		} catch (Exception e) { 
+	
+		}
+
+	}
+
+
+	public static void main (String [] args) { 
+
+		
+
+
+	}
+
+}

Propchange: incubator/flex/trunk/mustella/java/src/mustella/BaselineServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/mustella/java/src/mustella/BaselineWriter.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/mustella/java/src/mustella/BaselineWriter.java?rev=1333232&view=auto
==============================================================================
--- incubator/flex/trunk/mustella/java/src/mustella/BaselineWriter.java (added)
+++ incubator/flex/trunk/mustella/java/src/mustella/BaselineWriter.java Wed May  2 22:44:38 2012
@@ -0,0 +1,286 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package mustella;
+
+import java.io.*;
+import java.net.*;
+
+/**
+ *
+ * BaselineWriter - Reads a POST from a given Socket instance, writes the filename 
+ *                  designated in the post arguments. 
+ *
+ */
+
+public class BaselineWriter extends Thread { 
+
+
+	private String filename = null;
+	private String filename_tmp = null;
+
+
+	Socket sock = null;
+
+	String dir = null;
+
+
+	public boolean clobbered = false;
+	
+
+	private int length = -1;
+	private int total = 0;
+
+	public BaselineWriter (Socket sock) { 
+		this.sock = sock;
+	}
+
+	public BaselineWriter (Socket sock, String dir) { 
+		this.sock = sock;
+		this.dir = dir;
+	}
+
+
+	int headerLength = 0;
+
+	// The input stream we'll open on the socket.
+	InputStream stuff = null;
+
+	// stock reply
+	static final String reply = "HTTP/1.1 200 OK\r\n\r\n";	
+
+
+	public void run () { 
+
+		parseHeaders ();
+
+		if (scuttle)
+			return;
+
+		this.filename_tmp = filename + ".tmp";
+
+		if (dir != null) {
+			// this.filename_tmp = dir+ File.separator + this.filename_tmp;
+			this.filename_tmp = dir+ "/" + this.filename_tmp;
+			this.filename = dir+ "/" + this.filename;
+		}
+
+		// System.out.println ("BW result: " + this.filename_tmp);
+
+
+		BufferedOutputStream fos = null;
+
+		try { 
+
+
+			/// delete the existing file(s)
+			new File (filename_tmp).delete();
+			new File (filename).delete();
+
+
+
+			fos = new BufferedOutputStream(new FileOutputStream (filename_tmp));
+
+		
+			int avail = 0;	
+
+			ByteArrayOutputStream baos = new ByteArrayOutputStream();
+			// System.out.println ("Doing the write");
+
+			int b;
+			byte [] ba =null;
+
+			// The content length we're getting from the client is 
+			// the length of the PNG only.
+			// We need to add the headers (and substract the header/content \r\n)
+			// in theory, the -1 would tell us we were at the end of the stream.
+			// never ever saw a -1, so I guess it don't.
+			while (!clobbered && total < (length+(headerLength-2))) { 
+				b = stuff.read();
+				if (b == -1) { 
+					System.out.println ("QUIT saw the end of the stream");
+					break; 
+				}
+				
+				fos.write(b); // stuff.read());
+				total++;
+
+			}
+
+
+
+			fos.flush();
+			fos.close();
+			System.out.println ("Wrote file: " + filename + " length: "+  length);
+			// System.out.println ("The content length was: " + length);
+			// System.out.println ("header length was: " + headerLength);
+			// System.out.println ("Wrote this: " + new String(baos.toByteArray()));
+
+			new File(filename_tmp).renameTo (new File(filename));
+
+
+			/// write back happiness.
+			
+
+			BufferedOutputStream bus = new BufferedOutputStream (sock.getOutputStream());
+
+			bus.write (reply.getBytes(), 0, reply.length());
+	
+			bus.flush();
+
+			bus.close();
+
+			stuff.close();	
+
+
+		} catch (Exception e) { 
+			System.out.println ("Hosed on the image write");
+
+			e.printStackTrace();
+
+		}
+
+		BaselineServer.threads.remove (this);
+
+	}
+
+
+	private boolean scuttle = false;
+
+
+	public synchronized void parseHeaders() { 
+
+
+		String line = null;	
+
+
+		try {
+
+			stuff = sock.getInputStream();
+			
+
+			while (true) { 
+				line = readLine();
+
+				headerLength+=line.length();
+
+				// System.out.println ("HEADER: " + line);
+			
+				/**	
+				 * GET: this would be something we don't handle:
+				 */	
+				if (line.indexOf ("GET ") != -1) {
+					scuttle = true;
+					System.out.println ("Scuttle, this was a GET");
+					return;
+				}
+
+				// End of the header marker:
+				if (line.length() == 2 || line.equals ("\r\n")) { 
+					// System.out.println ("Would bust out here");
+					break;
+				}
+				
+				total += line.length();
+
+				if (line.indexOf ("POST ") != -1) {
+					// System.out.println ("SAW THE POST");
+
+					line = line.substring (line.indexOf("filename=")+9, line.indexOf (" ",10));
+					line = line.trim();
+					this.filename =  URLDecoder.decode(line);
+
+				}
+				if (line.indexOf ("Content-Length") != -1 || line.indexOf ("Content-length") != -1) {
+
+					// System.out.println ("SAW LENGTH");
+					line = line.substring (line.indexOf (":")+1);		
+					this.length = Integer.parseInt (line.trim());
+
+				}
+
+
+			}
+				
+
+
+		} catch (Exception e) { 
+
+			e.printStackTrace();
+
+
+		}
+
+
+	}
+
+
+	public String readLine() throws Exception {
+
+
+		String line = null;
+
+
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		int b;
+
+		while (true) { 
+
+			b = stuff.read();
+
+			baos.write (b);
+
+			if (b == '\n')
+				break;
+			
+		}
+
+
+
+
+		return  new String (baos.toByteArray());
+
+			
+
+	}
+
+	
+
+
+	/* 
+	public BaselineWriter (String filename, int length) { 
+		this.length = length;
+		this.filename = filename;
+		this.filename_tmp = filename + ".tmp";
+	}
+	*/
+
+
+	/* 
+	public synchronized void write (InputStream stuff) { 
+
+
+
+
+	}
+	*/
+
+
+
+
+}

Propchange: incubator/flex/trunk/mustella/java/src/mustella/BaselineWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/trunk/mustella/java/src/mustella/CompileMustellaSwfs.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/mustella/java/src/mustella/CompileMustellaSwfs.java?rev=1333232&view=auto
==============================================================================
--- incubator/flex/trunk/mustella/java/src/mustella/CompileMustellaSwfs.java (added)
+++ incubator/flex/trunk/mustella/java/src/mustella/CompileMustellaSwfs.java Wed May  2 22:44:38 2012
@@ -0,0 +1,1426 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package mustella; 
+import utils.*;
+import utils.FileUtils;
+
+import java.io.File;
+import java.util.regex.*;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.*;
+
+/**
+ * User: bolaghlin, derived from a dschaffer piece
+ * Date: Sep 21 2006 / Threaded 5/22/07
+ */
+public class CompileMustellaSwfs extends Thread {
+
+    /* 
+     * distributed related vars here
+     */
+    public static boolean distributed = false;
+
+    /* 
+     * pmd vars 
+     */
+    public static boolean pmd = false;
+
+    public static String compile_dir = null;
+
+    public static int compile_id= -1;
+
+    public static int directory_result = 0;
+
+    public static int hostId = 0;
+
+
+    private String[] defaultArgs;
+
+	private static String mobileConfigArg = null;
+	
+	private static String exclude_filename = null;
+    
+	private static String run_this_script = null;
+
+    private static String include_list = null;
+
+    private static boolean use_include_file = false;
+
+    private static boolean debugDump = false;
+
+    private static boolean skip_exclude = false;
+
+    private static boolean fork_compile = true;
+
+    private static boolean use_browser = false;
+
+    private static boolean save_failures = false;
+
+    private static boolean exit_on_compile_error = false;
+
+    private static String socket_mixin = "";
+
+    private static String mustella_dir = null;
+
+    private static HashMap swfs = new HashMap();
+    private static HashMap extraArgs = new HashMap();
+
+    public static int run_id = -1;
+
+    public static int exit_with = 0;
+
+    private static ArrayList survivors = new ArrayList();
+
+    private static boolean use_apollo = false;
+
+    private static boolean apollo_transform = false;
+
+    private static String apollo_transform_template = "air_transform/template.mxml";
+
+    private static String apollo_transform_prefix = "zzaird_";
+
+    private static String apollo_transform_prefix2 = "wwaird_";
+	
+	private static boolean use_qa_framework_dir = false;
+
+    private static String qa_framework_dir = null;
+
+    private static String apollo_location = ""; 
+
+    private static String file_of_tests = "";
+
+    private static String user_args = "";
+
+    public static double flex_version = 0.0;
+
+    public static int build_version = 0;
+
+
+    public static String height = "375";
+    public static String width = "500";
+
+
+
+    /// some mixins we may be using:
+    public static final String resultCollectorMixinName = "SendResultsToRunner";
+    public static String excludeListMixinName = "ExcludeFileLocation";
+    public static final String includeListMixinName = "CurrentIncludeList";
+
+
+    public static String htmlDir = "/templates/client-side-detection-with-history/"; 
+    private static String resultInclude =" -includes=SendFormattedResultsToLog";
+    private static String exitInclude = " -includes=ExitWhenDone"; 
+    public static int allowedCount = 1; 
+	
+	private static boolean run_mobile_tests = false;
+	private static String device_name = "";
+	private static String target_os_name = "";
+	private static String os_version = "";
+	
+    static { 
+		
+		//===================================================
+		// Mobile settings
+		//===================================================
+		try { 
+			exclude_filename = System.getProperty ("exclude_filename");
+		} catch (Exception e) { 
+			System.out.println("Didn't get an exclude_filename.");
+		} finally{
+			System.out.println ("exclude_filename: " + exclude_filename);
+		}
+
+		try { 
+			os_version = System.getProperty ("os_version");
+		} catch (Exception e) { 
+			System.out.println("Didn't get an os_version.");
+		} finally{
+			System.out.println ("os_version: " + os_version);
+		}
+		
+		try { 
+			target_os_name = System.getProperty ("target_os_name");
+		} catch (Exception e) { 
+			System.out.println("Didn't get a target_os_name.");
+		} finally{
+			System.out.println ("target_os_name: " + target_os_name);
+		}
+
+		try { 
+			device_name = System.getProperty ("device_name");
+		} catch (Exception e) { 
+			System.out.println("Didn't get a device_name.");
+		} finally{
+			System.out.println ("device_name: " + device_name);
+		}
+		
+		try { 
+			run_mobile_tests = new Boolean (System.getProperty ("run_mobile_tests")).booleanValue();
+		} catch (Exception e) { 
+			System.out.println("Didn't get run_mobile_tests.");
+			run_mobile_tests = false;
+		}
+		//===================================================
+		
+		try { 
+			use_apollo = new Boolean (System.getProperty ("use_apollo")).booleanValue();
+			// System.out.println ("use_apollo: " + use_apollo);
+		} catch (Exception e) { 
+		}
+
+		try { 
+			apollo_transform = new Boolean (System.getProperty ("apollo_transform")).booleanValue();
+			// System.out.println ("apollo_transform: " + apollo_transform);
+		} catch (Exception e) { 
+		}
+
+		// pmd distributed:
+		try { 
+			pmd = new Boolean (System.getProperty ("pmd")).booleanValue();
+		} catch (Exception e) { 
+			pmd=false;
+		}
+
+		// distributed:
+		try { 
+			distributed = new Boolean (System.getProperty ("distributed")).booleanValue();
+		} catch (Exception e) { 
+			distributed=false;
+		}
+
+
+		// distributed:
+		try { 
+			compile_dir = System.getProperty ("compile_dir");
+		} catch (Exception e) { 
+		}
+
+		// distributed:
+		try { 
+			compile_id = Integer.parseInt (System.getProperty ("compile_id"));
+		} catch (Exception e) { 
+		}
+
+		try { 
+			hostId = Integer.parseInt (System.getProperty ("hostId"));
+		} catch (Exception e) { 
+			hostId=1;
+		}
+
+
+		try { 
+			apollo_transform_template = System.getProperty ("apollo_transform_template");
+			// System.out.println ("apollo_transform_template: " + apollo_transform_template);
+		} catch (Exception e) { 
+		}
+
+		try { 
+			apollo_transform_prefix = System.getProperty ("apollo_transform_prefix");
+			// System.out.println ("apollo_transform_prefix: " + apollo_transform_prefix);
+		} catch (Exception e) { 
+		}
+
+		try { 
+			apollo_transform_prefix2 = System.getProperty ("apollo_transform_prefix2");
+			/// System.out.println ("apollo_transform_prefix2: " + apollo_transform_prefix2);
+		} catch (Exception e) { 
+		}
+
+		try { 
+			use_browser = new Boolean (System.getProperty ("use_browser")).booleanValue();
+			// System.out.println ("use_browser raw: " + System.getProperty("use_browser"));
+			// System.out.println ("use_browser: " + use_browser);
+
+
+		} catch (Exception e) { 
+		}
+
+		try { 
+			fork_compile = new Boolean (System.getProperty ("fork_compile")).booleanValue();
+			// System.out.println ("fork_compile: " + fork_compile);
+		} catch (Exception e) { 
+		}
+
+
+		try { 
+			apollo_location = System.getProperty ("apollo_location");
+			// System.out.println ("apollo: " + apollo_location);
+		} catch (Exception e) { 
+		}
+
+		// result_include is set in build.xml, then it gets overridden depending on if it's a local
+		// or server run.
+		try {
+			if (System.getProperty ("result_include") != null && !System.getProperty ("result_include").startsWith ("${")) { 
+				resultInclude = System.getProperty ("result_include");
+			} else {
+				resultInclude =" -includes=SendFormattedResultsToLog";
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			resultInclude =" -includes=SendFormattedResultsToLog";          
+		}
+		System.out.println ("result_include: " + resultInclude);
+
+		try { 
+			exitInclude = System.getProperty ("exit_include");
+			if (exitInclude != null && exitInclude.equals (""))
+				exitInclude = " -includes=ExitWhenDone"; 
+		} catch (Exception e) { 
+			exitInclude = " -includes=ExitWhenDone";
+		}
+
+		try { 
+			if (System.getProperty ("htmlDir")!=null && !System.getProperty ("htmlDir").equals("")) 
+				htmlDir = System.getProperty ("htmlDir");
+			// System.out.println ("htmlDir: " + htmlDir);
+		} catch (Exception e) { 
+		}
+
+		try { 
+			save_failures = new Boolean (System.getProperty ("save_failures")).booleanValue();
+			// System.out.println ("save_failures: " + save_failures);
+		} catch (Exception e) { 
+		}
+
+
+		try { 
+			skip_exclude = new Boolean (System.getProperty ("skip_exclude")).booleanValue();
+		} catch (Exception e) { 
+		}
+
+		try { 
+			excludeListMixinName = System.getProperty ("exclude_mixin");
+		} catch (Exception e) { 
+		}
+
+		try { 
+			mustella_dir = System.getProperty ("mustella.dir");
+		} catch (Exception e) { 
+		}
+
+		try { 
+			flex_version = Double.parseDouble(System.getProperty ("flex_version"));
+		} catch (Exception e) { 
+		}
+
+		try { 
+			build_version = Integer.parseInt (System.getProperty ("build_version"));
+		} catch (Exception e) { 
+		}
+
+		try { 
+				
+			if (System.getProperty ("user_args")!=null) { 
+				user_args += System.getProperty ("user_args");
+				// System.out.println ("saw a user arg: " + user_args);
+			}
+		} catch (Exception e) { 
+		}
+
+		try { 
+
+			allowedCount = Runtime.getRuntime().availableProcessors();
+			
+		} catch (Exception e) { 
+		}
+
+
+		if (System.getProperty ("exit_on_compile_error")!=null) { 
+			try { 
+			exit_on_compile_error = new Boolean (System.getProperty ("exit_on_compile_error")).booleanValue();
+			// System.out.println ("exit_on_compile_error: " + exit_on_compile_error);
+			} catch (Exception e) { 
+				
+				exit_on_compile_error = false;
+			}
+		}
+
+		if (System.getProperty ("use_qa_framework_dir")!=null && !System.getProperty ("use_qa_framework_dir").equals ("") ) { 
+
+			try { 
+				use_qa_framework_dir = new Boolean (System.getProperty ("use_qa_framework_dir")).booleanValue();
+
+			} catch (Exception e) {
+			}
+
+		}
+
+		if (System.getProperty ("include_list")!=null && !System.getProperty ("include_list").equals ("") ) { 
+
+			try { 
+				include_list = System.getProperty ("include_list");
+
+			} catch (Exception e) {
+			}
+
+		}
+
+		if (System.getProperty ("use_include_file")!=null && !System.getProperty ("use_include_file").equals ("") ) { 
+			try { 
+				use_include_file = new Boolean (System.getProperty ("use_include_file")).booleanValue();
+
+			} catch (Exception e) {
+			}
+
+		}
+
+
+		if (System.getProperty ("qa_framework_dir")!=null && !System.getProperty ("qa_framework_dir").equals ("") ) { 
+
+			try { 
+				qa_framework_dir = System.getProperty ("qa_framework_dir");
+
+			} catch (Exception e) {
+			}
+
+		}
+
+
+		if (System.getProperty ("socket_mixin")!=null) { 
+			socket_mixin = System.getProperty ("socket_mixin");
+			if (socket_mixin != null && !socket_mixin.equals (""))
+				socket_mixin = " -includes=" + socket_mixin;
+		}
+
+		if (System.getProperty ("run_id")!=null) { 
+			try { 
+				run_id = Integer.parseInt (System.getProperty ("run_id"));
+				// System.out.println ("compile mustella swfs, have this run id: " + run_id);
+			} catch (Exception e) { 
+				run_id = -1;
+			}
+		}
+
+
+		if (System.getProperty ("run_this_script")!=null) { 
+			try { 
+			run_this_script = System.getProperty ("run_this_script");
+			// System.out.println ("run script: " + run_this_script);
+			if (run_this_script.equals (""))
+				run_this_script = null;
+			} catch (Exception e) { 
+				run_this_script = null;
+			}
+		}
+
+
+    }// end static init block
+
+    public static String[] readIntoArray() {
+
+	BufferedReader br = null;
+
+	ArrayList al = new ArrayList();
+
+	String tmp = null;
+
+	String [] ret = null;
+
+	try { 
+
+		br = new BufferedReader (new FileReader(file_of_tests));
+
+		while ( (tmp = br.readLine()) != null) {
+			al.add (tmp);
+		}
+
+		br.close();
+		ret = new String[al.size()];
+
+		ret = (String[]) al.toArray((String[])ret);
+
+		return ret;
+
+	} catch (Exception e) {
+		e.printStackTrace();
+		
+	}
+
+	return (String[])null;
+    }
+
+    public static ArrayList threads = new ArrayList();
+
+
+    public static synchronized void removeFromList (Object o) { 
+	// System.out.println ("call to remove " + o );
+	threads.remove (o);
+	// System.out.println ("post thread look: " + threads);
+    }
+
+
+
+    static long compile_start=0;
+    static long compile_end=0;
+    
+
+    public static void main(String args[]) {
+
+		///  This isn't necessarily an error anymore. allow it
+		if (args.length == 0) {
+			System.out.println("CompileTestSwfs no mxml files to compile.");
+			System.exit(0);
+		}
+
+		file_of_tests = args[0];
+
+		/// just debugging:
+		// System.out.println("args to compile: " + args[0]);
+
+		String basedir = System.getProperty("basedir", ".");
+		/* AJH
+		InsertMilestone im1 = null;
+		DistributedMilestone dins1 = null;
+		
+		if (!distributed)
+			im1 = new InsertMilestone (run_id, "compile_start", System.currentTimeMillis());
+		else
+			dins1 = new DistributedMilestone (0, compile_id, compile_dir, -1, System.currentTimeMillis(),hostId);
+		*/
+		
+		compile_start = System.currentTimeMillis();
+
+		args = readIntoArray();
+
+		for (int i = 0; i < args.length; i++) {
+			if (new File(mustella_dir + "/" + "testing.halt").exists()) {
+				System.out.println("SAW HALT NOTIFICATION, halting compile at " + new Date());
+				break;
+			}
+
+			/// generate mustella args  ADD survivor check into the extraArg creation check
+			if (args[i].endsWith (".mxml")) { 
+				MustellaDirs.genHashMap (args[i], extraArgs, swfs, run_this_script);
+			}
+		}
+
+		// Write a mobile config class to mustella/tests/mobile.
+		if( run_mobile_tests ){			
+			mobileConfigArg = " -includes=" + MobileConfigWriter.write( device_name, target_os_name, os_version, qa_framework_dir, run_id, exclude_filename );
+		}
+		
+		// System.out.println ("the hash: " + swfs);
+
+		/// mustella args iteration
+		Iterator it = extraArgs.entrySet().iterator();
+
+		String swfName = null;
+		String swfFile = null;
+		ArrayList al = null;
+
+		Map.Entry mes = null;
+
+		long begin0=0,end0=0;
+
+		// InsertErrorResult ier = null;
+
+		while (true) { 
+			if (new File(mustella_dir + "/" + "testing.halt").exists()) {
+				System.out.println("SAW HALT NOTIFICATION, halting compile at " + new Date());
+               	break;
+	       	}
+			
+			if (threads.size() < allowedCount) {
+				//  System.out.println ("size vs. allowed: " + threads.size() + " " + allowedCount + " spawning another compile thread");
+				if (it.hasNext()) { 
+					mes = (Map.Entry) it.next();
+
+					swfName = (String) mes.getKey();
+					// swfFile = (String) swfs.get (swfName);
+					swfFile = swfName;
+					al = (ArrayList)((ArrayList) extraArgs.get (swfName)).clone();
+
+					if (swfFile != null)  { 
+						// retryCount=0;
+					
+						CompileMustellaSwfs tc = new CompileMustellaSwfs(swfFile, al);	
+						threads.add (tc);
+						tc.start();
+					}  else { 
+		
+						System.out.println ("COMPILE: busted for " + swfFile + " " + swfName + " references: " + al);
+
+						handleCompileError (swfName, al.toString(),   "a testSWF Reference points to a swf that could not be found." );
+					}
+				} else  { 
+					System.out.println ("nothing left to do");
+					break;
+				}
+			} else { 
+				try { 
+					Thread.sleep (200);
+				} catch (Exception e0) { 
+					e0.printStackTrace();
+				}			
+			}
+		}
+
+		/* 
+
+		while (threads.size() > 0) { 
+			try { 
+			Thread.sleep (1000);
+			// System.out.println ("Waiting for threads to finish: active "  + threads.size());
+			} catch (Exception e0) { 
+				e0.printStackTrace();
+			}
+		}
+		*/
+
+		/// experiment, rather than waiting forever
+		if (threads.size() > 0) {
+
+			Thread t = null;
+
+			 for (int i=0;i<threads.size();i++) { 
+				try { 
+					t = (Thread) threads.get(i);
+					t.join (180000);
+
+				} catch (Exception ee) {
+					ee.printStackTrace();
+				}
+			}
+		}
+
+		System.out.println ("All done with the compile");
+
+		if (debugDump) { 
+			try { Thread.sleep (4500); } catch (Exception e) { }
+		}
+
+
+		/* AJH
+		DistributedMilestone dins2 = null;
+		InsertMilestone im2 = null;
+		if (!distributed)
+			im2 = new InsertMilestone (run_id, "compile_end", System.currentTimeMillis());
+		else
+			dins2 = new DistributedMilestone (0, compile_id, compile_dir, directory_result, System.currentTimeMillis(), hostId);
+		*/
+		
+		compile_end = System.currentTimeMillis();
+
+		/* AJH
+		try { 
+			if (dins2 != null) { 
+				dins2.join (4000);	
+			} else if (im2 != null) {
+				im2.join (4000);
+			}
+
+		} catch (Exception ee) {
+			ee.printStackTrace();
+		}
+		*/
+
+		System.out.println ("leaving the compile, elapsed: " + ((compile_end-compile_start)/1000));
+		if (fork_compile) { 
+			System.out.println ("...via exit");
+			System.exit (exit_with);
+		}
+    }
+
+
+    String swf_name = null;
+    ArrayList arg_list = null;
+
+    public CompileMustellaSwfs (String swf, ArrayList args)  {
+
+		// System.out.println ("Compile constructor for " + swf);
+		this.swf_name = swf;
+		this.arg_list = args;
+    }
+
+    public void run () { 
+
+		// System.out.println ("Calling run on Compile for " + this + " at: " + new Date() + " for: " + swf_name);
+
+		//// what if we cleaned the args HERE
+		//// 
+		ArrayList al = new ArrayList();
+		String tmp = null;
+		String tmp_fixed = null;
+
+		for (int i=0;i<arg_list.size();i++) { 
+			tmp = (String) arg_list.get (i);
+
+			if ( tmp.trim().startsWith ("-includes=") ) { 
+				tmp_fixed = finalFixUp(tmp);
+				// System.out.println ("Would replace " + tmp + " with + " + tmp_fixed);
+
+				al.add (tmp_fixed);
+			} else { 
+				// System.out.println ("Leaving as is: " + tmp);
+				al.add (tmp);
+			}
+		}
+
+		compileMxml(swf_name, al);
+    }
+
+
+    public String finalFixUp (String s) {
+
+	
+	// 
+	s = s.substring ("-includes=".length()+1);
+
+	s = new File (s).getName();
+
+	if (s.indexOf (".mxml") != -1)
+		s = s.substring (0, s.indexOf (".mxml"));
+
+	/// System.out.println ("This is the filename I've fixed: " + s);
+
+
+	return "-includes=" +s;
+
+    }
+
+
+    public static void handleCompileError (String swfName, String args, String desc) { 
+
+    	/* AJH
+		if (run_id != -1)  { 
+			System.out.println ("(handleCompileError: inserting a compile error)"); 
+			InsertErrorResult ier = new InsertErrorResult (run_id, swfName, args, desc);
+			threads.add (ier);
+			System.out.println ("(started the insert error)");
+			try { Thread.sleep (1250); } catch (Exception e)  {} 
+
+		} else if (distributed && compile_id != -1) {
+			System.out.println ("(handleCompileError: inserting a compile error)"); 
+			InsertErrorResult ier = new InsertErrorResult (compile_id, swfName, args, desc);
+			threads.add (ier);
+			System.out.println ("(started the insert error)");
+			try { Thread.sleep (1250); } catch (Exception e)  {} 
+
+		} */
+		if (exit_on_compile_error)  { 
+       			System.out.println("Compile Error detected. Flag set to exit. bye");
+			System.exit (1);
+		} else { 
+			exit_with = 1;
+		}
+
+    }
+
+    public void compileMxml(String mxml, ArrayList ermineArgs) {
+
+	/**
+	 * assemble compile flags
+	 */
+        String dir = FileUtils.normalizeDir(mxml);
+        dir = dir.substring(0, dir.lastIndexOf("/"));
+        boolean coachMode = false;
+        if (System.getProperty("coach") != null && System.getProperty("coach").equals("true")) {
+            coachMode = true;
+        }
+
+	/// incremental
+        boolean incremental="true".equals(System.getProperty("incremental"));
+
+	/// additional as path
+        String asclasspath=System.getProperty("asclasspath");
+
+	/// additional frameworks
+        String frameworks=System.getProperty("frameworks",".");
+
+	///?
+        if (frameworks.endsWith("/")==false) frameworks+="/";
+
+        String basedir=System.getProperty("basedir");
+
+	// var to apply them
+        String args="";
+
+	/// we need to get in this guy's brain
+        // Obsolete String librarypath=System.getProperty("librarypath",frameworks+"/libs/framework.swc");
+        String librarypath="";
+
+	///  add excludes to the lib path if present:
+        if (System.getProperty("excludelibrarypath") != null && !System.getProperty("excludelibrarypath").equals("")) { 
+        	System.out.println ("Sent to me as excludelibrarypath: " + System.getProperty("excludelibrarypath"));
+        	librarypath+= System.getProperty("excludelibrarypath");
+
+		/// if we're excluding, add the ExcludeList mixin
+	} else if  (System.getProperty("exclude_source_path") != null && !System.getProperty("exclude_source_path").equals("")) { 
+		/// if not present, and not skip exclude, add that path
+		args+= " -source-path=" + System.getProperty("exclude_source_path");
+
+
+	}
+
+	// NOTE: Put this before the excludeListMixinName!
+	if ( CompileMustellaSwfs.run_mobile_tests )
+	{
+		args += mobileConfigArg;
+	}		
+		
+	if ( device_name.equalsIgnoreCase( "mac" ) ) {
+		args += " -includes=DesktopMacSettings";
+	}
+
+	if ( device_name.equalsIgnoreCase( "win" ) ) {
+		args += " -includes=DesktopWinSettings";
+	}
+		
+	// NOTE: Put this after anything which sets something related to excludes,
+	// such as AndroidSettings!
+	if (!skip_exclude) { 
+		args += " -includes=" + excludeListMixinName;
+
+	}
+
+	if (use_apollo) { 
+		args += " -includes=ApolloFilePath";
+	}
+
+	if (use_include_file) { 
+		args += " -includes=IncludeFileLocation";
+	}
+
+	if (user_args != null)
+		args += " " +user_args;
+
+        // if (run_this_script != null && include_list != null) { 
+
+	String extract = null;
+
+	/* 
+        if (include_list_file != null && !include_list_file.equals("")) { 
+
+		/// read the file by line, each line is a test_file test_case identifier
+		try { 
+
+		BufferedReader br = new BufferedReader(new FileReader(include_list_file));
+
+        	// System.out.println ("noticed an include designation, adding it softly for " + mxml);
+
+		String front = null;
+
+		/// if we're excluding, add the ExcludeList mixin
+		ArrayList alinc = new ArrayList();
+		String tmp = null;
+		for (int i=0;i<ermineArgs.size();i++) {
+			tmp = (String)ermineArgs.get(i);
+			if (tmp.indexOf ("-includes=")!= -1) { 
+				extract = tmp.substring ("-includes=".length());
+			} else if (tmp.indexOf ("-source-path=")!= -1) { 
+				front = tmp.substring ("-source-path=".length());
+			}
+		}
+
+		front = front.substring (front.indexOf("mustella" + File.separator + "tests")+15);
+		front = front.replaceAll ("\\\\", "/") + "/";
+
+
+		alinc.add ("\"" + transformName( front + extract, "") + "\": 1,");
+		alinc.add ("\"" + transformName( front + extract, "") + "$" + include_list + "\": 1");
+		String whereToWrite= System.getProperty("mustella.dir") + File.separator + "classes";
+		// we thought it best to write these to a temp location
+		GetExcIncCase.writeToFile (alinc, whereToWrite + File.separator + includeListMixinName + ".as", false);
+		args += " -includes=" + includeListMixinName;
+		args += " -source-path="+whereToWrite;
+	}
+	*/
+
+	if (include_list != null && !include_list.equals("")) { 
+		// System.out.println ("noticed an include designation, adding it softly for " + mxml);
+
+		String front = null;
+
+		/// if we're excluding, add the ExcludeList mixin
+		ArrayList alinc = new ArrayList();
+		String tmp = null;
+		for (int i=0;i<ermineArgs.size();i++) {
+			tmp = (String)ermineArgs.get(i);
+			if (tmp.indexOf ("-includes=")!= -1) { 
+				extract = tmp.substring ("-includes=".length());
+			} else if (tmp.indexOf ("-source-path=")!= -1) { 
+				front = tmp.substring ("-source-path=".length());
+			}
+		}
+
+		front = front.substring (front.indexOf("mustella" + File.separator + "tests")+15);
+		front = front.replaceAll ("\\\\", "/") + "/";
+
+		alinc.add ("\"" + transformName( front + extract, "") + "\": 1,");
+		alinc.add ("\"" + transformName( front + extract, "") + "$" + include_list + "\": 1");
+		String whereToWrite= System.getProperty("mustella.dir") + File.separator + "classes";
+		// we thought it best to write these to a temp location
+		GetExcIncCase.writeToFile (alinc, whereToWrite + File.separator + includeListMixinName + ".as", false);
+		args += " -includes=" + includeListMixinName;
+		args += " -source-path="+whereToWrite;
+	}
+
+
+	/// if there's a mustella swc, use that.
+	/// probably want to be able to TOGGLE THIS on the ant side  FIX 
+	String mustellaswc = "";
+	if (System.getProperty("mustellaswc") != null && !use_qa_framework_dir) { 
+		mustellaswc=System.getProperty("mustellaswc");
+	
+		if (mustellaswc.length() > 0)
+			args+= " -library-path+="+mustellaswc;
+	}
+
+	if (use_apollo) {
+		if (run_mobile_tests)
+			args+=" +configname=airmobile";
+		else
+			args+=" +configname=air";		
+	}
+
+	if (save_failures) {
+	   if (!distributed && !pmd) { 
+		System.out.println ("Choosing local runner bitmap save");
+		args+=" -includes=SaveBitmapFailures";
+	   } else if (distributed || pmd) { 
+		System.out.println ("Choosing the Dist server bitmap save");
+		args+=" -includes=SaveBitmapFailuresDistServer";
+	   }
+	}
+
+	/// adding
+	if (librarypath != null && librarypath.length() > 0) { 
+
+		args+=" -library-path+="+ librarypath;
+
+	}
+
+	String externallibrarypath=System.getProperty("external.librarypath",frameworks+"/libs/playerglobal.swc");
+
+	if (librarypath.indexOf(".swc")==-1) {
+		asclasspath+=","+frameworks;
+	}
+		
+	boolean strict=System.getProperty("strict")!=null && System.getProperty("strict").equals("true");
+
+	if (socket_mixin != null && !socket_mixin.equals("")) { 
+		args+=socket_mixin;
+	}
+
+	/// add mustella args to the arg string
+	// if somehow there are no ermine args, then there is no test to mixin; so no point in 
+	// compiling it
+	if (ermineArgs.size() == 0) { 
+		System.out.println ("Skipping compile on " + mxml + " no mustella includes survived");
+		removeFromList(this);
+		return;
+	}
+		
+	for (int i=0;i<ermineArgs.size();i++) { 
+		args+=" "+ (String)ermineArgs.get(i);
+	}
+
+	args+=" --allow-source-path-overlap=true ";
+	if (incremental)
+		args+="--incremental=true ";
+	if (coachMode==false)
+		args+="--show-coach-warnings="+coachMode+" ";
+	if (strict==false)
+		args+="--strict="+strict+" ";
+
+	/// if we're interactive, hang around; and send results correctly.
+	if (args.indexOf ("SendResultsToSnifferClient") == -1) { 
+		// System.out.println ("keeping resultInclude and exitInclude");
+		args += " " + resultInclude;
+		args += " " + exitInclude;
+	} 
+
+	String [] pieces = asclasspath.split (",");
+	for (int i=0;i<pieces.length;i++) { 
+		if (pieces[i] != null && pieces[i].length() > 0)
+			args+=" -source-path="+pieces[i];
+	}
+
+	if (use_qa_framework_dir) { 
+		
+		// System.out.println ("Adding qa fwk dir: " + qa_framework_dir);
+		
+		// If we're using android or iOS, use the CompareBitmap which handles file I/O. MXMLC will
+		// keep whichever CompareBitmap it encounters first.
+		if( target_os_name.equalsIgnoreCase( MobileUtil.ANDROID_OS ) ||
+			target_os_name.equalsIgnoreCase( MobileUtil.IOS ) || 
+			target_os_name.equalsIgnoreCase( MobileUtil.QNX ) )
+		{
+			//System.out.println("AIR files will override.");
+			args+= " -source-path="+qa_framework_dir+File.separator+"AIR";
+		}
+		
+		// Now add the rest.
+		args+= " -source-path="+qa_framework_dir;		
+	}
+
+	/// this is the include for the fwk to send stuff to the Runner
+
+	String services = System.getProperty("services");
+	if (services!= null && !services.equals("")) {
+		args+=" --services="+services;
+	}
+	String antArgs=System.getProperty("mxmlc.args");
+	if (antArgs!=null && !antArgs.equals("")) {
+		args=antArgs+" "+args;
+	}
+
+	args = checkAndAddUserArgs (mxml, args);
+
+	System.out.println ("ARGS: " + args);
+
+
+	/**
+	 * if this run is designated as an air_transform, do the dirty work here
+	 * we save this for the end, because we need to shift the args.
+	 */
+	if (apollo_transform) {
+		mxml = FileUtils.normalizeDirOS(mxml);
+		args = ApolloAppToWindow.doAll (args, apollo_transform_prefix, apollo_transform_prefix2, mxml, apollo_transform_template, dir);
+		mxml = ApolloAppToWindow.getNewMxmlName (dir, mxml, apollo_transform_prefix);
+	}
+
+    defaultArgs=StringUtils.StringToArray(args);
+
+	try {
+		// writeTag(mxml, "status=started");
+		// if compc is used to produce a swc, add it to the classpath
+
+		String compc = System.getProperty("compc");
+
+		if (compc != null && !compc.equals("")) {
+			defaultArgs = compc(mxml, defaultArgs);
+		}
+		
+		 // do a similar thing for rsl only do not put the rsl swc on the classpath
+		String rsl = System.getProperty("rsl");
+		if (rsl != null && !rsl.equals("")) {
+			rsl(mxml);
+			defaultArgs = StringUtils.StringToArray(StringUtils.arrayToString(defaultArgs) + " +frameworks-dir " + frameworks);
+		}
+
+		System.out.println ("okey doke, going to compile " + mxml);
+
+		CompileMxmlUtils compiler = new CompileMxmlUtils();
+		compiler.setPrintOut(true);
+
+		compiler.setDir(dir);
+
+		/**
+		System.out.println ("************");
+		System.out.println ("************");
+		
+		String defaultArgsDebugString = new String();
+		
+		for(int i = 0; i < defaultArgs.length; ++i){
+			defaultArgsDebugString += defaultArgs[i];
+		}
+		
+		System.out.println ("mxml: " + mxml);
+		System.out.println ("defaultArgs: " + defaultArgsDebugString);
+		**/
+		
+		compiler.compile(mxml, defaultArgs);
+		RuntimeExecHelper rh = compiler.getRuntimeExecHelper();
+
+		/// FIX collect these results / insert
+
+		// writeTag(mxml, "mxmlc=" + StringUtils.arrayToString(compiler.getExecArgs()) + "\ncompile time=" + StringUtils.formatTime(compiler.getLastRunTime()) + "\nexitvalue=" + rh.getExitValue() + "\nstdout=" + rh.getOutputText() + "\nstderr=" + rh.getErrorText());
+		// System.out.println("rh output: " + rh.getOutputText());
+		// System.out.println("rh error out: " + rh.getErrorText());
+		// System.out.println("exit value=" + rh.getExitValue());
+
+		String failedFile=null;
+
+		// InsertErrorResult ier = null;
+	
+		if (rh.getExitValue() != 0) { 
+			directory_result = 1;
+			failedFile = rh.getErrorText();
+			System.out.println("here's the failedFile; " + failedFile);
+
+			handleCompileError (mxml, args, failedFile);
+
+			/// insert failure into the database here. 
+			//ier = new InsertErrorResult (run_id, failedFile, rh.getErrorText());
+
+			removeFromList(this);
+
+			/// don't bother retrying anymore. No more Mr. Nice Guy
+			/* 
+			if (removeFromArgs (mxml, failedFile, ermineArgs) && retryCount < 4) { 
+				System.out.println ("Compile: Calling again");
+				compileMxml (mxml, ermineArgs);		
+			} else { 
+						System.out.println("!!compile failed, but could not fix cmd line, sorry");
+				if (!exit_on_compile_error)   { 
+							System.out.println("Not set to exit on compile error, continue");
+					removeFromList(this);
+				}  else { 
+					/// reachable?
+							System.out.println("getting out");
+					System.exit(1);
+
+				}		
+
+			}
+			*/
+
+		} else { 
+			// System.out.println ("that was just ducky");
+
+			/// if (System.getProperty("html")==null || System.getProperty("html").equals("false")==false) {
+
+			removeFromList(this);
+		}
+	} catch (Exception e) {
+		e.printStackTrace();
+		handleCompileError (mxml, args, e.toString());
+		removeFromList(this);
+	}
+    }
+
+    private static final String compile_arg_ending = ".compile";
+    private static final String property_arg_ending = ".htmlvars";
+
+
+    // private Hashtable htmlVars = new Hashtable();
+
+    public String checkAndAddUserArgs (String mxml, String args) { 
+
+		String comp_mxml = transformName(mxml, compile_arg_ending);
+
+		Map.Entry me = null;
+
+		if (new File(comp_mxml).exists()) { 
+			// System.out.println ("Saw the .compile file");
+
+			Properties p = new Properties();
+			try { 
+				// Since we may get duplicate compile key directives, we
+				// have to combine them.
+				// can't really use load
+
+				String line = null;
+				String key = null;
+				String val = null;
+				String tmp = null;
+				BufferedReader be = new BufferedReader (new FileReader (comp_mxml));
+
+				/// Simplified version: just throw the arg on there, as is
+				while ( (line=be.readLine()) != null) { 
+					if (!line.startsWith ("#"))
+						args += " "+ doSubstitute(line);
+				}
+
+				be.close();
+
+
+			} catch (Exception e) { 
+				System.err.println ("Exception on trying to load user .compile file, maybe ok");
+				// e.printStackTrace();
+
+
+			}
+		}
+
+		if (args.indexOf ("-debug") == -1){
+			args += " -debug";
+		}
+
+		return args;
+    }
+
+    public String doSubstitute (String line) { 
+
+	    	String sdk_dir=System.getProperty("sdk.dir");
+
+	    	String fwk_dir=System.getProperty("framework.dir");
+
+		if (sdk_dir != null && !sdk_dir.equals("")) { 
+
+			if ( line.indexOf ("${sdk.dir}") != -1)  { 
+				line = line.replaceAll ("\\$\\{sdk.dir\\}", FileUtils.normalizeDir(sdk_dir));
+			}
+		}
+
+		
+		if (mustella_dir != null && !mustella_dir.equals("")) { 
+			if ( line.indexOf ("${mustella.dir}") != -1)  { 
+				line = line.replaceAll ("\\$\\{mustella.dir\\}", FileUtils.normalizeDir(mustella_dir));
+			}
+
+		}
+
+		if (fwk_dir != null && !fwk_dir.equals("")) { 
+			if ( line.indexOf ("${framework.dir}") != -1)  { 
+				line = line.replaceAll ("\\$\\{framework.dir\\}", FileUtils.normalizeDir(fwk_dir));
+			}
+
+		}
+
+
+		return line;
+
+    }
+    
+
+
+    public static String transformName (String mxml, String addition) { 
+
+	if (mxml.endsWith (".mxml")) { 
+		mxml = mxml.substring (0, mxml.length()-5) + addition;
+
+	}
+
+	return mxml;
+
+	
+    }
+  
+    // counter to see if there's progress. 
+    private int retryCount = 0;
+    private int lastCount = 0;
+    private int currentCount = 0;
+    private String lastRemove = null;
+    
+    public boolean removeFromArgs (String mxml, String removeArg, ArrayList ermineArgs) { 
+
+	retryCount++;
+	HashMap theBroken = splitAndFix(removeArg);
+
+	currentCount = ermineArgs.size();
+	
+	if (currentCount < lastCount) {
+		lastCount = currentCount;
+	} else if (currentCount == lastCount) {
+		// we're making no headway, 	
+		return false;
+	}
+
+	System.out.println ("broken files: " + theBroken);
+
+	int countOfIncludes= countIncludes (ermineArgs);
+
+	// note futility right away.
+	if (countOfIncludes == 1) { 
+		System.out.println ("include count is 1. There's no hope, returning false");
+		return false;
+	}
+
+	System.out.println ("include count: " + countOfIncludes);
+	String fixed = null;
+
+
+	/// how do we know if there's a test left?
+	boolean others= false;
+	int count = 0;
+	String tmp = null;
+	boolean tookAction = false;
+	for (int i=0;i<ermineArgs.size();i++) { 
+
+		tmp = (String) ermineArgs.get (i);
+		if (tmp.indexOf ("-includes=") != -1) 
+			tmp = tmp.substring (11);
+		else { 
+			System.out.println ("skipping arg: "+ tmp);
+			continue;
+		
+		}
+			
+
+		// if it's a busted one, remove
+		if (theBroken.put (tmp, new Integer (1)) != null)  { 
+			tookAction = true;
+			ermineArgs.remove (i);		
+			if (lastRemove == null)
+				lastRemove= tmp;
+			else { 
+				if (lastRemove.equals (tmp)) { 
+					System.out.println ("Looks like we're trying again to remove: " + tmp);
+				} else { 
+					System.out.println ("removed from the pile: " + tmp + " of: " + count);	
+					lastRemove=tmp;
+				}
+			}
+			count++;
+			System.out.println ("removed from the pile: " + tmp + " of: " + count);
+		} else { 
+
+			System.out.println ("skipped removal of : " + tmp);
+		}
+
+		if (count == countOfIncludes) { 
+			System.out.println ("count now == includeCount, futile, return false");
+			return false;
+		}
+		
+	}
+
+	if (count < countOfIncludes && tookAction)
+		return true;
+
+	return false;
+    }
+
+    public int countIncludes (ArrayList al) { 
+
+	String tmp = null;
+
+	int count= 0;
+	
+	for (int i=0;i<al.size();i++) { 
+
+		tmp = (String) al.get (i);
+		if ( tmp.indexOf ("-includes=") != -1) { 
+
+			if (tmp.length() <= "-includes=".length())
+				continue;
+
+			/// unless includes are default ones, count
+			if (tmp.indexOf (resultCollectorMixinName) == -1 && tmp.indexOf (excludeListMixinName) ==-1) { 
+				System.out.println ("counting this: " + tmp);
+				count++;
+			}
+
+
+		}
+
+
+	}	
+
+	return count;
+
+    }
+
+    public static HashMap splitAndFix(String s){ 
+
+	String [] arr = s.split ("\n");
+
+	System.out.println ("This was the count: " + arr.length);
+
+
+	HashMap altmp = new HashMap();
+
+
+	for (int i=0;i<arr.length;i++) { 
+
+		if (arr[i].indexOf ("Error:") != -1)
+			altmp.put ( fix (arr[i]), new Integer(1));	
+	}
+
+
+	return altmp;
+
+
+
+    }
+
+
+    public static String fix(String s) { 
+
+	s = MustellaDirs.cleanFile (s);
+
+	System.out.println ("This is a path sep: " + File.pathSeparator);
+
+	if (s.indexOf (File.separator) != -1) 
+		s = s.substring (s.lastIndexOf (File.separator)+1);
+	else 
+		System.out.println ("There ain't none in " + s);
+
+	return s;
+
+    }
+
+
+    /// derive compile output file.
+    public static String getTagName(String mxml) {
+        String tag;
+        if (mxml.indexOf(".") > -1) {
+            tag = mxml.substring(0, mxml.lastIndexOf(".")) + ".output";
+        } else {
+            tag = mxml + ".output";
+        }
+        return tag;
+    }
+
+    
+    public static void writeTag(String mxml, String msg) {
+        String build = System.getProperty("build", "workspace");
+        String out = "hostname=" + StringUtils.getHostName() + "\n";
+        out += "date=" + StringUtils.getDate() + "\n";
+        out += "build=" + build + "\n";
+        out += msg;
+        String name = getTagName(mxml);
+        try {
+            FileUtils.writeFile(name, out);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static String[] compc(String mxml, String[] mxmlArgs) throws Exception {
+        //System.out.println(">>>>> compc if necessary >>>>>>> " + mxml);
+        CompcUtils compc = new CompcUtils();
+        //compc.setPrintOut(true);
+        File argFile = null;
+        try {
+            argFile = compc.getCompcArgFile(mxml);
+            if (argFile.exists()) {
+                compc.compile(argFile);
+                RuntimeExecHelper rh = compc.getRuntimeExecHelper();
+                mxmlArgs = compc.addSwcToClassPath(mxmlArgs);
+        //        writeTag(mxml, "COMPC compile time=" + StringUtils.formatTime(compc.getLastRunTime()) + "\nexitvalue=" + rh.getExitValue() + "\nstdout=" + rh.getOutputText() + "\nstderr=" + rh.getErrorText());
+                System.out.println("compc exit value=" + rh.getExitValue());
+            }
+        } catch (Exception e) {
+            System.out.println("compc argfile doesn't exist...carry on.");
+            e.printStackTrace();
+        }
+
+        return mxmlArgs;
+
+    }
+
+    public static void rsl(String mxml) throws Exception {
+        System.out.println(">>>>> building rsl(s)");
+        CompcUtils compc = new CompcUtils();
+        //compc.setPrintOut(true);
+        File argFile = null;
+        try {
+            argFile = compc.getRSLArgFile(mxml);
+            if (argFile.exists()) {
+                compc.compile(argFile);
+                RuntimeExecHelper rh = compc.getRuntimeExecHelper();
+                System.out.println("compc exit value=" + rh.getExitValue());
+            }
+        } catch (Exception e) {
+            System.out.println("rsl argfile doesn't exist...carry on.");
+            e.printStackTrace();
+        }
+
+    }
+}

Propchange: incubator/flex/trunk/mustella/java/src/mustella/CompileMustellaSwfs.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message