Skip to content

Commit 94b7447

Browse files
authored
Merge pull request #332 from MSP-Greg/00-sqlcipher-mswin
Fixes for Windows mswin & sqlcipher
2 parents 6be0f1a + b7ccee6 commit 94b7447

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

.github/workflows/sqlite3-ruby.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,8 @@ jobs:
8484
include:
8585
- os: "windows-2022"
8686
ruby: "mingw"
87-
# # I'm struggling to build against sqlcipher on mswin.
88-
# # find_header can't find sqlite3.h
89-
# # patches welcome from anyone who needs this functionality and can make it work.
90-
# - os: "windows-2022"
91-
# ruby: "mswin"
87+
- os: "windows-2022"
88+
ruby: "mswin"
9289
runs-on: ${{matrix.os}}
9390
steps:
9491
- if: matrix.os == 'windows-2022'
@@ -104,6 +101,6 @@ jobs:
104101
apt-get: "libsqlcipher-dev"
105102
brew: "sqlcipher"
106103
mingw: "sqlcipher"
107-
# vcpkg: "sqlcipher" # see above
104+
vcpkg: "sqlcipher"
108105
- run: bundle exec rake compile -- --with-sqlcipher
109106
- run: bundle exec rake test

ext/sqlite3/extconf.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def sqlcipher?
4444

4545
def configure_system_libraries
4646
pkg_config(libname)
47-
append_cflags("-DUSING_SQLCIPHER") if sqlcipher?
47+
append_cppflags("-DUSING_SQLCIPHER") if sqlcipher?
4848
end
4949

5050
def configure_packaged_libraries
@@ -75,10 +75,17 @@ def configure_packaged_libraries
7575

7676
def configure_extension
7777
if Gem::Requirement.new("< 2.7").satisfied_by?(Gem::Version.new(RUBY_VERSION))
78-
append_cflags("-DTAINTING_SUPPORT")
78+
append_cppflags("-DTAINTING_SUPPORT")
79+
end
80+
81+
if find_header("sqlite3.h")
82+
# noop
83+
elsif sqlcipher? && find_header("sqlcipher/sqlite3.h")
84+
append_cppflags("-DUSING_SQLCIPHER_INC_SUBDIR")
85+
else
86+
abort_could_not_find("sqlite3.h")
7987
end
8088

81-
abort_could_not_find("sqlite3.h") unless find_header("sqlite3.h")
8289
abort_could_not_find(libname) unless find_library(libname, "sqlite3_libversion_number", "sqlite3.h")
8390

8491
# Functions defined in 1.9 but not 1.8

ext/sqlite3/sqlite3_ruby.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
#define SQLITE3_UTF8_STR_NEW2(_obj) \
2222
(rb_enc_associate_index(rb_str_new2(_obj), rb_utf8_encindex()))
2323

24-
25-
#include <sqlite3.h>
24+
#ifdef USING_SQLCIPHER_INC_SUBDIR
25+
# include <sqlcipher/sqlite3.h>
26+
#else
27+
# include <sqlite3.h>
28+
#endif
2629

2730
#ifndef HAVE_TYPE_SQLITE3_INT64
2831
typedef sqlite_int64 sqlite3_int64;

0 commit comments

Comments
 (0)