Skip to content

Commit

Permalink
update build
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Dec 25, 2022
1 parent 647f20c commit 255d95e
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 138 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/build-qv2ray-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ on:
publish:
description: 'Publish: If want ignore'
required: false
artifact-pack:
description: 'artifact-pack: If want ignore'
required: false
jobs:
build-go:
strategy:
matrix:
cross_os: [ windows, linux, darwin ]
cross_arch: [ amd64 ]
include:
- cross_os: asset
cross_arch: asset
- cross_os: public_res
cross_arch: public_res
fail-fast: false
runs-on: ubuntu-latest
steps:
Expand All @@ -40,10 +43,10 @@ jobs:
if: steps.cache-common.outputs.cache-hit != 'true'
shell: bash
run: |
[ ${{ matrix.cross_os }} == asset ] || ./libs/get_source.sh
[ ${{ matrix.cross_os }} == asset ] || GOOS=${{ matrix.cross_os }} GOARCH=${{ matrix.cross_arch }} ./libs/build_go.sh
[ ${{ matrix.cross_os }} == asset ] || exit 0
./libs/build_asset.sh
[ ${{ matrix.cross_os }} == public_res ] || ./libs/get_source.sh
[ ${{ matrix.cross_os }} == public_res ] || GOOS=${{ matrix.cross_os }} GOARCH=${{ matrix.cross_arch }} ./libs/build_go.sh
[ ${{ matrix.cross_os }} == public_res ] || exit 0
./libs/build_public_res.sh
- name: Tar files
if: steps.cache-common.outputs.cache-hit != 'true'
run: tar czvf artifacts.tgz ./deployment
Expand Down Expand Up @@ -166,7 +169,8 @@ jobs:
name: NekoRay-${{ github.sha }}-${{ matrix.platform }}-${{ matrix.arch }}
path: artifacts.tgz
publish:
name: Publish Release
name: Pack & Publish Release
if: github.event.inputs.artifact-pack != 'y'
runs-on: ubuntu-latest
needs:
- build-cpp
Expand All @@ -185,9 +189,9 @@ jobs:
mv ghr*linux_amd64/ghr .
find . -name artifacts.tgz | xargs -n1 tar xvzf
cd deployment
cp -r assets/* linux64
cp -r assets/* windows64
rm -rf assets *.pdb
cp -r public_res/* linux64
cp -r public_res/* windows64
rm -rf public_res *.pdb
####
mv linux64 nekoray
zip -r $version_standalone-linux64.zip nekoray
Expand Down
10 changes: 5 additions & 5 deletions cmake/fuck_windows/fuck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ if (WIN32)
include(cmake/fuck_windows/generate_product_version.cmake)
generate_product_version(
QV2RAY_RC
NAME "Nekoray"
BUNDLE "Nekoray Project Family"
ICON "${CMAKE_SOURCE_DIR}/res/nekoray.ico"
COMPANY_NAME "Nekoray Workgroup"
COMPANY_COPYRIGHT "Nekoray Workgroup"
FILE_DESCRIPTION "Nekoray Main Application"
NAME "nekoray"
BUNDLE "nekoray"
COMPANY_NAME "nekoray"
COMPANY_COPYRIGHT "nekoray"
FILE_DESCRIPTION "nekoray"
)
add_definitions(-DUNICODE -D_UNICODE -DNOMINMAX)
set(GUI_TYPE WIN32)
Expand Down
52 changes: 29 additions & 23 deletions docs/Build_Linux.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
在 Linux 下编译 Nekoray

### git clone 源码
## git clone 源码

```
git clone https://github.com/MatsuriDayo/nekoray.git --recursive
```

### 简单编译法
## 简单编译法

条件:

1. C++ 依赖:`protobuf yaml-cpp zxing-cpp` 已用包管理器安装,并符合版本要求
1. C++ 依赖:`protobuf yaml-cpp zxing-cpp` 已用包管理器安装,并符合版本要求
2. 已安装 `qtbase` `qtsvg` `qttools` `qtx11extras`
3. Qt 版本必须大于等于 5.15
3. 已安装 Qt `5.12.x``5.15.x`
4. 系统为 `x86-64-linux-gnu`

```shell
Expand All @@ -26,37 +26,43 @@ ninja

解压 Release 的压缩包,替换其中的 `nekoray`,删除 `launcher` 即可使用。

### 复杂编译法
## 复杂编译法

#### CMake 参数
### CMake 参数

| CMake 参数 | 默认值 | 含义 |
|------------------|-----|-------------------------|
| QT_VERSION_MAJOR | 5 | QT版本 |
| NKR_NO_EXTERNAL | | 不包含外部C++依赖(以下所有) |
| NKR_NO_YAML | | 不包含yaml-cpp |
| NKR_NO_QHOTKEY | | 不包含qhotkey |
| NKR_NO_ZXING | | 不包含zxing |
| NKR_NO_GRPC | | 不包含gRPC |
| NKR_NO_QUICKJS | | 不包含quickjs |
| CMake 参数 | 默认值 | 含义 |
|-------------------|-------------------|-----------------------|
| QT_VERSION_MAJOR | 5 | QT版本 |
| NKR_NO_EXTERNAL | | 不包含外部 C/C++ 依赖 (以下所有) |
| NKR_NO_YAML | | 不包含 yaml-cpp |
| NKR_NO_QHOTKEY | | 不包含 qhotkey |
| NKR_NO_ZXING | | 不包含 zxing |
| NKR_NO_GRPC | | 不包含 gRPC |
| NKR_NO_QUICKJS | | 不包含 quickjs |
| NKR_PACKAGE | | 编译 package 版本 (aur) |
| NKR_PACKAGE_MACOS | | 编译 macos 版本 |
| NKR_LIBS | ./libs/deps/built | 依赖搜索目录 |
| NKR_DISABLE_LIBS | | 禁用 NKR_LIBS |

#### C++ 部分
1. `NKR_LIBS` 的值会被追加到 `CMAKE_PREFIX_PATH`
2. `NKR_PACKAGE` 打开后,`NKR_LIBS` 的默认值为 `./libs/deps/package` ,具体依赖请看 `build_deps_all.sh`
3. `NKR_PACKAGE_MACOS``NKR_PACKAGE` 打开后,应用将使用 appdata 目录存放配置,自动更新等功能将被禁用。

当您的发行版没有上面几个 C++ 依赖包,或者版本不符合要求时,可以参考 libs 文件夹内的默认编译脚本自行编译。
### C++ 部分

依赖搜寻 prefix 为 `libs/deps/bulit`
当您的发行版没有上面几个 C++ 依赖包,或者版本不符合要求时,可以参考 `build_deps_all.sh` 编译脚本自行编译。

条件:
条件: 已安装 Qt `5.12.x``5.15.x`

1. Qt 版本必须大于等于 5.15
#### 编译安装 C/C++ 依赖

首先编译安装C++依赖(这一步可能要挂梯)
(这一步可能要挂梯)

```shell
./libs/build_deps_all.sh
```

然后编译本体
#### 编译本体

```shell
mkdir build
Expand All @@ -67,7 +73,7 @@ ninja

编译完成后得到 `nekoray`

#### Go 部分
### Go 部分

1.`Matsuridayo/Matsuri` `Matsuridayo/v2ray-core` 置于 `../`
2. 进入 `go/cmd/nekoray_core` 文件夹 `go build` 得到 `nekoray_core`
Expand Down
26 changes: 21 additions & 5 deletions docs/Build_Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,39 @@ git clone https://github.com/MatsuriDayo/nekoray.git --recursive

### 下载 Qt SDK

目前使用的版本是 Qt 5.15.7 其他版本未测试
目前使用的版本是 Qt 5.15.x

暂时不建议使用 Qt 6.x

下载解压后,将 bin 目录添加到环境变量。

#### Qt 5.15.7 MSVC2019 x86_64

https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/20220503/Qt5.15.7-Windows-x86_64-VS2019-16.11.20-20221103.7z

#### 官方签名版 Qt 5.15.2 (可选,已知有内存泄漏的BUG)

在此下载 `qtbase` `qtsvg` `qttools` 的包并解压到同一个目录。

https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/

将 bin 目录添加到环境变量。

### C++ 部分编译

首先编译安装C++依赖(这一步可能要挂梯)
#### 编译安装 C/C++ 依赖

(这一步可能要挂梯)

```shell
bash ./libs/build_deps_all.sh
```

然后编译本体(根据你的 QT Sdk 的位置替换命令)
目前只有 bash 脚本,没有批处理或 powershell,如果 Windows 没有带 bash 建议自行安装。

CMake 参数等细节与 Linux 大同小异,有问题可以参照 Build_Linux 文档。

#### 编译本体

请根据你的 QT Sdk 的位置替换命令

```shell
mkdir build
Expand Down
1 change: 0 additions & 1 deletion examples/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions examples/build-alpine.md

This file was deleted.

30 changes: 0 additions & 30 deletions examples/netns-root.sh

This file was deleted.

13 changes: 0 additions & 13 deletions examples/netns.sh

This file was deleted.

9 changes: 0 additions & 9 deletions examples/readme.txt

This file was deleted.

14 changes: 0 additions & 14 deletions examples/set-cap.sh

This file was deleted.

18 changes: 13 additions & 5 deletions libs/build_deps_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ set -e

cd libs

# 参数
if [ -z $cmake ]; then
cmake="cmake"
fi
if [ -z $deps ]; then
deps="deps"
fi

# libs/deps/...
mkdir -p deps
cd deps
mkdir -p $deps
cd $deps
if [ -z $NKR_PACKAGE ]; then
INSTALL_PREFIX=$PWD/built
else
Expand All @@ -27,7 +35,7 @@ cd zxing-*
mkdir -p build
cd build

cmake .. -GNinja -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_BLACKBOX_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
$cmake .. -GNinja -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_BLACKBOX_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
ninja && ninja install

cd ../..
Expand All @@ -46,7 +54,7 @@ cd yaml-*
mkdir -p build
cd build

cmake .. -GNinja -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
$cmake .. -GNinja -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
ninja && ninja install

cd ../..
Expand All @@ -59,7 +67,7 @@ git clone --recurse-submodules -b v21.4 --depth 1 --shallow-submodules https://g
mkdir -p protobuf/build
cd protobuf/build

cmake .. -GNinja \
$cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF \
Expand Down
8 changes: 4 additions & 4 deletions libs/build_asset.sh → libs/build_public_res.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
set -e

source libs/deploy_common.sh
DEST=$DEPLOYMENT/assets
DEST=$DEPLOYMENT/public_res
rm -rf $DEST
mkdir -p $DEST

#### Download: geoip ####
#### Download geodata ####
curl -Lso $DEST/geoip.dat "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat"
curl -Lso $DEST/geosite.dat "https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat"
curl -Lso $DEST/geoip.db "https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db"
curl -Lso $DEST/geosite.db "https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db"

#### copy assets ####
cp assets/* $DEST
#### copy res/public ####
cp res/public/* $DEST
4 changes: 2 additions & 2 deletions libs/deploy_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ DEST=$DEPLOYMENT/macos-$ARCH
rm -rf $DEST
mkdir -p $DEST

#### copy golang & asset => .app ####
#### copy golang & public_res => .app ####
pushd download-artifact
find . -name artifacts.tgz | xargs -n1 tar xvzf
mv deployment/assets/* deployment/macos-$ARCH
mv deployment/public_res/* deployment/macos-$ARCH
mv deployment/macos-$ARCH/* $BUILD/nekoray.app/Contents/MacOS
popd

Expand Down
2 changes: 1 addition & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
if (args.contains("-tray")) NekoRay::dataStore->flag_tray = true;
if (args.contains("-debug")) NekoRay::dataStore->flag_debug = true;
#ifdef NKR_CPP_USE_APPDATA
NekoRay::dataStore->flag_use_appdata = true;
NekoRay::dataStore->flag_use_appdata = true; // Example: Package & MacOS
#endif
#ifdef NKR_CPP_DEBUG
NekoRay::dataStore->flag_debug = true;
Expand Down
8 changes: 4 additions & 4 deletions res/neko.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<file alias="icon/b-system-software-update.svg">icon/system-software-update.svg</file>
</qresource>
<qresource prefix="/neko">
<file alias="nekobox.png">../assets/nekobox.png</file>
<file alias="nekoray.png">../assets/nekoray.png</file>
<file alias="nekobox.png">public/nekobox.png</file>
<file alias="nekoray.png">public/nekoray.png</file>
<file>neko.css</file>
<file alias="vpn/vpn-run-root.sh">../examples/vpn-run-root.sh</file>
<file alias="vpn/sing-box-vpn.json">../examples/sing-box-vpn.json</file>
<file>vpn/vpn-run-root.sh</file>
<file>vpn/sing-box-vpn.json</file>
</qresource>
</RCC>
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 255d95e

Please sign in to comment.