diff --git a/package.json b/package.json index 9ecbcf5..30598a9 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,16 @@ "cph.language.c.Command": { "type": "string", "default": "gcc", - "description": "Command used to compile .c files. Example 'gcc', 'gcc-10', 'clang', etc." + "description": "Command used to compile .c files. Example 'gcc', 'gcc-10', 'clang', 'msvc', etc." + }, + "cph.language.c.OutputArg": { + "type": "string", + "default": "-o", + "enum": [ + "-o", + "/Fe:" + ], + "description": "C compiler's argument that specifies the output files." }, "cph.language.cpp.Args": { "title": "Compilation flags for .cpp files", @@ -131,6 +140,15 @@ "default": "g++", "description": "Command used to compile .cpp files. Example 'g++', 'g++-10', 'clang++', etc." }, + "cph.language.cpp.OutputArg": { + "type": "string", + "default": "-o", + "enum": [ + "-o", + "/Fe:" + ], + "description": "C++ compiler's argument that specifies the output files." + }, "cph.language.python.Args": { "title": "Compilation flags for Python", "type": "string", diff --git a/src/compiler.ts b/src/compiler.ts index 00a6a9d..bad8f27 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -3,6 +3,8 @@ import { Language } from './types'; import { spawn } from 'child_process'; import path from 'path'; import { + getCOutputArgPref, + getCppOutputArgPref, getSaveLocationPref, getHideStderrorWhenCompiledOK, } from './preferences'; @@ -56,7 +58,7 @@ const getFlags = (language: Language, srcPath: string): string[] => { case 'cpp': { ret = [ srcPath, - '-o', + getCppOutputArgPref(), getBinSaveLocation(srcPath), ...args, '-D', @@ -72,7 +74,12 @@ const getFlags = (language: Language, srcPath: string): string[] => { } case 'c': { { - ret = [srcPath, '-o', getBinSaveLocation(srcPath), ...args]; + ret = [ + srcPath, + getCOutputArgPref(), + getBinSaveLocation(srcPath), + ...args, + ]; if (onlineJudgeEnv) { ret.push('-D'); ret.push('ONLINE_JUDGE'); diff --git a/src/preferences.ts b/src/preferences.ts index 4ff7503..986f5b4 100644 --- a/src/preferences.ts +++ b/src/preferences.ts @@ -44,11 +44,17 @@ export const getTimeOutPref = (): number => export const getRetainWebviewContextPref = (): boolean => getPreference('general.retainWebviewContext'); +export const getCArgsPref = (): string[] => + getPreference('language.c.Args').split(' ') || []; + +export const getCOutputArgPref = (): string => + getPreference('language.c.OutputArg'); + export const getCppArgsPref = (): string[] => getPreference('language.cpp.Args').split(' ') || []; -export const getCArgsPref = (): string[] => - getPreference('language.c.Args').split(' ') || []; +export const getCppOutputArgPref = (): string => + getPreference('language.cpp.OutputArg'); export const getPythonArgsPref = (): string[] => getPreference('language.python.Args').split(' ') || []; diff --git a/src/types.ts b/src/types.ts index a881498..8d6f37f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -15,9 +15,11 @@ export type prefSection = | 'language.c.Args' | 'language.c.SubmissionCompiler' | 'language.c.Command' + | 'language.c.OutputArg' | 'language.cpp.Args' | 'language.cpp.SubmissionCompiler' | 'language.cpp.Command' + | 'language.cpp.OutputArg' | 'language.go.Args' | 'language.go.SubmissionCompiler' | 'language.go.Command'