Add instruction for development in vscode (#151)
* add instruction for development in vscode * [ci skip] update doc
This commit is contained in:
parent
94e955b07a
commit
9acca16f8e
|
@ -1,4 +1,5 @@
|
||||||
/.vs
|
/.vs
|
||||||
|
/.vscode
|
||||||
/dist
|
/dist
|
||||||
/packages/appimage/*/*.AppImage
|
/packages/appimage/*/*.AppImage
|
||||||
/packages/archlinux/*
|
/packages/archlinux/*
|
||||||
|
|
90
BUILD.md
90
BUILD.md
|
@ -1,6 +1,70 @@
|
||||||
# Dependancy
|
# General Development Notes
|
||||||
|
|
||||||
Red Panda C++ need Qt 5 (>=5.12) to build.
|
Red Panda C++ need Qt 5 (≥ 5.12) to build.
|
||||||
|
|
||||||
|
Recommended development environments:
|
||||||
|
1. Visual Studio Code.
|
||||||
|
* Better performance.
|
||||||
|
2. Qt Creator.
|
||||||
|
* (Almost) zero configuration.
|
||||||
|
* Built-in UI designer.
|
||||||
|
* Debugger integration with Qt.
|
||||||
|
|
||||||
|
To setup development environment in Visual Studio Code:
|
||||||
|
1. Install [clangd](https://clangd.llvm.org/) and [clangd extension](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd).
|
||||||
|
2. Install [Bear](https://github.com/rizsotto/Bear).
|
||||||
|
3. Install [CodeLLDB extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb).
|
||||||
|
4. Generate compilation database:
|
||||||
|
```bash
|
||||||
|
mkdir -p /path/to/build && cd /path/to/build
|
||||||
|
qmake CONFIG+=debug PREFIX=/path/to/pkg /path/to/src
|
||||||
|
bear -- make -j$(nproc)
|
||||||
|
```
|
||||||
|
5. Add `--compile-commands-dir=/path/to/build` to workspace-wide “Clangd: Arguments” or edit `.vscode/settings.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"clangd.arguments": [
|
||||||
|
"--compile-commands-dir=/path/to/build"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
6. Set up build task in `.vscode/tasks.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "cd /path/to/build && make -j$(nproc) && make install",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
and debug task in `.vscode/launch.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "build",
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "/path/to/pkg/bin/RedPandaIDE",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "/path/to/build",
|
||||||
|
"env": {
|
||||||
|
"QT_ASSUME_STDERR_HAS_CONSOLE": "1"
|
||||||
|
},
|
||||||
|
"preLaunchTask": "build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
|
|
||||||
|
@ -53,7 +117,7 @@ Prerequisites:
|
||||||
pacman -S $MINGW_PACKAGE_PREFIX-toolchain $MINGW_PACKAGE_PREFIX-qt5-static
|
pacman -S $MINGW_PACKAGE_PREFIX-toolchain $MINGW_PACKAGE_PREFIX-qt5-static
|
||||||
```
|
```
|
||||||
|
|
||||||
For build only:
|
To build:
|
||||||
|
|
||||||
1. In selected environment, set related variables:
|
1. In selected environment, set related variables:
|
||||||
```bash
|
```bash
|
||||||
|
@ -73,11 +137,6 @@ For build only:
|
||||||
mingw32-make install
|
mingw32-make install
|
||||||
```
|
```
|
||||||
|
|
||||||
For development:
|
|
||||||
|
|
||||||
1. Install Qt Creator (either MSYS2 edition from package `$MINGW_PACKAGE_PREFIX-qt-creator` or standalone edition from [Qt.io downloads site](https://download.qt.io/official_releases/qtcreator/)).
|
|
||||||
2. Open `Red_Panda_CPP.pro` with Qt Creator.
|
|
||||||
|
|
||||||
## Qt.io Qt Library with MinGW Toolchain or MSVC Toolchain
|
## Qt.io Qt Library with MinGW Toolchain or MSVC Toolchain
|
||||||
|
|
||||||
Prerequisites:
|
Prerequisites:
|
||||||
|
@ -90,7 +149,7 @@ Prerequisites:
|
||||||
2. For MSVC toolchain, install Visual Studio 2019 or later, or Visual Studio Build Tools 2019 or later, with _Desktop Development with C++_ workload.
|
2. For MSVC toolchain, install Visual Studio 2019 or later, or Visual Studio Build Tools 2019 or later, with _Desktop Development with C++_ workload.
|
||||||
- In _Installation Details_ panel, under the _Desktop Development with C++_ workload, select at least one _MSVC x86/x64 build tools_ and one _Windows SDK_.
|
- In _Installation Details_ panel, under the _Desktop Development with C++_ workload, select at least one _MSVC x86/x64 build tools_ and one _Windows SDK_.
|
||||||
|
|
||||||
For build only:
|
To build:
|
||||||
|
|
||||||
1. Launch Qt environment from Start Menu.
|
1. Launch Qt environment from Start Menu.
|
||||||
2. In Qt environment, set related variables:
|
2. In Qt environment, set related variables:
|
||||||
|
@ -135,10 +194,6 @@ For build only:
|
||||||
windeployqt "%INSTALL_DIR%\RedPandaIDE.exe"
|
windeployqt "%INSTALL_DIR%\RedPandaIDE.exe"
|
||||||
```
|
```
|
||||||
|
|
||||||
For development:
|
|
||||||
|
|
||||||
1. Open `Red_Panda_CPP.pro` with Qt Creator.
|
|
||||||
|
|
||||||
## Advanced Option: vcpkg Qt Static Library with MSVC Toolchain
|
## Advanced Option: vcpkg Qt Static Library with MSVC Toolchain
|
||||||
|
|
||||||
Prerequisites:
|
Prerequisites:
|
||||||
|
@ -220,9 +275,8 @@ General steps:
|
||||||
- Install recent version of GCC (≥ 7) or Clang (≥ 6) that supports C++17.
|
- Install recent version of GCC (≥ 7) or Clang (≥ 6) that supports C++17.
|
||||||
- Install Qt 5 (≥ 5.12) Base, SVG and Tools modules, including both libraries and development files.
|
- Install Qt 5 (≥ 5.12) Base, SVG and Tools modules, including both libraries and development files.
|
||||||
- Optionally install fcitx5-qt for building with static Qt library.
|
- Optionally install fcitx5-qt for building with static Qt library.
|
||||||
- Optionally install Qt Creator for development.
|
|
||||||
|
|
||||||
For build only:
|
To build:
|
||||||
|
|
||||||
1. Configure:
|
1. Configure:
|
||||||
```bash
|
```bash
|
||||||
|
@ -237,10 +291,6 @@ For build only:
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
For development:
|
|
||||||
|
|
||||||
1. Open `Red_Panda_CPP.pro` with Qt Creator
|
|
||||||
|
|
||||||
qmake variables:
|
qmake variables:
|
||||||
- `PREFIX`: default to `/usr/local`. It should be set to `/usr` or `/opt/redpanda-cpp` when packaging.
|
- `PREFIX`: default to `/usr/local`. It should be set to `/usr` or `/opt/redpanda-cpp` when packaging.
|
||||||
- `LIBEXECDIR`: directory for auxiliary executables, default to `$PREFIX/libexec`. Arch Linux uses `/usr/lib`.
|
- `LIBEXECDIR`: directory for auxiliary executables, default to `$PREFIX/libexec`. Arch Linux uses `/usr/lib`.
|
||||||
|
|
90
BUILD_cn.md
90
BUILD_cn.md
|
@ -1,6 +1,70 @@
|
||||||
# 依赖
|
# 通用开发说明
|
||||||
|
|
||||||
小熊猫C++需要Qt 5(>=5.12)
|
小熊猫 C++ 需要 Qt 5(≥ 5.12)。
|
||||||
|
|
||||||
|
推荐开发环境:
|
||||||
|
1. Visual Studio Code。
|
||||||
|
* 性能更好。
|
||||||
|
2. Qt Creator。
|
||||||
|
* (几乎)无需配置。
|
||||||
|
* 内建 UI 设计器。
|
||||||
|
* 调试器的 Qt 集成。
|
||||||
|
|
||||||
|
设置 Visual Studio Code 开发环境的步骤:
|
||||||
|
1. 安装 [clangd](https://clangd.llvm.org/) 和 [clangd 扩展](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd)。
|
||||||
|
2. 安装 [Bear](https://github.com/rizsotto/Bear)。
|
||||||
|
3. 安装 [CodeLLDB extension](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)。
|
||||||
|
4. 生成编译数据库:
|
||||||
|
```bash
|
||||||
|
mkdir -p /path/to/build && cd /path/to/build
|
||||||
|
qmake CONFIG+=debug PREFIX=/path/to/pkg /path/to/src
|
||||||
|
bear -- make -j$(nproc)
|
||||||
|
```
|
||||||
|
5. 在本工作区 “Clangd: Arguments” 中添加 `--compile-commands-dir=/path/to/build` 或直接修改 `.vscode/settings.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"clangd.arguments": [
|
||||||
|
"--compile-commands-dir=/path/to/build"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
6. 在 `.vscode/tasks.json` 中配置构建任务:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "cd /path/to/build && make -j$(nproc) && make install",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
并在 `.vscode/launch.json` 中配置调试任务:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "build",
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "/path/to/pkg/bin/RedPandaIDE",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "/path/to/build",
|
||||||
|
"env": {
|
||||||
|
"QT_ASSUME_STDERR_HAS_CONSOLE": "1"
|
||||||
|
},
|
||||||
|
"preLaunchTask": "build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
|
|
||||||
|
@ -53,7 +117,7 @@
|
||||||
pacman -S $MINGW_PACKAGE_PREFIX-toolchain $MINGW_PACKAGE_PREFIX-qt5-static
|
pacman -S $MINGW_PACKAGE_PREFIX-toolchain $MINGW_PACKAGE_PREFIX-qt5-static
|
||||||
```
|
```
|
||||||
|
|
||||||
仅构建:
|
构建:
|
||||||
|
|
||||||
1. 在选定的环境中,设置相关变量:
|
1. 在选定的环境中,设置相关变量:
|
||||||
```bash
|
```bash
|
||||||
|
@ -73,11 +137,6 @@
|
||||||
mingw32-make install
|
mingw32-make install
|
||||||
```
|
```
|
||||||
|
|
||||||
开发:
|
|
||||||
|
|
||||||
1. 安装 Qt Creator(MSYS2 `$MINGW_PACKAGE_PREFIX-qt-creator` 包或 [Qt.io 下载站点](https://download.qt.io/official_releases/qtcreator/)及[镜像站](http://mirrors.sjtug.sjtu.edu.cn/qt/official_releases/qtcreator/)的独立安装包均可)。
|
|
||||||
2. 用 Qt Creator 打开 `Red_Panda_CPP.pro` 文件。
|
|
||||||
|
|
||||||
## Qt.io 的 Qt 库 + MinGW 工具链或 MSVC 工具链
|
## Qt.io 的 Qt 库 + MinGW 工具链或 MSVC 工具链
|
||||||
|
|
||||||
前置条件:
|
前置条件:
|
||||||
|
@ -90,7 +149,7 @@
|
||||||
2. 对于 MSVC 工具链,安装 Visual Studio 2019 或更高版本,或 “Visual Studio 构建工具 2019” 或更高版本,附带 “使用 C++ 的桌面开发” 工作负载。
|
2. 对于 MSVC 工具链,安装 Visual Studio 2019 或更高版本,或 “Visual Studio 构建工具 2019” 或更高版本,附带 “使用 C++ 的桌面开发” 工作负载。
|
||||||
- 在 “安装详细信息” 面板,“使用 C++ 的桌面开发” 之下,至少选择一个 “MSVC x86/x64 生成工具” 和一个 Windows SDK。
|
- 在 “安装详细信息” 面板,“使用 C++ 的桌面开发” 之下,至少选择一个 “MSVC x86/x64 生成工具” 和一个 Windows SDK。
|
||||||
|
|
||||||
仅构建:
|
构建:
|
||||||
|
|
||||||
1. 从开始菜单中打开 Qt 环境。
|
1. 从开始菜单中打开 Qt 环境。
|
||||||
2. 在 Qt 环境中,设置相关变量:
|
2. 在 Qt 环境中,设置相关变量:
|
||||||
|
@ -135,10 +194,6 @@
|
||||||
windeployqt "%INSTALL_DIR%\RedPandaIDE.exe"
|
windeployqt "%INSTALL_DIR%\RedPandaIDE.exe"
|
||||||
```
|
```
|
||||||
|
|
||||||
开发:
|
|
||||||
|
|
||||||
1. 用 Qt Creator 打开 `Red_Panda_CPP.pro` 文件。
|
|
||||||
|
|
||||||
## 高级选项:vcpkg 的 Qt 静态库 + MSVC 工具链
|
## 高级选项:vcpkg 的 Qt 静态库 + MSVC 工具链
|
||||||
|
|
||||||
前置条件:
|
前置条件:
|
||||||
|
@ -220,9 +275,8 @@
|
||||||
- 安装支持 C++17 的 GCC(≥ 7)或 Clang(≥ 6)。
|
- 安装支持 C++17 的 GCC(≥ 7)或 Clang(≥ 6)。
|
||||||
- 安装 Qt 5(≥ 5.12)Base、SVG、Tools 模块,包括库和开发文件。
|
- 安装 Qt 5(≥ 5.12)Base、SVG、Tools 模块,包括库和开发文件。
|
||||||
- 如果使用静态版本的 Qt 编译,还要安装 fcitx5-qt。
|
- 如果使用静态版本的 Qt 编译,还要安装 fcitx5-qt。
|
||||||
- 根据需要,安装 Qt Creator 用于开发。
|
|
||||||
|
|
||||||
仅构建:
|
构建:
|
||||||
|
|
||||||
1. 配置:
|
1. 配置:
|
||||||
```bash
|
```bash
|
||||||
|
@ -237,10 +291,6 @@
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
开发:
|
|
||||||
|
|
||||||
1. 使用 Qt Creator 打开 `Red_Panda_CPP.pro` 文件。
|
|
||||||
|
|
||||||
qmake 变量:
|
qmake 变量:
|
||||||
- `PREFIX`:默认值是 `/usr/local`。打包时应该定义为 `/usr` 或 `/opt/redpanda-cpp`。
|
- `PREFIX`:默认值是 `/usr/local`。打包时应该定义为 `/usr` 或 `/opt/redpanda-cpp`。
|
||||||
- `LIBEXECDIR`:辅助程序的路径,默认值是 `$PREFIX/libexec`。Arch Linux 使用 `/usr/lib`。
|
- `LIBEXECDIR`:辅助程序的路径,默认值是 `$PREFIX/libexec`。Arch Linux 使用 `/usr/lib`。
|
||||||
|
|
Loading…
Reference in New Issue