This commit is contained in:
@@ -53,6 +53,61 @@ add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||
add_subdirectory("runner")
|
||||
|
||||
|
||||
# media_kit_libs_windows_video downloads its native archives with CMake's
|
||||
# file(DOWNLOAD). In some Windows network/proxy setups that leaves 0-byte files
|
||||
# without surfacing the download failure, so prefetch the exact archives with
|
||||
# PowerShell and let the plugin's own CMake verify/use them.
|
||||
function(ENSURE_WINDOWS_ARCHIVE URL MD5 OUTPUT_PATH)
|
||||
string(TOLOWER "${MD5}" EXPECTED_MD5)
|
||||
if(EXISTS "${OUTPUT_PATH}")
|
||||
file(MD5 "${OUTPUT_PATH}" CURRENT_MD5)
|
||||
string(TOLOWER "${CURRENT_MD5}" CURRENT_MD5)
|
||||
if(EXPECTED_MD5 STREQUAL CURRENT_MD5)
|
||||
return()
|
||||
endif()
|
||||
file(REMOVE "${OUTPUT_PATH}")
|
||||
endif()
|
||||
|
||||
find_program(POWERSHELL_EXE powershell.exe)
|
||||
if(NOT POWERSHELL_EXE)
|
||||
find_program(POWERSHELL_EXE pwsh)
|
||||
endif()
|
||||
if(NOT POWERSHELL_EXE)
|
||||
message(FATAL_ERROR "PowerShell is required to download ${URL}")
|
||||
endif()
|
||||
|
||||
get_filename_component(OUTPUT_DIR "${OUTPUT_PATH}" DIRECTORY)
|
||||
file(MAKE_DIRECTORY "${OUTPUT_DIR}")
|
||||
|
||||
message(STATUS "Downloading ${URL}")
|
||||
execute_process(
|
||||
COMMAND "${POWERSHELL_EXE}" -NoProfile -ExecutionPolicy Bypass -Command
|
||||
"$ProgressPreference='SilentlyContinue'; Invoke-WebRequest -Uri '${URL}' -OutFile '${OUTPUT_PATH}' -UseBasicParsing"
|
||||
RESULT_VARIABLE DOWNLOAD_RESULT
|
||||
)
|
||||
if(NOT DOWNLOAD_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to download ${URL}")
|
||||
endif()
|
||||
|
||||
file(MD5 "${OUTPUT_PATH}" CURRENT_MD5)
|
||||
string(TOLOWER "${CURRENT_MD5}" CURRENT_MD5)
|
||||
if(NOT EXPECTED_MD5 STREQUAL CURRENT_MD5)
|
||||
file(REMOVE "${OUTPUT_PATH}")
|
||||
message(FATAL_ERROR "Downloaded ${OUTPUT_PATH} failed MD5 check")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
ENSURE_WINDOWS_ARCHIVE(
|
||||
"https://github.com/media-kit/libmpv-win32-video-build/releases/download/2023-09-24/mpv-dev-x86_64-20230924-git-652a1dd.7z"
|
||||
"a832ef24b3a6ff97cd2560b5b9d04cd8"
|
||||
"${CMAKE_BINARY_DIR}/mpv-dev-x86_64-20230924-git-652a1dd.7z"
|
||||
)
|
||||
ENSURE_WINDOWS_ARCHIVE(
|
||||
"https://github.com/alexmercerind/flutter-windows-ANGLE-OpenGL-ES/releases/download/v1.0.1/ANGLE.7z"
|
||||
"e866f13e8d552348058afaafe869b1ed"
|
||||
"${CMAKE_BINARY_DIR}/ANGLE.7z"
|
||||
)
|
||||
|
||||
# Generated plugin build rules, which manage building the plugins and adding
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
@@ -107,3 +162,61 @@ install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
|
||||
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
CONFIGURATIONS Profile;Release
|
||||
COMPONENT Runtime)
|
||||
|
||||
# === Rust Sync Engine ===
|
||||
find_program(CARGO_CMD cargo
|
||||
PATHS
|
||||
"$ENV{USERPROFILE}\\.cargo\\bin"
|
||||
"$ENV{HOME}\\.cargo\\bin"
|
||||
"$ENV{CARGO_HOME}\\bin"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT CARGO_CMD)
|
||||
find_program(CARGO_CMD cargo)
|
||||
endif()
|
||||
|
||||
if(NOT CARGO_CMD)
|
||||
message(WARNING "cargo not found, skipping Rust sync engine build")
|
||||
else()
|
||||
set(SYNC_CORE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../native")
|
||||
set(RUST_TARGET_DIR "${CMAKE_BINARY_DIR}/rust_target")
|
||||
|
||||
# 1. 编译时间戳文件
|
||||
set(RUST_BUILD_STAMP "${CMAKE_CURRENT_BINARY_DIR}/sync_core_build.stamp")
|
||||
|
||||
# 2. 核心修复
|
||||
# 不管是 Debug 还是 Release,我们都同时通知 Cargo 去检查这两个配置。
|
||||
# 这样没有任何动态变量,参数数量是死死固定的,Cargo 100% 不会报错。
|
||||
add_custom_command(
|
||||
OUTPUT "${RUST_BUILD_STAMP}"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${RUST_TARGET_DIR}"
|
||||
|
||||
# 无论如何,都去编译 Debug(供 flutter run 使用)
|
||||
COMMAND ${CARGO_CMD} build
|
||||
--manifest-path "${SYNC_CORE_DIR}/Cargo.toml"
|
||||
--target-dir "${RUST_TARGET_DIR}"
|
||||
--features sync-core/windows-cfapi
|
||||
|
||||
# 无论如何,都去编译 Release(供 flutter build 使用)
|
||||
COMMAND ${CARGO_CMD} build --release
|
||||
--manifest-path "${SYNC_CORE_DIR}/Cargo.toml"
|
||||
--target-dir "${RUST_TARGET_DIR}"
|
||||
--features sync-core/windows-cfapi
|
||||
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${RUST_BUILD_STAMP}"
|
||||
COMMENT "Building Rust sync engine (Debug & Release)..."
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# 3. 让目标依赖时间戳
|
||||
add_custom_target(sync_core_build DEPENDS "${RUST_BUILD_STAMP}")
|
||||
add_dependencies(${BINARY_NAME} sync_core_build)
|
||||
|
||||
# 4. 动态选择文件夹名称表达式(这个表达式只在安装阶段求值,安全可靠)
|
||||
set(CONFIG_DIR_EXPR "$<IF:$<OR:$<CONFIG:Release>,$<CONFIG:Profile>>,release,debug>")
|
||||
|
||||
# 5. 动态选择 dll 路径进行安装复制
|
||||
install(FILES "${RUST_TARGET_DIR}/${CONFIG_DIR_EXPR}/sync_core.dll"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
||||
|
||||
@@ -38,3 +38,4 @@ target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
|
||||
|
||||
# Run the Flutter tool portions of the build. This must not be removed.
|
||||
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||
|
||||
|
||||
@@ -89,11 +89,11 @@ BEGIN
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "com.limo" "\0"
|
||||
VALUE "CompanyName", "saont.net" "\0"
|
||||
VALUE "FileDescription", "公云存储" "\0"
|
||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||
VALUE "InternalName", "公允存储" "\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2026 com.limo. All rights reserved." "\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2026 saont.net. All rights reserved." "\0"
|
||||
VALUE "OriginalFilename", "cloudreve4_flutter.exe" "\0"
|
||||
VALUE "ProductName", "公云存储" "\0"
|
||||
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
||||
|
||||
Reference in New Issue
Block a user