Exemple #1
0
        public void BuildCommandLine()
        {
            //List<String> args = new List<String>();
            //try
            //{
            Logger.Debug("ProjectOptions: BuildCommandLine");
            List <string> options = new List <string>();

            options.Add("dialect:" + _prjNode.GetProjectProperty("Dialect"));
            var asmNodes = new List <XSharpAssemblyReferenceNode>();

            _prjNode.FindNodesOfType(asmNodes);
            foreach (var asmNode in asmNodes)
            {
                options.Add("r:" + asmNode.Url);
            }
            var prjNodes = new List <XSharpProjectReferenceNode>();

            _prjNode.FindNodesOfType(prjNodes);
            foreach (var prjNode in prjNodes)
            {
                var path = prjNode.ReferencedProjectOutputPath;
                if (!string.IsNullOrEmpty(path))
                {
                    options.Add("r:" + path);
                }
            }
            var comNodes = new List <XSharpComReferenceNode>();

            _prjNode.FindNodesOfType(comNodes);
            foreach (var comNode in comNodes)
            {
                options.Add("r:" + comNode.Url);
            }

            var defines = "";
            var value   = "";

            if (DefinedPreprocessorSymbols != null)
            {
                foreach (var d in DefinedPreprocessorSymbols)
                {
                    defines = defines + d + ";";
                }
            }
            options.Add("d:" + defines);
            var include = _prjNode.GetProjectProperty("IncludePaths");

            if (!String.IsNullOrEmpty(include))
            {
                include = include + ";" + _includedirs;
            }
            else
            {
                include = _includedirs;
            }
            options.Add("i:" + include);
            options.Add("ns:" + _prjNode.GetProjectProperty("RootNamespace"));
            var flags = new string[] { "vo1", "vo2", "vo3", "vo4", "vo5", "vo6", "vo7", "vo8", "vo9",
                                       "vo10", "vo11", "vo12", "vo13", "vo14", "vo15", "vo16",
                                       "cs", "az", "ins", "lb", "memvar", "namedargs", "undeclared", "unsafe", "xpp1", "xpp2", "fox1",
                                       "allowdot", "enforceself", "enforcevirtual" };

            foreach (var flag in flags)
            {
                value = _prjNode.GetProjectProperty(flag);
                if (value != null && value.ToLower() == "true")
                {
                    options.Add(flag + "+");
                }
                else
                {
                    options.Add(flag + "-");
                }
            }
            value = _prjNode.GetProjectProperty("StandardDefs");
            if (value != null && value.Trim().Length > 0)
            {
                options.Add("stddefs:" + value);
            }
            value = _prjNode.GetProjectProperty("NoStandardDefs");
            if (value != null && value.ToLower() == "true")
            {
                options.Add("nostddefs+");
            }
            else
            {
                options.Add("nostddefs-");
            }

            ParseOptions = XSharpParseOptions.FromVsValues(options);
            if (this.ConfigCanonicalName != null && ConfigCanonicalName.ConfigName.ToUpper() == "DEBUG")
            {
                // dirty trick to set property with private setter
                PropertyInfo pi = ParseOptions.GetType().GetProperty("DebugEnabled");
                if (pi != null)
                {
                    pi.SetValue(ParseOptions, true);
                }
            }
            _prjNode.ProjectModel.ResetParseOptions(ParseOptions);
            var self = _prjNode.GetProjectProperty(XSharpProjectFileConstants.EnforceSelf);

            _prjNode.EnforceSelf = self?.ToLower() == "true";
        }
Exemple #2
0
        public void BuildCommandLine()
        {
            //List<String> args = new List<String>();
            //try
            //{
            var dialect    = _prjNode.GetProjectProperty("Dialect");
            var references = new List <string>();
            var asmNodes   = new List <XSharpAssemblyReferenceNode>();

            _prjNode.FindNodesOfType <XSharpAssemblyReferenceNode>(asmNodes);
            foreach (var asmNode in asmNodes)
            {
                references.Add(asmNode.Url);
            }
            var prjNodes = new List <XSharpProjectReferenceNode>();

            _prjNode.FindNodesOfType <XSharpProjectReferenceNode>(prjNodes);
            foreach (var prjNode in prjNodes)
            {
                references.Add(prjNode.ReferencedProjectOutputPath);
            }
            var comNodes = new List <XSharpComReferenceNode>();

            _prjNode.FindNodesOfType <XSharpComReferenceNode>(comNodes);
            foreach (var comNode in comNodes)
            {
                references.Add(comNode.Url);
            }

            var defines = new List <string>();

            foreach (var d in DefinedPreprocessorSymbols)
            {
                defines.Add(d);
            }
            var include = _prjNode.GetProjectProperty("IncludePaths");

            if (!String.IsNullOrEmpty(include))
            {
                include = include + ";" + _includedirs;
            }
            else
            {
                include = _includedirs;
            }
            ParseOptions = XSharpParseOptions.FromVsValues(defines, include, references, dialect);

            /*
             * args.Add("/dialect:" + _prjNode.GetProjectProperty("Dialect"));
             * // Add pseudo references so the Vulcan/VO dialect will be allowed
             * args.Add("/errorendlocation");
             * args.Add("/r:vulcanrt.dll");
             * args.Add("/r:vulcanrtfuncs.dll");
             * if (String.Equals(ConfigCanonicalName.ConfigName, "DEBUG", StringComparison.OrdinalIgnoreCase))
             * {
             *  args.Add("/debug:full");
             * }
             * var tmp = "";
             *
             * foreach (var d in DefinedPreprocessorSymbols)
             * {
             *  tmp += ";" + d;
             * }
             * if (tmp.Length > 0)
             * {
             *  args.Add("/d:" + tmp.Substring(1));
             * }
             * tmp = _prjNode.GetProjectProperty("DisabledWarnings");
             * if (tmp?.Length > 0)
             * {
             *  tmp = tmp.Replace(",", ";");
             *  args.Add("/warningaserror-:" + tmp);
             * }
             * args.Add("/warn:" + WarningLevel.ToString());
             * for (int i = 1; i < 16; i++)
             * {
             *  var sw = "vo" + i.ToString();
             *  tmp = _prjNode.GetProjectProperty(sw);
             *  if (!String.IsNullOrEmpty(tmp))
             *  {
             *      args.Add("/"+sw+  (tmp.ToLower() == "true" ? "+" : "-"));
             *  }
             * }
             * var include = _prjNode.GetProjectProperty("IncludePaths");
             * if (!String.IsNullOrEmpty(include))
             * {
             *  include = include + ";" + _includedirs;
             * }
             * else
             *  include = _includedirs;
             * args.Add("/i:" + include);
             * tmp = _prjNode.GetProjectProperty("NoStandardDefs");
             * if (!String.IsNullOrEmpty(tmp) && tmp.ToLower() == "true")
             *  args.Add("/nostddefs");
             *
             * tmp = _prjNode.GetProjectProperty("INS");
             * if (!String.IsNullOrEmpty(tmp) && tmp.ToLower() == "true")
             *  args.Add("/ins");
             *
             * if (this.TreatWarningsAsErrors)
             *  args.Add("/warnaserror");
             */
            //}
            //finally
            //{
            //    if (args.Count > 0)
            //    {
            //        var cmdlineargs = xsCmdLineparser.Parse(args.ToArray(), null, null, null);
            //        ParseOptions = cmdlineargs.ParseOptions;
            //    }
            //    else
            //    {
            //        var cmdlineargs = xsCmdLineparser.Parse(new string[0], null, null, null);
            //        ParseOptions = cmdlineargs.ParseOptions;

            //    }
            //    //ParseOptions.ParseLevel = ParseLevel.Parse;
            //}
        }