コード例 #1
0
 public BuildSystem(IProject project, bool CreateDefaults)
 {
     if (project == null)
     {
         throw new ArgumentNullException();
     }
     if (CreateDefaults)
     {
         BuildConfig debug   = new BuildConfig(project, "Debug");
         BuildConfig release = new BuildConfig(project, "Release");
         buildConfigs.Add(debug);
         buildConfigs.Add(release);
     }
     Project = project;
 }
コード例 #2
0
        /// <summary>
        /// Builds the build system according to the BuildConfig
        /// </summary>
        /// <returns></returns>
        public bool Build()
        {
            if (_buildConfigs.Count < 1 || _currentConfigIndex == -1)
            {
                throw new MissingConfigException("Missing config");
            }

            _isBuilding = true;
            BuildConfig config    = _buildConfigs[_currentConfigIndex];
            bool        succeeded = config.Build(_project);

            _outputText = config.OutputText;
            _isBuilding = false;
            return(succeeded);
        }
コード例 #3
0
        public void ReadXML(XmlTextReader reader)
        {
            reader.MoveToNextElement();
            if (reader.Name != "BuildSystem")
            {
                throw new ArgumentException("Invalid XML Format");
            }
            string[] includeDirs = reader.GetAttribute("IncludeDirs").Split(';');
            foreach (string include in includeDirs)
            {
                if (!string.IsNullOrEmpty(include))
                {
                    this.Project.IncludeDirs.Add(include);
                }
            }
            while (reader.MoveToNextElement())
            {
                string      configName  = reader.Name;
                BuildConfig configToAdd = new BuildConfig(Project, configName);
                buildConfigs.Add(configToAdd);
                if (reader.IsEmptyElement)
                {
                    continue;
                }
                reader.MoveToNextElement();
                int    count     = Convert.ToInt32(reader.GetAttribute("Count"));
                string inputFile = reader.GetAttribute("InputFile");
                switch (reader.Name)
                {
                case "ExternalBuildStep":
                    string            arguments = reader.GetAttribute("Arguments");
                    ExternalBuildStep exstep    = new ExternalBuildStep(Project, count, inputFile, arguments);
                    configToAdd.Steps.Add(exstep);
                    break;

                case "InternalBuildStep":
                    string            outputFile = reader.GetAttribute("OutputFile");
                    StepType          type       = (StepType)Convert.ToInt16(reader.GetAttribute("StepType"));
                    InternalBuildStep instep     = new InternalBuildStep(Project, count, type, inputFile, outputFile);
                    configToAdd.Steps.Add(instep);
                    break;

                default:
                    throw new ArgumentException("Invalid XML Format");
                }
            }
        }
コード例 #4
0
        public override bool Equals(object obj)
        {
            if (!(obj is BuildConfig))
            {
                return(false);
            }
            BuildConfig config = (BuildConfig)obj;

            if (config.name == this.name && config.steps.Count == this.steps.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
        public void ReadXML(XmlTextReader reader)
        {
            FilePath root = _project.ProjectDirectory;

            if (reader.Name != "BuildSystem")
            {
                throw new ArgumentException("Invalid XML Format");
            }

            var attribute = reader.GetAttribute("IncludeDirs");

            if (attribute != null)
            {
                string[] includeDirs = attribute.Split(';');
                foreach (string include in includeDirs.Where(include => !string.IsNullOrEmpty(include)))
                {
                    string path = Uri.UnescapeDataString(new Uri(Path.Combine(root, include)).AbsolutePath);
                    _project.IncludeDirs.Add(new FilePath(path));
                }
            }

            BuildConfig configToAdd = null;

            while (reader.MoveToNextElement())
            {
                if (reader.Name.Contains("Step"))
                {
                    if (configToAdd == null)
                    {
                        throw new ArgumentException("Invalid XML Format");
                    }

                    int    count     = Convert.ToInt32(reader.GetAttribute("StepNum"));
                    string inputFile = reader.GetAttribute("InputFile");
                    switch (reader.Name)
                    {
                    case "ExternalBuildStep":
                        string arguments = reader.GetAttribute("Arguments");
                        if (inputFile != null)
                        {
                            ExternalBuildStep exstep = new ExternalBuildStep(
                                count,
                                root.Combine(inputFile),
                                arguments);
                            configToAdd.AddStep(exstep);
                        }
                        break;

                    case "InternalBuildStep":
                        string        outputFile = reader.GetAttribute("OutputFile");
                        BuildStepType type       = (BuildStepType)Convert.ToInt16(reader.GetAttribute("StepType"));
                        if (inputFile != null && outputFile != null)
                        {
                            InternalBuildStep instep = new InternalBuildStep(
                                count,
                                type,
                                root.Combine(inputFile),
                                root.Combine(outputFile));
                            configToAdd.AddStep(instep);
                        }
                        break;

                    default:
                        throw new ArgumentException("Invalid XML Format");
                    }
                }
                else
                {
                    string configName = reader.Name;
                    configToAdd = new BuildConfig(configName);
                    _buildConfigs.Add(configToAdd);
                }
            }
        }
コード例 #6
0
 private bool Equals(BuildConfig other)
 {
     return(string.Equals(Name, other.Name) && Equals(_steps, other._steps));
 }