Skip to content
This repository was archived by the owner on Dec 10, 2022. It is now read-only.

Commit c926c1e

Browse files
committed
update
1 parent fdc0072 commit c926c1e

File tree

10 files changed

+70
-29
lines changed

10 files changed

+70
-29
lines changed

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"args": [
99
// "--help"
1010
"--use-gui",
11-
"--gui-address=http://localhost:3000/config.html",
11+
"--gui-address=http://localhost:3000/pages/config.html",
1212
"--verbose"
1313
],
1414
"externalConsole": false
15-
}
15+
},
16+
"cmake.configureOnOpen": true
1617
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# 更新日志 Change Log
22

3+
## 3.0.2
4+
*2021.8.14*
5+
6+
- 修复错误的测试文件注释
7+
38
## 3.0.1
49
*2021.8.8*
510

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.21.0)
22

3-
project(vscch3 VERSION 3.0.1)
3+
project(vscch3 VERSION 3.0.2)
44

55
set(CMAKE_CXX_STANDARD 20)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)

pages/config.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<v-row justify="center">
5555
<v-col md="9">
5656
<div class="text-h4 text-center pt-2">欢迎使用 VS Code Config Helper!</div>
57-
<div class="subtitle-1 text-center pt-1">谷雨同学制作 · 版本 <code>v3.0.0~alpha</code></div>
57+
<div class="subtitle-1 text-center pt-1">谷雨同学制作 · 版本 <code>{{backendVersion}}</code></div>
5858
</v-col>
5959
</v-row>
6060
<v-row justify="center">

pages/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ const vm = new Vue({
6262
// Get folder name (not exe)
6363
this.vscodePath = dirname(v.VscodePath);
6464
}
65+
if ("Version" in v) {
66+
this.backendVersion = v.Version;
67+
}
6568
this.compilers = v.Compilers.map(m => ({
6669
path: dirname(m.Path),
6770
version: m.VersionNumber,
@@ -82,6 +85,7 @@ const vm = new Vue({
8285
},
8386
data: {
8487
currentStep: 1,
88+
backendVersion: "v3.0.0",
8589
vscodePath: "",
8690
vscodeStatus: "resolved",
8791
mingwTableHeader: [

pages/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</div>
6868
</v-col>
6969
</v-row>
70-
<v-footer fixed="70px">
70+
<v-footer fixed height="70px">
7171
<v-row justify="center">
7272
<v-col cols="9">
7373
<a href="https://guyutongxue.gitee.io/VSCodeConfigHelper" target="_blank">版本 2.x 主页</a>
@@ -97,9 +97,9 @@
9797
this.latestVersion = v["tag_name"];
9898
if (v["assets"] && v["assets"].length > 0) {
9999
const asset = v["assets"][0];
100-
githubUrl = asset["browser_download_url"];
100+
this.githubUrl = asset["browser_download_url"];
101101
} else {
102-
githubUrl = v["html_url"];
102+
this.githubUrl = v["html_url"];
103103
}
104104
});
105105
},

src/environment.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <unordered_set>
2626
#include <optional>
2727

28+
#include "config.h"
29+
2830
struct CompilerInfo {
2931
std::string Path;
3032
std::string VersionText;
@@ -61,4 +63,5 @@ inline void to_json(nlohmann::json& j, const Environment& e) {
6163
j["VscodePath"] = nullptr;
6264
}
6365
j["Compilers"] = e.Compilers();
66+
j["Version"] = PROJECT_VERSION;
6467
}

src/generator.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ std::string Generator::generateTestFile() {
367367
"按下 "s + (options.UseExternalTerminal ? "F6" : "Ctrl + F5") + " 编译运行。"};
368368
const std::string compileResultComment{"按下 "s +
369369
(options.UseExternalTerminal
370-
? "F5 后,您将在下方弹出的终端(Terminal)"
371-
: "F6 后,您将在弹出的") +
370+
? "F6 后,您将在弹出的"
371+
: "F5 后,您将在下方弹出的终端(Terminal)") +
372372
"窗口中看到这一行字。"};
373373
bool isCpp{options.Language == ConfigOptions::LanguageType::Cpp};
374374
std::string (*c)(const std::string&){nullptr};
@@ -378,7 +378,7 @@ std::string Generator::generateTestFile() {
378378
c = [](const std::string& s) { return "/* " + s + " */"; };
379379
std::ostringstream oss;
380380
oss << c("VS Code C/C++ 测试代码 \"Hello World\"") << '\n';
381-
oss << c("由 VSCodeConfigHelper 生成") << '\n';
381+
oss << c("由 VSCodeConfigHelper v" PROJECT_VERSION " 生成") << '\n';
382382
oss << '\n';
383383
oss << c("您可以在当前的文件夹(工作文件夹)下编写代码。") << '\n';
384384
oss << '\n';
@@ -460,7 +460,6 @@ void Generator::generateShortcut() {
460460

461461
void Generator::generate() {
462462
try {
463-
fs::path mingwPath(options.MingwPath);
464463
fs::path dotVscode(fs::path(options.WorkspacePath) / ".vscode");
465464

466465
ExtensionManager extensions(options.VscodePath);
@@ -475,13 +474,21 @@ void Generator::generate() {
475474
if (options.ShouldInstallL11n) {
476475
extensions.install("ms-ceintl.vscode-language-pack-zh-hans");
477476
}
478-
479-
if (options.UseExternalTerminal) {
480-
saveFile(mingwPath / "pause-console.ps1", Embed::PAUSE_CONSOLE_PS1);
481-
addKeybinding("f6", "workbench.action.tasks.runTask", "run and pause");
482-
}
483-
if (options.ApplyNonAsciiCheck) {
484-
saveFile(mingwPath / "check-ascii.ps1", Embed::CHECK_ASCII_PS1);
477+
if constexpr (Native::isWindows) {
478+
fs::path mingwPath(options.MingwPath);
479+
if (options.UseExternalTerminal) {
480+
saveFile(mingwPath / "pause-console.ps1", Embed::PAUSE_CONSOLE_PS1);
481+
addKeybinding("f6", "workbench.action.tasks.runTask", "run and pause");
482+
}
483+
if (options.ApplyNonAsciiCheck) {
484+
saveFile(mingwPath / "check-ascii.ps1", Embed::CHECK_ASCII_PS1);
485+
}
486+
if (!options.NoSetEnv) {
487+
addToPath(mingwPath);
488+
}
489+
} else {
490+
// *nix specified
491+
// TODO
485492
}
486493

487494
if (fs::exists(dotVscode)) {
@@ -492,10 +499,6 @@ void Generator::generate() {
492499
generateTasksJson(dotVscode / "tasks.json");
493500
generateLaunchJson(dotVscode / "launch.json");
494501
generatePropertiesJson(dotVscode / "c_cpp_properties.json");
495-
496-
if (!options.NoSetEnv) {
497-
addToPath(mingwPath);
498-
}
499502
if (options.GenerateTestFile == ConfigOptions::GenTestType::Auto) {
500503
if (fs::exists(fs::path(options.WorkspacePath) / "helloworld.cpp")) {
501504
options.GenerateTestFile = ConfigOptions::GenTestType::Never;

src/native.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with VS Code Config Helper. If not, see <http://www.gnu.org/licenses/>.
1717

18+
#ifdef _WIN32
19+
1820
#include "native.h"
1921

2022
#include <conio.h>
@@ -183,4 +185,6 @@ void checkSystemVersion() {
183185
#endif
184186
}
185187

186-
} // namespace Native
188+
} // namespace Native
189+
190+
#endif // _WIN32

src/native.h

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
// Copyright (C) 2021 Guyutongxue
2-
//
2+
//
33
// This file is part of VS Code Config Helper.
4-
//
4+
//
55
// VS Code Config Helper is free software: you can redistribute it and/or modify
66
// it under the terms of the GNU General Public License as published by
77
// the Free Software Foundation, either version 3 of the License, or
88
// (at your option) any later version.
9-
//
9+
//
1010
// VS Code Config Helper is distributed in the hope that it will be useful,
1111
// but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
// GNU General Public License for more details.
14-
//
14+
//
1515
// You should have received a copy of the GNU General Public License
1616
// along with VS Code Config Helper. If not, see <http://www.gnu.org/licenses/>.
1717

1818
#pragma once
1919

20+
#ifdef _WIN32
2021
#include <windows.h>
22+
#endif
2123

2224
#include <boost/filesystem.hpp>
2325
#include <optional>
2426
#include <string>
2527

2628
namespace Native {
2729

30+
#ifdef _WIN32
31+
2832
std::optional<std::string> browseFolder(const std::string& initDir);
2933

3034
bool createLink(const std::string& link, const std::string& target,
3135
const std::string& description = "", const std::string& args = "");
3236

33-
std::optional<std::string> getRegistry(HKEY hkey, const std::string& path,
34-
const std::string& key, bool expand = false);
37+
std::optional<std::string> getRegistry(HKEY hkey, const std::string& path, const std::string& key,
38+
bool expand = false);
3539

3640
bool setRegistry(HKEY hkey, const std::string& path, const std::string& key,
3741
const std::string& value);
@@ -48,4 +52,21 @@ char getch();
4852

4953
void checkSystemVersion();
5054

55+
constexpr const bool isWindows{true};
56+
57+
#else
58+
59+
constexpr const bool isWindows{false};
60+
61+
constexpr const char* cCompiler{"gcc"};
62+
constexpr const char* cppCompiler{"g++"};
63+
64+
#ifdef __APPLE__
65+
66+
constexpr const char* cCompiler{"clang"};
67+
constexpr const char* cppCompiler{"clang++"};
68+
69+
#endif // __APPLE__
70+
#endif // _WIN32
71+
5172
} // namespace Native

0 commit comments

Comments
 (0)