Exemple #1
0
        private void ReadDependeciesForAllTasks()
        {
            using (StreamReader sr = new StreamReader(makefileName))
            {
                bool alreadyReadLine = false;
                string line = "";
                while (alreadyReadLine || (line = sr.ReadLine()) != null)
                {
                    alreadyReadLine = false;

                    TaskParser parser = new TaskParser(line);
                    string target = parser.GetTarget();

                    if (firstTaskIsInitial)
                    {
                        initialTask = target;
                        firstTaskIsInitial = false;
                    }

                    if (taskToDescription.ContainsKey(target))
                    {
                        throw new BuildSystemException(String.Format("Task \"{0}\" declaration occurs more than one time.", target));
                    }

                    Task task = new Task(parser.GetDependenciesList());
                    taskToDescription.Add(target, task);
                    while ((line = sr.ReadLine()) != null) // skip actions
                    {
                        if (line.Length == 0)
                        {
                            continue; // blank line are expected
                        }

                        if (line[0] != ' ' && line[0] != '\t')
                        {
                            alreadyReadLine = true; // found not an action
                            break;
                        }
                    }
                }

                if (initialTask == null)
                {
                    throw new BuildSystemException(String.Format("File \"{0}\" is empty.", makefileName));
                }
            }
        }
Exemple #2
0
        private void ReadActionsForTasksFromDependencyTree()
        {
            using (StreamReader sr = new StreamReader(makefileName))
            {
                bool alreadyReadLine = false;
                string line = "";
                while (alreadyReadLine || (line = sr.ReadLine()) != null)
                {
                    alreadyReadLine = false;

                    TaskParser parser = new TaskParser(line);
                    string target = parser.GetTarget();
                    if (taskToNode.ContainsKey(target))
                    {
                        taskToDescription[target].Actions = ReadActionsForTask(sr, out line);
                        if (line != null)
                        {
                            alreadyReadLine = true;
                        }
                    }
                    else // skip actions
                    {
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.Length == 0)
                            {
                                continue;
                            }

                            if (line[0] != ' ' && line[0] != '\t')
                            {
                                alreadyReadLine = true;
                                break;
                            }
                        }
                    }
                }
            }
        }