import { determinePlatform } from "../util"; import { Store } from "../store"; import * as path from "path"; export function soiWorkspaceTemplate_0_8_0(store: Store): string { if (determinePlatform() === "windows-amd64") { return JSON.stringify({ workspace: { templateVersion: "0.8.0" }, settings: { compilerPath: path.join( store.soicodeExtensionDataPath, "bundle", "soiheaders", "bundle", "compiler", "bin", "g++.exe" ), debuggerPath: "no/gdb", soiHeaderPath: path.join( store.soicodeExtensionDataPath, "bundle", "soiheaders", "bundle", "soiheader" ), cppHeaderPath: path.join( store.soicodeExtensionDataPath, "bundle", "soiheaders", "bundle", "compiler", "include" ), flags: "-Wall -Wextra -std=c++17 -g3 -ggdb3 -D_GLIBCXX_DEBUG", useBundledSoiHeaders: true } }); } if (determinePlatform() === "darwin-amd64") { return JSON.stringify({ workspace: { templateVersion: "0.8.0" }, settings: { compilerPath: "/usr/bin/c++", debuggerPath: "/usr/bin/gdb", cppHeaderPath: "", soiHeaderPath: path.join( store.soicodeExtensionDataPath, "bundle", "soiheaders", "bundle", "soiheader" ), flags: "-Wall -Wextra -std=c++17 -g3 -ggdb3 -D_GLIBCXX_DEBUG", useBundledSoiHeaders: true } }); } return JSON.stringify({ workspace: { templateVersion: "0.8.0" }, settings: { compilerPath: "/usr/bin/c++", debuggerPath: "/usr/bin/gdb", cppHeaderPath: "", soiHeaderPath: path.join( store.soicodeExtensionDataPath, "bundle", "soiheaders", "bundle", "soiheader" ), flags: "-Wall -Wextra -std=c++17 -g3 -ggdb3 -fsanitize=address,undefined -D_GLIBCXX_DEBUG", useBundledSoiHeaders: true } }); } export interface WorkspaceSettings { workspace: { templateVersion: string; }; settings: { compilerPath: string; debuggerPath: string; cppHeaderPath: string; soiHeaderPath: string; flags: string; useBundledSoiheaders: boolean; }; } export function checkIsWorkspaceSettings(o: any): WorkspaceSettings { if (typeof o.workspace !== "object") { throw new Error("workspace needs to be an Object."); } if (typeof o.workspace.templateVersion !== "string") { throw new Error( "workspace: invalid or missing templateVersion (should be a string)." ); } if (o.workspace.templateVersion !== "0.8.0") { throw new Error( "workspace.templateVersion: You use a unsupported versionnumber. Update the plugin" ); } if (typeof o.settings !== "object") { throw new Error( "settings: invalid or missing settings entry (should be an object)" ); } if (typeof o.settings.compilerPath !== "string") { throw new Error( "settings.compilerPath: invalid or missing settings.compilerPath setting (should be a string)" ); } if (typeof o.settings.debuggerPath !== "string") { throw new Error( "settings.debuggerPath: invalid or missing settings.debuggerPath setting (should be a string)" ); } if (typeof o.settings.cppHeaderPath !== "string") { throw new Error( "settings.cppHeaderPath: invalid or missing settings.cppHeaderPath setting (should be a string)" ); } if (typeof o.settings.soiHeaderPath !== "string") { throw new Error( "settings.soiHeaderPath: invalid or missing settings.soiHeaderPath setting (should be a string)" ); } if (typeof o.settings.flags !== "string") { throw new Error( "settings.flags: invalid or missing settings.flags setting (should be a string)" ); } if (typeof o.settings.flags !== "string") { throw new Error( "settings.useBundledSoiheaders: invalid or missing settings.useBundledSoiheaders setting (should be a boolean)" ); } return o; }