Skip to content

Commit

Permalink
Merge branch 'staged' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Jul 13, 2024
2 parents e2ba22e + 262c3c1 commit 6b045de
Show file tree
Hide file tree
Showing 178 changed files with 210 additions and 37,202 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/PR-check-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ on:
- master
- experimental
- staged
paths-ignore:
- "docs/**"
- "*.md"
- "locale/**"
- "website/**"
jobs:
job_ubuntu_build_check:
name: ubuntu Build and analyze
Expand Down Expand Up @@ -108,6 +103,7 @@ jobs:
New-Item -Path './build_dir' -ItemType Directory
cmake -S . -B "./build_dir" `
-G Ninja `
-DWITH_VCPKG_BREAKPAD=ON `
-DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" `
-DWITH_FFMPEG_PLAYER=OFF
cmake --build "./build_dir"
56 changes: 56 additions & 0 deletions .github/workflows/create-vcpkg-export-archive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Create vcpkg export archive
on:
workflow_dispatch:


env:
outputName: goldendict-ng-vcpkg-export

jobs:
create_new_cache:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Create export
run: |
# ensure always up to date
vcpkg x-update-baseline
vcpkg install --x-feature=breakpad
vcpkg export --raw --output-dir=.\exports --output=${{ env.outputName }}
echo "Starts compressing..."
cd .\exports
cmake -E tar c ${{ env.outputName }}.tar.zst --zstd .\${{ env.outputName }}

- name: Upload as release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$vcpkgBaselineVersion = $(Get-Content .\vcpkg-configuration.json | ConvertFrom-Json).'default-registry'.'baseline'
$dateString = Get-Date -Format "yyMMdd"
$tagName = "vcpkg_${dateString}_${vcpkgBaselineVersion}"
cd .\exports\
$fileHash = $(Get-FileHash ${{ env.outputName }}.tar.zst SHA512).Hash
$notes=@"
GoldenDict-ng's windows build artifacts created with vcpkg, for development purpose only.
vcpkg baseline version: <https://github.com/microsoft/vcpkg/tree/${vcpkgBaselineVersion}>
SHA512:
``````
${fileHash}
``````
packages:
``````
"@
Add-Content -Path .\note.txt -Value ${notes}
vcpkg list | Add-Content .\note.txt
Add-Content -Path .\note.txt -Value "``````"
Get-Content .\note.txt
gh release create "${tagName}" --notes-file=.\note.txt --title "vcpkg package export archive" --latest=false
gh release upload "${tagName}" ${{ env.outputName }}.tar.zst --clobber
12 changes: 1 addition & 11 deletions .github/workflows/release-windows-vcpkg-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,8 @@ jobs:
}
]
}
- name: setup vcpkg github caches variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Build binaries
id: build
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
run: |
# Launch-VsDevShell also provides Ninja
& 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Launch-VsDevShell.ps1' `
Expand All @@ -128,8 +120,6 @@ jobs:
-DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DWITH_FFMPEG_PLAYER=OFF `
-DUSE_VCPKG=ON `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" `
-DWITH_VCPKG_BREAKPAD=ON
cmake --build "./build_dir"
- name: CPack create package
Expand Down Expand Up @@ -160,7 +150,7 @@ jobs:
${{steps.build_changelog.outputs.changelog}}
'@
$tagExist = gh api --silent "repos/:owner/:repo/git/refs/tags/${{github.ref_name}}"
$tagExist = gh api --silent "repos/:owner/:repo/git/refs/tags/${tagName}"
if (-not $?) {
if ($env:prerelease -eq "true") {
gh release create ${tagName} --target ${{github.ref_name}} --notes-file=./change_note.txt --latest=false --prerelease
Expand Down
77 changes: 40 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ cmake_minimum_required(VERSION 3.25) # ubuntu 23.04 Fedora 36
option(WITH_FFMPEG_PLAYER "Enable support for FFMPEG player" ON)
option(WITH_EPWING_SUPPORT "Enable epwing support" ON)
option(WITH_ZIM "enable zim support" ON)
option(WITH_TTS "enable QTexttoSpeech support" ON)
option(WITH_TTS "enable QTexttoSpeech support" OFF)

# options for linux packaging
option(USE_SYSTEM_FMT "use system fmt instead of bundled one" OFF)
option(USE_SYSTEM_TOML "use system toml++ instead of bundled one" OFF)

# vcpkg build - only tested on Windows, does not support FFMPEG
option(USE_VCPKG "uses VCPKG for providing dependencies" OFF)
option(WITH_VCPKG_BREAKPAD "build with Breakpad support for VCPKG build only" OFF)

## Change binary & resources folder to parallel install with original GD.
Expand All @@ -22,9 +20,29 @@ option(USE_ALTERNATIVE_NAME "Force the name goldendict-ng " OFF)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") # to put staff in the ./cmake folder

if(WITH_VCPKG_BREAKPAD)
list(APPEND VCPKG_MANIFEST_FEATURES "breakpad")
endif()

# vcpkg handling code, must be placed before project()
if (WIN32)
if (DEFINED CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
else ()
message(STATUS "CMAKE_TOOLCHAIN_FILE is not set. Try fetching cached vcpkg.")
include(FetchContent)
FetchContent_Declare(
vcpkg-export
URL https://github.com/xiaoyifang/goldendict-ng/releases/download/vcpkg_240711_3d72d8c930e1b6a1b2432b262c61af7d3287dcd0/goldendict-ng-vcpkg-export.tar.zst
URL_HASH SHA512=CB7AB20F03CE1BB1D46FE5DF25C9B9F4E365B72CE0A817B3C9E39BD0C85DC571F992363A1A5E8DD1E31C44FF88C51E9A88A537688C6070B4E58FF8FA2585EAB7
)
FetchContent_MakeAvailable(vcpkg-export)
set(VCPKG_MANIFEST_MODE OFF CACHE BOOL "disable existing manifest mode caused by the existrance of vcpkg.json" FORCE)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_BINARY_DIR}/_deps/vcpkg-export-src/scripts/buildsystems/vcpkg.cmake")
endif ()
endif ()


if (WITH_VCPKG_BREAKPAD)
list(APPEND VCPKG_MANIFEST_FEATURES "breakpad")
endif ()

include(FeatureSummary)

Expand Down Expand Up @@ -203,10 +221,8 @@ endif ()

#### libraries linking && includes for Win or Unix

if (USE_VCPKG)
if (WIN32)
include(Deps_Vcpkg)
elseif (WIN32)
include(Deps_Win)
else ()
include(Deps_Unix)
endif ()
Expand Down Expand Up @@ -313,36 +329,23 @@ if (WIN32)
LIBRARY_OUTPUT_DIRECTORY "${GD_WIN_OUTPUT_DIR}"
)

if (NOT USE_VCPKG)
add_custom_target(windeploy
COMMENT "Deploy everything to the output dir"
DEPENDS ${GOLDENDICT} # build this target will check if Goldendict.exe is already built
COMMAND ${WINDEPLOYQT_EXECUTABLE} --no-quick-import "${GD_WIN_OUTPUT_DIR}/${GOLDENDICT}.exe" --plugindir "${GD_WIN_OUTPUT_DIR}/plugins"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/opencc" "${GD_WIN_OUTPUT_DIR}/opencc"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/LICENSE.txt" "${GD_WIN_OUTPUT_DIR}/LICENSE.txt"
COMMAND ${CMAKE_COMMAND} -E rm -f "${GD_WIN_OUTPUT_DIR}/goldendict.exe.manifest" "${GD_WIN_OUTPUT_DIR}/eb.dll.manifest"
WORKING_DIRECTORY ${GD_WIN_OUTPUT_DIR}
)

else () # VCPKG deploy
set(CMAKE_INSTALL_PREFIX "${GD_WIN_OUTPUT_DIR}" CACHE PATH "If you see this message, don't change this unless you want look into CMake build script. If you are an expert, yes, this is wrong. Help welcomed." FORCE)
set(CMAKE_INSTALL_PREFIX "${GD_WIN_OUTPUT_DIR}" CACHE PATH "If you see this message, don't change this unless you want look into CMake build script. If you are an expert, yes, this is wrong. Help welcomed." FORCE)

qt_generate_deploy_script(
TARGET ${GOLDENDICT}
OUTPUT_SCRIPT deploy_script
CONTENT "qt_deploy_runtime_dependencies(
EXECUTABLE \"${CMAKE_INSTALL_PREFIX}/goldendict.exe\"
BIN_DIR .
LIB_DIR .
)"
)
qt_generate_deploy_script(
TARGET ${GOLDENDICT}
OUTPUT_SCRIPT deploy_script
CONTENT "qt_deploy_runtime_dependencies(
EXECUTABLE \"${CMAKE_INSTALL_PREFIX}/goldendict.exe\"
BIN_DIR .
LIB_DIR .
)"
)

install(SCRIPT ${deploy_script})
install(DIRECTORY "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/opencc" DESTINATION .)
# TODO: do we really need to carry a copy of openSSL?
install(FILES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/libssl-3-x64.dll" DESTINATION .)
install(FILES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/libcrypto-3-x64.dll" DESTINATION .)
endif ()
install(SCRIPT ${deploy_script})
install(DIRECTORY "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/opencc" DESTINATION .)
# TODO: do we really need to carry a copy of openSSL?
install(FILES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/libssl-3-x64.dll" DESTINATION .)
install(FILES "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/libcrypto-3-x64.dll" DESTINATION .)

# trick CPack to make the output folder as NSIS installer
install(DIRECTORY "${GD_WIN_OUTPUT_DIR}/"
Expand Down
50 changes: 0 additions & 50 deletions cmake/Deps_Win.cmake

This file was deleted.

Loading

0 comments on commit 6b045de

Please sign in to comment.