Exemplo n.º 1
0
    // Assumption: filename already exists and is already verified to be a file
    public static void LoadFile(MetabuildProject metabuild, String filename)
    {
        Console.WriteLine("[DEBUG] Metabuild.LoadFile \"{0}\"", filename);
        String relativeDir = null;

        using (LfdTextReader reader = new LfdTextReader(new StreamReader(new FileStream(
                                                                             filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))))
        {
            LfdParser parser = new LfdParser(reader, filename);
            LfdLine   line   = parser.reader.ReadLineIgnoreComments();
            for (; ;)
            {
                if (line == null)
                {
                    return;
                }

                if (line.id == "Import")
                {
                    parser.errors.EnforceFieldCount(line, 1);
                    MetabuildUnit.LoadDirOrFile(metabuild, line.fields[0]);
                    line = parser.reader.ReadLineIgnoreComments();
                }
                else if (line.id == "CSharpProject")
                {
                    if (relativeDir == null)
                    {
                        relativeDir = Path.GetDirectoryName(filename);
                    }
                    line = CSharpProject.Parse(metabuild, parser, line, false, relativeDir);
                }
                else if (line.id == "CSharpTestProject")
                {
                    if (relativeDir == null)
                    {
                        relativeDir = Path.GetDirectoryName(filename);
                    }
                    line = CSharpProject.Parse(metabuild, parser, line, true, relativeDir);
                }
                else if (line.id == "GeneratePathPrefix")
                {
                    parser.errors.EnforceFieldCount(line, 1);
                    if (metabuild.generatePathPrefix != null)
                    {
                        throw parser.errors.Error(line, "GeneratePathPrefix was set more than once");
                    }
                    metabuild.generatePathPrefix = line.fields[0];
                    line = parser.reader.ReadLineIgnoreComments();
                }
                else
                {
                    throw parser.errors.Error(line, "unknown directive '{0}'", line.id);
                }
            }
        }
    }
Exemplo n.º 2
0
    private MetabuildProject(String projectDir, String projectFile)
    {
        this.projectDir           = projectDir;
        this.projectFile          = projectFile;
        this.unresolvedReferences = new List <IUnresolvedReference>();
        MetabuildUnit.LoadFile(this, projectFile);
        List <IUnresolvedReference> saveUnresolvedReferences = this.unresolvedReferences;

        this.unresolvedReferences = null;

        UInt32 resolveFailCount = 0;

        foreach (IUnresolvedReference reference in saveUnresolvedReferences)
        {
            if (!reference.Resolve(this))
            {
                resolveFailCount++;
            }
        }
        if (resolveFailCount > 0)
        {
            throw new ProjectLoadException(String.Format("{0} unresolved reference(s)", resolveFailCount));
        }
    }