コード例 #1
0
        /// <summary>
        /// Start background process
        /// </summary>
        private void StartMxmlcRunner(string flexPath)
        {
            currentSDK = flexPath;
            if (mxmlcRunner != null && mxmlcRunner.IsRunning)
            {
                mxmlcRunner.KillProcess();
            }

            CheckIsFlex4SDK(flexPath);
            string shell = isFlex4SDK ? "Mxmlc4Shell" : "MxmlcShell";

            string cmd = jvmConfig["java.args"]
                         + " -classpath \"" + mxmlcPath + ";" + flexShellsPath + "\" " + shell;

            TraceManager.Add(TextHelper.GetString("Info.StartMxmlcRunner") + "\n"
                             + JvmConfigHelper.GetJavaEXE(jvmConfig) + " " + cmd, -1);
            // run compiler shell
            mxmlcRunner = new ProcessRunner();
            mxmlcRunner.WorkingDirectory = Path.Combine(flexPath, "frameworks");
            mxmlcRunner.RedirectInput    = true;
            mxmlcRunner.Run(JvmConfigHelper.GetJavaEXE(jvmConfig), cmd, true);
            mxmlcRunner.Output += mxmlcRunner_Output;
            mxmlcRunner.Error  += mxmlcRunner_Error;
            errorState          = 0;
            Thread.Sleep(100);
        }
コード例 #2
0
        void CompileWithMxmlc(string mxmlcArgs)
        {
            var javaExe = JvmConfigHelper.GetJavaEXE(jvmConfig, CompilerPath);

            Console.WriteLine("Running java as: " + javaExe);
            var frameworks = Path.Combine(CompilerPath, "frameworks");
            var args       = $"-Dflexcompiler=\"{CompilerPath}\" -Dflexlib=\"{frameworks}\" {jvmArgs} -jar \"{mxmlcPath}\"";

            args += " -js-output-type=FLEXJS";
            args += " -sdk-js-lib=\"" + Path.Combine(frameworks, "js", "FlexJS", "generated-sources") + "\" ";
            var index = mxmlcArgs.LastIndexOf("-o ");

            if (index != -1)
            {
                mxmlcArgs = mxmlcArgs.Remove(index);
            }
            args += mxmlcArgs;
            args += " -targets=SWF";
            args += " " + project.CompileTargets.First();
            args += " -output=" + project.OutputPath;
            if (!ProcessRunner.Run(javaExe, args, false, false))
            {
                throw new BuildException("Build halted with errors (mxmlc).");
            }
        }
コード例 #3
0
        /// <summary>
        /// Start background process
        /// </summary>
        private void StartAscRunner()
        {
            string cmd = "-Duser.language=en -Duser.region=US"
                         + " -classpath \"" + ascPath + ";" + flexShellsPath + "\" AscShell";

            TraceManager.Add(TextHelper.GetString("Info.StartAscRunner") + " java " + cmd, -1);
            // run asc shell
            ascRunner = new ProcessRunner();
            ascRunner.WorkingDirectory = Path.GetDirectoryName(ascPath);
            ascRunner.RedirectInput    = true;
            ascRunner.Run(JvmConfigHelper.GetJavaEXE(jvmConfig), cmd, true);
            ascRunner.Output += ascRunner_Output;
            ascRunner.Error  += ascRunner_Error;
            errorState        = 0;
            Thread.Sleep(100);
        }
コード例 #4
0
        public void CompileWithMxmlc(string workingdir, string arguments, bool configChanged)
        {
            if (fcsh != null)
            {
                string   output;
                string[] errors;
                string[] warnings;
                string   jar    = ascshPath != null ? ascshPath : fcshPath;
                string   jvmarg = VMARGS + " -Dapplication.home=\"" + sdkPath
                                  //+ "\" -Dflexlib=\"" + Path.Combine(sdkPath, "frameworks")
                                  + "\" -jar \"" + jar + "\"";
                fcsh.Compile(workingdir, configChanged, arguments, out output, out errors, out warnings, jvmarg, JvmConfigHelper.GetJavaEXE(jvmConfig, sdkPath));

                string[] lines = output.Split('\n');
                foreach (string line in lines)
                {
                    if (!line.StartsWith("Recompile:", StringComparison.Ordinal) && !line.StartsWith("Reason:", StringComparison.Ordinal))
                    {
                        Console.Write(line);
                    }
                }
                foreach (string warning in warnings)
                {
                    Console.Error.WriteLine(warning);
                }
                foreach (string error in errors)
                {
                    Console.Error.WriteLine(error);
                }

                if (errors.Length > 0)
                {
                    throw new BuildException("Build halted with errors (fcsh).");
                }
            }
            else
            {
                string jar     = asc2Mode ? asc2Path : mxmlcPath;
                string javaExe = JvmConfigHelper.GetJavaEXE(jvmConfig, sdkPath);
                Console.WriteLine("Running java as: " + javaExe);
                string jvmarg = VMARGS + " -jar \"" + jar + "\" +flexlib=\"" + Path.Combine(sdkPath, "frameworks") + "\" ";
                if (!ProcessRunner.Run(javaExe, jvmarg + arguments, false, asc2Mode))
                {
                    throw new BuildException("Build halted with errors (" + (asc2Mode ? "mxmlc-cli" : "mxmlc") + ").");
                }
            }
        }
コード例 #5
0
 public FlexJSProjectBuilder(AS3Project project, string compilerPath) : base(project, compilerPath)
 {
     this.project = project;
     mxmlcPath    = Path.Combine(compilerPath, "js", "lib", "mxmlc.jar");
     if (!File.Exists(mxmlcPath))
     {
         throw new Exception("Could not locate js\\lib\\mxmlc.jar in FlexJS SDK.");
     }
     jvmConfig = JvmConfigHelper.ReadConfig(compilerPath);
     if (jvmConfig.ContainsKey("java.args"))
     {
         var args = jvmConfig["java.args"];
         if (args.Trim().Length > 0)
         {
             jvmArgs = args;
         }
     }
 }
コード例 #6
0
        bool Initialize(string flexSDKPath, Dictionary <string, string> jvmConfig, string projectPath)
        {
            cmdQueue = new Queue <string>();

            string fdbPath = Path.Combine(flexSDKPath, "lib\\fdb.jar");

            if (!File.Exists(fdbPath))
            {
                fdbPath = Path.Combine(flexSDKPath, "lib\\legacy\\fdb.jar");
            }
            if (!File.Exists(fdbPath))
            {
                process = null;
                return(false);
            }

            workingDir = projectPath;
            process    = new Process();
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardInput  = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.FileName  = JvmConfigHelper.GetJavaEXE(jvmConfig);
            process.StartInfo.Arguments = jvmConfig["java.args"]
                                          + "  -Dfile.encoding=UTF-8 -Dapplication.home=\"" + flexSDKPath + "\" -jar \"" + fdbPath + "\"";
            process.StartInfo.WorkingDirectory       = workingDir;
            process.StartInfo.StandardErrorEncoding  = Encoding.UTF8;
            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
            process.Start();

            process.Exited += process_Exited;

            errorThread = new Thread(ReadErrors);
            errorThread.Start();

            fdbThread = new Thread(FdbRun);
            fdbThread.Start();

            Thread.Sleep(100);
            return(true);
        }
コード例 #7
0
ファイル: FdbWrapper.cs プロジェクト: xeronith/flashdevelop
        public void Run(string projectPath, string flexSDKPath)
        {
            flexSDKPath = PathHelper.ResolvePath(flexSDKPath, projectPath);
            if (flexSDKPath != null && Directory.Exists(flexSDKPath))
            {
                if (flexSDKPath.EndsWith("bin", StringComparison.OrdinalIgnoreCase))
                {
                    flexSDKPath = Path.GetDirectoryName(flexSDKPath);
                }
            }
            else
            {
                return;
            }

            Dictionary <string, string> jvmConfig = JvmConfigHelper.ReadConfig(flexSDKPath);

            if (process == null || process.HasExited)
            {
                Initialize(flexSDKPath, jvmConfig, projectPath);
            }
        }
コード例 #8
0
        /// <summary>
        /// Start background process
        /// </summary>
        private void StartAscRunner(string flexPath)
        {
            currentSDK = flexPath;
            if (ascRunner != null && ascRunner.IsRunning)
            {
                ascRunner.KillProcess();
            }

            string cmd = jvmConfig["java.args"]
                         + " -classpath \"" + ascPath + ";" + flexShellsPath + "\" AscShell";

            TraceManager.Add(TextHelper.GetString("Info.StartAscRunner") + "\n"
                             + JvmConfigHelper.GetJavaEXE(jvmConfig) + " " + cmd, 0);
            // run asc shell
            ascRunner = new ProcessRunner();
            ascRunner.WorkingDirectory = Path.GetDirectoryName(ascPath);
            ascRunner.RedirectInput    = true;
            ascRunner.Run(JvmConfigHelper.GetJavaEXE(jvmConfig), cmd, true);
            ascRunner.Output += ascRunner_Output;
            ascRunner.Error  += ascRunner_Error;
            errorState        = 0;
            Thread.Sleep(100);
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        internal bool Start(bool alwaysStart)
        {
            if (!alwaysStart && !CheckCurrent())
            {
                return(false);
            }
            UpdateMenuState(DebuggerState.Starting);

            // load JVM.. only once
            if (!jvm_up)
            {
                try
                {
                    BridgeSetup bridgeSetup = null;
                    bridgeSetup = new BridgeSetup();

                    string flexSDKPath = null;
                    if (currentProject != null)
                    {
                        flexSDKPath = currentProject.CurrentSDK;
                    }
                    else
                    {
                        flexSDKPath = PathHelper.ResolvePath(PluginBase.MainForm.ProcessArgString("$(FlexSDK)"));
                    }

                    if (flexSDKPath != null && Directory.Exists(flexSDKPath))
                    {
                        Dictionary <string, string> jvmConfig = JvmConfigHelper.ReadConfig(flexSDKPath);
                        String javaHome = JvmConfigHelper.GetJavaHome(jvmConfig, flexSDKPath);
                        if (!String.IsNullOrEmpty(javaHome))
                        {
                            bridgeSetup.JavaHome = javaHome;
                        }
                    }

                    bridgeSetup.AddAllJarsClassPath(PathHelper.PluginDir);
                    bridgeSetup.AddAllJarsClassPath(Path.Combine(PathHelper.ToolDir, @"flexlibs\lib"));
                    Bridge.CreateJVM(bridgeSetup);
                    Bridge.RegisterAssembly(typeof(IProgress).Assembly); // ??
                    Bridge.RegisterAssembly(typeof(Bootstrap).Assembly);
                    jvm_up = true;
                }
                catch (Exception ex)
                {
                    String msg = "Debugger startup error. For troubleshooting see: http://www.flashdevelop.org/wikidocs/index.php?title=F.A.Q\n";
                    TraceManager.Add(msg + "Error details: " + ex.ToString());
                    return(false);
                }
            }

            PluginBase.MainForm.ProgressBar.Visible   = true;
            PluginBase.MainForm.ProgressLabel.Visible = true;
            PluginBase.MainForm.ProgressLabel.Text    = TextHelper.GetString("Info.WaitingForPlayer");
            if (bgWorker == null || !bgWorker.IsBusy)
            {
                // only run a debugger if one is not already runnin - need to redesign core to support multiple debugging instances
                // other option: detach old worker, wait for it to exit and start new one
                bgWorker         = new BackgroundWorker();
                bgWorker.DoWork += bgWorker_DoWork;
                bgWorker.RunWorkerAsync();
            }
            return(true);
        }
コード例 #10
0
        public void RunMxmlc(string cmd, string flexPath)
        {
            if (running)
            {
                return;
            }
            string basePath = null;

            if (PluginBase.CurrentProject != null)
            {
                basePath = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath);
            }
            flexPath = PathHelper.ResolvePath(flexPath, basePath);

            if (flexPath != null && Directory.Exists(flexPath))
            {
                if (flexPath.EndsWith("bin", StringComparison.OrdinalIgnoreCase))
                {
                    flexPath = Path.GetDirectoryName(flexPath);
                }
                mxmlcPath = Path.Combine(Path.Combine(flexPath, "lib"), "mxmlc.jar");
            }
            if (mxmlcPath == null || !File.Exists(mxmlcPath))
            {
                DialogResult result = MessageBox.Show(TextHelper.GetString("Info.OpenCompilerSettings"), TextHelper.GetString("Title.ConfigurationRequired"), MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    IASContext context = ASContext.GetLanguageContext("as3");
                    if (context == null)
                    {
                        return;
                    }
                    PluginBase.MainForm.ShowSettingsDialog("AS3Context", "SDK");
                }
                return;
            }

            flexShellsPath = CheckResource("FlexShells.jar", flexShellsJar);
            if (!File.Exists(flexShellsPath))
            {
                ErrorManager.ShowInfo(TextHelper.GetString("Info.ResourceError"));
                return;
            }

            jvmConfig = JvmConfigHelper.ReadConfig(Path.Combine(flexPath, "bin\\jvm.config"));

            try
            {
                running = true;
                EventManager.DispatchEvent(this, new NotifyEvent(EventType.ProcessStart));

                if (mxmlcRunner == null || !mxmlcRunner.IsRunning)
                {
                    StartMxmlcRunner(flexPath);
                }

                //cmd = mainForm.ProcessArgString(cmd);
                //TraceManager.Add("MxmlcShell command: "+cmd, -1);

                ASContext.SetStatusText(TextHelper.GetString("Info.MxmlcRunning"));
                notificationSent = false;
                mxmlcRunner.HostedProcess.StandardInput.WriteLine(cmd);
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }
コード例 #11
0
        public void CheckAS3(string filename, string flexPath, string src)
        {
            if (running || filename.EndsWith(".mxml"))
            {
                return;
            }
            string basePath = null;

            if (PluginBase.CurrentProject != null)
            {
                basePath = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath);
            }
            flexPath = PathHelper.ResolvePath(flexPath, basePath);
            // asc.jar in Flex2SDK
            if (flexPath != null && Directory.Exists(flexPath))
            {
                if (flexPath.EndsWith("bin", StringComparison.OrdinalIgnoreCase))
                {
                    flexPath = Path.GetDirectoryName(flexPath);
                }
                ascPath = Path.Combine(flexPath, "lib\\asc.jar");
            }
            // asc_authoring.jar in Flash CS3
            if (ascPath == null)
            {
                ascPath = FindAscAuthoring();
            }

            if (ascPath == null)
            {
                if (src != null)
                {
                    return;              // silent checking
                }
                DialogResult result = MessageBox.Show(TextHelper.GetString("Info.SetFlex2OrCS3Path"), TextHelper.GetString("Title.ConfigurationRequired"), MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    IASContext context = ASContext.GetLanguageContext("as3");
                    if (context == null)
                    {
                        return;
                    }
                    PluginBase.MainForm.ShowSettingsDialog("AS3Context", "SDK");
                }
                else if (result == DialogResult.No)
                {
                    PluginBase.MainForm.ShowSettingsDialog("ASCompletion", "Flash");
                }
                return;
            }

            flexShellsPath = CheckResource("FlexShells.jar", flexShellsJar);
            if (!File.Exists(flexShellsPath))
            {
                if (src != null)
                {
                    return;              // silent checking
                }
                ErrorManager.ShowInfo(TextHelper.GetString("Info.ResourceError"));
                return;
            }

            jvmConfig = JvmConfigHelper.ReadConfig(Path.Combine(flexPath ?? "", "bin\\jvm.config"));

            try
            {
                running = true;
                if (src == null)
                {
                    EventManager.DispatchEvent(this, new NotifyEvent(EventType.ProcessStart));
                }
                if (ascRunner == null || !ascRunner.IsRunning)
                {
                    StartAscRunner();
                }

                notificationSent = false;
                if (src == null)
                {
                    silentChecking = false;
                    //TraceManager.Add("Checking: " + filename, -1);
                    ASContext.SetStatusText(TextHelper.GetString("Info.AscRunning"));
                    ascRunner.HostedProcess.StandardInput.WriteLine(filename);
                }
                else
                {
                    silentChecking = true;
                    ascRunner.HostedProcess.StandardInput.WriteLine(filename + "$raw$");
                    ascRunner.HostedProcess.StandardInput.WriteLine(src);
                    ascRunner.HostedProcess.StandardInput.WriteLine(filename + "$raw$");
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(TextHelper.GetString("Info.CheckError"), ex);
            }
        }
コード例 #12
0
        public void CheckAS3(string filename, string flexPath, string src)
        {
            if (running)
            {
                return;
            }

            // let other plugins preprocess source/handle checking
            Hashtable data = new Hashtable();

            data["filename"] = filename;
            data["src"]      = src;
            data["ext"]      = Path.GetExtension(filename);
            DataEvent de = new DataEvent(EventType.Command, "AS3Context.CheckSyntax", data);

            EventManager.DispatchEvent(this, de);
            if (de.Handled)
            {
                return;
            }

            src      = (string)data["src"];
            filename = (string)data["filename"];
            if (".mxml" == (string)data["ext"]) // MXML not supported by ASC without preprocessing
            {
                return;
            }

            string basePath = null;

            if (PluginBase.CurrentProject != null)
            {
                basePath = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath);
            }
            flexPath = PathHelper.ResolvePath(flexPath, basePath);
            // asc.jar in FlexSDK
            if (flexPath != null && Directory.Exists(Path.Combine(flexPath, "lib")))
            {
                ascPath = Path.Combine(flexPath, "lib\\asc.jar");
            }
            // included asc.jar
            if (ascPath == null || !File.Exists(ascPath))
            {
                ascPath = PathHelper.ResolvePath(Path.Combine(PathHelper.ToolDir, "flexlibs/lib/asc.jar"));
            }

            if (ascPath == null)
            {
                if (src != null)
                {
                    return;              // silent checking
                }
                DialogResult result = MessageBox.Show(TextHelper.GetString("Info.SetFlex2OrCS3Path"), TextHelper.GetString("Title.ConfigurationRequired"), MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    IASContext context = ASContext.GetLanguageContext("as3");
                    if (context == null)
                    {
                        return;
                    }
                    PluginBase.MainForm.ShowSettingsDialog("AS3Context", "SDK");
                }
                else if (result == DialogResult.No)
                {
                    PluginBase.MainForm.ShowSettingsDialog("ASCompletion", "Flash");
                }
                return;
            }

            flexShellsPath = CheckResource("FlexShells.jar", flexShellsJar);
            if (!File.Exists(flexShellsPath))
            {
                if (src != null)
                {
                    return;              // silent checking
                }
                ErrorManager.ShowInfo(TextHelper.GetString("Info.ResourceError"));
                return;
            }

            jvmConfig = JvmConfigHelper.ReadConfig(flexPath);

            try
            {
                running = true;
                if (src == null)
                {
                    EventManager.DispatchEvent(this, new NotifyEvent(EventType.ProcessStart));
                }
                if (ascRunner == null || !ascRunner.IsRunning || currentSDK != flexPath)
                {
                    StartAscRunner(flexPath);
                }

                notificationSent = false;
                if (src == null)
                {
                    silentChecking = false;
                    //TraceManager.Add("Checking: " + filename, -1);
                    ASContext.SetStatusText(TextHelper.GetString("Info.AscRunning"));
                    ascRunner.HostedProcess.StandardInput.WriteLine(filename);
                }
                else
                {
                    silentChecking = true;
                    ascRunner.HostedProcess.StandardInput.WriteLine(filename + "$raw$");
                    ascRunner.HostedProcess.StandardInput.WriteLine(src);
                    ascRunner.HostedProcess.StandardInput.WriteLine(filename + "$raw$");
                }
            }
            catch (Exception ex)
            {
                ErrorManager.AddToLog(TextHelper.GetString("Info.CheckError"), ex);
                TraceManager.AddAsync(TextHelper.GetString("Info.CheckError") + "\n" + ex.Message);
            }
        }