From c926c1e945c679bb67f44f90cee628d4ff6419e6 Mon Sep 17 00:00:00 2001 From: Guyutongxue Date: Sat, 14 Aug 2021 13:28:34 +0800 Subject: [PATCH] update --- .vscode/settings.json | 5 +++-- CHANGELOG.md | 5 +++++ CMakeLists.txt | 2 +- pages/config.html | 2 +- pages/config.js | 4 ++++ pages/index.html | 6 +++--- src/environment.h | 3 +++ src/generator.cpp | 33 ++++++++++++++++++--------------- src/native.cpp | 6 +++++- src/native.h | 33 +++++++++++++++++++++++++++------ 10 files changed, 70 insertions(+), 29 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3e3c681..a513f88 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,9 +8,10 @@ "args": [ // "--help" "--use-gui", - "--gui-address=http://localhost:3000/config.html", + "--gui-address=http://localhost:3000/pages/config.html", "--verbose" ], "externalConsole": false - } + }, + "cmake.configureOnOpen": true } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d9fd4e..aa3ffa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # 更新日志 Change Log +## 3.0.2 +*2021.8.14* + +- 修复错误的测试文件注释 + ## 3.0.1 *2021.8.8* diff --git a/CMakeLists.txt b/CMakeLists.txt index 424071a..2bcaa4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.21.0) -project(vscch3 VERSION 3.0.1) +project(vscch3 VERSION 3.0.2) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/pages/config.html b/pages/config.html index f3892b7..8ccfb8e 100644 --- a/pages/config.html +++ b/pages/config.html @@ -54,7 +54,7 @@
欢迎使用 VS Code Config Helper!
-
谷雨同学制作 · 版本 v3.0.0~alpha
+
谷雨同学制作 · 版本 {{backendVersion}}
diff --git a/pages/config.js b/pages/config.js index 5dae27e..56fadb0 100644 --- a/pages/config.js +++ b/pages/config.js @@ -62,6 +62,9 @@ const vm = new Vue({ // Get folder name (not exe) this.vscodePath = dirname(v.VscodePath); } + if ("Version" in v) { + this.backendVersion = v.Version; + } this.compilers = v.Compilers.map(m => ({ path: dirname(m.Path), version: m.VersionNumber, @@ -82,6 +85,7 @@ const vm = new Vue({ }, data: { currentStep: 1, + backendVersion: "v3.0.0", vscodePath: "", vscodeStatus: "resolved", mingwTableHeader: [ diff --git a/pages/index.html b/pages/index.html index 3de9c10..8863a09 100644 --- a/pages/index.html +++ b/pages/index.html @@ -67,7 +67,7 @@ - + 版本 2.x 主页 @@ -97,9 +97,9 @@ this.latestVersion = v["tag_name"]; if (v["assets"] && v["assets"].length > 0) { const asset = v["assets"][0]; - githubUrl = asset["browser_download_url"]; + this.githubUrl = asset["browser_download_url"]; } else { - githubUrl = v["html_url"]; + this.githubUrl = v["html_url"]; } }); }, diff --git a/src/environment.h b/src/environment.h index 9b3a444..66f0494 100644 --- a/src/environment.h +++ b/src/environment.h @@ -25,6 +25,8 @@ #include #include +#include "config.h" + struct CompilerInfo { std::string Path; std::string VersionText; @@ -61,4 +63,5 @@ inline void to_json(nlohmann::json& j, const Environment& e) { j["VscodePath"] = nullptr; } j["Compilers"] = e.Compilers(); + j["Version"] = PROJECT_VERSION; } \ No newline at end of file diff --git a/src/generator.cpp b/src/generator.cpp index a793dc8..9f3b48e 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -367,8 +367,8 @@ std::string Generator::generateTestFile() { "按下 "s + (options.UseExternalTerminal ? "F6" : "Ctrl + F5") + " 编译运行。"}; const std::string compileResultComment{"按下 "s + (options.UseExternalTerminal - ? "F5 后,您将在下方弹出的终端(Terminal)" - : "F6 后,您将在弹出的") + + ? "F6 后,您将在弹出的" + : "F5 后,您将在下方弹出的终端(Terminal)") + "窗口中看到这一行字。"}; bool isCpp{options.Language == ConfigOptions::LanguageType::Cpp}; std::string (*c)(const std::string&){nullptr}; @@ -378,7 +378,7 @@ std::string Generator::generateTestFile() { c = [](const std::string& s) { return "/* " + s + " */"; }; std::ostringstream oss; oss << c("VS Code C/C++ 测试代码 \"Hello World\"") << '\n'; - oss << c("由 VSCodeConfigHelper 生成") << '\n'; + oss << c("由 VSCodeConfigHelper v" PROJECT_VERSION " 生成") << '\n'; oss << '\n'; oss << c("您可以在当前的文件夹(工作文件夹)下编写代码。") << '\n'; oss << '\n'; @@ -460,7 +460,6 @@ void Generator::generateShortcut() { void Generator::generate() { try { - fs::path mingwPath(options.MingwPath); fs::path dotVscode(fs::path(options.WorkspacePath) / ".vscode"); ExtensionManager extensions(options.VscodePath); @@ -475,13 +474,21 @@ void Generator::generate() { if (options.ShouldInstallL11n) { extensions.install("ms-ceintl.vscode-language-pack-zh-hans"); } - - if (options.UseExternalTerminal) { - saveFile(mingwPath / "pause-console.ps1", Embed::PAUSE_CONSOLE_PS1); - addKeybinding("f6", "workbench.action.tasks.runTask", "run and pause"); - } - if (options.ApplyNonAsciiCheck) { - saveFile(mingwPath / "check-ascii.ps1", Embed::CHECK_ASCII_PS1); + if constexpr (Native::isWindows) { + fs::path mingwPath(options.MingwPath); + if (options.UseExternalTerminal) { + saveFile(mingwPath / "pause-console.ps1", Embed::PAUSE_CONSOLE_PS1); + addKeybinding("f6", "workbench.action.tasks.runTask", "run and pause"); + } + if (options.ApplyNonAsciiCheck) { + saveFile(mingwPath / "check-ascii.ps1", Embed::CHECK_ASCII_PS1); + } + if (!options.NoSetEnv) { + addToPath(mingwPath); + } + } else { + // *nix specified + // TODO } if (fs::exists(dotVscode)) { @@ -492,10 +499,6 @@ void Generator::generate() { generateTasksJson(dotVscode / "tasks.json"); generateLaunchJson(dotVscode / "launch.json"); generatePropertiesJson(dotVscode / "c_cpp_properties.json"); - - if (!options.NoSetEnv) { - addToPath(mingwPath); - } if (options.GenerateTestFile == ConfigOptions::GenTestType::Auto) { if (fs::exists(fs::path(options.WorkspacePath) / "helloworld.cpp")) { options.GenerateTestFile = ConfigOptions::GenTestType::Never; diff --git a/src/native.cpp b/src/native.cpp index 8999b98..aea4455 100644 --- a/src/native.cpp +++ b/src/native.cpp @@ -15,6 +15,8 @@ // You should have received a copy of the GNU General Public License // along with VS Code Config Helper. If not, see . +#ifdef _WIN32 + #include "native.h" #include @@ -183,4 +185,6 @@ void checkSystemVersion() { #endif } -} // namespace Native \ No newline at end of file +} // namespace Native + +#endif // _WIN32 \ No newline at end of file diff --git a/src/native.h b/src/native.h index ee5e649..f2de642 100644 --- a/src/native.h +++ b/src/native.h @@ -1,23 +1,25 @@ // Copyright (C) 2021 Guyutongxue -// +// // This file is part of VS Code Config Helper. -// +// // VS Code Config Helper is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // VS Code Config Helper is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with VS Code Config Helper. If not, see . #pragma once +#ifdef _WIN32 #include +#endif #include #include @@ -25,13 +27,15 @@ namespace Native { +#ifdef _WIN32 + std::optional browseFolder(const std::string& initDir); bool createLink(const std::string& link, const std::string& target, const std::string& description = "", const std::string& args = ""); -std::optional getRegistry(HKEY hkey, const std::string& path, - const std::string& key, bool expand = false); +std::optional getRegistry(HKEY hkey, const std::string& path, const std::string& key, + bool expand = false); bool setRegistry(HKEY hkey, const std::string& path, const std::string& key, const std::string& value); @@ -48,4 +52,21 @@ char getch(); void checkSystemVersion(); +constexpr const bool isWindows{true}; + +#else + +constexpr const bool isWindows{false}; + +constexpr const char* cCompiler{"gcc"}; +constexpr const char* cppCompiler{"g++"}; + +#ifdef __APPLE__ + +constexpr const char* cCompiler{"clang"}; +constexpr const char* cppCompiler{"clang++"}; + +#endif // __APPLE__ +#endif // _WIN32 + } // namespace Native \ No newline at end of file