Ejemplo n.º 1
0
        private SamSettings BuildSamSettings(String serialized)
        {
            Regex           argsRe = new Regex("([^&=]+)=([^&]+)", RegexOptions.Compiled);
            MatchCollection mc     = argsRe.Matches(serialized);
            int             c      = mc.Count;
            Match           m;
            SamSettings     settings = new SamSettings();
            GroupCollection gc;

            for (int i = 0; i < c; i++)
            {
                m  = mc[i];
                gc = m.Groups;
                switch (gc[1].Value)
                {
                case "-c":
                case "--config":
                    settings.Config = gc[2].Value;
                    break;

                case "-d":
                case "--depfile":
                    settings.Depfile = gc[2].Value;
                    break;

                case "output":
                    settings.Output = gc[2].Value;
                    break;
                }
            }
            return(settings);
        }
Ejemplo n.º 2
0
        public void SaveConfigFiles()
        {
            String folder   = this.GetConfigFilesStorageFolder();
            String fullName = Path.Combine(folder, STORAGE_FILE_NAME);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            using (StreamWriter file = new StreamWriter(fullName))
            {
                foreach (String line in this.configFilesList)
                {
                    if (this.buildSettings.ContainsKey(line))
                    {
                        SamSettings s        = this.buildSettings[line];
                        String      fullLine = line;
                        fullLine += '?';
                        if (!String.IsNullOrEmpty(s.Config))
                        {
                            fullLine += "-c=" + s.Config;
                        }
                        if (!String.IsNullOrEmpty(s.Depfile))
                        {
                            if (fullLine.EndsWith("?"))
                            {
                                fullLine += "-d=" + s.Config;
                            }
                            else
                            {
                                fullLine += "&-d=" + s.Config;
                            }
                        }
                        if (!String.IsNullOrEmpty(s.Output))
                        {
                            if (fullLine.EndsWith("?"))
                            {
                                fullLine += "output=" + s.Output;
                            }
                            else
                            {
                                fullLine += "&output=" + s.Output;
                            }
                        }
                        if (fullLine.EndsWith("?"))
                        {
                            fullLine = fullLine.Substring(0, fullLine.Length - 1);
                        }
                        file.WriteLine(fullLine);
                    }
                }
                file.Close();
            }
        }
Ejemplo n.º 3
0
        public SamSettings SettingsForPath(String path)
        {
            if (this.buildSettings.ContainsKey(path))
            {
                return(this.buildSettings[path]);
            }
            SamSettings s = new SamSettings();

            s.Input = path;
            this.buildSettings[path] = s;
            return(s);
        }
Ejemplo n.º 4
0
        private void ReadConfigFiles()
        {
            if (this.configFilesList == null)
            {
                this.configFilesList = new List <String>();
            }
            else
            {
                this.configFilesList.Clear();
            }
            String folder   = GetConfigFilesStorageFolder();
            String fullName = Path.Combine(folder, STORAGE_FILE_NAME);

            this.buildSettings = new Dictionary <String, SamSettings>();
            Char argsSeparator = '?';

            String[] parts;

            if (File.Exists(fullName))
            {
                using (StreamReader file = new StreamReader(fullName))
                {
                    String line;
                    String argsLine = null;
                    while ((line = file.ReadLine()) != null)
                    {
                        if (line.IndexOf(argsSeparator) > -1)
                        {
                            parts = line.Split(new Char[1] {
                                argsSeparator
                            });
                            line     = parts[0];
                            argsLine = parts[1];
                        }
                        if (line.Length > 0 && !this.configFilesList.Contains(line))
                        {
                            this.configFilesList.Add(line);
                            if (!String.IsNullOrEmpty(argsLine))
                            {
                                SamSettings s = this.BuildSamSettings(argsLine);
                                s.Input = line;
                                this.buildSettings[line] = s;
                            }
                        }
                    }
                    file.Close();
                }
            }
        }
Ejemplo n.º 5
0
        public void RunTarget(String file, SamSettings settings)
        {
            String command = this.settingObject.SamHome;

            // TODO: Put this into resources
            if (String.IsNullOrEmpty(command) || !File.Exists(command))
            {
                MessageBox.Show(
                    LocaleHelper.GetErrorString(LocaleHelper.NO_SAM_HOME));
                return;
            }
            if (settings == null || String.IsNullOrEmpty(settings.Output))
            {
                MessageBox.Show(
                    LocaleHelper.GetErrorString(LocaleHelper.NO_OUTPUT_FILE));
                return;
            }
            String arguments = "";

            //Usage: SamHaXe [options] <resources.xml> <assets.swf>
            //options:
            //-c <config file name>, --config <config file name>
            //       If given, config is read from the specified file.
            //-d <file name>, --depfile <file name>
            //       If given, resource dependecies will be written into the specified file.
            //-h, --help
            //       Display this help message.
            //-l, --module-list
            //       List all import modules with a short description.
            //-m module:key=value[:key=value:...], --module-options module:key=value[:key=value:...]
            //       The specified options are passed to the specified import module. (Exaple: Binary:myopt=somevalue)
            //--module-help module[=interface_version[;flash_version]][:module[=interface_version[;flash_version]]...]
            //       Prints help message of listed modules.
            if (!String.IsNullOrEmpty(settings.Config))
            {
                arguments += "-c \"" + settings.Config + "\" ";
            }
            if (!String.IsNullOrEmpty(settings.Depfile))
            {
                arguments += "-d \"" + settings.Depfile + "\" ";
            }
            arguments += "\"" + settings.Input + "\" \"" + settings.Output + "\"";

            Globals.MainForm.CallCommand("RunProcessCaptured", command + ";" + arguments);
        }
Ejemplo n.º 6
0
 public void UpdateSettings(String path, SamSettings setting)
 {
     this.buildSettings[path] = setting;
 }