- if (aot_build_flags != null) {
- Console.WriteLine("AOT compiling tests");
-
- object aot_monitor = new object ();
- var aot_queue = new Queue<String> (tests);
-
- List<Thread> build_threads = new List<Thread> (concurrency);
-
- for (int j = 0; j < concurrency; ++j) {
- Thread thread = new Thread (() => {
- while (true) {
- String test_name;
-
- lock (aot_monitor) {
- if (aot_queue.Count == 0)
- break;
- test_name = aot_queue.Dequeue ();
- }
-
- string test_bitcode_output = test_name + "_bitcode_tmp";
- string test_bitcode_arg = ",temp-path=" + test_bitcode_output;
- string aot_args = aot_build_flags + test_bitcode_arg + " " + test_name;
-
- Directory.CreateDirectory(test_bitcode_output);
-
- ProcessStartInfo job = new ProcessStartInfo (runtime, aot_args);
- job.UseShellExecute = false;
- job.EnvironmentVariables[ENV_TIMEOUT] = timeout.ToString();
- if (mono_path != null)
- job.EnvironmentVariables[MONO_PATH] = mono_path;
- if (mono_gac_prefix != null)
- job.EnvironmentVariables[MONO_GAC_PREFIX] = mono_gac_prefix;
- Process compiler = new Process ();
- compiler.StartInfo = job;
-
- compiler.Start ();
-
- if (!compiler.WaitForExit (timeout * 1000)) {
- try {
- compiler.Kill ();
- } catch {
- }
- throw new Exception(String.Format("Timeout AOT compiling tests, output in {0}", test_bitcode_output));
- } else if (compiler.ExitCode != 0) {
- throw new Exception(String.Format("Error AOT compiling tests, output in {0}", test_bitcode_output));
- } else {
- Directory.Delete (test_bitcode_output, true);
- }
- }
- });
-
- thread.Start ();
-
- build_threads.Add (thread);
- }
-
- for (int j = 0; j < build_threads.Count; ++j)
- build_threads [j].Join ();
-
- Console.WriteLine("Done compiling");
- }
-