Пример #1
0
        public ProcessResult compile(string file, ArduinoBoard board, string additionals = "")
        {
            string cmd;
            string baseFile = Path.GetFileName(file);

            Dictionary <string, string> compileDict = new Dictionary <string, string>();

            compileDict.Add("includes", " -I\"" + board.corePath + "\" " + " -I\"" + board.variantPath + "\"" + additionals);// + " -I\"" + avrLibcInc + "\"");
            compileDict.Add("source_file", file);
            compileDict.Add("object_file", buildPath + baseFile + ".o");
            compileDict.Add("build.mcu", board.cpu);

            switch (Path.GetExtension(file))
            {
            case ".c":
                cmd = ConfigParser.parseLine(board.getCompilerC(), compileDict);
                break;

            case ".cpp":
                string cpp = board.getCompilerCPP();
                cmd = ConfigParser.parseLine(cpp, compileDict);
                break;

            case ".S":
                cmd = ConfigParser.parseLine(board.getCompilerS(), compileDict);
                break;

            default:
                cmd = "";
                break;
            }

            return(runCmd(cmd));
        }
Пример #2
0
        public string getSize(string file, ArduinoBoard board)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("build.path", buildPath);
            dict.Add("build.project_name", "sketch");

            string        cmd = ConfigParser.parseLine(board.getSize(), dict);
            ProcessResult res = runCmd(cmd);

            if (res.returnCode != 0)
            {
                return(String.Empty);
            }

            var    matches = Regex.Matches(res.output.ToString(), board.getSizeRegex(), RegexOptions.Multiline);
            string sout    = "";

            foreach (Match m in matches)
            {
                if (m.Success)
                {
                    sout += m.ToString();
                }
            }

            return(sout);
        }
Пример #3
0
        public ProcessResult createHEX(string file, ArduinoBoard board)
        {
            Dictionary <string, string> compileDict = new Dictionary <string, string>();

            compileDict.Add("build.path", buildPath);
            compileDict.Add("build.project_name", "sketch");

            string cmd = ConfigParser.parseLine(board.getHEX(), compileDict);

            return(runCmd(cmd));
        }
Пример #4
0
        public ProcessResult linkArchive(string file, string archive_file, ArduinoBoard board)
        {
            Dictionary <string, string> linkDict = new Dictionary <string, string>();

            linkDict.Add("build.path", buildPath);
            linkDict.Add("archive_file", archive_file);
            linkDict.Add("object_file", buildPath + file + ".o");

            string cmd = ConfigParser.parseLine(board.getArchive(), linkDict);

            return(runCmd(cmd));
        }
Пример #5
0
        public ProcessResult combine(string file, string archive_file, ArduinoBoard board)
        {
            Dictionary <string, string> compileDict = new Dictionary <string, string>();

            compileDict.Add("build.path", buildPath);
            compileDict.Add("build.project_name", "sketch");
            compileDict.Add("object_files", buildPath + "sketch.cpp.o");
            compileDict.Add("archive_file", archive_file);
            compileDict.Add("build.mcu", board.cpu);
            compileDict.Add("build.variant.path", board.variantPath);

            string cmd = ConfigParser.parseLine(board.getCombine(), compileDict);

            return(runCmd(cmd));
        }
Пример #6
0
        public string upload(string filename, ArduinoBoard board, string port)
        {
            string cmd = "";

            Dictionary <string, string> toolDict = new Dictionary <string, string>();

            toolDict.Add("build.path", buildPath);
            toolDict.Add("build.project_name", "sketch");
            toolDict.Add("upload.verbose", "");
            toolDict.Add("serial.port", port);
            toolDict.Add("serial.port.file", port);
            toolDict.Add("build.mcu", board.cpu);

            cmd = ConfigParser.parseLine(board.getUploadCmd(), toolDict);

            return(cmd);
        }
Пример #7
0
 public string getUploadCmd(string tool)
 {
     return(ConfigParser.parseLine(cfg["tools." + tool + ".upload.pattern"], this.getToolConfig()));
 }