Ejemplo n.º 1
0
            public ProvData(WrenchProvider pb)
            {
                this.pb = pb;

                int ntarg = pb.NumTargets;

                dep_chunk_len  = 0;
                name_chunk_len = 0;

                dep_offsets  = new int[ntarg];
                name_offsets = new int[ntarg];

                targids = new Dictionary <int, WrenchTarget> ();
                int nseen = 0;

                foreach (WrenchTarget tb in pb.DefinedTargets)
                {
                    targids[tb.ShortId] = tb;
                    nseen++;
                }

                if (nseen != ntarg)
                {
                    throw ExHelp.App("Report NumTargets ({0}) for provider {1} not number " +
                                     "actually seen ({2})", ntarg, pb.Basis, nseen);
                }
            }
Ejemplo n.º 2
0
        public override bool Initialize(WrenchProvider wp, IWarningLogger log, Queue children)
        {
            bool ret = false;

            ret |= wp.DefineConstantTarget("name", new MBString(pinfo.Name), log);
            ret |= wp.DefineConstantTarget("version", new MBString(pinfo.Version), log);
            ret |= wp.DefineConstantTarget("compat_code", new MBString(pinfo.CompatCode), log);
            ret |= wp.DefineConstantTarget("compat-code", new MBString(pinfo.CompatCode), log);

            return(ret);
        }
Ejemplo n.º 3
0
	public override bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children)
	{
	    bool ret = false;

	    ret |= wp.DefineConstantTarget ("name", new MBString (pinfo.Name), log);
	    ret |= wp.DefineConstantTarget ("version", new MBString (pinfo.Version), log);
	    ret |= wp.DefineConstantTarget ("compat_code", new MBString (pinfo.CompatCode), log);
	    ret |= wp.DefineConstantTarget ("compat-code", new MBString (pinfo.CompatCode), log);

	    return ret;
	}
Ejemplo n.º 4
0
        public BuildfileParser(StreamReader reader, string topsrc, string resource_subdir,
                               string location_base, WrenchProvider wp, IWarningLogger log)
        {
            lexer = new BuildfileTokenizer(reader);

            this.topsrc          = topsrc;
            this.resource_subdir = resource_subdir;
            this.location_base   = location_base;
            this.wp  = wp;
            this.log = log;

            cur_nlc = wp.NameContext;
        }
Ejemplo n.º 5
0
	public BuildfileParser (StreamReader reader, string topsrc, string resource_subdir, 
				string location_base, WrenchProvider wp, IWarningLogger log)
	{
	    lexer = new BuildfileTokenizer (reader);

	    this.topsrc = topsrc;
	    this.resource_subdir = resource_subdir;
	    this.location_base = location_base;
	    this.wp = wp;
	    this.log = log;

	    cur_nlc = wp.NameContext;
	}
Ejemplo n.º 6
0
	public override bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children)
	{
	    bool is_top = (basis == "/");

	    string topsrc = ss.PathToSourceRelative ("");
	    string file = ss.PathToSourceRelative (srcrel);

	    BuildfileParser parser = BuildfileParser.CreateForFile (topsrc, srcrel, wp, log);

	    if (parser.Parse () > 0)
		// Parse errors
		return true;

	    // FIXME: tell the parser whether a project[] section is OK and have
	    // it signal the error. That way we get line info.

	    if (!is_top && parser.PInfo != null) {
		log.Error (2006, "Found a project[] directive in a non-toplevel buildfile", file);
		return true;
	    } else if (is_top && parser.PInfo == null) {
		log.Error (2006, "Toplevel buildfile did not have a project[] directive", file);
		return true;
	    }

	    if (is_top) {
		// kinda ugly.
		parser.PInfo.BuildfileName = Path.GetFileName (srcrel);

		if (((GraphBuilder) wp.Owner).SetProjectInfo (parser.PInfo, log))
		    return true;

		children.Enqueue (new ProjectProviderLoader (parser.PInfo));
	    }

	    foreach (string sub in parser.Subdirs)
		children.Enqueue (new BuildfileProviderLoader (basis + sub, ss));

	    foreach (BuildfileParser.InsideInfo ii in parser.Insides) {
		foreach (string s in ii.Bases)
		    children.Enqueue (new InsideProviderLoader (basis + s, ii.Context));
	    }

	    if (parser.ManualLoads != null) {
		foreach (string k in parser.ManualLoads.Keys) {
		    string srel = (string) parser.ManualLoads[k];
		    children.Enqueue (new BuildfileProviderLoader (basis + k, DeclarationLoc, ss, srel));
		}
	    }
	    
	    return false;
	}
Ejemplo n.º 7
0
	public static BuildfileParser CreateForFile (string topsrc, string srcrel,
						     WrenchProvider wp, IWarningLogger log)
	{
	    string file = Path.Combine (topsrc, srcrel);
	    string resdir = Path.GetDirectoryName (srcrel);

	    if (resdir.Length == 0)
		resdir = ".";

	    FileStream fs = new FileStream (file, FileMode.Open, FileAccess.Read);
	    BufferedStream bs = new BufferedStream (fs);
	    StreamReader reader = new StreamReader (bs);

	    BuildfileParser p = new BuildfileParser (reader, topsrc, resdir, 
						     file, wp, log);
	    p.AddResourceFile (Path.GetFileName (srcrel));

	    return p;
	}
Ejemplo n.º 8
0
        public BuildfileLoader LoadChildProvider(WrenchProject proj, string basis,
                                                 string subbasis, out bool pub)
        {
            // well, this is just a pain in the ass

            string path;
            string file;

            if (parser.ManualLoads != null)
            {
                if (parser.ManualLoads.Contains(subbasis))
                {
                    string me = basis.Substring(0, basis.Length - subbasis.Length);
                    path = proj.PathToBasisSource(me);
                    file = Path.Combine(path, (string)parser.ManualLoads[subbasis]);

                    pub = true;
                    return(LoadChildFile(file, proj));
                }
            }

            pub = false;

            if (parser.InsideNameContext != null)
            {
                for (int i = 0; i < parser.WhereInside.Length; i++)
                {
                    if (subbasis == parser.WhereInside[i])
                    {
                        WrenchProvider wp = new WrenchProvider();
                        wp.NameContext = (NameLookupContext)parser.InsideNameContext.Clone();
                        return(wp);
                    }
                }
            }

            path = proj.PathToBasisSource(basis);
            file = Path.Combine(path, proj.Info.BuildfileName);

            return(LoadChildFile(file, proj));
        }
Ejemplo n.º 9
0
        public static BuildfileParser CreateForFile(string topsrc, string srcrel,
                                                    WrenchProvider wp, IWarningLogger log)
        {
            string file   = Path.Combine(topsrc, srcrel);
            string resdir = Path.GetDirectoryName(srcrel);

            if (resdir.Length == 0)
            {
                resdir = ".";
            }

            FileStream     fs     = new FileStream(file, FileMode.Open, FileAccess.Read);
            BufferedStream bs     = new BufferedStream(fs);
            StreamReader   reader = new StreamReader(bs);

            BuildfileParser p = new BuildfileParser(reader, topsrc, resdir,
                                                    file, wp, log);

            p.AddResourceFile(Path.GetFileName(srcrel));

            return(p);
        }
Ejemplo n.º 10
0
 internal WrenchTarget(WrenchProvider wp, string name, short id) : base(wp)
 {
     this.name = name;
     this.id   = id;
 }
Ejemplo n.º 11
0
 public override bool Initialize(WrenchProvider wp, IWarningLogger log, Queue children)
 {
     wp.NameContext = nlc;
     return(false);
 }
Ejemplo n.º 12
0
 public abstract bool Initialize(WrenchProvider wp, IWarningLogger log, Queue children);
Ejemplo n.º 13
0
        public override bool Initialize(WrenchProvider wp, IWarningLogger log, Queue children)
        {
            bool is_top = (basis == "/");

            string topsrc = ss.PathToSourceRelative("");
            string file   = ss.PathToSourceRelative(srcrel);

            BuildfileParser parser = BuildfileParser.CreateForFile(topsrc, srcrel, wp, log);

            if (parser.Parse() > 0)
            {
                // Parse errors
                return(true);
            }

            // FIXME: tell the parser whether a project[] section is OK and have
            // it signal the error. That way we get line info.

            if (!is_top && parser.PInfo != null)
            {
                log.Error(2006, "Found a project[] directive in a non-toplevel buildfile", file);
                return(true);
            }
            else if (is_top && parser.PInfo == null)
            {
                log.Error(2006, "Toplevel buildfile did not have a project[] directive", file);
                return(true);
            }

            if (is_top)
            {
                // kinda ugly.
                parser.PInfo.BuildfileName = Path.GetFileName(srcrel);

                if (((GraphBuilder)wp.Owner).SetProjectInfo(parser.PInfo, log))
                {
                    return(true);
                }

                children.Enqueue(new ProjectProviderLoader(parser.PInfo));
            }

            foreach (string sub in parser.Subdirs)
            {
                children.Enqueue(new BuildfileProviderLoader(basis + sub, ss));
            }

            foreach (BuildfileParser.InsideInfo ii in parser.Insides)
            {
                foreach (string s in ii.Bases)
                {
                    children.Enqueue(new InsideProviderLoader(basis + s, ii.Context));
                }
            }

            if (parser.ManualLoads != null)
            {
                foreach (string k in parser.ManualLoads.Keys)
                {
                    string srel = (string)parser.ManualLoads[k];
                    children.Enqueue(new BuildfileProviderLoader(basis + k, DeclarationLoc, ss, srel));
                }
            }

            return(false);
        }
Ejemplo n.º 14
0
	    public ProvData (WrenchProvider pb)
	    {
		this.pb = pb;

		int ntarg = pb.NumTargets;

		dep_chunk_len = 0;
		name_chunk_len = 0;

		dep_offsets = new int[ntarg];
		name_offsets = new int[ntarg];

		targids = new Dictionary<int,WrenchTarget> ();
		int nseen = 0;

		foreach (WrenchTarget tb in pb.DefinedTargets) {
		    targids[tb.ShortId] = tb;
		    nseen++;
		}

		if (nseen != ntarg)
		    throw ExHelp.App ("Report NumTargets ({0}) for provider {1} not number " +
				      "actually seen ({2})", ntarg, pb.Basis, nseen);
	    }
Ejemplo n.º 15
0
	public BuildfileLoader LoadChildProvider (WrenchProject proj, string basis, 
						  string subbasis, out bool pub) {
	    // well, this is just a pain in the ass
	    
	    string path;
	    string file;
	    
	    if (parser.ManualLoads != null) {
		if (parser.ManualLoads.Contains (subbasis)) {
		    string me = basis.Substring (0, basis.Length - subbasis.Length);
		    path = proj.PathToBasisSource (me);
		    file = Path.Combine (path, (string) parser.ManualLoads[subbasis]);
		    
		    pub = true;
		    return LoadChildFile (file, proj);
		}
	    }
	    
	    pub = false;
	    
	    if (parser.InsideNameContext != null) {
		for (int i = 0; i < parser.WhereInside.Length; i++) {
		    if (subbasis == parser.WhereInside[i]) {
			WrenchProvider wp = new WrenchProvider ();
			wp.NameContext = (NameLookupContext) parser.InsideNameContext.Clone ();
			return wp;
		    }
		}
	    }
	    
	    path = proj.PathToBasisSource (basis);
	    file = Path.Combine (path, proj.Info.BuildfileName);
	    
	    return LoadChildFile (file, proj);
	}
Ejemplo n.º 16
0
	public override bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children)
	{
	    wp.NameContext = nlc;
	    return false;
	}
Ejemplo n.º 17
0
	public abstract bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children);
Ejemplo n.º 18
0
	internal WrenchTarget (WrenchProvider wp, string name, short id) : base (wp) 
	{
	    this.name = name;
	    this.id = id;
	}