|
7 | 7 | ENV["CC"] = RbConfig::CONFIG["CC"] |
8 | 8 |
|
9 | 9 | cross_build_p = enable_config("cross-build") |
10 | | -system_libraries_p = enable_config("system-libraries") |
11 | 10 | sqlcipher_p = with_config("sqlcipher") |
| 11 | +system_libraries_p = sqlcipher_p || enable_config("system-libraries") |
| 12 | +libname = sqlcipher_p ? "sqlcipher" : "sqlite3" |
| 13 | + |
| 14 | +def abort_could_not_find(missing) |
| 15 | + abort("Could not find #{missing}. Please visit https://github.com/sparklemotion/sqlite3-ruby for installation instructions.") |
| 16 | +end |
12 | 17 |
|
13 | 18 | if system_libraries_p |
14 | | - # if sqlcipher_p # TODO test and document this |
15 | | - # message "Building sqlite3-ruby using system sqlcipher.\n" |
16 | | - # pkg_config("sqlcipher") # TODO test and document this |
17 | | - # else |
18 | | - message "Building sqlite3-ruby using system sqlite3.\n" |
19 | | - pkg_config("sqlite3") # TODO document |
20 | | - # end |
| 19 | + message "Building sqlite3-ruby using system #{libname}.\n" |
| 20 | + pkg_config(libname) |
| 21 | + append_cflags("-DUSING_SQLCIPHER") if sqlcipher_p |
| 22 | + |
21 | 23 | else |
22 | 24 | message "Building sqlite3-ruby using packaged sqlite3.\n" |
23 | 25 | MiniPortile.new("sqlite3", "3.38.5").tap do |recipe| |
|
66 | 68 |
|
67 | 69 | append_cflags("-DTAINTING_SUPPORT") if Gem::Requirement.new("< 2.7").satisfied_by?(Gem::Version.new(RUBY_VERSION)) |
68 | 70 |
|
69 | | -def abort_could_not_find_library(missing) |
70 | | - if RUBY_PLATFORM =~ /mingw|mswin/ |
71 | | - abort "#{missing} is missing. Install SQLite3 from " + |
72 | | - "http://www.sqlite.org/ first." |
73 | | - else |
74 | | - abort <<-error |
75 | | -#{missing} is missing. Try 'brew install sqlite3', |
76 | | -'yum install sqlite-devel' or 'apt-get install libsqlite3-dev' |
77 | | -and check your shared library search path (the |
78 | | -location where your sqlite3 shared library is located). |
79 | | - error |
80 | | - end |
81 | | -end |
82 | | - |
83 | | -abort_could_not_find_library('sqlite3.h') unless find_header 'sqlite3.h' |
84 | | - |
85 | | -# TODO sqlcipher support |
86 | | -# if with_config('sqlcipher') |
87 | | -# append_cflags("-DUSING_SQLCIPHER") |
88 | | -# abort_could_not_find_library('sqlcipher') unless find_library 'sqlcipher', 'sqlite3_libversion_number' |
89 | | -# else |
90 | | - abort_could_not_find_library('sqlite3') unless find_library("sqlite3", "sqlite3_libversion_number", "sqlite3.h") |
91 | | -# end |
| 71 | +abort_could_not_find("sqlite3.h") unless find_header("sqlite3.h") |
| 72 | +abort_could_not_find(libname) unless find_library(libname, "sqlite3_libversion_number", "sqlite3.h") |
92 | 73 |
|
93 | 74 | # Functions defined in 1.9 but not 1.8 |
94 | 75 | have_func('rb_proc_arity') |
|
0 commit comments