Skip to content

Commit

Permalink
build: use vcpkg on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kanru committed Sep 19, 2024
1 parent e8ac272 commit 3383f93
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 63 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down
34 changes: 4 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down
47 changes: 20 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
Binary file modified capi/data/mini.dat
Binary file not shown.

0 comments on commit 3383f93

Please sign in to comment.