Пример #1
0
        public static HaxeProject Load(string path)
        {
            string ext = Path.GetExtension(path).ToLower();

            if (ext == ".hxml")
            {
                HaxeProject hxproj = new HaxeProject(path);
                hxproj.RawHXML = File.ReadAllLines(path);
                return(hxproj);
            }
            else if (ext == ".nmml")
            {
                HaxeProject hxproj = new HaxeProject(path);
                hxproj.MovieOptions.Platform = HaxeMovieOptions.NME_PLATFORM;
                hxproj.OutputType            = OutputType.Application;
                hxproj.OutputPath            = hxproj.GetRelativePath(path);
                return(hxproj);
            }

            HaxeProjectReader reader = new HaxeProjectReader(path);

            try
            {
                return(reader.ReadProject());
            }
            catch (System.Xml.XmlException exception)
            {
                string format = string.Format("Error in XML Document line {0}, position {1}.",
                                              exception.LineNumber, exception.LinePosition);
                throw new Exception(format, exception);
            }
            finally { reader.Close(); }
        }
Пример #2
0
        public static HaxeProject Load(string path)
        {
            string ext = Path.GetExtension(path).ToLower();

            if (ext == ".hxml")
            {
                HaxeProject hxproj = new HaxeProject(path);
                hxproj.RawHXML = File.ReadAllLines(path);
                return(hxproj);
            }

            HaxeProjectReader reader = new HaxeProjectReader(path);

            try
            {
                return(reader.ReadProject());
            }
            catch (XmlException exception)
            {
                string format = string.Format("Error in XML Document line {0}, position {1}.",
                                              exception.LineNumber, exception.LinePosition);
                throw new Exception(format, exception);
            }
            finally { reader.Close(); }
        }
Пример #3
0
        public HaxeProjectBuilder(HaxeProject project, string compilerPath)
            : base(project, compilerPath)
        {
            this.project = project;

            string basePath = compilerPath ?? @"C:\Motion-Twin\haxe"; // default installation
            haxePath = Path.Combine(basePath, "haxe.exe");
            if (!File.Exists(haxePath)) 
                haxePath = "haxe.exe"; // hope you have it in your environment path!
        }
Пример #4
0
        /// <summary>
        /// Watch NME projects to update the configuration & HXML command using 'nme display'
        /// </summary>
        /// <param name="project"></param>
        public static void Monitor(IProject project)
        {
            if (updater == null)
            {
                updater = new System.Timers.Timer();
                updater.Interval = 200;
                updater.SynchronizingObject = PluginCore.PluginBase.MainForm as System.Windows.Forms.Form;
                updater.Elapsed += updater_Elapsed;
                updater.AutoReset = false;
            }

            hxproj = null;
            StopWatcher();

            if (project is HaxeProject)
            {
                hxproj = project as HaxeProject;
                hxproj.ProjectUpdating += new ProjectUpdatingHandler(hxproj_ProjectUpdating);
                hxproj_ProjectUpdating(hxproj);
            }
        }
Пример #5
0
 /// <summary>
 /// Determines if we're using NME or OpenFL
 /// </summary>
 /// <param name="project"></param>
 /// <returns></returns>
 static public string GetBuilder(HaxeProject project)
 {
     return(GetBuilder(project.OutputPathAbsolute));
 }
Пример #6
0
        public string[] BuildHXML(string[] paths, string outfile, bool release)
        {
            List <String> pr = new List <String>();

            if (rawHXML != null)
            {
                pr.AddRange(rawHXML);
            }
            else
            {
                // SWC libraries
                if (IsFlashOutput)
                {
                    foreach (LibraryAsset asset in LibraryAssets)
                    {
                        if (asset.IsSwc)
                        {
                            pr.Add("-swf-lib " + asset.Path);
                        }
                    }
                }

                // libraries
                foreach (string lib in CompilerOptions.Libraries)
                {
                    if (lib.Length > 0)
                    {
                        if (lib.Trim().StartsWith("-lib"))
                        {
                            pr.Add(lib);
                        }
                        else
                        {
                            pr.Add("-lib " + lib);
                        }
                    }
                }

                // class paths
                List <String> classPaths = new List <String>();
                foreach (string cp in paths)
                {
                    classPaths.Add(cp);
                }
                foreach (string cp in this.Classpaths)
                {
                    classPaths.Add(cp);
                }
                foreach (string cp in classPaths)
                {
                    String ccp = String.Join("/", cp.Split('\\'));
                    pr.Add("-cp " + Quote(ccp));
                }

                // compilation mode
                string mode = null;
                if (IsFlashOutput)
                {
                    mode = "swf";
                }
                else if (IsJavacriptOutput)
                {
                    mode = "js";
                }
                else if (IsNekoOutput)
                {
                    mode = "neko";
                }
                else if (IsPhpOutput)
                {
                    mode = "php";
                }
                else if (IsCppOutput)
                {
                    mode = "cpp";
                }
                else if (IsCSharpOutput)
                {
                    mode = "cs";
                }
                else if (IsJavaOutput)
                {
                    mode = "java";
                }
                //else throw new SystemException("Unknown mode");

                if (mode != null)
                {
                    outfile = String.Join("/", outfile.Split('\\'));
                    pr.Add("-" + mode + " " + Quote(outfile));
                }

                // nme options

                /*if (IsNmeOutput)
                 * {
                 *  pr.Add("--remap flash:nme");
                 * }*/

                // flash options
                if (IsFlashOutput)
                {
                    string htmlColor = this.MovieOptions.Background.Substring(1);

                    if (htmlColor.Length > 0)
                    {
                        htmlColor = ":" + htmlColor;
                    }

                    pr.Add("-swf-header " + string.Format("{0}:{1}:{2}{3}", MovieOptions.Width, MovieOptions.Height, MovieOptions.Fps, htmlColor));

                    if (!UsesInjection && LibraryAssets.Count > 0)
                    {
                        pr.Add("-swf-lib " + Quote(LibrarySWFPath));
                    }

                    if (CompilerOptions.FlashStrict)
                    {
                        pr.Add("--flash-strict");
                    }

                    // convert Flash version to haxe supported parameter
                    string param        = null;
                    int    majorVersion = MovieOptions.MajorVersion;
                    int    minorVersion = MovieOptions.MinorVersion;

                    if (MovieOptions.Platform == HaxeMovieOptions.AIR_PLATFORM ||
                        MovieOptions.Platform == HaxeMovieOptions.AIR_MOBILE_PLATFORM)
                    {
                        PlatformData.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);
                    }
                    if (movieOptions.Platform == HaxeMovieOptions.NME_PLATFORM)
                    {
                        HaxeProject.GuessFlashPlayerForNME(ref majorVersion, ref minorVersion);
                    }

                    if (majorVersion >= 10)
                    {
                        if (minorVersion > 0)
                        {
                            param = majorVersion + "." + minorVersion;
                        }
                        else
                        {
                            param = "" + majorVersion;
                        }
                    }
                    else
                    {
                        param = "" + majorVersion;
                    }
                    if (param != null)
                    {
                        pr.Add("-swf-version " + param);
                    }
                }

                // defines
                foreach (string def in CompilerOptions.Directives)
                {
                    pr.Add("-D " + Quote(def));
                }

                // add project files marked as "always compile"
                foreach (string relTarget in CompileTargets)
                {
                    string absTarget = GetAbsolutePath(relTarget);
                    // guess the class name from the file name
                    foreach (string cp in classPaths)
                    {
                        if (absTarget.StartsWith(cp, StringComparison.OrdinalIgnoreCase))
                        {
                            string className = GetClassName(absTarget, cp);
                            if (CompilerOptions.MainClass != className)
                            {
                                pr.Add(className);
                            }
                        }
                    }
                }

                // add main class
                if (CompilerOptions.MainClass != null && CompilerOptions.MainClass.Length > 0)
                {
                    pr.Add("-main " + CompilerOptions.MainClass);
                }

                // extra options
                foreach (string opt in CompilerOptions.Additional)
                {
                    String p = opt.Trim();
                    if (p == "" || p[0] == '#')
                    {
                        continue;
                    }
                    char[]   space = { ' ' };
                    string[] parts = p.Split(space, 2);
                    if (parts.Length == 1)
                    {
                        pr.Add(p);
                    }
                    else
                    {
                        pr.Add(parts[0] + ' ' + Quote(parts[1]));
                    }
                }
            }

            // debug
            if (!release)
            {
                pr.Insert(0, "-debug");
                if (CurrentSDK == null || CurrentSDK.IndexOf("Motion-Twin") < 0)
                {
                    pr.Insert(1, "--each");
                }
                if (IsFlashOutput && MovieOptions.DebuggerSupported && CompilerOptions.EnableDebug)
                {
                    pr.Insert(1, "-D fdb");
                    if (CompilerOptions.NoInlineOnDebug)
                    {
                        pr.Insert(2, "--no-inline");
                    }
                }
            }
            return(pr.ToArray());
        }
Пример #7
0
        public static HaxeProject Load(string path)
        {
            string ext = Path.GetExtension(path).ToLower();
            if (ext == ".hxml")
            {
                HaxeProject hxproj = new HaxeProject(path);
                hxproj.RawHXML = File.ReadAllLines(path);
                return hxproj;
            }
            else if (ext == ".nmml")
            {
                HaxeProject hxproj = new HaxeProject(path);
                hxproj.MovieOptions.Platform = HaxeMovieOptions.NME_PLATFORM;
                hxproj.OutputType = OutputType.Application;
                hxproj.OutputPath = hxproj.GetRelativePath(path);
                return hxproj;
            }

            HaxeProjectReader reader = new HaxeProjectReader(path);

            try
            {
                return reader.ReadProject();
            }
            catch (System.Xml.XmlException exception)
            {
                string format = string.Format("Error in XML Document line {0}, position {1}.",
                    exception.LineNumber, exception.LinePosition);
                throw new Exception(format, exception);
            }
            finally { reader.Close(); }
        }
Пример #8
0
 /// <summary>
 /// Determines if we're using NME or OpenFL
 /// </summary>
 /// <param name="project"></param>
 /// <returns></returns>
 static public string GetBuilder(HaxeProject project)
 {
     return GetBuilder(project.OutputPathAbsolute);
 }
Пример #9
0
        public static HaxeProject Load(string path)
        {
            string ext = Path.GetExtension(path).ToLower();
            if (ext == ".hxml")
            {
                HaxeProject hxproj = new HaxeProject(path);
                hxproj.RawHXML = File.ReadAllLines(path);
                return hxproj;
            }

            HaxeProjectReader reader = new HaxeProjectReader(path);

            try
            {
                return reader.ReadProject();
            }
            catch (XmlException exception)
            {
                string format = string.Format("Error in XML Document line {0}, position {1}.",
                    exception.LineNumber, exception.LinePosition);
                throw new Exception(format, exception);
            }
            finally { reader.Close(); }
        }
Пример #10
0
 public HaxeProjectReader(string filename)
     : base(filename, new HaxeProject(filename))
 {
     this.project = base.Project as HaxeProject;
 }
Пример #11
0
 public HaxeProjectReader(string filename)
     : base(filename, new HaxeProject(filename))
 {
     this.project = base.Project as HaxeProject;
 }
Пример #12
0
        private void storeOrigDocumentClass(HaxeProject project)
        {
            string origMain = project.CompilerOptions.MainClass.Replace(".", "\\");
            string projectPath = Path.GetDirectoryName(project.ProjectPath);

            foreach (string cp in project.AbsoluteClasspaths)
            {
                if (File.Exists(Path.Combine(cp, origMain + ".hx")))
                {
                    this.origDocumentPath = Path.Combine(cp, origMain + ".hx");
                    break;
                }
            }
        }
Пример #13
0
 public HaxeProjectWriter(HaxeProject project, string filename)
     : base(project, filename)
 {
     this.project = base.Project as HaxeProject;
 }
 static string GetCommand(HaxeProject project, string name, bool processArguments)
 {
     var platform = project.MovieOptions.PlatformSupport;
     var version = platform.GetVersion(project.MovieOptions.Version);
     if (version.Commands == null)
     {
         throw new Exception(String.Format("No external commands found for target {0} and version {1}",
             project.MovieOptions.Platform, project.MovieOptions.Version));
     }
     if (version.Commands.ContainsKey(name))
     {
         var cmd = version.Commands[name].Value;
         if (platform.ExternalToolchain == "haxelib") cmd = "run " + cmd;
         else if (platform.ExternalToolchain == "cmd") cmd = "/c " + cmd;
         
         if (!processArguments) return cmd;
         else return PluginBase.MainForm.ProcessArgString(cmd);
     }
     else return null;
 }
 /// <summary>
 /// Get build/run/clean commands
 /// </summary>
 static string GetCommand(HaxeProject project, string name)
 {
     return GetCommand(project, name, true);
 }
Пример #16
0
 public HaxeProjectWriter(HaxeProject project, string filename)
     : base(project, filename)
 {
     this.project = base.Project as HaxeProject;
 }