in mustella/java/src/mustella/CompileMustellaSwfs.java [738:1120]
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.replaceAll ("\\\\", "/") + "/";
int test_index = front.indexOf(mustella_test_dir);
int test_length = mustella_test_dir.length();
front = front.substring (test_index + test_length + 1);
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_mustella_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_mustella_framework_dir) {
// System.out.println ("Adding qa fwk dir: " + mustella_framework_dir);
// Now add the rest.
args+= " -source-path+="+mustella_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+="+mustella_framework_dir+File.separator+"AIR";
}
}
/// 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);
}
// ------- ArgumentParser -------------
ArgumentParser parser = new ArgumentParser(args);
defaultArgs = parser.parseArguments();
if( debugDump ) {
for(int i=0; i < defaultArgs.size(); i++) {
System.out.println("ARG "+i+": "+defaultArgs.get(i));
}
}
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.add("+frameworks-dir");
defaultArgs.add(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.size(); ++i){
defaultArgsDebugString += defaultArgs.get(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);
}
}