Skip to content
This repository was archived by the owner on Jan 7, 2020. It is now read-only.

Commit 767b65b

Browse files
committed
Support prebuilt dependencies
1 parent 5bd27af commit 767b65b

File tree

10 files changed

+34
-7
lines changed

10 files changed

+34
-7
lines changed

.appveyor.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ branches:
33
- /dev.*/ # do not build dev branch
44

55
image:
6-
- Visual Studio 2017
6+
- Visual Studio 2019
77

88
platform:
99
- x86
@@ -19,7 +19,12 @@ install:
1919
- git submodule init
2020
- git submodule update
2121
- powershell .\scripts\prepare.ps1
22+
- set /p APP_ID=<app_id.txt
2223

2324
build_script:
2425
- powershell .\scripts\generate.ps1 %CONFIGURATION%
2526
- powershell .\scripts\build.ps1 %CONFIGURATION%
27+
28+
artifacts:
29+
- path: build/Release/Release/%APP_ID%
30+
type: zip

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.vscode/.ropeproject
55
.vscode/ipch
66
vcpkg
7+
vcpkg-export-*
78
build
89
!lib/*.lib
910
scripts/install.ps1

.vscode/tasks.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
"problemMatcher": [],
1414
"group": "build"
1515
},
16+
{
17+
"label": "prepare prebuilt",
18+
"type": "shell",
19+
"command": "powershell",
20+
"args": [
21+
"-NoProfile",
22+
"-File",
23+
"'${workspaceFolder}/scripts/prepare_prebuilt.ps1'"
24+
],
25+
"problemMatcher": [],
26+
"group": "build"
27+
},
1628
{
1729
"label": "generate debug",
1830
"type": "shell",

CMakeSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"msvc_x86"
1616
],
1717
"buildRoot": "${projectDir}\\build\\${name}",
18-
"cmakeCommandArgs": "-A Win32 -T v142 -DCMAKE_BUILD_TYPE=${name}",
18+
"cmakeCommandArgs": "-T v142 -DCMAKE_BUILD_TYPE=${name}",
1919
"buildCommandArgs": "",
2020
"ctestCommandArgs": "",
2121
"variables": [
@@ -37,7 +37,7 @@
3737
"msvc_x86"
3838
],
3939
"buildRoot": "${projectDir}\\build\\${name}",
40-
"cmakeCommandArgs": "-A Win32 -T v142 -DCMAKE_BUILD_TYPE=${name}",
40+
"cmakeCommandArgs": "-T v142 -DCMAKE_BUILD_TYPE=${name}",
4141
"buildCommandArgs": "",
4242
"ctestCommandArgs": "",
4343
"variables": [

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ CQ_MAIN {
7676

7777
在开始使用之前,请确保你已经安装了 Git,且 `PATH` 中存在 `git` 命令。不需要安装 vcpkg,后面的脚本中会自动安装。
7878

79-
然后确保安装了 **Visual Studio 2017 或 2019**,并勾选「使用 C++ 的桌面开发」,确保安装了 CMake、**MSVC v141 或 v142****Windows 10 SDK** 这三个组件。其中,如果系统中已经安装了 CMake,无需再在 VS Installer 中安装,但需要确保命令已添加进 `PATH`。除此之外,vcpkg 还要求安装 VS 的**英文语言包**
79+
然后确保安装了 **Visual Studio 2019****Visual Studio 2019 生成工具**(如果使用 2017 版本可能需要自行修改 `CMakeSettings.json` 中的 `generator` 参数),并勾选「使用 C++ 的桌面开发」,确保安装了 **MSVC v142****Windows 10 SDK****用于 Windows 的 C++ CMake 工具** 这三个组件。其中,如果系统中已经安装了 CMake,无需再在 VS Installer 中安装,但需要确保命令已添加进 `PATH`。除此之外,vcpkg 还要求安装 VS 的**英文语言包**
80+
81+
> 推荐使用 VS Code 开发,只需安装 Visual Studio 2019 生成工具,不需要安装臃肿的 VS IDE。
8082
8183
### 下载 SDK
8284

@@ -91,9 +93,16 @@ git submodule update
9193

9294
```ps1
9395
powershell .\scripts\prepare.ps1
96+
97+
# 如果不打算使用 vcpkg 管理依赖,可以运行:
98+
powershell .\scripts\prepare_prebuilt.ps1
99+
100+
# 请不要混用上面的两个脚本,只需运行一个即可
94101
```
95102

96-
[`scripts/prepare.ps1`](scripts/prepare.ps1) 脚本会在当前项目目录的 `vcpkg` 子目录中安装 vcpkg,并安装所需依赖。
103+
[`scripts/prepare.ps1`](scripts/prepare.ps1) 脚本会在当前项目目录的 `vcpkg` 子目录中安装 vcpkg,并安装所需依赖;[`scripts/prepare_prebuilt.ps1`](scripts/prepare_prebuilt.ps1) 脚本则会下载预编译的依赖库,直接解压到当前项目目录。
104+
105+
> 如何选择?如果你只是想快速试用 demo,建议使用 prepare_prebuilt;如果你的网络环境不佳,使用 prepare 安装依赖太慢,也可以使用 prepare_prebuilt;如果你打算开发较大型的插件项目,且希望使用 vcpkg 来方便地管理依赖,可以使用 prepare。
97106
98107
*注意,如果 PowerShell 提示不让运行脚本,需要先使用管理员权限打开 PowerShell,运行 `Set-ExecutionPolicy Unrestricted`,然后再重新运行上面的脚本;如果 vcpkg 安装依赖时出错,比较常见的问题是网络超时,请适当设置 `HTTP_PROXY``HTTPS_PROXY`*
99108

@@ -118,7 +127,7 @@ powershell .\scripts\generate.ps1 Debug
118127
powershell .\scripts\build.ps1 Debug
119128
```
120129

121-
上面两条命令分别生成 build 目录和构建项目,将 `Debug` 改为 `Release` 可以构建 release 版本。如果安装了 CMake 还没支持的较新版本 VS,需要先手动进入 VS 2017 或 2019 的 Developer Command Prompt,再执行上面的命令。
130+
上面两条命令分别生成 build 目录和构建项目,将 `Debug` 改为 `Release` 可以构建 release 版本。如果安装了 CMake 还没支持的较新版本 VS,需要先手动进入 VS 2019 的 Developer Command Prompt,再执行上面的命令。
122131

123132
如果你使用 VS Code,可以直接运行 task;如果使用 VS,可以直接选择菜单 CMake - 全部生成。
124133

@@ -164,7 +173,7 @@ git submodule update
164173

165174
### 安装依赖
166175

167-
如果需要安装依赖,可以直接使用 vcpkg,通过 `--triplet x86-windows-static-custom` 指定 triplet,或者使用 SDK 提供的包装脚本(参数和 vcpkg 相同),例如:
176+
如果需要安装依赖,可以直接使用 vcpkg(注意,前提是前面的准备步骤中安装了完整的 vcpkg,而不是预编译依赖),通过 `--triplet x86-windows-static-custom` 指定 triplet,或者使用 SDK 提供的包装脚本(参数和 vcpkg 相同),例如:
168177

169178
```ps1
170179
.\scripts\vcpkg.ps1 install curl

scripts/build.ps1

0 Bytes
Binary file not shown.

scripts/generate.ps1

-374 Bytes
Binary file not shown.

scripts/helpers.ps1

786 Bytes
Binary file not shown.

scripts/prepare.ps1

304 Bytes
Binary file not shown.

scripts/prepare_prebuilt.ps1

2.32 KB
Binary file not shown.

0 commit comments

Comments
 (0)