Пример #1
0
        CommonConfigurationOptions ExtractSW4STM32Options(XmlDocument cproject, XmlDocument project, XmlElement cconfiguration, string cprojectDir)
        {
            var toolchainConfigNode           = cconfiguration.SelectSingleNode(ToolchainConfigKey) as XmlNode ?? throw new Exception("Failed to locate the configuration node");
            CommonConfigurationOptions result = new CommonConfigurationOptions();

            var gccNode       = toolchainConfigNode.SelectSingleNode("tool[starts-with(@id, 'fr.ac6.managedbuild.tool.gnu.cross.c.compiler')]") as XmlElement ?? throw new Exception("Missing gcc tool node");
            var linkerNode    = toolchainConfigNode.SelectSingleNode("tool[starts-with(@id, 'fr.ac6.managedbuild.tool.gnu.cross.c.linker')]") as XmlElement ?? throw new Exception("Missing linker tool node");
            var cppLinkerNode = toolchainConfigNode.SelectSingleNode("tool[starts-with(@id, 'fr.ac6.managedbuild.tool.gnu.cross.cpp.linker')]") as XmlElement;

            result.IncludeDirectories = gccNode.LookupOptionValueAsList("gnu.c.compiler.option.include.paths")
                                        .Select(a => TranslatePath(cprojectDir, a, PathTranslationFlags.AddExtraComponentToBaseDir))
                                        .Where(d => d != null).ToArray();

            result.PreprocessorMacros = gccNode.LookupOptionValueAsList("gnu.c.compiler.option.preprocessor.def.symbols")
                                        .Select(a => a.Trim()).Where(a => a != "").ToArray();

            result.BoardName = toolchainConfigNode.LookupOptionValue("fr.ac6.managedbuild.option.gnu.cross.board", true);
            result.MCU       = toolchainConfigNode.LookupOptionValue("fr.ac6.managedbuild.option.gnu.cross.mcu");
            List <string> libs = new List <string>();

            string[] libraryPaths = linkerNode.LookupOptionValueAsList("gnu.c.link.option.paths", true);
            foreach (var lib in linkerNode.LookupOptionValueAsList("gnu.c.link.option.libs", true))
            {
                if (!lib.StartsWith(":"))
                {
                    throw new Exception("Unexpected library file format: " + lib);
                }

                foreach (var libDir in libraryPaths)
                {
                    var fullPath = TranslatePath(cprojectDir, libDir, PathTranslationFlags.AddExtraComponentToBaseDir);

                    string candidate = Path.Combine(fullPath, $"{lib.Substring(1)}");
                    if (File.Exists(candidate))
                    {
                        libs.Add(Path.GetFullPath(candidate));
                        break;
                    }
                }
            }

            var sourceFilters   = cconfiguration.SelectNodes(SourceEntriesKey).OfType <XmlElement>().Select(e => new SourceFilterEntry(e)).Where(e => e.IsValid).ToArray();
            var relLinkerScript = linkerNode.LookupOptionValue("fr.ac6.managedbuild.tool.gnu.cross.c.linker.script");
            var linkerScript    = TranslatePath(cprojectDir, relLinkerScript, PathTranslationFlags.AddExtraComponentToBaseDir);

            if (linkerScript != null)
            {
                result.LinkerScript = Path.GetFullPath(linkerScript);
            }

            result.LDFLAGS     = linkerNode.LookupOptionValue("gnu.c.link.option.ldflags");
            result.SourceFiles = ParseSourceList(project, cprojectDir, sourceFilters);
            result.Libraries   = libs;

            return(result);
        }
Пример #2
0
        CommonConfigurationOptions ExtractSTM32CubeIDEOptions(XmlDocument cproject, XmlDocument project, XmlElement cconfiguration, string cprojectDir)
        {
            var toolchainConfigNode           = cconfiguration.SelectSingleNode(ToolchainConfigKey) as XmlNode ?? throw new Exception("Failed to locate the configuration node");
            CommonConfigurationOptions result = new CommonConfigurationOptions();

            var gccNode       = toolchainConfigNode.SelectSingleNode("tool[@superClass = 'com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler']") as XmlElement ?? throw new Exception("Missing gcc tool node");
            var linkerNode    = toolchainConfigNode.SelectSingleNode("tool[@superClass = 'com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker']") as XmlElement ?? throw new Exception("Missing linker tool node");
            var cppLinkerNode = toolchainConfigNode.SelectSingleNode("tool[@superClass = 'com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker']") as XmlElement;

            result.IncludeDirectories = gccNode.LookupOptionValueAsList("com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths")
                                        .Select(a => TranslatePath(cprojectDir, a, PathTranslationFlags.AddExtraComponentToBaseDir))
                                        .Where(d => d != null).ToArray();

            result.PreprocessorMacros = gccNode.LookupOptionValueAsList("com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols")
                                        .Select(a => a.Trim()).Where(a => a != "" && a != "DEBUG" && a != "RELEASE").ToArray();

            result.MCU       = toolchainConfigNode.LookupOptionValue("com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu");
            result.BoardName = toolchainConfigNode.LookupOptionValue("com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board");

            var relLinkerScript = linkerNode.LookupOptionValue("com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script");
            var linkerScript    = TranslatePath(cprojectDir, relLinkerScript, PathTranslationFlags.None);

            if (linkerScript != null)
            {
                result.LinkerScript = Path.GetFullPath(linkerScript);
            }

            result.LDFLAGS = linkerNode.LookupOptionValue("com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags", true);

            result.Libraries = new List <string>();

            List <SourceFilterEntry>         sourceFilters    = new List <SourceFilterEntry>();
            Dictionary <string, SourceEntry> sourceReferences = new Dictionary <string, SourceEntry>();

            foreach (var node in cconfiguration.SelectNodes(SourceEntriesKey).OfType <XmlElement>())
            {
                if (!string.IsNullOrEmpty(node.GetAttribute("name")))
                {
                    var entry = new SourceEntry(node);
                    if (entry.IsValid)
                    {
                        sourceReferences[entry.Name] = entry;
                    }
                }
                else if (!string.IsNullOrEmpty(node.GetAttribute("excluding")))
                {
                    var entry = new SourceFilterEntry(node);
                    if (entry.IsValid)
                    {
                        sourceFilters.Add(entry);
                    }
                }
            }

            var sources = ParseSourceList(project, cprojectDir, sourceFilters.ToArray(), sourceReferences)
                          .Where(f => !f.FullPath.EndsWith(".ioc")).ToList(); //.ioc files have too long names that will exceed our path length limit

            result.SourceFiles = ExpandSourcePaths(sources);

            return(result);
        }
Пример #3
0
 protected virtual void OnVendorSampleParsed(VendorSample sample, CommonConfigurationOptions options)
 {
 }
Пример #4
0
 protected override void OnVendorSampleParsed(VendorSample sample, CommonConfigurationOptions options)
 {
     base.OnVendorSampleParsed(sample, options);
     OptionDictionary[sample] = options; //Remember advanced sample data that didn't make it into the VendorSample object.
 }