Skip to content

Commit cb7ba9a

Browse files
ladisginoperasfantom
authored andcommitted
Change cmake option from string to array
1 parent 84ea263 commit cb7ba9a

File tree

12 files changed

+32
-16
lines changed

12 files changed

+32
-16
lines changed

server/proto/testgen.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ enum ProjectConfigStatus {
219219
message ProjectConfigRequest {
220220
ProjectContext projectContext = 1;
221221
ConfigMode configMode = 2;
222-
string cmakeOptions = 3;
222+
repeated string cmakeOptions = 3;
223223
}
224224

225225
message ProjectConfigResponse {

server/src/Server.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,11 @@ Server::TestsGenServiceImpl::ConfigureProject(ServerContext *context,
605605
return UserProjectConfiguration::CheckProjectConfiguration(buildDirPath, writer);
606606
case ConfigMode::CREATE_BUILD_DIR:
607607
return UserProjectConfiguration::RunBuildDirectoryCreation(buildDirPath, writer);
608-
case ConfigMode::GENERATE_JSON_FILES:
608+
case ConfigMode::GENERATE_JSON_FILES: {
609+
std::vector<string> cmakeOptions(request->cmakeoptions().begin(), request->cmakeoptions().end());
609610
return UserProjectConfiguration::RunProjectConfigurationCommands(
610-
buildDirPath, projectContext.projectname(), request->cmakeoptions(), writer);
611+
buildDirPath, projectContext.projectname(), cmakeOptions, writer);
612+
}
611613
default:
612614
return Status(StatusCode::CANCELLED, "Invalid request type.");
613615
}

server/src/building/UserProjectConfiguration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ Status UserProjectConfiguration::RunBuildDirectoryCreation(const fs::path &build
4646
Status
4747
UserProjectConfiguration::RunProjectConfigurationCommands(const fs::path &buildDirPath,
4848
const string &projectName,
49-
const string &cmakeOptions,
49+
vector<string> cmakeOptions,
5050
ProjectConfigWriter const &writer) {
5151
try {
5252
fs::path bearShPath = createBearShScript(buildDirPath);
53-
54-
ShellExecTask::ExecutionParameters cmakeParams(Paths::getCMake(), {cmakeOptions, ".."});
53+
cmakeOptions.emplace_back("..");
54+
ShellExecTask::ExecutionParameters cmakeParams(Paths::getCMake(), cmakeOptions);
5555
ShellExecTask::ExecutionParameters bearMakeParams(Paths::getBear(), {Paths::getMake(), MakefileUtils::threadFlag()});
5656

5757

server/src/building/UserProjectConfiguration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class UserProjectConfiguration {
2828

2929
static Status RunProjectConfigurationCommands(const fs::path &buildDirPath,
3030
const string &projectName,
31-
const string &cmakeOptions,
31+
vector<string> cmakeOptions,
3232
ProjectConfigWriter const &writer);
3333

3434
private:

vscode-plugin/media/wizard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h2>🏗️Build Directory</h2>
110110
<h2>🎌CMake Options</h2>
111111
<p>Options passed to CMake command. </p>
112112
<label class="utbot-form__tab_label" for="cmakeOptions">CMake options</label>
113-
<input class="utbot-form__tab_input" id="cmakeOptions" placeholder="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_EXPORT_LINK_COMMANDS=ON">
113+
<textarea class="utbot-form__tab_input" id="cmakeOptions" placeholder="{{cmakeOptions}}"></textarea>
114114

115115
</div>
116116

vscode-plugin/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,14 @@
473473
"markdownDescription": "%unittestbot.paths.buildDirectory.description%"
474474
},
475475
"unittestbot.paths.cmakeOptions": {
476-
"type": "string",
477-
"default": "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_EXPORT_LINK_COMMANDS=ON",
476+
"type": "array",
477+
"items": {
478+
"type": "string"
479+
},
480+
"default": [
481+
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
482+
"-DCMAKE_EXPORT_LINK_COMMANDS=ON"
483+
],
478484
"markdownDescription": "%unittestbot.paths.cmakeOptions.description%"
479485
},
480486
"unittestbot.paths.testsDirectory": {

vscode-plugin/src/client/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ export class Client {
379379
projectName: string,
380380
projectPath: string,
381381
buildDirRelativePath: string,
382-
cmakeOptions: string,
382+
cmakeOptions: Array<string>,
383383
configMode: ConfigMode,
384384
progressKey: utbotUI.ProgressKey,
385385
token: vs.CancellationToken,
@@ -392,7 +392,7 @@ export class Client {
392392
const projectConfigRequest = new ProjectConfigRequest();
393393
projectConfigRequest.setProjectcontext(projectContext);
394394
projectConfigRequest.setConfigmode(configMode);
395-
projectConfigRequest.setCmakeoptions(cmakeOptions);
395+
projectConfigRequest.setCmakeoptionsList(cmakeOptions);
396396
try {
397397
const response = this.testsService.configureProject(projectConfigRequest, this.metadata);
398398
await this.handleServerResponse(response, progressKey, token, resolve, reject, responseHandler);

vscode-plugin/src/config/defaultValues.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export class DefaultConfigValues {
1616
public static readonly POSSIBLE_BUILD_DIR_NAMES = ['out', 'build'];
1717
public static readonly POSSIBLE_TEST_DIR_NAMES = ['test'];
1818

19+
public static readonly DEFAULT_CMAKE_OPTIONS = ['-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '-DCMAKE_EXPORT_LINK_COMMANDS=ON'];
20+
1921
public static getDefaultHost(): string {
2022
let host = Prefs.getGlobalHost();
2123
const sftHost = vsUtils.getFromSftpConfig("host");

vscode-plugin/src/config/prefs.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ export class Prefs {
201201
return this.getLocalBuildDirPath();
202202
}
203203

204-
public static getCmakeOptions(): string {
205-
return this.getAsset(Prefs.CMAKE_OPTIONS_PREF);
204+
public static getCmakeOptions(): Array<string> {
205+
return this.getAssetBase(Prefs.CMAKE_OPTIONS_PREF, defcfg.DefaultConfigValues.DEFAULT_CMAKE_OPTIONS);
206206
}
207207

208208

@@ -358,7 +358,8 @@ export class Prefs {
358358
}
359359

360360
public static async setCmakeOptions(options: string): Promise<void> {
361-
await this.setAsset(Prefs.CMAKE_OPTIONS_PREF, options);
361+
const cmakeOptions = options.split("\n")
362+
await this.setAsset(Prefs.CMAKE_OPTIONS_PREF, cmakeOptions);
362363
}
363364

364365
public static getBuildDirectory(): string {

vscode-plugin/src/config/projectConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class ProjectConfig {
2020
private readonly projectName: string;
2121
private readonly projectPath: string;
2222
private readonly buildDirRelativePath: string;
23-
private readonly cmakeOptions: string;
23+
private readonly cmakeOptions: Array<string>;
2424

2525
constructor(private readonly client: Client) {
2626
this.projectName = Prefs.getProjectName();

vscode-plugin/src/wizard/wizard.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export class UtbotWizardPanel {
191191
.setPredictedRemotePath(defcfg.DefaultConfigValues.getDefaultRemotePath())
192192
.setPredictedBuildDirectory(predictedBuildDirectory)
193193
.setPlatform(os.platform())
194+
.setCmakeOptions(defcfg.DefaultConfigValues.DEFAULT_CMAKE_OPTIONS)
194195
.build();
195196
}
196197
}

vscode-plugin/src/wizard/wizardHtmlBuilder.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,9 @@ export class WizardHtmlBuilder {
6868
this.content = this.content.replace('{{os}}', platform);
6969
return this;
7070
}
71+
public setCmakeOptions(cmakeOptions: Array<string>): WizardHtmlBuilder {
72+
this.content = this.content.replace('{{cmakeOptions}}', cmakeOptions.join("\n"));
73+
return this;
74+
}
7175

7276
}

0 commit comments

Comments
 (0)