Skip to content

Commit

Permalink
Merge pull request #332 from MSP-Greg/00-sqlcipher-mswin
Browse files Browse the repository at this point in the history
Fixes for Windows mswin & sqlcipher
  • Loading branch information
flavorjones committed Aug 10, 2022
2 parents 6be0f1a + b7ccee6 commit 94b7447
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/sqlite3-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
13 changes: 10 additions & 3 deletions ext/sqlite3/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions ext/sqlite3/sqlite3_ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
#define SQLITE3_UTF8_STR_NEW2(_obj) \
(rb_enc_associate_index(rb_str_new2(_obj), rb_utf8_encindex()))


#include <sqlite3.h>
#ifdef USING_SQLCIPHER_INC_SUBDIR
# include <sqlcipher/sqlite3.h>
#else
# include <sqlite3.h>
#endif

#ifndef HAVE_TYPE_SQLITE3_INT64
typedef sqlite_int64 sqlite3_int64;
Expand Down

0 comments on commit 94b7447

Please sign in to comment.