コード例 #1
0
        /// <summary>
        /// Generates the switches for switches that either have literal strings appended, or have
        /// different switches based on what the property is set to.
        /// </summary>
        /// <remarks>The string switch emits a switch that depends on what the parameter is set to, with and
        /// arguments
        /// e.g., Optimization = "Full" will emit /Ox, whereas Optimization = "Disabled" will emit /Od</remarks>
        /// <param name="clb"></param>
        /// <param name="toolSwitch"></param>
        private void EmitStringSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
        {
            String strSwitch = String.Empty;

            strSwitch += toolSwitch.SwitchValue + toolSwitch.Separator;

            StringBuilder val = new StringBuilder(GetEffectiveArgumentsValues(toolSwitch));
            String        str = toolSwitch.Value;

            if (!toolSwitch.MultiValues)
            {
                str.Trim();

                if (!str.StartsWith("\""))
                {
                    str = "\"" + str;
                    if (str.EndsWith("\\") && !str.EndsWith("\\\\"))
                    {
                        str += "\\\"";
                    }
                    else
                    {
                        str += "\"";
                    }
                }
                val.Insert(0, str);
            }

            if ((strSwitch.Length == 0) && (val.ToString().Length == 0))
            {
                return;
            }

            clb.AppendSwitchUnquotedIfNotNull(strSwitch, val.ToString());
        }
コード例 #2
0
 /// <summary>
 /// Emit a switch that's a scalar task item
 /// </summary>
 private static void EmitTaskItemSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (!String.IsNullOrEmpty(toolSwitch.Name))
     {
         clb.AppendSwitch(toolSwitch.Name + toolSwitch.Separator);
     }
 }
コード例 #3
0
        /// <summary>
        /// Generates the commands for the switches that may have an array of arguments
        /// The switch may be empty.
        /// </summary>
        /// <remarks>For stringarray switches (e.g., Sources), the toolSwitchName (if it exists) is emitted
        /// along with each and every one of the file names separately (if no separator is included), or with all of the
        /// file names separated by the separator.
        /// e.g., AdditionalIncludeDirectores = "@(Files)" where Files has File1, File2, and File3, the switch
        /// /IFile1 /IFile2 /IFile3 or the switch /IFile1;File2;File3 is emitted (the latter case has a separator
        /// ";" specified)</remarks>
        /// <param name="clb"></param>
        /// <param name="toolSwitch"></param>
        private static void EmitStringArraySwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
        {
            string[] ArrTrimStringList = new string [toolSwitch.StringList.Length];
            for (int i = 0; i < toolSwitch.StringList.Length; ++i)
            {
                //Make sure the file doesn't contain escaped " (\")
                if (toolSwitch.StringList[i].StartsWith("\"") && toolSwitch.StringList[i].EndsWith("\""))
                {
                    ArrTrimStringList[i] = toolSwitch.StringList[i].Substring(1, toolSwitch.StringList[i].Length - 2);
                }
                else
                {
                    ArrTrimStringList[i] = toolSwitch.StringList[i];
                }
            }

            if (String.IsNullOrEmpty(toolSwitch.Separator))
            {
                foreach (string fileName in ArrTrimStringList)
                {
                    clb.AppendSwitchIfNotNull(toolSwitch.SwitchValue, fileName);
                }
            }
            else
            {
                clb.AppendSwitchIfNotNull(toolSwitch.SwitchValue, ArrTrimStringList, toolSwitch.Separator);
            }
        }
コード例 #4
0
        /// <summary>
        /// Checks to see if the argument is required and whether an argument exists, and returns the
        /// argument or else fallback argument if it exists.
        ///
        /// These are the conditions to look at:
        ///
        /// ArgumentRequired    ArgumentParameter   FallbackArgumentParameter   Result
        /// true                isSet               NA                          The value in ArgumentParameter gets returned
        /// true                isNotSet            isSet                       The value in FallbackArgumentParamter gets returned
        /// true                isNotSet            isNotSet                    An error occurs, as argumentrequired is true
        /// false               isSet               NA                          The value in ArgumentParameter gets returned
        /// false               isNotSet            isSet                       The value in FallbackArgumentParameter gets returned
        /// false               isNotSet            isNotSet                    The empty string is returned, as there are no arguments, and no arguments are required
        /// </summary>
        /// <param name="toolSwitch"></param>
        /// <returns></returns>
        protected virtual string GetEffectiveArgumentsValues(ToolSwitch toolSwitch)
        {
            //if (!toolSwitch.ArgumentRequired && !IsPropertySet(toolSwitch.ArgumentParameter) &&
            //    !IsPropertySet(toolSwitch.FallbackArgumentParameter))
            //{
            //    return String.Empty;
            //}

            //// check to see if it has an argument
            //if (toolSwitch.ArgumentRequired)
            //{
            //    if (!IsPropertySet(toolSwitch.ArgumentParameter) && !IsPropertySet(toolSwitch.FallbackArgumentParameter))
            //    {
            //        throw new ArgumentException(logPrivate.FormatResourceString("ArgumentRequired", toolSwitch.Name));
            //    }
            //}
            //// if it gets to here, the argument or the fallback is set
            //if (IsPropertySet(toolSwitch.ArgumentParameter))
            //{
            //    return ActiveToolSwitches[toolSwitch.ArgumentParameter].ArgumentValue;
            //}
            //else
            //{
            //    return ActiveToolSwitches[toolSwitch.FallbackArgumentParameter].ArgumentValue;
            //}
            return("GetEffectiveArgumentValue not Impl");
        }
コード例 #5
0
 /// <summary>
 /// Appends the directory name to the end of a switch
 /// Ensure the name ends with a slash
 /// </summary>
 /// <remarks>For directory switches (e.g., TrackerLogDirectory), the toolSwitchName (if it exists) is emitted
 /// along with the FileName which is ensured to have a trailing slash</remarks>
 /// <param name="clb"></param>
 /// <param name="toolSwitch"></param>
 private static void EmitDirectorySwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (!String.IsNullOrEmpty(toolSwitch.SwitchValue))
     {
         //clb.AppendSwitchIfNotNull(toolSwitch.Name + toolSwitch.Separator, EnsureTrailingSlash(toolSwitch.ArgumentValue));
         clb.AppendSwitch(toolSwitch.SwitchValue + toolSwitch.Separator);
     }
 }
コード例 #6
0
ファイル: llvm.cs プロジェクト: Matway/mpl-vs-template
 protected override void PostProcessSwitchList()
 {
     ToolExe = InputFiles[0].GetMetadata("CompilerPath");
     ActiveToolSwitches["OutputFile"] = new ToolSwitch(ToolSwitchType.File)
     {
         SwitchValue = "-o ", Value = InputFiles[0].GetMetadata("OutputFile")
     };
     AdditionalOptions = InputFiles[0].GetMetadata("AdditionalOptions");
 }
コード例 #7
0
ファイル: User.cs プロジェクト: personDevelop/sdfc
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);

            if (this.ContextMenuStrip == null || !this.ContextMenuStrip.Visible)
            {
                this.mouseOn    = false;
                this.BackColor  = Color.White;
                this.toolSwitch = ToolSwitch.Null;
            }
        }
コード例 #8
0
        /// <summary>
        /// Generates a part of the command line depending on the type
        /// </summary>
        /// <remarks>Depending on the type of the switch, the switch is emitted with the proper values appended.
        /// e.g., File switches will append file names, directory switches will append filenames with "\" on the end</remarks>
        /// <param name="clb"></param>
        /// <param name="toolSwitch"></param>
        protected void GenerateCommandsAccordingToType(CommandLineBuilder clb, ToolSwitch toolSwitch, bool bRecursive)
        {
            // if this property has a parent skip printing it as it was printed as part of the parent prop printing
            if (toolSwitch.Parents.Count > 0 && !bRecursive)
            {
                return;
            }

            switch (toolSwitch.Type)
            {
            case ToolSwitchType.Boolean:
                EmitBooleanSwitch(clb, toolSwitch);
                break;

            case ToolSwitchType.String:
                EmitStringSwitch(clb, toolSwitch);
                break;

            case ToolSwitchType.StringArray:
                EmitStringArraySwitch(clb, toolSwitch);
                break;

            case ToolSwitchType.Integer:
                EmitIntegerSwitch(clb, toolSwitch);
                break;

            case ToolSwitchType.File:
                EmitFileSwitch(clb, toolSwitch);
                break;

            case ToolSwitchType.Directory:
                EmitDirectorySwitch(clb, toolSwitch);
                break;

            case ToolSwitchType.ITaskItem:
                EmitTaskItemSwitch(clb, toolSwitch);
                break;

            case ToolSwitchType.ITaskItemArray:
                EmitTaskItemArraySwitch(clb, toolSwitch);
                break;

            case ToolSwitchType.AlwaysAppend:
                EmitAlwaysAppendSwitch(clb, toolSwitch);
                break;

            default:
                // should never reach this point - if it does, there's a bug somewhere.
                ErrorUtilities.VerifyThrow(false, "InternalError");
                break;
            }
        }
コード例 #9
0
 /// <summary>
 /// Generates the commands for switches that have integers appended.
 /// </summary>
 /// <remarks>For integer switches (e.g., WarningLevel), the toolSwitchName is emitted
 /// with the appropriate integer appended, as well as any arguments
 /// e.g., WarningLevel = "4" will emit /W4</remarks>
 /// <param name="clb"></param>
 /// <param name="toolSwitch"></param>
 private void EmitIntegerSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (toolSwitch.IsValid)
     {
         if (!String.IsNullOrEmpty(toolSwitch.Separator))
         {
             clb.AppendSwitch(toolSwitch.SwitchValue + toolSwitch.Separator + toolSwitch.Number.ToString() + GetEffectiveArgumentsValues(toolSwitch));
         }
         else
         {
             clb.AppendSwitch(toolSwitch.SwitchValue + toolSwitch.Number.ToString() + GetEffectiveArgumentsValues(toolSwitch));
         }
     }
 }
コード例 #10
0
 /// <summary>
 /// Emit a switch that's an array of task items
 /// </summary>
 private static void EmitTaskItemArraySwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (String.IsNullOrEmpty(toolSwitch.Separator))
     {
         foreach (ITaskItem itemName in toolSwitch.TaskItemArray)
         {
             clb.AppendSwitchIfNotNull(toolSwitch.SwitchValue, itemName.ItemSpec);
         }
     }
     else
     {
         clb.AppendSwitchIfNotNull(toolSwitch.SwitchValue, toolSwitch.TaskItemArray, toolSwitch.Separator);
     }
 }
コード例 #11
0
ファイル: User.cs プロジェクト: personDevelop/sdfc
        protected override void OnContextMenuStripChanged(EventArgs e)
        {
            base.OnContextMenuStripChanged(e);

            if (this.ContextMenuStrip != null)
            {
                this.ContextMenuStrip.Closed += delegate
                {
                    this.mouseOn    = false;
                    this.BackColor  = Color.White;
                    this.toolSwitch = ToolSwitch.Null;
                }
            }
            ;
        }
コード例 #12
0
 /// <summary>
 /// Generates the command line for switches that are reversible
 /// </summary>
 /// <remarks>A reversible boolean switch will emit a certain switch if set to true, but emit that
 /// exact same switch with a flag appended on the end if set to false.
 /// e.g., GlobalOptimizations = "true" will emit /Og, and GlobalOptimizations = "false" will emit /Og-</remarks>
 /// <param name="clb"></param>
 /// <param name="toolSwitch"></param>
 private void EmitReversibleBooleanSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     // if the value is set to true, append whatever the TrueSuffix is set to.
     // Otherwise, append whatever the FalseSuffix is set to.
     if (!String.IsNullOrEmpty(toolSwitch.ReverseSwitchValue))
     {
         string        suffix = (toolSwitch.BooleanValue) ? toolSwitch.TrueSuffix : toolSwitch.FalseSuffix;
         StringBuilder val    = new StringBuilder(GetEffectiveArgumentsValues(toolSwitch));
         val.Insert(0, suffix);
         val.Insert(0, toolSwitch.Separator);
         val.Insert(0, toolSwitch.TrueSuffix);
         val.Insert(0, toolSwitch.ReverseSwitchValue);
         clb.AppendSwitch(val.ToString());
     }
 }
コード例 #13
0
ファイル: User.cs プロジェクト: personDevelop/sdfc
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (e.Button == MouseButtons.Left && this.beginDrop)
            {
                if (Math.Abs(e.X - this.dropX) > 20 || Math.Abs(e.Y - this.dropY) > 20)
                {
                    this.DoDragDrop(this, DragDropEffects.Move);
                }
                return;
            }

            if (e.X < this.Height + 2 || e.Y < this.Height - 20 || this.toolList == null || e.X > this.Height + 2 + (20 * this.toolList.Count))//不在工具栏区域
            {
                if (this.toolSwitch != ToolSwitch.Null)
                {
                    this.toolSwitch = ToolSwitch.Null;
                    this.Invalidate();
                }
                return;
            }

            if (e.X >= this.Height + 2 && e.X <= this.Height + 2 + 13)
            {
                this.toolSwitch = this.toolList[0];
            }
            else if (e.X >= this.Height + 2 + 20 && e.X <= this.Height + 2 + 20 + 13)
            {
                this.toolSwitch = this.toolList[1];
            }
            else if (e.X >= this.Height + 2 + 40 && e.X <= this.Height + 2 + 40 + 13 && this.toolList.Count > 2)
            {
                this.toolSwitch = this.toolList[2];
            }
            else if (e.X > this.Height + 2 + 60 && e.X <= this.Height + 2 + 60 + 13 && this.toolList.Count > 3)
            {
                this.toolSwitch = this.toolList[3];
            }
            else
            {
                this.toolSwitch = ToolSwitch.Null;
            }

            this.Invalidate();
        }
コード例 #14
0
        protected string GenerateResponseFileCommandsExceptSwitches(string[] switchesToRemove)
        {
            this.AddDefaultsToActiveSwitchList();
            this.AddFallbacksToActiveSwitchList();
            this.PostProcessSwitchList();
            CommandLineBuilder clb = new CommandLineBuilder(true);

            if (SwitchOrderList != null)
            {
                foreach (string str in this.SwitchOrderList)
                {
                    if (this.IsPropertySet(str))
                    {
                        ToolSwitch property = this.ActiveToolSwitches[str];
                        if (!this.VerifyDependenciesArePresent(property) || !this.VerifyRequiredArgumentsArePresent(property, false))
                        {
                            continue;
                        }
                        bool flag = true;
                        if (switchesToRemove != null)
                        {
                            foreach (string str2 in switchesToRemove)
                            {
                                if (str.Equals(str2, StringComparison.OrdinalIgnoreCase))
                                {
                                    flag = false;
                                    break;
                                }
                            }
                        }
                        if (flag)
                        {
                            this.GenerateCommandsAccordingToType(clb, property, false);
                        }
                        continue;
                    }
                    if (string.Equals(str, "AlwaysAppend", StringComparison.OrdinalIgnoreCase))
                    {
                        clb.AppendSwitch(this.AlwaysAppend);
                    }
                }
            }
            this.BuildAdditionalArgs(clb);
            return(clb.ToString());
        }
コード例 #15
0
 /// <summary>
 /// Generates the switches that are nonreversible
 /// </summary>
 /// <remarks>A boolean switch is emitted if it is set to true. If it set to false, nothing is emitted.
 /// e.g. nologo = "true" will emit /Og, but nologo = "false" will emit nothing.</remarks>
 /// <param name="clb"></param>
 /// <param name="toolSwitch"></param>
 private void EmitBooleanSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (toolSwitch.BooleanValue)
     {
         if (!String.IsNullOrEmpty(toolSwitch.SwitchValue))
         {
             StringBuilder val = new StringBuilder(GetEffectiveArgumentsValues(toolSwitch));
             val.Insert(0, toolSwitch.Separator);
             val.Insert(0, toolSwitch.TrueSuffix);
             val.Insert(0, toolSwitch.SwitchValue);
             clb.AppendSwitch(val.ToString());
         }
     }
     else
     {
         EmitReversibleBooleanSwitch(clb, toolSwitch);
     }
 }
コード例 #16
0
                protected void setPropertyString(string propertyName, string value, string switchName)
                {
                    ActiveToolSwitches.Remove(propertyName);

                    var s = new ToolSwitch(ToolSwitchType.String)
                    {
                        DisplayName          = propertyName,
                        Description          = propertyName,
                        ArgumentRelationList = new ArrayList(),
                        Value       = value,
                        Required    = true,
                        SwitchValue = switchName,
                        Separator   = " "
                    };

                    ActiveToolSwitches.Add(propertyName, s);
                    AddActiveSwitchToolValue(s);
                }
コード例 #17
0
                private void setPropertyTaskItem(string propertyName, ITaskItem value, string switchName)
                {
                    ActiveToolSwitches.Remove(propertyName);

                    var s = new ToolSwitch(ToolSwitchType.ITaskItem)
                    {
                        DisplayName          = propertyName,
                        Description          = propertyName,
                        ArgumentRelationList = new ArrayList(),
                        TaskItem             = value,
                        Required             = true,
                        SwitchValue          = switchName,
                        Separator            = " "
                    };

                    ActiveToolSwitches.Add(propertyName, s);
                    AddActiveSwitchToolValue(s);
                }
コード例 #18
0
ファイル: CompileD.cs プロジェクト: bleskodev/visuald
        private void SetFileProperty(string name,
                                     string displayName,
                                     string description,
                                     string switchValue,
                                     string value)
        {
            base.ActiveToolSwitches.Remove(name);
            ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.File);

            toolSwitch.DisplayName          = displayName;
            toolSwitch.Description          = description;
            toolSwitch.ArgumentRelationList = new ArrayList();
            toolSwitch.SwitchValue          = switchValue;
            toolSwitch.Name  = name;
            toolSwitch.Value = value;
            base.ActiveToolSwitches.Add(name, toolSwitch);
            base.AddActiveSwitchToolValue(toolSwitch);
        }
コード例 #19
0
ファイル: CompileD.cs プロジェクト: bleskodev/visuald
        private void SetDirectoryProperty(string name,
                                          string displayName,
                                          string description,
                                          string switchValue,
                                          string value)
        {
            base.ActiveToolSwitches.Remove(name);
            ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.Directory);

            toolSwitch.DisplayName          = displayName;
            toolSwitch.Description          = description;
            toolSwitch.ArgumentRelationList = new ArrayList();
            toolSwitch.SwitchValue          = switchValue;
            toolSwitch.Name  = name;
            toolSwitch.Value = VCToolTask.EnsureTrailingSlash(value);
            base.ActiveToolSwitches.Add(name, toolSwitch);
            base.AddActiveSwitchToolValue(toolSwitch);
        }
コード例 #20
0
ファイル: CompileD.cs プロジェクト: qmutz/visuald
        // IToolSwitchProvider
        public void SetProperty(string name, string displayName, string description, string switchValue,
                                DToolSwitchType dtype, object value,
                                bool multipleValues = false, bool required = false, string separator = null)
        {
            var type = (ToolSwitchType)dtype;

            if (dtype == DToolSwitchType.StringPathArray)
            {
                type = GetToolSwitchTypeForStringPathArray();
            }

            base.ActiveToolSwitches.Remove(name);
            ToolSwitch toolSwitch = new ToolSwitch(type);

            toolSwitch.DisplayName = displayName;
            toolSwitch.Description = description;
            toolSwitch.SwitchValue = switchValue;
            toolSwitch.Name        = name;

            switch (type)
            {
            case ToolSwitchType.Boolean: toolSwitch.BooleanValue = (bool)value; break;

            case ToolSwitchType.Integer: toolSwitch.Number = (int)value; break;

            case ToolSwitchType.File:
            case ToolSwitchType.Directory:
            case ToolSwitchType.String: toolSwitch.Value = (string)value; break;

            case (ToolSwitchType)9 /*ToolSwitchType.StringPathArray*/:
            case ToolSwitchType.StringArray: toolSwitch.StringList = (string[])value; break;

            case ToolSwitchType.ITaskItem: toolSwitch.TaskItem = (ITaskItem)value; break;

            case ToolSwitchType.ITaskItemArray: toolSwitch.TaskItemArray = (ITaskItem[])value; break;
            }

            toolSwitch.MultipleValues = multipleValues;
            toolSwitch.Required       = required;
            toolSwitch.Separator      = separator;
            base.ActiveToolSwitches.Add(name, toolSwitch);
            AddActiveSwitchToolValue(toolSwitch);
        }
コード例 #21
0
ファイル: CompileD.cs プロジェクト: bleskodev/visuald
        private void SetEnumProperty(string name,
                                     string displayName,
                                     string description,
                                     string[][] switchMap,
                                     string value)
        {
            base.ActiveToolSwitches.Remove(name);
            ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.String);

            toolSwitch.DisplayName          = displayName;
            toolSwitch.Description          = description;
            toolSwitch.ArgumentRelationList = new ArrayList();
            toolSwitch.SwitchValue          = base.ReadSwitchMap(name, switchMap, value);
            toolSwitch.Name           = name;
            toolSwitch.Value          = value;
            toolSwitch.MultipleValues = true;
            base.ActiveToolSwitches.Add(name, toolSwitch);
            base.AddActiveSwitchToolValue(toolSwitch);
        }
コード例 #22
0
    public void ToolInitialization()
    {
        ToolSwitch DoorOpen = new ToolSwitch()
        {
            triggerName = "Close",
            active      = true
        };
        ToolSwitch DoorClose = new ToolSwitch()
        {
            triggerName = "Open",
            active      = false
        };

        tSwitch = new List <ToolSwitch>
        {
            DoorOpen,
            DoorClose
        };
        SetStatus(status);
    }
コード例 #23
0
    // Use this for initialization
    public void ToolInitialization()
    {
        //status = 0;
        ToolSwitch lightOn = new ToolSwitch()
        {
            triggerName = "Light On",
            active      = true
        };
        ToolSwitch lightDown = new ToolSwitch()
        {
            triggerName = "Light Down",
            active      = false
        };

        tSwitch = new List <ToolSwitch>
        {
            lightOn,
            lightDown
        };
        SetStatus(status);
    }
コード例 #24
0
 /// <summary>
 /// Verifies that the dependencies are present, and if the dependencies are present, or if the property
 /// doesn't have any dependencies, the switch gets emitted
 /// </summary>
 /// <param name="property"></param>
 /// <returns></returns>
 protected virtual bool VerifyDependenciesArePresent(ToolSwitch property)
 {
     // check the dependency
     if (property.Parents.Count > 0)
     {
         // has a dependency, now check to see whether at least one parent is set
         // if it is set, add to the command line
         // otherwise, ignore it
         bool isSet = false;
         foreach (string parentName in property.Parents)
         {
             isSet = isSet || HasSwitch(parentName);
         }
         return(isSet);
     }
     else
     {
         // no dependencies to account for
         return(true);
     }
 }
コード例 #25
0
        /// <summary>
        /// Generates the command line for the tool.
        /// </summary>
        private string GenerateCommands()
        {
            // the next three methods are overridden by the base class
            // here it does nothing unless overridden
            AddDefaultsToActiveSwitchList();

            AddFallbacksToActiveSwitchList();

            PostProcessSwitchList();

#if WHIDBEY_BUILD
            CommandLineBuilder commandLineBuilder = new CommandLineBuilder();
#else
            CommandLineBuilder commandLineBuilder = new CommandLineBuilder(true /* quote hyphens */);
#endif

            // iterates through the list of set toolswitches
            foreach (string propertyName in SwitchOrderList)
            {
                if (IsPropertySet(propertyName))
                {
                    ToolSwitch property = activeToolSwitches[propertyName];

                    // verify the dependencies
                    if (VerifyDependenciesArePresent(property) && VerifyRequiredArgumentsArePresent(property, false))
                    {
                        GenerateCommandsAccordingToType(commandLineBuilder, property, false);
                    }
                }
                else if (String.Equals(propertyName, "AlwaysAppend", StringComparison.OrdinalIgnoreCase))
                {
                    commandLineBuilder.AppendSwitch(AlwaysAppend);
                }
            }

            // additional args should go on the end
            BuildAdditionalArgs(commandLineBuilder);
            return(commandLineBuilder.ToString());
        }
コード例 #26
0
        /// <summary>
        /// Generates the switches that have filenames attached to the end
        /// </summary>
        /// <remarks>For file switches (e.g., PrecompiledHeaderFile), the toolSwitchName (if it exists) is emitted
        /// along with the FileName which may or may not have quotes</remarks>
        /// e.g., PrecompiledHeaderFile = "File" will emit /FpFile
        /// <param name="clb"></param>
        /// <param name="toolSwitch"></param>
        private static void EmitFileSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
        {
            if (!String.IsNullOrEmpty(toolSwitch.Value))
            {
                String str = toolSwitch.Value;
                str.Trim();

                if (!str.StartsWith("\""))
                {
                    str = "\"" + str;
                    if (str.EndsWith("\\") && !str.EndsWith("\\\\"))
                    {
                        str += "\\\"";
                    }
                    else
                    {
                        str += "\"";
                    }
                }

                //we want quotes always, AppendSwitchIfNotNull will add them on as needed bases
                clb.AppendSwitchUnquotedIfNotNull(toolSwitch.SwitchValue + toolSwitch.Separator, str);
            }
        }
コード例 #27
0
        protected override void PostProcessSwitchList()
        {
            var firstFile = InputFiles.First();

            ToolExe = firstFile.GetMetadata("CompilerPath");

            ToolSwitch argument;

            argument = new ToolSwitch(ToolSwitchType.String)
            {
                MultipleValues = true
            };
            if (firstFile.GetMetadata("PointerSize") == "32")
            {
                argument.SwitchValue = "-32bits";
            }
            else if (firstFile.GetMetadata("PointerSize") == "64")
            {
                argument.SwitchValue = "-64bits";
            }
            ActiveToolSwitches["PointerSize"] = argument;

            ActiveToolSwitches["Definitions"] = new ToolSwitch(ToolSwitchType.StringArray)
            {
                StringList = firstFile.GetMetadata("Definitions").Split(';'), SwitchValue = "-D "
            };
            ActiveToolSwitches["IncludeFolders"] = new ToolSwitch(ToolSwitchType.StringPathArray)
            {
                StringList = firstFile.GetMetadata("IncludeFolders").Split(';'), SwitchValue = "-I "
            };

            argument = new ToolSwitch(ToolSwitchType.String)
            {
                MultipleValues = true
            };
            if (firstFile.GetMetadata("CallTrace") == "SingleThreaded")
            {
                argument.SwitchValue = "-call_trace 1";
            }
            else if (firstFile.GetMetadata("CallTrace") == "MSVC")
            {
                argument.SwitchValue = "-call_trace 2";
            }
            ActiveToolSwitches["CallTrace"] = argument;

            if (firstFile.GetMetadata("ShowMemoryUsage") != "true")
            {
                ActiveToolSwitches.Remove("ShowMemoryUsage");
            }
            else
            {
                ActiveToolSwitches["ShowMemoryUsage"] = new ToolSwitch(ToolSwitchType.String)
                {
                    MultipleValues = true, SwitchValue = "-debug_memory"
                }
            };

            ActiveToolSwitches["AdditionalDependencies"] = new ToolSwitch(ToolSwitchType.StringArray)
            {
                StringList = firstFile.GetMetadata("AdditionalDependencies").Split(';'), SwitchValue = "-linker_option /DEFAULTLIB:"
            };

            if (firstFile.GetMetadata("DisableDebugInfo") != "true")
            {
                ActiveToolSwitches.Remove("DisableDebugInfo");
            }
            else
            {
                ActiveToolSwitches["DisableDebugInfo"] = new ToolSwitch(ToolSwitchType.String)
                {
                    MultipleValues = true, SwitchValue = "-ndebug"
                }
            };

            ActiveToolSwitches["OutputFile"] = new ToolSwitch(ToolSwitchType.File)
            {
                SwitchValue = "-o ", Value = firstFile.GetMetadata("OutputFile")
            };

            if (firstFile.GetMetadata("PartialCompilation") != "true")
            {
                ActiveToolSwitches.Remove("PartialCompilation");
            }
            else
            {
                ActiveToolSwitches["PartialCompilation"] = new ToolSwitch(ToolSwitchType.String)
                {
                    MultipleValues = true, SwitchValue = "-part"
                }
            };

            if (firstFile.GetMetadata("RecursionDepthLimit") == "")
            {
                ActiveToolSwitches.Remove("RecursionDepthLimit");
            }
            else
            {
                ActiveToolSwitches["RecursionDepthLimit"] = new ToolSwitch(ToolSwitchType.Integer)
                {
                    IsValid = true, Number = int.Parse(firstFile.GetMetadata("RecursionDepthLimit")), SwitchValue = "-recursion_depth_limit "
                }
            };

            if (firstFile.GetMetadata("StaticLoopLimit") == "")
            {
                ActiveToolSwitches.Remove("StaticLoopLimit");
            }
            else
            {
                ActiveToolSwitches["StaticLoopLimit"] = new ToolSwitch(ToolSwitchType.Integer)
                {
                    IsValid = true, Number = int.Parse(firstFile.GetMetadata("StaticLoopLimit")), SwitchValue = "-static_loop_length_limit "
                }
            };

            AdditionalOptions = firstFile.GetMetadata("AdditionalOptions");
        }
    }
}
コード例 #28
0
 /// <summary>
 /// Verifies that the required args are present. This function throws if we have missing required args
 /// </summary>
 /// <param name="property"></param>
 /// <returns></returns>
 protected virtual bool VerifyRequiredArgumentsArePresent(ToolSwitch property, bool bThrowOnError)
 {
     return true;
 }
コード例 #29
0
 /// <summary>
 /// Emit a switch that's always appended
 /// </summary>
 private static void EmitAlwaysAppendSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     clb.AppendSwitch(toolSwitch.Name);
 }
コード例 #30
0
        /// <summary>
        /// Verifies that the dependencies are present, and if the dependencies are present, or if the property
        /// doesn't have any dependencies, the switch gets emitted
        /// </summary>
        /// <param name="property"></param>
        /// <returns></returns>
        protected virtual bool VerifyDependenciesArePresent(ToolSwitch property)
        {
            // check the dependency 
            if (property.Parents.Count > 0)
            {
                // has a dependency, now check to see whether at least one parent is set
                // if it is set, add to the command line
                // otherwise, ignore it
                bool isSet = false;
                foreach (string parentName in property.Parents)
                {
                    isSet = isSet || HasSwitch(parentName);

                }
                return isSet;
            }
            else
            {
                // no dependencies to account for
                return true;
            }
        }
コード例 #31
0
 /// <summary>
 /// Emit a switch that's a scalar task item
 /// </summary>
 private static void EmitTaskItemSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (!String.IsNullOrEmpty(toolSwitch.Name))
     {
         clb.AppendSwitch(toolSwitch.Name + toolSwitch.Separator);
     }
 }
コード例 #32
0
 /// <summary>
 /// Generates the switches that are nonreversible
 /// </summary>
 /// <remarks>A boolean switch is emitted if it is set to true. If it set to false, nothing is emitted.
 /// e.g. nologo = "true" will emit /Og, but nologo = "false" will emit nothing.</remarks>
 /// <param name="clb"></param>
 /// <param name="toolSwitch"></param>
 private void EmitBooleanSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (toolSwitch.BooleanValue)
     {
         if (!String.IsNullOrEmpty(toolSwitch.SwitchValue))
         {
             StringBuilder val = new StringBuilder(GetEffectiveArgumentsValues(toolSwitch));
             val.Insert(0, toolSwitch.Separator);
             val.Insert(0, toolSwitch.TrueSuffix);
             val.Insert(0, toolSwitch.SwitchValue);
             clb.AppendSwitch(val.ToString());
         }
     }
     else
         EmitReversibleBooleanSwitch(clb, toolSwitch);
 }
コード例 #33
0
        /// <summary>
        /// Generates the switches for switches that either have literal strings appended, or have 
        /// different switches based on what the property is set to.
        /// </summary>
        /// <remarks>The string switch emits a switch that depends on what the parameter is set to, with and
        /// arguments
        /// e.g., Optimization = "Full" will emit /Ox, whereas Optimization = "Disabled" will emit /Od</remarks>
        /// <param name="clb"></param>
        /// <param name="toolSwitch"></param>
        private void EmitStringSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
        {
            String strSwitch = String.Empty;
            strSwitch += toolSwitch.SwitchValue + toolSwitch.Separator;
            
            StringBuilder val = new StringBuilder(GetEffectiveArgumentsValues(toolSwitch));
            String str = toolSwitch.Value;

            if (!toolSwitch.MultiValues)
            {

                str.Trim();

                if (!str.StartsWith("\""))
                {
                    str = "\"" + str;
                    if (str.EndsWith("\\") && !str.EndsWith("\\\\"))
                        str += "\\\"";
                    else
                        str += "\"";
                }
                val.Insert(0, str);
            }

            if ((strSwitch.Length == 0) && (val.ToString().Length == 0))
                return;

            clb.AppendSwitchUnquotedIfNotNull(strSwitch, val.ToString());
            
        }
コード例 #34
0
 /// <summary>
 /// Verifies that the required args are present. This function throws if we have missing required args
 /// </summary>
 /// <param name="property"></param>
 /// <returns></returns>
 protected virtual bool VerifyRequiredArgumentsArePresent(ToolSwitch property, bool bThrowOnError)
 {
     return(true);
 }
コード例 #35
0
 /// <summary>
 /// Emit a switch that's always appended
 /// </summary>
 private static void EmitAlwaysAppendSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     clb.AppendSwitch(toolSwitch.Name);
 }
コード例 #36
0
        /// <summary>
        /// Generates the switches that have filenames attached to the end
        /// </summary>
        /// <remarks>For file switches (e.g., PrecompiledHeaderFile), the toolSwitchName (if it exists) is emitted
        /// along with the FileName which may or may not have quotes</remarks>
        /// e.g., PrecompiledHeaderFile = "File" will emit /FpFile
        /// <param name="clb"></param>
        /// <param name="toolSwitch"></param>
        private static void EmitFileSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
        {
            if (!String.IsNullOrEmpty(toolSwitch.Value))
            {
                String str = toolSwitch.Value;
                str.Trim();

                if (!str.StartsWith("\""))
                {
                    str = "\"" + str;
                    if (str.EndsWith("\\") && !str.EndsWith("\\\\"))
                        str += "\\\"";
                    else
                        str += "\"";
                }

                //we want quotes always, AppendSwitchIfNotNull will add them on as needed bases 
                clb.AppendSwitchUnquotedIfNotNull(toolSwitch.SwitchValue + toolSwitch.Separator, str);
            }
        }
コード例 #37
0
 /// <summary>
 /// Appends the directory name to the end of a switch
 /// Ensure the name ends with a slash
 /// </summary>
 /// <remarks>For directory switches (e.g., TrackerLogDirectory), the toolSwitchName (if it exists) is emitted
 /// along with the FileName which is ensured to have a trailing slash</remarks>
 /// <param name="clb"></param>
 /// <param name="toolSwitch"></param>
 private static void EmitDirectorySwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (!String.IsNullOrEmpty(toolSwitch.SwitchValue))
     {
         //clb.AppendSwitchIfNotNull(toolSwitch.Name + toolSwitch.Separator, EnsureTrailingSlash(toolSwitch.ArgumentValue));
         clb.AppendSwitch(toolSwitch.SwitchValue + toolSwitch.Separator);
     }
 }
コード例 #38
0
        /// <summary>
        /// Checks to see if the argument is required and whether an argument exists, and returns the 
        /// argument or else fallback argument if it exists.
        /// 
        /// These are the conditions to look at:
        /// 
        /// ArgumentRequired    ArgumentParameter   FallbackArgumentParameter   Result
        /// true                isSet               NA                          The value in ArgumentParameter gets returned
        /// true                isNotSet            isSet                       The value in FallbackArgumentParamter gets returned
        /// true                isNotSet            isNotSet                    An error occurs, as argumentrequired is true
        /// false               isSet               NA                          The value in ArgumentParameter gets returned
        /// false               isNotSet            isSet                       The value in FallbackArgumentParameter gets returned
        /// false               isNotSet            isNotSet                    The empty string is returned, as there are no arguments, and no arguments are required
        /// </summary>
        /// <param name="toolSwitch"></param>
        /// <returns></returns>
        protected virtual string GetEffectiveArgumentsValues(ToolSwitch toolSwitch)
        {
            //if (!toolSwitch.ArgumentRequired && !IsPropertySet(toolSwitch.ArgumentParameter) && 
            //    !IsPropertySet(toolSwitch.FallbackArgumentParameter))
            //{
            //    return String.Empty;
            //}

            //// check to see if it has an argument
            //if (toolSwitch.ArgumentRequired)
            //{
            //    if (!IsPropertySet(toolSwitch.ArgumentParameter) && !IsPropertySet(toolSwitch.FallbackArgumentParameter))
            //    {
            //        throw new ArgumentException(logPrivate.FormatResourceString("ArgumentRequired", toolSwitch.Name));
            //    }
            //}
            //// if it gets to here, the argument or the fallback is set
            //if (IsPropertySet(toolSwitch.ArgumentParameter))
            //{
            //    return ActiveToolSwitches[toolSwitch.ArgumentParameter].ArgumentValue;
            //}
            //else
            //{
            //    return ActiveToolSwitches[toolSwitch.FallbackArgumentParameter].ArgumentValue;
            //}
            return "GetEffectiveArgumentValue not Impl";
        }
コード例 #39
0
 /// <summary>
 /// Generates the command line for switches that are reversible
 /// </summary>
 /// <remarks>A reversible boolean switch will emit a certain switch if set to true, but emit that 
 /// exact same switch with a flag appended on the end if set to false.
 /// e.g., GlobalOptimizations = "true" will emit /Og, and GlobalOptimizations = "false" will emit /Og-</remarks>
 /// <param name="clb"></param>
 /// <param name="toolSwitch"></param>
 private void EmitReversibleBooleanSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     // if the value is set to true, append whatever the TrueSuffix is set to.
     // Otherwise, append whatever the FalseSuffix is set to.
     if (!String.IsNullOrEmpty(toolSwitch.ReverseSwitchValue))
     {
         string suffix = (toolSwitch.BooleanValue) ? toolSwitch.TrueSuffix : toolSwitch.FalseSuffix;
         StringBuilder val = new StringBuilder(GetEffectiveArgumentsValues(toolSwitch));
         val.Insert(0, suffix);
         val.Insert(0, toolSwitch.Separator);
         val.Insert(0, toolSwitch.TrueSuffix);
         val.Insert(0, toolSwitch.ReverseSwitchValue);
         clb.AppendSwitch(val.ToString());
     }
 }
コード例 #40
0
 /// <summary>
 /// Generates the commands for switches that have integers appended.
 /// </summary>
 /// <remarks>For integer switches (e.g., WarningLevel), the toolSwitchName is emitted
 /// with the appropriate integer appended, as well as any arguments
 /// e.g., WarningLevel = "4" will emit /W4</remarks>
 /// <param name="clb"></param>
 /// <param name="toolSwitch"></param>
 private void EmitIntegerSwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (toolSwitch.IsValid)
     {
         if (!String.IsNullOrEmpty(toolSwitch.Separator))
         {
             clb.AppendSwitch(toolSwitch.SwitchValue + toolSwitch.Separator + toolSwitch.Number.ToString() + GetEffectiveArgumentsValues(toolSwitch));
         }
         else
         {
             clb.AppendSwitch(toolSwitch.SwitchValue + toolSwitch.Number.ToString() + GetEffectiveArgumentsValues(toolSwitch));
         }
     }
 }
コード例 #41
0
 /// <summary>
 /// Emit a switch that's an array of task items
 /// </summary>
 private static void EmitTaskItemArraySwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
 {
     if (String.IsNullOrEmpty(toolSwitch.Separator))
     {
         foreach (ITaskItem itemName in toolSwitch.TaskItemArray)
         {
             clb.AppendSwitchIfNotNull(toolSwitch.SwitchValue, itemName.ItemSpec);
         }
     }
     else
     {
         clb.AppendSwitchIfNotNull(toolSwitch.SwitchValue, toolSwitch.TaskItemArray, toolSwitch.Separator);
     }
 }
コード例 #42
0
        /// <summary>
        /// Generates a part of the command line depending on the type
        /// </summary>
        /// <remarks>Depending on the type of the switch, the switch is emitted with the proper values appended.
        /// e.g., File switches will append file names, directory switches will append filenames with "\" on the end</remarks>
        /// <param name="clb"></param>
        /// <param name="toolSwitch"></param>
        protected void GenerateCommandsAccordingToType(CommandLineBuilder clb, ToolSwitch toolSwitch, bool bRecursive)
        {
            // if this property has a parent skip printing it as it was printed as part of the parent prop printing
            if (toolSwitch.Parents.Count > 0 && !bRecursive)
                return;

            switch (toolSwitch.Type)
            {
                case ToolSwitchType.Boolean:
                    EmitBooleanSwitch(clb, toolSwitch);
                    break;
                case ToolSwitchType.String:
                    EmitStringSwitch(clb, toolSwitch);
                    break;
                case ToolSwitchType.StringArray:
                    EmitStringArraySwitch(clb, toolSwitch);
                    break;
                case ToolSwitchType.Integer:
                    EmitIntegerSwitch(clb, toolSwitch);
                    break;
                case ToolSwitchType.File:
                    EmitFileSwitch(clb, toolSwitch);
                    break;
                case ToolSwitchType.Directory:
                    EmitDirectorySwitch(clb, toolSwitch);
                    break;
                case ToolSwitchType.ITaskItem:
                    EmitTaskItemSwitch(clb, toolSwitch);
                    break;
                case ToolSwitchType.ITaskItemArray:
                    EmitTaskItemArraySwitch(clb, toolSwitch);
                    break;
                case ToolSwitchType.AlwaysAppend:
                    EmitAlwaysAppendSwitch(clb, toolSwitch);
                    break;
                default:
                    // should never reach this point - if it does, there's a bug somewhere.
                    ErrorUtilities.VerifyThrow(false, "InternalError");
                    break;
            }
        }
コード例 #43
0
        /// <summary>
        /// Generates the commands for the switches that may have an array of arguments
        /// The switch may be empty.
        /// </summary>
        /// <remarks>For stringarray switches (e.g., Sources), the toolSwitchName (if it exists) is emitted
        /// along with each and every one of the file names separately (if no separator is included), or with all of the 
        /// file names separated by the separator.
        /// e.g., AdditionalIncludeDirectores = "@(Files)" where Files has File1, File2, and File3, the switch
        /// /IFile1 /IFile2 /IFile3 or the switch /IFile1;File2;File3 is emitted (the latter case has a separator 
        /// ";" specified)</remarks>
        /// <param name="clb"></param>
        /// <param name="toolSwitch"></param>
        private static void EmitStringArraySwitch(CommandLineBuilder clb, ToolSwitch toolSwitch)
        {
            string[] ArrTrimStringList = new string [toolSwitch.StringList.Length];
            for (int i=0; i<toolSwitch.StringList.Length; ++i)
            {
                //Make sure the file doesn't contain escaped " (\") 
                if (toolSwitch.StringList[i].StartsWith("\"") && toolSwitch.StringList[i].EndsWith("\""))
                {
                    ArrTrimStringList[i] = toolSwitch.StringList[i].Substring(1, toolSwitch.StringList[i].Length - 2);
                }
                else
                {
                    ArrTrimStringList[i] = toolSwitch.StringList[i];
                }
            }

            if (String.IsNullOrEmpty(toolSwitch.Separator))
            {
                foreach (string fileName in ArrTrimStringList)
                {
                    clb.AppendSwitchIfNotNull(toolSwitch.SwitchValue, fileName);
                }
            }
            else
            {
                clb.AppendSwitchIfNotNull(toolSwitch.SwitchValue, ArrTrimStringList, toolSwitch.Separator);
            }
        }