From f7fc4d16da2fd09f10213ab052255ffc2eafa456 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Jun 2024 04:20:03 +0330 Subject: [PATCH] Feat: Add win7 build and upgrade QT to 6.7.2 --- .github/workflows/build-qv2ray-cmake.yml | 55 ++++++---- CMakeLists.txt | 134 +++++------------------ libs/build_go.sh | 12 +- libs/deploy_windows64.sh | 33 +++--- libs/download_qtsdk_win.sh | 10 -- libs/env_qtsdk.sh | 8 -- 6 files changed, 87 insertions(+), 165 deletions(-) delete mode 100644 libs/download_qtsdk_win.sh delete mode 100644 libs/env_qtsdk.sh diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml index 998ff97..7784650 100644 --- a/.github/workflows/build-qv2ray-cmake.yml +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -21,6 +21,8 @@ jobs: include: - cross_os: public_res cross_arch: public_res + - cross_os: windows7 + cross_arch: amd64 fail-fast: false runs-on: ubuntu-latest steps: @@ -35,10 +37,15 @@ jobs: path: artifacts.tgz key: CommonCache-${{ matrix.cross_os }}-${{ matrix.cross_arch }}-${{ hashFiles('libs/*.sh', 'go_status', '*.txt') }} - name: Install Golang - if: steps.cache-common.outputs.cache-hit != 'true' + if: steps.cache-common.outputs.cache-hit != 'true' && matrix.cross_os != 'windows7' uses: actions/setup-go@v5.0.0 with: - go-version: ^1.22 + go-version: '1.22.4' + - name: Install Older Golang + if: steps.cache-common.outputs.cache-hit != 'true' && matrix.cross_os == 'windows7' + uses: actions/setup-go@v5.0.0 + with: + go-version: '1.20' - name: Build golang parts if: steps.cache-common.outputs.cache-hit != 'true' shell: bash @@ -62,18 +69,17 @@ jobs: include: - platform: windows-2022 arch: x64 - qt_version: "6.5" + qt_version: "6.7.2" - platform: ubuntu-20.04 arch: x64 - qt_version: "6.5" + qt_version: "6.7.2" - platform: macos-13 arch: amd64 - qt_version: "6.5" + qt_version: "6.7.2" - platform: macos-14 arch: arm64 - qt_version: "6.5" + qt_version: "6.7.2" fail-fast: false - runs-on: ${{ matrix.platform }} env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true @@ -84,41 +90,42 @@ jobs: submodules: "recursive" - name: Install MSVC compiler if: matrix.platform == 'windows-2022' - uses: ilammy/msvc-dev-cmd@v1 + uses: ilammy/msvc-dev-cmd@v1.13.0 with: - # 14.1 is for vs2017, 14.2 is vs2019, following the upstream vcpkg build from Qv2ray-deps repo toolset: 14.2 arch: ${{ matrix.arch }} - name: Download Artifacts uses: actions/download-artifact@v4.1.7 with: path: download-artifact - - name: Linux - Install Qt 6.5 + # ========================================================================================================= Qt Install + - name: Linux - Install Qt if: matrix.platform == 'ubuntu-20.04' uses: jurplel/install-qt-action@v4.0.0 with: - version: 6.5 + version: ${{ matrix.qt_version }} setup-python: true cache: true cache-key-prefix: QtCache-${{ matrix.platform }}-${{ matrix.arch }} - - name: macOS - Install Qt 6.5 + - name: macOS - Install Qt if: matrix.platform == 'macos-13' || matrix.platform == 'macos-14' uses: jurplel/install-qt-action@v4.0.0 with: - version: 6.5 + version: ${{ matrix.qt_version }} setup-python: true cache: true cache-key-prefix: QtCache-${{ matrix.platform }}-${{ matrix.arch }} - # ========================================================================================================= Qt Install - - name: Windows - Download Custom Qt ${{ matrix.qt_version }} SDK - shell: bash + - name: Windows - Install Qt if: matrix.platform == 'windows-2022' - env: - DL_QT_VER: ${{ matrix.qt_version }} - run: bash ./libs/download_qtsdk_win.sh + uses: jurplel/install-qt-action@v4.0.0 + with: + version: ${{ matrix.qt_version }} + setup-python: true + cache: true + cache-key-prefix: QtCache-${{ matrix.platform }}-${{ matrix.arch }} # ========================================================================================================= 编译与 Qt 无关的依赖 - name: Install ninja-build tool - uses: seanmiddleditch/gha-setup-ninja@v3 + uses: seanmiddleditch/gha-setup-ninja@v5 - name: Cache Download id: cache-deps uses: actions/cache@v4.0.2 @@ -134,11 +141,9 @@ jobs: shell: bash if: matrix.platform == 'windows-2022' env: - DL_QT_VER: ${{ matrix.qt_version }} CC: cl.exe CXX: cl.exe run: | - source libs/env_qtsdk.sh $PWD/qtsdk/Qt mkdir build cd build cmake -GNinja -DQT_VERSION_MAJOR=6 -DCMAKE_BUILD_TYPE=Release .. @@ -200,6 +205,10 @@ jobs: zip -r $version_standalone-linux64.zip nekoray rm -rf nekoray #### + mv windows7 nekoray + zip -r $version_standalone-windows7.zip nekoray + rm -rf nekoray + #### mv windows64 nekoray zip -r $version_standalone-windows64.zip nekoray rm -rf nekoray @@ -212,6 +221,8 @@ jobs: - name: Clean Up run: | cd deployment + rm -rf windows-arm64 + rm -rf linux-arm64 rm -rf linux64 rm -rf windows64 rm -rf macos-amd64 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c1bd05..b5699b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,26 +7,18 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -# WINDOWS PDB FILE -if (WIN32) - if (MSVC) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") - endif () -endif () - # Find Qt if (NOT QT_VERSION_MAJOR) - set(QT_VERSION_MAJOR 5) + set(QT_VERSION_MAJOR 6) endif () find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Svg LinguistTools) if (NKR_CROSS) - set_property(TARGET Qt5::moc PROPERTY IMPORTED_LOCATION /usr/bin/moc) - set_property(TARGET Qt5::uic PROPERTY IMPORTED_LOCATION /usr/bin/uic) - set_property(TARGET Qt5::rcc PROPERTY IMPORTED_LOCATION /usr/bin/rcc) - set_property(TARGET Qt5::lrelease PROPERTY IMPORTED_LOCATION /usr/bin/lrelease) - set_property(TARGET Qt5::lupdate PROPERTY IMPORTED_LOCATION /usr/bin/lupdate) + set_property(TARGET Qt6::moc PROPERTY IMPORTED_LOCATION /usr/bin/moc) + set_property(TARGET Qt6::uic PROPERTY IMPORTED_LOCATION /usr/bin/uic) + set_property(TARGET Qt6::rcc PROPERTY IMPORTED_LOCATION /usr/bin/rcc) + set_property(TARGET Qt6::lrelease PROPERTY IMPORTED_LOCATION /usr/bin/lrelease) + set_property(TARGET Qt6::lupdate PROPERTY IMPORTED_LOCATION /usr/bin/lupdate) endif () #### Platform Variables #### @@ -69,69 +61,22 @@ if (NKR_PACKAGE OR NKR_PACKAGE_MACOS) nkr_add_compile_definitions(NKR_CPP_USE_APPDATA) endif () -#### NKR EXTERNAL #### +add_subdirectory(3rdparty/qjs) +list(APPEND NKR_EXTERNAL_TARGETS quickjs) -if (NKR_NO_EXTERNAL) - set(NKR_NO_GRPC 1) - set(NKR_NO_YAML 1) - set(NKR_NO_ZXING 1) - set(NKR_NO_QHOTKEY 1) - set(NKR_NO_QUICKJS 1) -endif () +include("cmake/myproto.cmake") +list(APPEND NKR_EXTERNAL_TARGETS myproto) -# quickjs (static submodule) -if (NKR_NO_QUICKJS) - nkr_add_compile_definitions(NKR_NO_QUICKJS) -else () - add_subdirectory(3rdparty/qjs) - list(APPEND NKR_EXTERNAL_TARGETS quickjs) -endif () +find_package(yaml-cpp CONFIG REQUIRED) # only Release is built +list(APPEND NKR_EXTERNAL_TARGETS yaml-cpp) -# grpc -if (NKR_NO_GRPC) - nkr_add_compile_definitions(NKR_NO_GRPC) -else () - # My proto - include("cmake/myproto.cmake") - list(APPEND NKR_EXTERNAL_TARGETS myproto) -endif () +find_package(ZXing CONFIG REQUIRED) +list(APPEND NKR_EXTERNAL_TARGETS ZXing::ZXing) -# yaml-cpp -if (NKR_NO_YAML) - nkr_add_compile_definitions(NKR_NO_YAML) -else () - find_package(yaml-cpp CONFIG REQUIRED) # only Release is built - list(APPEND NKR_EXTERNAL_TARGETS yaml-cpp) -endif () - -# zxing-cpp -if (NKR_NO_ZXING) - nkr_add_compile_definitions(NKR_NO_ZXING) -else () - find_package(ZXing CONFIG REQUIRED) - list(APPEND NKR_EXTERNAL_TARGETS ZXing::ZXing) -endif () - -# QHotkey (static submodule) -if (NKR_NO_QHOTKEY) - nkr_add_compile_definitions(NKR_NO_QHOTKEY) -else () - set(QHOTKEY_INSTALL OFF) - set(BUILD_SHARED_LIBS OFF) - add_subdirectory(3rdparty/QHotkey) - list(APPEND NKR_EXTERNAL_TARGETS qhotkey) -endif () - -#### debug print #### - -if (DBG_CMAKE) - print_all_variables() - print_target_properties(myproto) - print_target_properties(yaml-cpp) - print_target_properties(ZXing::ZXing) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_COMMAND} -E time") -endif () +set(QHOTKEY_INSTALL OFF) +set(BUILD_SHARED_LIBS OFF) +add_subdirectory(3rdparty/QHotkey) +list(APPEND NKR_EXTERNAL_TARGETS qhotkey) # Sources set(PROJECT_SOURCES @@ -240,10 +185,6 @@ set(PROJECT_SOURCES ui/dialog_hotkey.h ui/dialog_hotkey.ui - - - - ui/widget/ProxyItem.cpp ui/widget/ProxyItem.h ui/widget/ProxyItem.ui @@ -262,28 +203,10 @@ set(PROJECT_SOURCES ) # Qt exe -if (${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(nekoray - MANUAL_FINALIZATION - ${PROJECT_SOURCES} - ) - # Define target properties for Android with Qt 6 as: - # set_property(TARGET nekoray APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR - # ${CMAKE_CURRENT_SOURCE_DIR}/android) - # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation -else () - if (ANDROID) - add_library(nekoray SHARED - ${PROJECT_SOURCES} - ) - # Define properties for Android with Qt 5 after find_package() calls as: - # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") - else () - add_executable(nekoray - ${PROJECT_SOURCES} - ) - endif () -endif () +qt_add_executable(nekoray + MANUAL_FINALIZATION + ${PROJECT_SOURCES} +) # Target @@ -316,12 +239,9 @@ set(TS_FILES set(LUPDATE_OPTIONS -locations none -no-obsolete ) -if (${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_lupdate(nekoray TS_FILES ${TS_FILES} OPTIONS ${LUPDATE_OPTIONS}) - qt_add_lrelease(nekoray TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES) -else () - qt5_create_translation(QM_FILES ${PROJECT_SOURCES} ${TS_FILES} OPTIONS ${LUPDATE_OPTIONS}) -endif () +qt_add_lupdate(nekoray TS_FILES ${TS_FILES} OPTIONS ${LUPDATE_OPTIONS}) +qt_add_lrelease(nekoray TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES) + configure_file(translations/translations.qrc ${CMAKE_BINARY_DIR} COPYONLY) target_sources(nekoray PRIVATE ${CMAKE_BINARY_DIR}/translations.qrc) @@ -334,6 +254,4 @@ target_link_libraries(nekoray PRIVATE ${PLATFORM_LIBRARIES} ) -if (QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(nekoray) -endif () +qt_finalize_executable(nekoray) diff --git a/libs/build_go.sh b/libs/build_go.sh index 3b0df74..0df46ae 100755 --- a/libs/build_go.sh +++ b/libs/build_go.sh @@ -4,10 +4,16 @@ set -e source libs/env_deploy.sh [ "$GOOS" == "windows" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/windows64 || true [ "$GOOS" == "windows" ] && [ "$GOARCH" == "arm64" ] && DEST=$DEPLOYMENT/windows-arm64 || true +[ "$GOOS" == "windows7" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/windows7 || true [ "$GOOS" == "linux" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/linux64 || true [ "$GOOS" == "linux" ] && [ "$GOARCH" == "arm64" ] && DEST=$DEPLOYMENT/linux-arm64 || true [ "$GOOS" == "darwin" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/macos-amd64 || true [ "$GOOS" == "darwin" ] && [ "$GOARCH" == "arm64" ] && DEST=$DEPLOYMENT/macos-arm64 || true +if [ $GOOS = "windows7" ]; then + GOOS=windows + OLD=y +fi + if [ -z $DEST ]; then echo "Please set GOOS GOARCH" exit 1 @@ -25,5 +31,9 @@ popd #### Go: nekobox_core #### pushd go/cmd/nekobox_core -go build -v -o $DEST -trimpath -ldflags "-w -s -X $neko_common.Version_neko=$version_standalone" -tags "with_clash_api,with_gvisor,with_quic,with_wireguard,with_utls,with_ech,with_dhcp" +if [ -z $OLD ]; then + go build -v -o $DEST -trimpath -ldflags "-w -s -X $neko_common.Version_neko=$version_standalone" -tags "with_clash_api,with_gvisor,with_quic,with_wireguard,with_utls,with_ech,with_dhcp" +else + go build -v -o $DEST -trimpath -ldflags "-w -s -X $neko_common.Version_neko=$version_standalone" -tags "with_clash_api,with_gvisor,with_quic,with_wireguard,with_utls,with_dhcp" +fi popd diff --git a/libs/deploy_windows64.sh b/libs/deploy_windows64.sh index 1d8a6f0..ff3882a 100755 --- a/libs/deploy_windows64.sh +++ b/libs/deploy_windows64.sh @@ -2,16 +2,17 @@ set -e source libs/env_deploy.sh -if [ "$DL_QT_VER" == "5.15" ]; then - DEST=$DEPLOYMENT/windows7-x64 -else - DEST=$DEPLOYMENT/windows64 -fi +DEST=$DEPLOYMENT/windows64 rm -rf $DEST mkdir -p $DEST +DEST7=$DEPLOYMENT/windows7 +rm -rf $DEST7 +mkdir -p $DEST7 + #### copy exe #### cp $BUILD/nekoray.exe $DEST +cp $BUILD/nekoray.exe $DEST7 cd download-artifact cd *windows-amd64 @@ -21,21 +22,21 @@ cd *public_res tar xvzf artifacts.tgz -C ../../ cd ../.. +cd download-artifact +cd *windows7-amd64 +tar xvzf artifacts.tgz -C ../../ +cd ../.. + +cp $DEPLOYMENT/public_res/* $DEST7 mv $DEPLOYMENT/public_res/* $DEST #### deploy qt & DLL runtime #### pushd $DEST -windeployqt nekoray.exe --no-compiler-runtime --no-system-d3d-compiler --no-opengl-sw --verbose 2 -rm -rf translations -rm -rf libEGL.dll libGLESv2.dll Qt6Pdf.dll - -if [ "$DL_QT_VER" != "5.15" ]; then - cp $SRC_ROOT/qtsdk/Qt/bin/libcrypto-3-x64.dll . - cp $SRC_ROOT/qtsdk/Qt/bin/libssl-3-x64.dll . -fi - +windeployqt nekoray.exe --no-translations --no-system-d3d-compiler --no-compiler-runtime --no-opengl-sw --verbose 2 popd -#### prepare deployment #### -cp $BUILD/*.pdb $DEPLOYMENT +pushd $DEST7 +windeployqt nekoray.exe --no-translations --no-system-d3d-compiler --no-compiler-runtime --no-opengl-sw --verbose 2 +popd +rm -rf $DEST/dxcompiler.dll $DEST/dxil.dll $DEST7/dxcompiler.dll $DEST7/dxil.dll \ No newline at end of file diff --git a/libs/download_qtsdk_win.sh b/libs/download_qtsdk_win.sh deleted file mode 100644 index 690fdec..0000000 --- a/libs/download_qtsdk_win.sh +++ /dev/null @@ -1,10 +0,0 @@ -mkdir qtsdk -cd qtsdk -if [ "$DL_QT_VER" == "5.15" ]; then - curl -LSO https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/20220503/Qt5.15.7-Windows-x86_64-VS2019-16.11.20-20221103.7z -else - curl -LSO https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/20220503/Qt6.5.2-Windows-x86_64-VS2022-17.6.5-20230803.7z -fi -7z x *.7z -rm *.7z -mv Qt* Qt diff --git a/libs/env_qtsdk.sh b/libs/env_qtsdk.sh deleted file mode 100644 index 0cf6eaa..0000000 --- a/libs/env_qtsdk.sh +++ /dev/null @@ -1,8 +0,0 @@ -echo "Setting Qt Sdk Dir to" "$1" -export Qt5_DIR="$1" -export Qt6_DIR=$Qt5_DIR -export PATH=$PATH:$Qt5_DIR/bin -export LD_LIBRARY_PATH=$Qt5_DIR/lib -export PKG_CONFIG_PATH=$Qt5_DIR/lib/pkgconfig -export QT_PLUGIN_PATH=$Qt5_DIR/plugins -export QML2_IMPORT_PATH=$Qt5_DIR/lib/qml