diff --git a/src/soiworkspace.ts b/src/soiworkspace.ts index 3155d643cae11d70d0bf918f5834e81c997f1b6d..840fcd41a39e5b2bee7a55f1837afd2f28f98f15 100644 --- a/src/soiworkspace.ts +++ b/src/soiworkspace.ts @@ -52,6 +52,7 @@ async function determineWorkspaceFolder(): Promise { } async function determineWorkspaceSettingsFileContent( + store: Store, workspace: string ): Promise { let workspaceSettings = await vscode.workspace.findFiles("soiworkspace.json"); @@ -73,7 +74,7 @@ async function determineWorkspaceSettingsFileContent( try { await fs.writeFile( path.join(workspace, "soiworkspace.json"), - soiWorkspaceTemplate_0_8_0() + soiWorkspaceTemplate_0_8_0(store) ); } catch (err) { vscode.window.showErrorMessage( @@ -98,9 +99,11 @@ async function determineWorkspaceSettingsFileContent( } async function determineWorkspaceSettings( + store: Store, workspace: string ): Promise { let workspaceSettingsFileContent = await determineWorkspaceSettingsFileContent( + store, workspace ); if (workspaceSettingsFileContent === null) { @@ -118,12 +121,14 @@ async function determineWorkspaceSettings( } } -export async function readWorkspaceState(): Promise { +export async function readWorkspaceState( + store: Store +): Promise { let workdir = await determineWorkspaceFolder(); if (workdir === null) { return "NoFolderOpen"; } - let settings = await determineWorkspaceSettings(workdir); + let settings = await determineWorkspaceSettings(store, workdir); if (settings === null) { return "NoSOIWorkspace"; } @@ -139,6 +144,6 @@ export async function readWorkspaceState(): Promise { export async function initializeWorkspace(store: Store) { let workspace = await determineWorkspaceFolder(); if (workspace !== null) { - await determineWorkspaceSettings(workspace); + await determineWorkspaceSettings(store, workspace); } } diff --git a/src/soiworkspaceFormats/soiworkspace-0-8-0.ts b/src/soiworkspaceFormats/soiworkspace-0-8-0.ts index 9ab729ac00682cbfa5afee1f3dfadcb960e105e0..134e6b07d54588b599cf4dc5b79a22797b506db1 100644 --- a/src/soiworkspaceFormats/soiworkspace-0-8-0.ts +++ b/src/soiworkspaceFormats/soiworkspace-0-8-0.ts @@ -1,4 +1,51 @@ -export function soiWorkspaceTemplate_0_8_0(): string { +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 `{ + "workspace":{ + "templateVersion":"0.8.0" + }, + "settings": { + "compilerPath": "${path.join( + store.soicodeExtensionDataPath, + "bundle", + "soiheaders", + "compiler", + "bin" + )}", + "debuggerPath": "no/gdb", + "cppHeaderPath": "${path.join( + store.soicodeExtensionDataPath, + "bundle", + "soiheaders", + "soiheader" + )}", + "soiHeaderPath": "", + "flags": "-Wall -Wextra -std=c++17 -g3 -ggdb3 -D_GLIBCXX_DEBUG", + "useBundledSoiHeaders": true + } +} +`; + } + if (determinePlatform() === "darwin-amd64") { + return `{ + "workspace":{ + "templateVersion":"0.8.0" + }, + "settings": { + "compilerPath": "/usr/bin/c++", + "debuggerPath": "/usr/bin/gdb", + "cppHeaderPath": "", + "soiHeaderPath": "", + "flags": "-Wall -Wextra -std=c++17 -g3 -ggdb3 -D_GLIBCXX_DEBUG", + "useBundledSoiHeaders": true + } +} +`; + } return `{ "workspace":{ "templateVersion":"0.8.0" diff --git a/src/store.ts b/src/store.ts index 223578d1c5435a0e2970797bd5ae9433d3328f15..ad415e38a023549e35d5f67c1df10b318d467c0a 100644 --- a/src/store.ts +++ b/src/store.ts @@ -55,7 +55,7 @@ export class Store { } emitFsChange(this: Store) { - readWorkspaceState().then(workspaceState => { + readWorkspaceState(this).then(workspaceState => { this.workspace = workspaceState; for (let sub of this.fileChangeSubscribers) { sub();