コード例 #1
0
        public CompileOptions BuildCompileOptions(Node node)
        {
            O = new CompileOptions()
            {
                BoardId  = node.BoardType.ToUpper(),
                RevMajor = node.VersionMajor,
                RevMinor = node.VersionMinor,
                NodeId   = node.Id,
                Chip     = node.Chip,
                Defines  =
                {
                    CompilerController.HSEValue(node.HSEValue)
                },
                CubeMXModulesToInclude = node.CubeMXModules,
                IncDirectories         = new List <string>()
            };
            string firmwaredir = Path.Combine(Properties.Settings.Default.SensactDirectory, "firmware");
            string moddir      = Path.Combine(firmwaredir, "modules");
            string bspDir      = Path.Combine(moddir, "bsp", node.BoardType);

            O.IncDirectories.Add(bspDir);
            foreach (string file in Directory.EnumerateFiles(bspDir))
            {
                AddFile(file);
            }


            string genDir = Path.Combine(moddir, "generated");

            O.IncDirectories.Add(genDir);
            //check if there are hw specific files for each file in the bsp directory
            foreach (string file in Directory.EnumerateFiles(genDir, "*.cpp", SearchOption.TopDirectoryOnly))
            {
                AddFile(file);
            }
            string driversDir = Path.Combine(moddir, "drivers");

            O.IncDirectories.Add(driversDir);
            foreach (Driver driver in  node.Drivers)
            {
                string file = Path.Combine(driversDir, Convert.ToString(driver) + ".cpp");
                if (File.Exists(file))
                {
                    AddFile(file);
                }
                else
                {
                    throw new Exception("HAL file " + file + " does not exist");
                }
            }
            string coreDir = Path.Combine(moddir, "core");

            O.IncDirectories.Add(coreDir);
            foreach (string file in Directory.EnumerateFiles(coreDir, "*.cpp", SearchOption.TopDirectoryOnly))
            {
                AddFile(file);
            }

            return(O);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            ModelContainer mc = CreateAndCheckModelContainer();

            if (mc == null)
            {
                Console.WriteLine("See errors and then press any key to exit");
                Console.ReadKey();
                return;
            }
            SourceCodeGenerator.GenerateAppIds_h(mc);
            SourceCodeGenerator.GenerateModel_cpp(mc);
            SourceCodeGenerator.GenerateCommandAndEventTypes_h(mc);
            SourceCodeGenerator.GenerateApplication_H_and_CPP(mc);
            SourceCodeGenerator.GenerateHeaderIncludesForApplications(mc);

            if (Properties.Settings.Default.DoNotCompile)
            {
                return;
            }
            foreach (Node n in mc.Model.Nodes)
            {
                SensactFileCollector p  = new SensactFileCollector();
                CompileOptions       o  = p.BuildCompileOptions(n);
                CompilerController   cc = new CompilerController(o);
                string firmwareBinPath  = Path.Combine(Properties.Settings.Default.SensactDirectory, "firmwareBin", n.Id + ".hex");
                cc.Compile(firmwareBinPath);
            }



            return;
        }