private void AddBuildScript(string targName, string targConditional, string buildToolWrapper, ToolOptions options, Project proj, params string[] propTags)
        {
            ProjectTargetElement targ;
            ProjectTaskElement task;

            targ = proj.Xml.AddTarget(targName);
            targ.Condition = targConditional;

            foreach (BuildScript p in options.BuildToolParameters.PreBuild)
            {
                task = targ.AddTask(TargetTaskTag);
                task.Condition = p.Conditional;
                task.SetParameter("Command", p.Script);
            }
            foreach (BuildScript p in options.BuildToolParameters.Parameters)
            {
                task = targ.AddTask(TargetTaskTag);
                task.Condition = p.Conditional;
                task.SetParameter("Command", buildToolWrapper + " " + p.Script + " " + string.Join(" ", propTags));
            }
            foreach (BuildScript p in options.BuildToolParameters.PostBuild)
            {
                task = targ.AddTask(TargetTaskTag);
                task.Condition = p.Conditional;
                task.SetParameter("Command", p.Script);
            }
        }
        private string RemoveFlagsAndWrapper(string script, ToolOptions toolOptions, params List<ToolFlag>[] commonFlags)
        {
            int idx = -1;
            string scriptLower = script.ToLower();

            foreach (ToolFlag flag in toolOptions.ToolFlags)
            {
                scriptLower = script.ToLower();
                if ((idx = scriptLower.IndexOf(flag.Flag.ToLower())) >= 0)
                {
                    script = script.Remove(idx, flag.Flag.Length);
                }
            }

            if (commonFlags != null)
            {
                foreach (List<ToolFlag> flags in commonFlags)
                {
                    foreach (ToolFlag flag in flags)
                    {
                        scriptLower = script.ToLower();
                        if ((idx = scriptLower.IndexOf(flag.Flag.ToLower())) >= 0)
                        {
                            script = script.Remove(idx, flag.Flag.Length);
                        }
                    }
                }
            }

            script = RemoveWrapper(script);

            script = RemoveCommonFlags(script);

            return script.Trim();
        }
        private void LoadTargetTasks(ProjectTargetElement target, List<EnvVar> vars, BuildToolDefine tool, ToolOptions toolOptions, params List<ToolFlag>[] commonFlags)
        {
            foreach (ProjectTaskElement task in target.Tasks)
            {
                BuildScript script = new BuildScript();

                string exeCmdEnv = ToEnvVar(tool.Description.ToLower()).Trim();
                string exeCmd = tool.Description.ToLower();

                int idx = -1;
                script.Conditional = task.Condition;
                script.Script = task.GetParameter(TaskScriptAttributeName);
                if (!string.IsNullOrEmpty(script.Script))
                {
                    if ((idx = script.Script.ToLower().IndexOf(exeCmdEnv)) >= 0)
                    {
                        // remove exe command and 
                        script.Script = script.Script.Remove(idx, exeCmdEnv.Length);

                        script.Script = RemoveFlagsAndWrapper(script.Script, toolOptions, commonFlags);

                        toolOptions.BuildToolParameters.Parameters.Add(script);
                    }
                    else if ((idx = script.Script.ToLower().IndexOf(exeCmd)) >= 0)
                    {
                        // remove exe command and 
                        script.Script = script.Script.Remove(idx, exeCmd.Length);

                        script.Script = RemoveFlagsAndWrapper(script.Script, toolOptions, commonFlags);

                        toolOptions.BuildToolParameters.Parameters.Add(script);
                    }
                    else if (toolOptions.BuildToolParameters.Parameters.Count > 0)
                    {
                        toolOptions.BuildToolParameters.PostBuild.Add(script);
                    }
                    else
                    {
                        toolOptions.BuildToolParameters.PreBuild.Add(script);
                    }
                }
                else if(string.Compare(task.Name, SetEnvScriptTag) == 0)
                {
                    EnvVar var = new EnvVar();
                    var.Name = task.GetParameter("Name");
                    var.Conditional = task.Condition;
                    var.Value = task.GetParameter("Value");
                    vars.Add(var);
                }
            }
        }
 public void CopyTo(ToolOptions dest)
 {
     CopyHelper.CopyTo(this, dest);
 }