Esempio n. 1
0
        public Program.RuleForFunction GetRule(Expression fname, out string wc_pattern)
        {
            Expression.EvalResult e = fname.Evaluate(this);
            if (e.Type != Expression.EvalResult.ResultType.String)
            {
                throw new Exception("build expects a string argument");
            }

            string f = e.strval;

            return(GetRule(f, out wc_pattern));
        }
Esempio n. 2
0
            private void FlattenToString(Expression.EvalResult er, List <string> ret, MakeState s)
            {
                switch (er.Type)
                {
                case Expression.EvalResult.ResultType.String:
                    ret.Add(er.strval);
                    break;

                case Expression.EvalResult.ResultType.Array:
                    foreach (Expression.EvalResult ea in er.arrval)
                    {
                        FlattenToString(ea, ret, s);
                    }
                    break;

                default:
                    throw new NotSupportedException();
                }
            }
Esempio n. 3
0
        public override Expression.EvalResult Run(MakeState s, List <Expression.EvalResult> args)
        {
            string fname     = args[0].strval;
            string config    = args[1].strval;
            string tools_ver = args[2].strval;
            bool   do_unsafe = (args[3].intval == 0) ? false : true;

            string cur_dir = Environment.CurrentDirectory;

            System.IO.FileInfo fi = new System.IO.FileInfo(fname);
            if (!fi.Exists)
            {
                throw new Exception("_typroject: " + fname + " does not exist");
            }

            /* Extract out imports */
            List <string> imports = new List <string>();

            foreach (var import in args[4].arrval)
            {
                imports.Add(import.strval);
            }

            /* Extract out ref overrides */
            List <string> ref_overrides = new List <string>();

            foreach (var ro in args[5].arrval)
            {
                ref_overrides.Add(ro.strval);
            }


            typroject.Project p = null;
            if (fname.ToLower().EndsWith(".csproj"))
            {
                p = typroject.Project.xml_read(fi.OpenRead(), config, fi.DirectoryName, cur_dir, imports, ref_overrides);
            }
            else if (fname.ToLower().EndsWith(".sources"))
            {
                p = typroject.Project.sources_read(fi.OpenRead(), config, fi.DirectoryName, cur_dir);
            }

            if (args[6].strval != "")
            {
                p.lib_dir = args[6].strval;
            }

            Dictionary <string, Expression.EvalResult> ret = new Dictionary <string, Expression.EvalResult>();

            ret["OutputFile"]        = new Expression.EvalResult(p.OutputFile);
            ret["OutputType"]        = new Expression.EvalResult(p.output_type.ToString());
            ret["AssemblyName"]      = new Expression.EvalResult(p.assembly_name);
            ret["Configuration"]     = new Expression.EvalResult(p.configuration);
            ret["Defines"]           = new Expression.EvalResult(p.defines);
            ret["Sources"]           = new Expression.EvalResult(p.Sources);
            ret["Resources"]         = new Expression.EvalResult(p.Resources);
            ret["GACReferences"]     = new Expression.EvalResult(p.References);
            ret["ProjectReferences"] = new Expression.EvalResult(new string[] { });
            foreach (typroject.Project pref in p.ProjectReferences)
            {
                ret["ProjectReferences"].arrval.Add(new Expression.EvalResult(pref.ProjectFile));
            }
            ret["References"] = new Expression.EvalResult(new string[] { });
            foreach (var rref in p.References)
            {
                ret["References"].arrval.Add(new Expression.EvalResult(rref));
            }
            ret["ProjectFile"] = new Expression.EvalResult(fi.FullName);
            ret["ProjectName"] = new Expression.EvalResult(p.ProjectName);

            BuildFunction build = new BuildFunction(p);

            ret[build.Mangle()] = new Expression.EvalResult(build);

            if (do_unsafe)
            {
                build.do_unsafe = true;
            }
            if (tools_ver != "")
            {
                p.tools_ver = tools_ver;
            }

            return(new Expression.EvalResult(ret));
        }