private static void addConfigOption(Dictionary <string, string> options, PropertiesJson props, string prefix, string key) { var option = options.FirstOrDefault(o => o.Key == key).Value; if (option != null) { props.configurations[0].defines.Add(prefix + option); } }
public static string generate(IProject project, LibManager libManager, SetupData setup) { var cfg = project.selectedConfiguration; var props = new PropertiesJson() { configurations = new List <ConfigurationJson>() { new ConfigurationJson() { name = "VisualTeensy", compilerPath = Path.Combine(cfg.compiler, "arm-none-eabi-gcc.exe").Replace('\\', '/'), intelliSenseMode = "gcc-arm", cppStandard = "gnu++14", // hack: might be better to extract from boards.txt includePath = new List <string>() { $"{Path.Combine(setup.arduinoCoreBase,"cores",cfg.core).Replace('\\', '/') + "/**"}", $"{Path.Combine(setup.arduinoBase, "hardware", "teensy", "avr", "libraries/**")}".Replace('\\', '/'), $"{Path.Combine(setup.arduinoBase ,"libraries/**")}".Replace('\\', '/'), $"{setup.sharedLibrariesFolder}/**".Replace('\\', '/'), }, forcedInclude = new List <string>() { Path.Combine(setup.arduinoCoreBase, "cores", cfg.core, "arduino.h").Replace('\\', '/'), }, defines = new List <string>() } } }; var options = cfg.selectedBoard.getAllOptions(); var defines = options.FirstOrDefault(o => o.Key == "build.flags.defs"); if (defines.Value != null) { foreach (var define in defines.Value.Split(new string[] { "-D" }, StringSplitOptions.RemoveEmptyEntries)) { props.configurations[0].defines.Add(define.Trim()); } } addConfigOption(options, props, "F_CPU=", "build.fcpu"); addConfigOption(options, props, "", "build.usbtype"); addConfigOption(options, props, "LAYOUT_", "build.keylayout"); props.configurations[0].defines.Add("ARDUINO=10813"); return(JsonConvert.SerializeObject(props, Formatting.Indented)); }
public static string generate(IProject project, LibManager libManager) { if (project.selectedConfiguration.compilerBase == null) { return(""); // hack } var props = new PropertiesJson() { configurations = new List <ConfigurationJson>() { new ConfigurationJson() { name = "VisualTeensy", compilerPath = Path.Combine(project.selectedConfiguration.compilerBase, "bin", "arm-none-eabi-gcc.exe").Replace('\\', '/'), intelliSenseMode = "gcc-x64", includePath = new List <string>() { "src/**", "lib/**", project.selectedConfiguration.coreBase?.Replace('\\', '/') + "/**", libManager.sharedRepositoryPath.Replace('\\', '/') + "/**" }, defines = new List <string>() } } }; var options = project.selectedConfiguration.selectedBoard.getAllOptions(); var defines = options.FirstOrDefault(o => o.Key == "build.flags.defs"); if (defines.Value != null) { foreach (var define in defines.Value.Split(new string[] { "-D" }, StringSplitOptions.RemoveEmptyEntries)) { props.configurations[0].defines.Add(define.Trim()); } } addConfigOption(options, props, "F_CPU=", "build.fcpu"); addConfigOption(options, props, "", "build.usbtype"); addConfigOption(options, props, "LAYOUT_", "build.keylayout"); props.configurations[0].defines.Add("ARDUINO"); return(JsonConvert.SerializeObject(props, Formatting.Indented)); }
public static string generate(IProject project, LibManager libManager, SetupData setup) { var props = new PropertiesJson() { configurations = new List <ConfigurationJson>() { new ConfigurationJson() { name = "VisualTeensy", compilerPath = Path.Combine(project.selectedConfiguration.compilerBase, "bin", "arm-none-eabi-gcc.exe").Replace('\\', '/'), intelliSenseMode = "gcc-x64", includePath = new List <string>() { project.selectedConfiguration.coreBase?.Replace('\\', '/') + "/*", $"{Path.Combine(setup.arduinoBase, "hardware", "teensy", "avr", "libraries/**")}".Replace('\\', '/'), $"{Path.Combine(setup.arduinoBase ,"libraries/**")}".Replace('\\', '/'), $"{Path.Combine(Helpers.getSketchbookFolder() ,"libraries/**")}".Replace('\\', '/'), }, forcedInclude = new List <string>() { Path.Combine(project.selectedConfiguration.coreBase, "arduino.h").Replace('\\', '/'), }, defines = new List <string>() } } }; var options = project.selectedConfiguration.selectedBoard.getAllOptions(); var defines = options.FirstOrDefault(o => o.Key == "build.flags.defs"); if (defines.Value != null) { foreach (var define in defines.Value.Split(new string[] { "-D" }, StringSplitOptions.RemoveEmptyEntries)) { props.configurations[0].defines.Add(define.Trim()); } } addConfigOption(options, props, "F_CPU=", "build.fcpu"); addConfigOption(options, props, "", "build.usbtype"); addConfigOption(options, props, "LAYOUT_", "build.keylayout"); props.configurations[0].defines.Add("ARDUINO"); return(JsonConvert.SerializeObject(props, Formatting.Indented)); }
public static string generate(IProject project, SetupData setup, LibManager libManager) { var cfg = project.selectedConfiguration; if (!cfg.isOk) { return("ERROR"); } ; var brd = cfg.selectedBoard; // if (project.selectedConfiguration.compilerBase == null || brd == null) return ""; // hack var props = new PropertiesJson() { configurations = new List <ConfigurationJson>() { new ConfigurationJson() { name = "VisualTeensy", compilerPath = Path.Combine(cfg.compiler, "arm-none-eabi-gcc.exe").Replace('\\', '/'), intelliSenseMode = "gcc-x64", includePath = new List <string>(), defines = new List <string>() } } }; var cfgp = props.configurations[0]; // include path ------------------------------------------------------------- cfgp.includePath.Add("src/**"); cfgp.includePath.Add(cfg.core.Replace('\\', '/')); foreach (var lib in cfg.sharedLibs) { cfgp.includePath.Add(Path.Combine(lib.sourceUri.LocalPath, "**").Replace('\\', '/')); } foreach (var lib in cfg.localLibs) { cfgp.includePath.Add(Path.Combine("lib", lib.targetFolderName, "**").Replace('\\', '/')); } // Compiler switches ---------------------------------------------------------- var options = project.selectedConfiguration?.selectedBoard?.getAllOptions(); if (options == null) { return(""); } var defines = options.FirstOrDefault(o => o.Key == "build.flags.defs"); if (defines.Value != null) { foreach (var define in defines.Value.Split(new string[] { "-D" }, StringSplitOptions.RemoveEmptyEntries)) { props.configurations[0].defines.Add(define.Trim()); } } var boardDef = "ARDUINO_" + options.FirstOrDefault(o => o.Key == "build.board").Value; props.configurations[0].defines.Add(boardDef); addConfigOption(options, props, "F_CPU=", "build.fcpu"); addConfigOption(options, props, "", "build.usbtype"); addConfigOption(options, props, "LAYOUT_", "build.keylayout"); props.configurations[0].defines.Add("ARDUINO"); return(JsonConvert.SerializeObject(props, Formatting.Indented)); }