From 3383f936f6a217cfc61369c39c33bdc87e74983f Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Thu, 19 Sep 2024 08:25:07 +0900 Subject: [PATCH] build: use vcpkg on Windows --- .github/workflows/ci.yml | 12 +++++++--- CMakeLists.txt | 34 ++++------------------------ Cargo.lock | 47 +++++++++++++++++---------------------- Cargo.toml | 3 --- capi/data/mini.dat | Bin 91045 -> 91023 bytes 5 files changed, 33 insertions(+), 63 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcf40fd8..6f6ec330 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,10 +34,16 @@ jobs: run: sudo apt-get install ninja-build - if: ${{ matrix.os == 'macos-latest' }} run: brew install ninja - - if: ${{ matrix.os == 'windows-latest' }} - run: choco install ninja - if: ${{ matrix.os == 'windows-latest' }} uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 + - if: ${{ matrix.os == 'windows-latest' }} + run: | + choco install ninja + echo VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT >> $env:GITHUB_ENV + echo CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake >> $env:GITHUB_ENV + echo VCPKG_TARGET_TRIPLET=x64-windows-static >> $env:GITHUB_ENV + & $env:VCPKG_INSTALLATION_ROOT\vcpkg install --triplet x64-windows-static sqlite3 + & $env:VCPKG_INSTALLATION_ROOT\vcpkg install --triplet x64-windows-static-md sqlite3 - name: Setup rustup run: | @@ -46,7 +52,7 @@ jobs: - name: Build run: | - cmake --preset ${{ matrix.preset }} + cmake --preset ${{ matrix.preset }} -DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_TARGET_TRIPLET }} cmake --build build cmake --install build --prefix install diff --git a/CMakeLists.txt b/CMakeLists.txt index daaad08b..10dfc941 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,6 +89,9 @@ if(CMAKE_SYSTEM MATCHES "Windows") corrosion_add_target_rustflags(chewing_capi -Ctarget-feature=+crt-static) corrosion_add_target_rustflags(chewing_testhelper -Ctarget-feature=+crt-static) corrosion_add_target_rustflags(chewing-cli -Ctarget-feature=+crt-static) + if(VCPKG_TARGET_TRIPLET) + corrosion_set_env_vars(chewing-cli VCPKGRS_TRIPLET=${VCPKG_TARGET_TRIPLET}) + endif() endif() # Feature probe @@ -99,39 +102,10 @@ set(CURSES_NEED_WIDE true) find_package(Curses) if(WITH_SQLITE3) - find_package(SQLite3 QUIET) + find_package(SQLite3 REQUIRED) if(SQLite3_FOUND) message(STATUS "Found SQLite3 version ${SQLite3_VERSION}") include_directories(SQLite3_INCLUDE_DIRS) - else() - message(STATUS "Fetching SQLite3 source from internet") - FetchContent_Declare( - SQLite3 - URL https://www.sqlite.org/2024/sqlite-amalgamation-3460000.zip - URL_HASH SHA3_256=1221eed70de626871912bfca144c00411f0c30d3c2b7935cff3963b63370ef7c - ) - FetchContent_MakeAvailable(SQLite3) - - include_directories(${sqlite3_SOURCE_DIR}) - add_library(sqlite3_library STATIC - ${sqlite3_SOURCE_DIR}/sqlite3.c - ${sqlite3_SOURCE_DIR}/sqlite3.h - ) - find_package(Threads) - target_link_libraries(sqlite3_library PUBLIC ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) - set(SQLite3_LIBRARIES sqlite3_library) - - add_executable(sqlite3 - ${sqlite3_SOURCE_DIR}/shell.c - ) - target_link_libraries(sqlite3 PRIVATE ${SQLite3_LIBRARIES}) - set_target_properties(sqlite3 PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${sqlite3_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${sqlite3_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${sqlite3_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${sqlite3_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${sqlite3_BINARY_DIR} - ) endif() endif() diff --git a/Cargo.lock b/Cargo.lock index c269f1c4..747a025f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "bitflags" @@ -75,12 +75,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "cc" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" - [[package]] name = "cfg-if" version = "1.0.0" @@ -127,9 +121,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.15" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", "clap_derive", @@ -137,9 +131,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", @@ -254,9 +248,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fuzzer" @@ -311,9 +305,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libredox" @@ -331,7 +325,6 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" dependencies = [ - "cc", "pkg-config", "vcpkg", ] @@ -377,18 +370,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -417,9 +410,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags", "errno", @@ -442,9 +435,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.72" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -486,9 +479,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "utf8parse" diff --git a/Cargo.toml b/Cargo.toml index bb4f7e73..8a7d4b42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,6 @@ directories = "5.0.0" log = { workspace = true } rusqlite = { version = ">= 0.28.0", optional = true } -[target.'cfg(windows)'.dependencies] -rusqlite = { version = ">= 0.28.0", features = ["bundled"], optional = true } - [dev-dependencies] tempfile = { workspace = true } diff --git a/capi/data/mini.dat b/capi/data/mini.dat index 435c3509528f185bbc95314d96aba7e11c4ca121..510d5aec1e7d3523cb6baffeb75d30b345b8de36 100644 GIT binary patch delta 40 vcmZ2_oVEWrtAIf>V{#V{i?fGoI1?j-LCQn{Z#Gr~Jxe`<#`3M@jC#oc?70f= delta 62 zcmeA_&bstCtAIf>WAXwX7H1FFa3)3ugQ|%F-ZIh#dX{E@Q^MkYqa Rx+$4OC6$edTN4@ek^vc@5jy|?