Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output argument support for MSVC #506

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 9 additions & 2 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Language } from './types';
import { spawn } from 'child_process';
import path from 'path';
import {
getCOutputArgPref,
getCppOutputArgPref,
getSaveLocationPref,
getHideStderrorWhenCompiledOK,
} from './preferences';
Expand Down Expand Up @@ -56,7 +58,7 @@ const getFlags = (language: Language, srcPath: string): string[] => {
case 'cpp': {
ret = [
srcPath,
'-o',
getCppOutputArgPref(),
getBinSaveLocation(srcPath),
...args,
'-D',
Expand All @@ -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');
Expand Down
10 changes: 8 additions & 2 deletions src/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ') || [];
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading