コード例 #1
0
        protected override void DoBuild(string[] extraClasspaths, bool noTrace)
        {
            Environment.CurrentDirectory = project.Directory;

            string output    = project.FixDebugReleasePath(project.OutputPathAbsolute);
            string outputDir = Path.GetDirectoryName(project.OutputPathAbsolute);

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            string serverPort = Environment.ExpandEnvironmentVariables("%HAXE_SERVER_PORT%");
            string connect    = (!serverPort.StartsWith("%") && serverPort != "0")
                ? "--connect " + serverPort : "";

            if (project.IsNmeOutput && !string.IsNullOrEmpty(project.TargetBuild))
            {
                haxePath = haxePath.Replace("haxe.exe", "haxelib.exe");
                string config      = project.TargetBuild;
                string haxeNmeArgs = String.Join(" ", BuildNmeCommand(extraClasspaths, output, config, noTrace, null));// +" " + connect;
                Console.WriteLine("haxelib " + haxeNmeArgs);
                if (!ProcessRunner.Run(haxePath, haxeNmeArgs, false, false))
                {
                    throw new BuildException("Build halted with errors (haxelib.exe).");
                }
                return;
            }

            // always use relative path for CPP (because it prepends ./)
            if (project.IsCppOutput)
            {
                output = project.FixDebugReleasePath(project.OutputPath);
            }

            if (project.IsFlashOutput)
            {
                SwfmillLibraryBuilder libraryBuilder = new SwfmillLibraryBuilder();

                // before doing anything else, make sure any resources marked as "keep updated"
                // are properly kept up to date if possible
                libraryBuilder.KeepUpdated(project);

                // if we have any resources, build our library file and run swfmill on it
                libraryBuilder.BuildLibrarySwf(project, false);
            }

            string haxeArgs = connect + " " + String.Join(" ", project.BuildHXML(extraClasspaths, output, noTrace));

            Console.WriteLine("haxe " + haxeArgs);

            if (!ProcessRunner.Run(haxePath, haxeArgs, false, false))
            {
                throw new BuildException("Build halted with errors (haxe.exe).");
            }
        }
コード例 #2
0
        protected override void DoBuild(string[] extraClasspaths, bool noTrace)
        {
            Environment.CurrentDirectory = project.Directory;

            string output    = project.FixDebugReleasePath(project.OutputPathAbsolute);
            string outputDir = Path.GetDirectoryName(project.OutputPathAbsolute);

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            string serverPort = Environment.ExpandEnvironmentVariables("%HAXE_SERVER_PORT%");
            string connect    = (!serverPort.StartsWith("%") && serverPort != "0")
                ? "--connect " + serverPort : "";

            if (project.MovieOptions.HasPlatformSupport && project.MovieOptions.PlatformSupport.ExternalToolchain != null)
            {
                Console.WriteLine("Automatic NME/OpenFL build by FDBuild is deprecated.");
                return;
            }

            // always use relative path for CPP (because it prepends ./)
            //if (project.IsCppOutput)
            //    output = project.FixDebugReleasePath(project.OutputPath);

            if (project.IsFlashOutput)
            {
                SwfmillLibraryBuilder libraryBuilder = new SwfmillLibraryBuilder();

                // before doing anything else, make sure any resources marked as "keep updated"
                // are properly kept up to date if possible
                libraryBuilder.KeepUpdated(project);

                // if we have any resources, build our library file and run swfmill on it
                libraryBuilder.BuildLibrarySwf(project, false);
            }

            string haxeArgs = connect + " " + String.Join(" ", project.BuildHXML(extraClasspaths, output, noTrace));

            Console.WriteLine("haxe " + haxeArgs);

            if (!ProcessRunner.Run(haxePath, haxeArgs, false, false))
            {
                throw new BuildException("Build halted with errors (haxe.exe).");
            }
        }
コード例 #3
0
        protected override void DoBuild(string[] extraClasspaths, bool noTrace)
        {
            Environment.CurrentDirectory = project.Directory;

            string outputDir = Path.GetDirectoryName(project.OutputPathAbsolute);

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            if (project.IsFlashOutput)
            {
                SwfmillLibraryBuilder libraryBuilder = new SwfmillLibraryBuilder();

                // before doing anything else, make sure any resources marked as "keep updated"
                // are properly kept up to date if possible
                libraryBuilder.KeepUpdated(project);

                // if we have any resources, build our library file and run swfmill on it
                libraryBuilder.BuildLibrarySwf(project, false);
            }

            string output = project.FixDebugReleasePath(project.OutputPathAbsolute);

            // always use relative path for CPP (because it prepends ./)
            if (project.IsCppOutput)
            {
                output = project.OutputPath;
            }

            string haxeArgs = String.Join(" ", project.BuildHXML(extraClasspaths, output, noTrace));

            Console.WriteLine("haxe " + haxeArgs);

            if (!ProcessRunner.Run(haxePath, haxeArgs, false))
            {
                throw new BuildException("Build halted with errors (haxe.exe).");
            }
        }
コード例 #4
0
        private void initProcess(bool completionMode)
        {
            // check haxe project & context
            if (PluginBase.CurrentProject == null || !(PluginBase.CurrentProject is HaxeProject) ||
                !(Context.Context is HaXeContext.Context))
            {
                return;
            }

            PluginBase.MainForm.CallCommand("SaveAllModified", null);

            HaxeProject hp = (PluginBase.CurrentProject as HaxeProject);

            // Current file
            string file = PluginBase.MainForm.CurrentDocument.FileName;

            // Locate carret position
            Int32 pos = position + 1; // sci.CurrentPos;

            // locate a . or (
            while (pos > 1 && sci.CharAt(pos - 1) != '.' && sci.CharAt(pos - 1) != '(')
            {
                pos--;
            }

            try
            {
                Byte[]     bom = new Byte[4];
                FileStream fs  = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);
                if (fs.CanSeek)
                {
                    fs.Read(bom, 0, 4);
                    fs.Close();
                    if (bom[0] == 0xef && bom[1] == 0xbb && bom[2] == 0xbf)
                    {
                        pos += 3; // Skip BOM
                    }
                }
            }
            catch {}

            // Build haXe command
            string[] paths = ProjectManager.PluginMain.Settings.GlobalClasspaths.ToArray();
            string   hxml  = String.Join(" ", hp.BuildHXML(paths, "__nothing__", true));

            // Get the current class edited (ensure completion even if class not reference in the project)
            int    start   = file.LastIndexOf("\\") + 1;
            int    end     = file.LastIndexOf(".");
            string package = Context.Context.CurrentModel.Package;

            if (package != "")
            {
                string cl       = Context.Context.CurrentModel.Package + "." + file.Substring(start, end - start);
                string libToAdd = file.Split(new string[] { "\\" + String.Join("\\", cl.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries)) }, StringSplitOptions.RemoveEmptyEntries).GetValue(0).ToString();
                hxml = hxml + " " + "-cp \"" + libToAdd + "\" " + cl;
            }
            else
            {
                hxml = hxml + " " + file.Substring(start, end - start);
            }

            // Build haXe built-in completion/check syntax command
            string args = completionMode
                ? "--display \"" + file + "\"@" + pos.ToString() + " " + hxml
                : "--no-output " + hxml;

            // compiler path
            string haxePath       = Environment.GetEnvironmentVariable("HAXEPATH");
            string customHaxePath = (Context.Context.Settings as HaXeSettings).HaXePath;

            if (customHaxePath != null && customHaxePath.Length > 0)
            {
                haxePath = PathHelper.ResolvePath(customHaxePath);
            }

            string process = Path.Combine(haxePath, "haxe.exe");

            if (!File.Exists(process))
            {
                ErrorManager.ShowInfo(String.Format(TextHelper.GetString("Info.HaXeExeError"), "\n"));
                p = null;
                return;
            }

            // Run haXe compiler
            p = new Process();
            p.StartInfo.FileName              = process;
            p.StartInfo.Arguments             = args;
            p.StartInfo.UseShellExecute       = false;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow        = true;
            p.StartInfo.WindowStyle           = ProcessWindowStyle.Hidden;
            p.StartInfo.WorkingDirectory      = hp.Directory;
            p.EnableRaisingEvents             = true;
        }
コード例 #5
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (hxsettings == null)
            {
                throw new Exception("BuildClassPath() must be overridden");
            }

            // external version definition
            // expected from project manager: "9;path;path..."
            flashVersion = hxsettings.DefaultFlashVersion;
            string exPath = externalClassPath ?? "";

            if (exPath.Length > 0)
            {
                try
                {
                    int p = exPath.IndexOf(';');
                    flashVersion = Convert.ToInt16(exPath.Substring(0, p));
                    exPath       = exPath.Substring(p + 1).Trim();
                }
                catch { }
            }

            // NOTE: version > 10 for non-Flash platforms
            string lang = null;

            features.Directives = new List <string>();
            if (IsJavaScriptTarget)
            {
                lang = "js";
                features.Directives.Add(lang);
            }
            else if (IsNekoTarget)
            {
                lang = "neko";
                features.Directives.Add(lang);
            }
            else if (IsPhpTarget)
            {
                lang = "php";
                features.Directives.Add(lang);
            }
            else if (IsCppTarget)
            {
                lang = "cpp";
                features.Directives.Add(lang);
            }
            else
            {
                features.Directives.Add("flash");
                features.Directives.Add("flash" + flashVersion);
                lang = (flashVersion >= 9) ? "flash9" : "flash";
            }
            features.Directives.Add("true");

            //
            // Class pathes
            //
            classPath = new List <PathModel>();
            // haXe std
            if (hxsettings.HaXePath != null)
            {
                string haxeCP = Path.Combine(hxsettings.HaXePath, "std");
                if (Directory.Exists(haxeCP))
                {
                    PathModel std = PathModel.GetModel(haxeCP, this);
                    if (!std.WasExplored && !Settings.LazyClasspathExploration)
                    {
                        PathExplorer stdExplorer = new PathExplorer(this, std);
                        stdExplorer.HideDirectories(new string[] { "flash", "flash9", "js", "neko", "php", "cpp" });
                        stdExplorer.OnExplorationDone += new PathExplorer.ExplorationDoneHandler(RefreshContextCache);
                        stdExplorer.Run();
                    }
                    AddPath(std);

                    PathModel specific = PathModel.GetModel(Path.Combine(haxeCP, lang), this);
                    if (!specific.WasExplored && !Settings.LazyClasspathExploration)
                    {
                        PathExplorer speExplorer = new PathExplorer(this, specific);
                        speExplorer.OnExplorationDone += new PathExplorer.ExplorationDoneHandler(RefreshContextCache);
                        speExplorer.Run();
                    }
                    AddPath(specific);
                }
            }
            HaxeProject proj = PluginBase.CurrentProject as HaxeProject;

            // swf-libs
            if (IsFlashTarget && flashVersion >= 9 && proj != null)
            {
                foreach (LibraryAsset asset in proj.LibraryAssets)
                {
                    if (asset.IsSwf)
                    {
                        string path = proj.GetAbsolutePath(asset.Path);
                        if (File.Exists(path))
                        {
                            AddPath(path);
                        }
                    }
                }
                foreach (string p in proj.CompilerOptions.Additional)
                {
                    if (p.IndexOf("-swf-lib ") == 0)
                    {
                        string path = proj.GetAbsolutePath(p.Substring(9));
                        if (File.Exists(path))
                        {
                            AddPath(path);
                        }
                    }
                }
            }

            // add haxe libraries
            if (proj != null)
            {
                foreach (string param in proj.BuildHXML(new string[0], "", false))
                {
                    if (param.IndexOf("-lib ") == 0)
                    {
                        AddPath(LookupLibrary(param.Substring(5)));
                    }
                }
            }


            // add external pathes
            List <PathModel> initCP = classPath;

            classPath = new List <PathModel>();
            string[] cpathes;
            if (exPath.Length > 0)
            {
                cpathes = exPath.Split(';');
                foreach (string cpath in cpathes)
                {
                    AddPath(cpath.Trim());
                }
            }
            // add user pathes from settings
            if (settings.UserClasspath != null && settings.UserClasspath.Length > 0)
            {
                foreach (string cpath in settings.UserClasspath)
                {
                    AddPath(cpath.Trim());
                }
            }
            // add initial pathes
            foreach (PathModel mpath in initCP)
            {
                AddPath(mpath);
            }

            // parse top-level elements
            InitTopLevelElements();
            if (cFile != null)
            {
                UpdateTopLevelElements();
            }

            // add current temporaty path
            if (temporaryPath != null)
            {
                string tempPath = temporaryPath;
                temporaryPath = null;
                SetTemporaryPath(tempPath);
            }
            FinalizeClasspath();
        }