diff --git a/.github/workflows/sqlite3-ruby.yml b/.github/workflows/sqlite3-ruby.yml index ee5e9fb2..b6c97992 100644 --- a/.github/workflows/sqlite3-ruby.yml +++ b/.github/workflows/sqlite3-ruby.yml @@ -84,11 +84,8 @@ jobs: include: - os: "windows-2022" ruby: "mingw" - # # I'm struggling to build against sqlcipher on mswin. - # # find_header can't find sqlite3.h - # # patches welcome from anyone who needs this functionality and can make it work. - # - os: "windows-2022" - # ruby: "mswin" + - os: "windows-2022" + ruby: "mswin" runs-on: ${{matrix.os}} steps: - if: matrix.os == 'windows-2022' @@ -104,6 +101,6 @@ jobs: apt-get: "libsqlcipher-dev" brew: "sqlcipher" mingw: "sqlcipher" - # vcpkg: "sqlcipher" # see above + vcpkg: "sqlcipher" - run: bundle exec rake compile -- --with-sqlcipher - run: bundle exec rake test diff --git a/ext/sqlite3/extconf.rb b/ext/sqlite3/extconf.rb index b42eb9aa..cf8b9c33 100644 --- a/ext/sqlite3/extconf.rb +++ b/ext/sqlite3/extconf.rb @@ -44,7 +44,7 @@ def sqlcipher? def configure_system_libraries pkg_config(libname) - append_cflags("-DUSING_SQLCIPHER") if sqlcipher? + append_cppflags("-DUSING_SQLCIPHER") if sqlcipher? end def configure_packaged_libraries @@ -75,10 +75,17 @@ def configure_packaged_libraries def configure_extension if Gem::Requirement.new("< 2.7").satisfied_by?(Gem::Version.new(RUBY_VERSION)) - append_cflags("-DTAINTING_SUPPORT") + append_cppflags("-DTAINTING_SUPPORT") + end + + if find_header("sqlite3.h") + # noop + elsif sqlcipher? && find_header("sqlcipher/sqlite3.h") + append_cppflags("-DUSING_SQLCIPHER_INC_SUBDIR") + else + abort_could_not_find("sqlite3.h") end - abort_could_not_find("sqlite3.h") unless find_header("sqlite3.h") abort_could_not_find(libname) unless find_library(libname, "sqlite3_libversion_number", "sqlite3.h") # Functions defined in 1.9 but not 1.8 diff --git a/ext/sqlite3/sqlite3_ruby.h b/ext/sqlite3/sqlite3_ruby.h index a647c440..9cea90dc 100644 --- a/ext/sqlite3/sqlite3_ruby.h +++ b/ext/sqlite3/sqlite3_ruby.h @@ -21,8 +21,11 @@ #define SQLITE3_UTF8_STR_NEW2(_obj) \ (rb_enc_associate_index(rb_str_new2(_obj), rb_utf8_encindex())) - -#include +#ifdef USING_SQLCIPHER_INC_SUBDIR +# include +#else +# include +#endif #ifndef HAVE_TYPE_SQLITE3_INT64 typedef sqlite_int64 sqlite3_int64;