Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Windows mswin & sqlcipher #332

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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