public static void FillBasic(ref ProgramConfiguration Config) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { //C:\\Users\\userName\\AppData\\Roaming\\Sublime Text 3\\Packages\\User Config.BuildSysLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Sublime Text 3\\Packages\\User"); // C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\x86_64-w64-mingw32\\bits\\stdc++.h Config.LocationPCHBITSTD = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\x86_64-w64-mingw32\\bits\\stdc++.h"); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { string usr = Environment.GetEnvironmentVariable("USER"); Config.LocationPCHBITSTD = "/usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h"; Config.BuildSysLocation = $"/home/{usr}/.config/sublime-text-3/Packages/User"; } }
static void CMDMake(string[] input) { if (input.Length >= 2) { switch (input[1].ToLower()) { case "build-system": case "bs": case "buildsystem": string ext = Settings.GetExtension(); string FS = @" { ""cmd"": [""g++" + ext + @""",""-std=c++14"", ""${file}"", ""-o"", ""${file_base_name}" + ext + @""", ""&&"" , ""${file_base_name}" + ext + @"<inputf.txt>outputf.txt""], ""shell"":true, ""working_dir"":""$file_path"", ""selector"":""Source.cpp"" } "; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { FS = @" { ""cmd"": [""g++ -std=c++14 \""${file}\"" -o \""${file_path}/${file_base_name}\"" && ${file_path}/${file_base_name}<inputf.txt>outputf.txt""], ""shell"":true, ""working_dir"":""${file_path}"", ""selector"":""Source.cpp"" } "; } bool generate = false; if (input.Length == 3) { switch (input[2].ToLower()) { case "set": case "s": case "apply": generate = true; break; } } if (generate) { ProgramConfiguration cpf = Settings.GetProgramConfiguration(); string path = Path.Combine(cpf.BuildSysLocation, cpf.BuildSysName); File.WriteAllText(path, FS); } else { Console.WriteLine("Please copy these lines\n" + FS); } break; case "config": case "configuration": case "configs": case "configurations": Console.Write("Configuration file deleted successfully. Now"); Settings.CreateConfigs(); break; case "info": if (input[0].ToLower() != "get") { WriteError("Wrong command. Please use get info to know bs. And make bs to generate bs."); break; } var cfg = Settings.GetProgramConfiguration(); WriteDetail("Current Working Dir: " + cfg.ParentFolder); WriteDetail("C++ Template: " + cfg.SourceTemplate); WriteDetail("C++ Build System: " + cfg.BuildSysName); string info = File.ReadAllText(Path.Combine(cfg.BuildSysLocation, cfg.BuildSysName)); WriteError("Build Config is :"); WriteDetail(info); break; default: WriteError("Your command '" + input[0] + "' is wrong"); ShowDetailOfCommand("config"); ShowDetailOfCommand("bs"); break; } } }
public static ProgramConfiguration CreateConfigs(string path = "") { if (string.IsNullOrEmpty(path)) { path = Path.Combine(AppContext.BaseDirectory, ConfigFileName); } ProgramConfiguration Configs = new ProgramConfiguration(); FillBasic(ref Configs); Console.WriteLine("\nConfiguration File doesn't exists. So a new file will be created\nPlease specify the full location (including full name) of your source template?"); Configs.SourceTemplate = Console.ReadLine(); while (!File.Exists(Configs.SourceTemplate)) { Console.WriteLine(PATH_WRONG); Configs.SourceTemplate = Console.ReadLine(); } Console.WriteLine("Please type the location of a folder where you want to create project folders"); Configs.ParentFolder = Console.ReadLine(); while (!Directory.Exists(Configs.ParentFolder)) { Console.WriteLine(PATH_WRONG); Configs.ParentFolder = Console.ReadLine(); } Console.WriteLine("Checking the location of your build system folders."); while (!Directory.Exists(Configs.BuildSysLocation)) { Console.WriteLine(PATH_WRONG + "\nWrong Path: " + Configs.BuildSysLocation); Configs.BuildSysLocation = Console.ReadLine(); } Configs.BuildSysName = "CPPCPP14BS.sublime-build"; try { string ext = GetExtension(); string FS = @" { ""cmd"": [""g++" + ext + @""",""-std=c++14"", ""${file}"", ""-o"", ""${file_base_name}" + ext + @""", ""&&"" , ""${file_base_name}" + ext + @"<inputf.txt>outputf.txt""], ""shell"":true, ""working_dir"":""$file_path"", ""selector"":""Source.cpp"" } "; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { FS = @" { ""cmd"": [""g++ -std=c++14 \""${file}\"" -o \""${file_path}/${file_base_name}\"" && ${file_path}/${file_base_name}<inputf.txt>outputf.txt""], ""shell"":true, ""working_dir"":""${file_path}"", ""selector"":""Source.cpp"" } "; } File.WriteAllText(Path.Combine(Configs.BuildSysLocation, Configs.BuildSysName), FS); } catch (Exception ex) { Console.WriteLine("Some thing bad happened"); Console.WriteLine(ex.Message); return(null); } Console.WriteLine("Checking location of Mingw bits\\stdc++ file"); while (!File.Exists(Configs.LocationPCHBITSTD)) { Console.WriteLine(PATH_WRONG + "\nWrong Path: " + Configs.LocationPCHBITSTD); Configs.LocationPCHBITSTD = Console.ReadLine(); } string output = JsonConvert.SerializeObject(Configs); File.WriteAllText(path, output); return(Configs); }