Example #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);
                }
            }
Example #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);
        }
Example #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;
	}
Example #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;
        }
Example #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;
	}
	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;
	}
Example #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;
	}
Example #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));
        }
Example #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);
        }
Example #10
0
 internal WrenchTarget(WrenchProvider wp, string name, short id) : base(wp)
 {
     this.name = name;
     this.id   = id;
 }
Example #11
0
 public override bool Initialize(WrenchProvider wp, IWarningLogger log, Queue children)
 {
     wp.NameContext = nlc;
     return(false);
 }
Example #12
0
 public abstract bool Initialize(WrenchProvider wp, IWarningLogger log, Queue children);
        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);
        }
Example #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);
	    }
Example #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);
	}
Example #16
0
	public override bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children)
	{
	    wp.NameContext = nlc;
	    return false;
	}
Example #17
0
	public abstract bool Initialize (WrenchProvider wp, IWarningLogger log, Queue children);
Example #18
0
	internal WrenchTarget (WrenchProvider wp, string name, short id) : base (wp) 
	{
	    this.name = name;
	    this.id = id;
	}