private void AddBuildToolFlags(ToolChainOptions options, Project proj, ProjectPropertyGroupElement group)
        {
            //ProjectPropertyGroupElement group;
            //ProjectPropertyElement prop;

            AddFormattedPropGroup(CommonToolFlagTag, options.CommonFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach(ToolFlag flag in options.CommonFlags)
            //{
            //    prop = group.AddProperty(CommonToolFlagTag, ToEnvVar(CommonToolFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(CCppCommonFlagTag, options.C_CppFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.C_CppFlags)
            //{
            //    prop = group.AddProperty(CCppCommonFlagTag, ToEnvVar(CCppCommonFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(CFlagTag, options.CFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.CFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(CFlagTag, ToEnvVar(CFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(CppFlagTag, options.CppFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.CppFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(CppFlagTag, ToEnvVar(CppFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(AsmFlagTag, options.AsmFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.AsmFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(AsmFlagTag, ToEnvVar(AsmFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(ArchiverFlagTag, options.ArchiverFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.ArchiverFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(ArchiverFlagTag, ToEnvVar(ArchiverFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}

            AddFormattedPropGroup(LinkerFlagTag, options.LinkerFlags.ToolFlags, proj, group);

            //group = proj.Xml.AddPropertyGroup();
            //foreach (ToolFlag flag in options.LinkerFlags.ToolFlags)
            //{
            //    prop = group.AddProperty(LinkerFlagTag, ToEnvVar(LinkerFlagTag) + flag.Flag);
            //    prop.Condition = flag.Conditional;
            //}
        }
        private ToolChainOptions LoadToolChainOptions(ProjectPropertyGroupElement grp)
        {
            ToolChainOptions opts = new ToolChainOptions();
            List<ProjectPropertyElement> remList = new List<ProjectPropertyElement>();

            foreach (ProjectPropertyElement bp in grp.Properties)
            {
                ToolFlag flag;
                remList.Add(bp);

                switch (bp.Name)
                {
                    case "ToolName":
                        opts.ToolName = bp.Value;
                        break;
                    case "DEVICE_TYPE":
                        opts.DeviceType = bp.Value;
                        break;
                    case CommonToolFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.CommonFlags.Add(flag);
                        break;
                    case CCppCommonFlagTag:
                    case CCppTargFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.C_CppFlags.Add(flag);
                        break;
                    case CppFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.CppFlags.ToolFlags.Add(flag);
                        break;
                    case AsmFlagTag:
                    case AsmArmFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.AsmFlags.ToolFlags.Add(flag);
                        break;
                    case ArchiverFlagTag:
                    case ArchiverArmFlagTag:
                    case ArchiverPlatFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.ArchiverFlags.ToolFlags.Add(flag);
                        break;
                    case LinkerFlagTag:
                        flag = new ToolFlag();
                        flag.Flag = RemoveCommonFlags(bp.Value);
                        flag.Conditional = bp.Condition;
                        opts.LinkerFlags.ToolFlags.Add(flag);
                        break;

                    default:
                        {
                            string uc = bp.Name.ToUpper();

                            if (uc.Contains("CC_CPP_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.C_CppFlags.Add(flag);
                            }
                            else if (uc.Contains("CC_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.CFlags.ToolFlags.Add(flag);
                            }
                            else if (uc.Contains("AS_"))
                            {
                                flag = new ToolFlag();
                                flag.Flag = RemoveCommonFlags(bp.Value);
                                flag.Conditional = bp.Condition;
                                opts.AsmFlags.ToolFlags.Add(flag);
                            }
                            else
                            {
                                remList.Remove(bp);
                            }
                        }
                        break;
                }
            }
            foreach (ProjectPropertyElement bp in remList)
            {
                grp.RemoveChild(bp);
            }

            return opts;
        }
        private Project GenerateBuildOptionTargetFile(ToolChainOptions ToolChainOptions)
        {
            Project proj = new Project();
            proj.Xml.DefaultTargets = "Build";

            AddEnvVarCollection(ToolChainOptions.EnvironmentVariables, proj);
            AddBuildToolFlags(ToolChainOptions, proj, null);

            return proj;
        }
 public void CopyTo(ToolChainOptions dest)
 {
     CopyHelper.CopyTo(this, dest);
 }