sqlite3 1.5.4 → 2.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +594 -1
- data/CONTRIBUTING.md +112 -6
- data/{faq/faq.md → FAQ.md} +52 -84
- data/INSTALLATION.md +267 -0
- data/LICENSE +18 -22
- data/README.md +87 -124
- data/dependencies.yml +10 -11
- data/ext/sqlite3/aggregator.c +153 -147
- data/ext/sqlite3/aggregator.h +6 -4
- data/ext/sqlite3/backup.c +86 -64
- data/ext/sqlite3/backup.h +2 -2
- data/ext/sqlite3/database.c +744 -484
- data/ext/sqlite3/database.h +23 -4
- data/ext/sqlite3/exception.c +116 -92
- data/ext/sqlite3/exception.h +5 -1
- data/ext/sqlite3/extconf.rb +68 -33
- data/ext/sqlite3/sqlite3.c +177 -115
- data/ext/sqlite3/sqlite3_ruby.h +2 -2
- data/ext/sqlite3/statement.c +590 -293
- data/ext/sqlite3/statement.h +4 -3
- data/ext/sqlite3/timespec.h +20 -0
- data/lib/sqlite3/constants.rb +195 -47
- data/lib/sqlite3/database.rb +252 -195
- data/lib/sqlite3/errors.rb +54 -1
- data/lib/sqlite3/fork_safety.rb +66 -0
- data/lib/sqlite3/pragmas.rb +196 -143
- data/lib/sqlite3/resultset.rb +14 -105
- data/lib/sqlite3/statement.rb +58 -13
- data/lib/sqlite3/value.rb +17 -20
- data/lib/sqlite3/version.rb +2 -21
- data/lib/sqlite3/version_info.rb +17 -0
- data/lib/sqlite3.rb +8 -4
- data/ports/archives/sqlite-autoconf-3530200.tar.gz +0 -0
- metadata +16 -108
- data/API_CHANGES.md +0 -49
- data/ChangeLog.cvs +0 -88
- data/Gemfile +0 -3
- data/LICENSE-DEPENDENCIES +0 -20
- data/faq/faq.rb +0 -145
- data/faq/faq.yml +0 -426
- data/lib/sqlite3/translator.rb +0 -118
- data/ports/archives/sqlite-autoconf-3400000.tar.gz +0 -0
- data/test/helper.rb +0 -27
- data/test/test_backup.rb +0 -33
- data/test/test_collation.rb +0 -82
- data/test/test_database.rb +0 -545
- data/test/test_database_flags.rb +0 -95
- data/test/test_database_readonly.rb +0 -36
- data/test/test_database_readwrite.rb +0 -41
- data/test/test_deprecated.rb +0 -44
- data/test/test_encoding.rb +0 -155
- data/test/test_integration.rb +0 -507
- data/test/test_integration_aggregate.rb +0 -336
- data/test/test_integration_open_close.rb +0 -30
- data/test/test_integration_pending.rb +0 -115
- data/test/test_integration_resultset.rb +0 -142
- data/test/test_integration_statement.rb +0 -194
- data/test/test_result_set.rb +0 -37
- data/test/test_sqlite3.rb +0 -30
- data/test/test_statement.rb +0 -263
- data/test/test_statement_execute.rb +0 -35
data/ext/sqlite3/database.h
CHANGED
|
@@ -3,15 +3,34 @@
|
|
|
3
3
|
|
|
4
4
|
#include <sqlite3_ruby.h>
|
|
5
5
|
|
|
6
|
+
/* bits in the `flags` field */
|
|
7
|
+
#define SQLITE3_RB_DATABASE_READONLY 0x01
|
|
8
|
+
#define SQLITE3_RB_DATABASE_DISCARDED 0x02
|
|
9
|
+
|
|
6
10
|
struct _sqlite3Ruby {
|
|
7
|
-
|
|
11
|
+
sqlite3 *db;
|
|
12
|
+
VALUE busy_handler;
|
|
13
|
+
VALUE functions;
|
|
14
|
+
VALUE collations;
|
|
15
|
+
VALUE aggregators;
|
|
16
|
+
VALUE trace_handler;
|
|
17
|
+
VALUE authorizer;
|
|
18
|
+
int stmt_timeout;
|
|
19
|
+
struct timespec stmt_deadline;
|
|
20
|
+
rb_pid_t owner;
|
|
21
|
+
int flags;
|
|
8
22
|
};
|
|
9
23
|
|
|
10
24
|
typedef struct _sqlite3Ruby sqlite3Ruby;
|
|
11
|
-
typedef sqlite3Ruby *
|
|
25
|
+
typedef sqlite3Ruby *sqlite3RubyPtr;
|
|
26
|
+
|
|
27
|
+
/* Pinning a collection doesn't pin what's in it, hence both. */
|
|
28
|
+
void rb_sqlite3_pin_array_and_contents(VALUE ary);
|
|
12
29
|
|
|
13
30
|
void init_sqlite3_database();
|
|
14
|
-
void set_sqlite3_func_result(sqlite3_context *
|
|
15
|
-
|
|
31
|
+
void set_sqlite3_func_result(sqlite3_context *ctx, VALUE result);
|
|
32
|
+
|
|
33
|
+
sqlite3RubyPtr sqlite3_database_unwrap(VALUE database);
|
|
34
|
+
VALUE sqlite3val2rb(sqlite3_value *val);
|
|
16
35
|
|
|
17
36
|
#endif
|
data/ext/sqlite3/exception.c
CHANGED
|
@@ -1,98 +1,122 @@
|
|
|
1
1
|
#include <sqlite3_ruby.h>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
static VALUE
|
|
4
|
+
status2klass(int status)
|
|
4
5
|
{
|
|
5
|
-
|
|
6
|
+
/* Consider only lower 8 bits, to work correctly when
|
|
7
|
+
extended result codes are enabled. */
|
|
8
|
+
switch (status & 0xff) {
|
|
9
|
+
case SQLITE_OK:
|
|
10
|
+
return Qnil;
|
|
11
|
+
case SQLITE_ERROR:
|
|
12
|
+
return rb_path2class("SQLite3::SQLException");
|
|
13
|
+
case SQLITE_INTERNAL:
|
|
14
|
+
return rb_path2class("SQLite3::InternalException");
|
|
15
|
+
case SQLITE_PERM:
|
|
16
|
+
return rb_path2class("SQLite3::PermissionException");
|
|
17
|
+
case SQLITE_ABORT:
|
|
18
|
+
return rb_path2class("SQLite3::AbortException");
|
|
19
|
+
case SQLITE_BUSY:
|
|
20
|
+
return rb_path2class("SQLite3::BusyException");
|
|
21
|
+
case SQLITE_LOCKED:
|
|
22
|
+
return rb_path2class("SQLite3::LockedException");
|
|
23
|
+
case SQLITE_NOMEM:
|
|
24
|
+
return rb_path2class("SQLite3::MemoryException");
|
|
25
|
+
case SQLITE_READONLY:
|
|
26
|
+
return rb_path2class("SQLite3::ReadOnlyException");
|
|
27
|
+
case SQLITE_INTERRUPT:
|
|
28
|
+
return rb_path2class("SQLite3::InterruptException");
|
|
29
|
+
case SQLITE_IOERR:
|
|
30
|
+
return rb_path2class("SQLite3::IOException");
|
|
31
|
+
case SQLITE_CORRUPT:
|
|
32
|
+
return rb_path2class("SQLite3::CorruptException");
|
|
33
|
+
case SQLITE_NOTFOUND:
|
|
34
|
+
return rb_path2class("SQLite3::NotFoundException");
|
|
35
|
+
case SQLITE_FULL:
|
|
36
|
+
return rb_path2class("SQLite3::FullException");
|
|
37
|
+
case SQLITE_CANTOPEN:
|
|
38
|
+
return rb_path2class("SQLite3::CantOpenException");
|
|
39
|
+
case SQLITE_PROTOCOL:
|
|
40
|
+
return rb_path2class("SQLite3::ProtocolException");
|
|
41
|
+
case SQLITE_EMPTY:
|
|
42
|
+
return rb_path2class("SQLite3::EmptyException");
|
|
43
|
+
case SQLITE_SCHEMA:
|
|
44
|
+
return rb_path2class("SQLite3::SchemaChangedException");
|
|
45
|
+
case SQLITE_TOOBIG:
|
|
46
|
+
return rb_path2class("SQLite3::TooBigException");
|
|
47
|
+
case SQLITE_CONSTRAINT:
|
|
48
|
+
return rb_path2class("SQLite3::ConstraintException");
|
|
49
|
+
case SQLITE_MISMATCH:
|
|
50
|
+
return rb_path2class("SQLite3::MismatchException");
|
|
51
|
+
case SQLITE_MISUSE:
|
|
52
|
+
return rb_path2class("SQLite3::MisuseException");
|
|
53
|
+
case SQLITE_NOLFS:
|
|
54
|
+
return rb_path2class("SQLite3::UnsupportedException");
|
|
55
|
+
case SQLITE_AUTH:
|
|
56
|
+
return rb_path2class("SQLite3::AuthorizationException");
|
|
57
|
+
case SQLITE_FORMAT:
|
|
58
|
+
return rb_path2class("SQLite3::FormatException");
|
|
59
|
+
case SQLITE_RANGE:
|
|
60
|
+
return rb_path2class("SQLite3::RangeException");
|
|
61
|
+
case SQLITE_NOTADB:
|
|
62
|
+
return rb_path2class("SQLite3::NotADatabaseException");
|
|
63
|
+
default:
|
|
64
|
+
return rb_path2class("SQLite3::Exception");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void
|
|
69
|
+
rb_sqlite3_raise(sqlite3 *db, int status)
|
|
70
|
+
{
|
|
71
|
+
VALUE klass = status2klass(status);
|
|
72
|
+
if (NIL_P(klass)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
VALUE exception = rb_exc_new2(klass, sqlite3_errmsg(db));
|
|
77
|
+
rb_iv_set(exception, "@code", INT2FIX(status));
|
|
78
|
+
|
|
79
|
+
rb_exc_raise(exception);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* accepts a sqlite3 error message as the final argument, which will be `sqlite3_free`d
|
|
84
|
+
*/
|
|
85
|
+
void
|
|
86
|
+
rb_sqlite3_raise_msg(sqlite3 *db, int status, const char *msg)
|
|
87
|
+
{
|
|
88
|
+
VALUE klass = status2klass(status);
|
|
89
|
+
if (NIL_P(klass)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
VALUE exception = rb_exc_new2(klass, msg);
|
|
94
|
+
rb_iv_set(exception, "@code", INT2FIX(status));
|
|
95
|
+
sqlite3_free((void *)msg);
|
|
96
|
+
|
|
97
|
+
rb_exc_raise(exception);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void
|
|
101
|
+
rb_sqlite3_raise_with_sql(sqlite3 *db, int status, const char *sql)
|
|
102
|
+
{
|
|
103
|
+
VALUE klass = status2klass(status);
|
|
104
|
+
if (NIL_P(klass)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const char *error_msg = sqlite3_errmsg(db);
|
|
109
|
+
int error_offset = -1;
|
|
110
|
+
#ifdef HAVE_SQLITE3_ERROR_OFFSET
|
|
111
|
+
error_offset = sqlite3_error_offset(db);
|
|
112
|
+
#endif
|
|
6
113
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
case SQLITE_ERROR:
|
|
14
|
-
klass = rb_path2class("SQLite3::SQLException");
|
|
15
|
-
break;
|
|
16
|
-
case SQLITE_INTERNAL:
|
|
17
|
-
klass = rb_path2class("SQLite3::InternalException");
|
|
18
|
-
break;
|
|
19
|
-
case SQLITE_PERM:
|
|
20
|
-
klass = rb_path2class("SQLite3::PermissionException");
|
|
21
|
-
break;
|
|
22
|
-
case SQLITE_ABORT:
|
|
23
|
-
klass = rb_path2class("SQLite3::AbortException");
|
|
24
|
-
break;
|
|
25
|
-
case SQLITE_BUSY:
|
|
26
|
-
klass = rb_path2class("SQLite3::BusyException");
|
|
27
|
-
break;
|
|
28
|
-
case SQLITE_LOCKED:
|
|
29
|
-
klass = rb_path2class("SQLite3::LockedException");
|
|
30
|
-
break;
|
|
31
|
-
case SQLITE_NOMEM:
|
|
32
|
-
klass = rb_path2class("SQLite3::MemoryException");
|
|
33
|
-
break;
|
|
34
|
-
case SQLITE_READONLY:
|
|
35
|
-
klass = rb_path2class("SQLite3::ReadOnlyException");
|
|
36
|
-
break;
|
|
37
|
-
case SQLITE_INTERRUPT:
|
|
38
|
-
klass = rb_path2class("SQLite3::InterruptException");
|
|
39
|
-
break;
|
|
40
|
-
case SQLITE_IOERR:
|
|
41
|
-
klass = rb_path2class("SQLite3::IOException");
|
|
42
|
-
break;
|
|
43
|
-
case SQLITE_CORRUPT:
|
|
44
|
-
klass = rb_path2class("SQLite3::CorruptException");
|
|
45
|
-
break;
|
|
46
|
-
case SQLITE_NOTFOUND:
|
|
47
|
-
klass = rb_path2class("SQLite3::NotFoundException");
|
|
48
|
-
break;
|
|
49
|
-
case SQLITE_FULL:
|
|
50
|
-
klass = rb_path2class("SQLite3::FullException");
|
|
51
|
-
break;
|
|
52
|
-
case SQLITE_CANTOPEN:
|
|
53
|
-
klass = rb_path2class("SQLite3::CantOpenException");
|
|
54
|
-
break;
|
|
55
|
-
case SQLITE_PROTOCOL:
|
|
56
|
-
klass = rb_path2class("SQLite3::ProtocolException");
|
|
57
|
-
break;
|
|
58
|
-
case SQLITE_EMPTY:
|
|
59
|
-
klass = rb_path2class("SQLite3::EmptyException");
|
|
60
|
-
break;
|
|
61
|
-
case SQLITE_SCHEMA:
|
|
62
|
-
klass = rb_path2class("SQLite3::SchemaChangedException");
|
|
63
|
-
break;
|
|
64
|
-
case SQLITE_TOOBIG:
|
|
65
|
-
klass = rb_path2class("SQLite3::TooBigException");
|
|
66
|
-
break;
|
|
67
|
-
case SQLITE_CONSTRAINT:
|
|
68
|
-
klass = rb_path2class("SQLite3::ConstraintException");
|
|
69
|
-
break;
|
|
70
|
-
case SQLITE_MISMATCH:
|
|
71
|
-
klass = rb_path2class("SQLite3::MismatchException");
|
|
72
|
-
break;
|
|
73
|
-
case SQLITE_MISUSE:
|
|
74
|
-
klass = rb_path2class("SQLite3::MisuseException");
|
|
75
|
-
break;
|
|
76
|
-
case SQLITE_NOLFS:
|
|
77
|
-
klass = rb_path2class("SQLite3::UnsupportedException");
|
|
78
|
-
break;
|
|
79
|
-
case SQLITE_AUTH:
|
|
80
|
-
klass = rb_path2class("SQLite3::AuthorizationException");
|
|
81
|
-
break;
|
|
82
|
-
case SQLITE_FORMAT:
|
|
83
|
-
klass = rb_path2class("SQLite3::FormatException");
|
|
84
|
-
break;
|
|
85
|
-
case SQLITE_RANGE:
|
|
86
|
-
klass = rb_path2class("SQLite3::RangeException");
|
|
87
|
-
break;
|
|
88
|
-
case SQLITE_NOTADB:
|
|
89
|
-
klass = rb_path2class("SQLite3::NotADatabaseException");
|
|
90
|
-
break;
|
|
91
|
-
default:
|
|
92
|
-
klass = rb_eRuntimeError;
|
|
93
|
-
}
|
|
114
|
+
VALUE exception = rb_exc_new2(klass, error_msg);
|
|
115
|
+
rb_iv_set(exception, "@code", INT2FIX(status));
|
|
116
|
+
if (sql) {
|
|
117
|
+
rb_iv_set(exception, "@sql", rb_str_new2(sql));
|
|
118
|
+
rb_iv_set(exception, "@sql_offset", INT2FIX(error_offset));
|
|
119
|
+
}
|
|
94
120
|
|
|
95
|
-
|
|
96
|
-
rb_iv_set(klass, "@code", INT2FIX(status));
|
|
97
|
-
rb_exc_raise(klass);
|
|
121
|
+
rb_exc_raise(exception);
|
|
98
122
|
}
|
data/ext/sqlite3/exception.h
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
#define SQLITE3_EXCEPTION_RUBY
|
|
3
3
|
|
|
4
4
|
#define CHECK(_db, _status) rb_sqlite3_raise(_db, _status);
|
|
5
|
+
#define CHECK_MSG(_db, _status, _msg) rb_sqlite3_raise_msg(_db, _status, _msg);
|
|
6
|
+
#define CHECK_PREPARE(_db, _status, _sql) rb_sqlite3_raise_with_sql(_db, _status, _sql)
|
|
5
7
|
|
|
6
|
-
void rb_sqlite3_raise(sqlite3 *
|
|
8
|
+
void rb_sqlite3_raise(sqlite3 *db, int status);
|
|
9
|
+
void rb_sqlite3_raise_msg(sqlite3 *db, int status, const char *msg);
|
|
10
|
+
void rb_sqlite3_raise_with_sql(sqlite3 *db, int status, const char *sql);
|
|
7
11
|
|
|
8
12
|
#endif
|
data/ext/sqlite3/extconf.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require "mkmf"
|
|
2
|
-
require "mini_portile2"
|
|
3
2
|
require "yaml"
|
|
4
3
|
|
|
5
4
|
module Sqlite3
|
|
@@ -20,7 +19,7 @@ module Sqlite3
|
|
|
20
19
|
|
|
21
20
|
configure_extension
|
|
22
21
|
|
|
23
|
-
create_makefile(
|
|
22
|
+
create_makefile("sqlite3/sqlite3_native")
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def configure_cross_compiler
|
|
@@ -50,15 +49,25 @@ module Sqlite3
|
|
|
50
49
|
|
|
51
50
|
def configure_packaged_libraries
|
|
52
51
|
minimal_recipe.tap do |recipe|
|
|
53
|
-
recipe.configure_options += [
|
|
52
|
+
recipe.configure_options += [
|
|
53
|
+
"--disable-shared",
|
|
54
|
+
"--enable-static",
|
|
55
|
+
"--enable-fts5"
|
|
56
|
+
]
|
|
54
57
|
ENV.to_h.tap do |env|
|
|
55
|
-
|
|
58
|
+
user_cflags = with_config("sqlite-cflags")
|
|
59
|
+
more_cflags = [
|
|
56
60
|
"-fPIC", # needed for linking the static library into a shared library
|
|
57
61
|
"-O2", # see https://github.com/sparklemotion/sqlite3-ruby/issues/335 for some benchmarks
|
|
62
|
+
"-fvisibility=hidden", # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
|
|
63
|
+
"-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1",
|
|
64
|
+
"-DSQLITE_USE_URI=1",
|
|
65
|
+
"-DSQLITE_ENABLE_DBPAGE_VTAB=1",
|
|
66
|
+
"-DSQLITE_ENABLE_DBSTAT_VTAB=1"
|
|
58
67
|
]
|
|
59
|
-
env["CFLAGS"] = [env["CFLAGS"],
|
|
60
|
-
recipe.configure_options += env.
|
|
61
|
-
|
|
68
|
+
env["CFLAGS"] = [user_cflags, env["CFLAGS"], more_cflags].flatten.join(" ")
|
|
69
|
+
recipe.configure_options += env.slice(*ENV_ALLOWLIST)
|
|
70
|
+
.map { |key, value| "#{key}=#{value.strip}" }
|
|
62
71
|
end
|
|
63
72
|
|
|
64
73
|
unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
|
|
@@ -69,62 +78,75 @@ module Sqlite3
|
|
|
69
78
|
# on macos, pkg-config will not return --cflags without this
|
|
70
79
|
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t"
|
|
71
80
|
|
|
81
|
+
# only needed for Ruby 3.1.3, see https://bugs.ruby-lang.org/issues/19233
|
|
82
|
+
RbConfig::CONFIG["PKG_CONFIG"] = config_string("PKG_CONFIG") || "pkg-config"
|
|
83
|
+
|
|
72
84
|
lib_path = File.join(recipe.path, "lib")
|
|
73
85
|
pcfile = File.join(lib_path, "pkgconfig", "sqlite3.pc")
|
|
74
86
|
abort_pkg_config("pkg_config") unless pkg_config(pcfile)
|
|
75
87
|
|
|
76
88
|
# see https://bugs.ruby-lang.org/issues/18490
|
|
77
|
-
|
|
89
|
+
ldflags = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
|
|
78
90
|
abort_pkg_config("xpopen") unless $?.success?
|
|
79
|
-
|
|
91
|
+
ldflags = ldflags.split
|
|
80
92
|
|
|
81
93
|
# see https://github.com/flavorjones/mini_portile/issues/118
|
|
82
94
|
"-L#{lib_path}".tap do |lib_path_flag|
|
|
83
|
-
|
|
95
|
+
ldflags.prepend(lib_path_flag) unless ldflags.include?(lib_path_flag)
|
|
84
96
|
end
|
|
85
97
|
|
|
86
|
-
|
|
98
|
+
ldflags.each { |ldflag| append_ldflags(ldflag) }
|
|
99
|
+
|
|
100
|
+
append_cppflags("-DUSING_PACKAGED_LIBRARIES")
|
|
101
|
+
append_cppflags("-DUSING_PRECOMPILED_LIBRARIES") if cross_build?
|
|
87
102
|
end
|
|
88
103
|
end
|
|
89
104
|
|
|
90
105
|
def configure_extension
|
|
91
|
-
|
|
92
|
-
append_cppflags("-DTAINTING_SUPPORT")
|
|
93
|
-
end
|
|
106
|
+
append_cflags("-fvisibility=hidden") # see https://github.com/rake-compiler/rake-compiler-dock/issues/87
|
|
94
107
|
|
|
95
|
-
if find_header("sqlite3.h")
|
|
96
|
-
# noop
|
|
97
|
-
elsif sqlcipher? && find_header("sqlcipher/sqlite3.h")
|
|
108
|
+
if sqlcipher? && find_header("sqlcipher/sqlite3.h")
|
|
98
109
|
append_cppflags("-DUSING_SQLCIPHER_INC_SUBDIR")
|
|
110
|
+
elsif find_header("sqlite3.h")
|
|
111
|
+
# noop
|
|
99
112
|
else
|
|
100
113
|
abort_could_not_find("sqlite3.h")
|
|
101
114
|
end
|
|
102
115
|
|
|
103
116
|
abort_could_not_find(libname) unless find_library(libname, "sqlite3_libversion_number", "sqlite3.h")
|
|
104
117
|
|
|
118
|
+
# Truffle Ruby doesn't support this yet:
|
|
119
|
+
# https://github.com/oracle/truffleruby/issues/3408
|
|
120
|
+
have_func("rb_enc_interned_str_cstr")
|
|
121
|
+
|
|
105
122
|
# Functions defined in 1.9 but not 1.8
|
|
106
|
-
have_func(
|
|
123
|
+
have_func("rb_proc_arity")
|
|
107
124
|
|
|
108
125
|
# Functions defined in 2.1 but not 2.0
|
|
109
|
-
have_func(
|
|
126
|
+
have_func("rb_integer_pack")
|
|
110
127
|
|
|
111
128
|
# These functions may not be defined
|
|
112
|
-
have_func(
|
|
113
|
-
have_func(
|
|
114
|
-
have_func(
|
|
115
|
-
have_func(
|
|
116
|
-
have_func(
|
|
129
|
+
have_func("sqlite3_initialize")
|
|
130
|
+
have_func("sqlite3_backup_init")
|
|
131
|
+
have_func("sqlite3_column_database_name")
|
|
132
|
+
have_func("sqlite3_enable_load_extension")
|
|
133
|
+
have_func("sqlite3_load_extension")
|
|
117
134
|
|
|
118
|
-
unless have_func(
|
|
135
|
+
unless have_func("sqlite3_open_v2") # https://www.sqlite.org/releaselog/3_5_0.html
|
|
119
136
|
abort("\nPlease use a version of SQLite3 >= 3.5.0\n\n")
|
|
120
137
|
end
|
|
121
138
|
|
|
122
|
-
have_func(
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
have_func("sqlite3_prepare_v2")
|
|
140
|
+
have_func("sqlite3_db_name", "sqlite3.h") # v3.39.0
|
|
141
|
+
have_func("sqlite3_error_offset", "sqlite3.h") # v3.38.0
|
|
142
|
+
|
|
143
|
+
have_type("sqlite3_int64", "sqlite3.h")
|
|
144
|
+
have_type("sqlite3_uint64", "sqlite3.h")
|
|
125
145
|
end
|
|
126
146
|
|
|
127
147
|
def minimal_recipe
|
|
148
|
+
require "mini_portile2"
|
|
149
|
+
|
|
128
150
|
MiniPortile.new(libname, sqlite3_config[:version]).tap do |recipe|
|
|
129
151
|
if sqlite_source_dir
|
|
130
152
|
recipe.source_directory = sqlite_source_dir
|
|
@@ -145,8 +167,7 @@ module Sqlite3
|
|
|
145
167
|
end
|
|
146
168
|
|
|
147
169
|
def mini_portile_config
|
|
148
|
-
|
|
149
|
-
YAML.load_file(File.join(package_root_dir, "dependencies.yml"))
|
|
170
|
+
YAML.load_file(File.join(package_root_dir, "dependencies.yml"), symbolize_names: true)
|
|
150
171
|
end
|
|
151
172
|
|
|
152
173
|
def abort_could_not_find(missing)
|
|
@@ -154,7 +175,7 @@ module Sqlite3
|
|
|
154
175
|
end
|
|
155
176
|
|
|
156
177
|
def abort_pkg_config(id)
|
|
157
|
-
abort("\nCould not configure the build properly (#{id}). Please install
|
|
178
|
+
abort("\nCould not configure the build properly (#{id}). Please install the `pkg-config` utility.\n\n")
|
|
158
179
|
end
|
|
159
180
|
|
|
160
181
|
def cross_build?
|
|
@@ -169,6 +190,14 @@ module Sqlite3
|
|
|
169
190
|
minimal_recipe.download
|
|
170
191
|
end
|
|
171
192
|
|
|
193
|
+
def darwin?
|
|
194
|
+
RbConfig::CONFIG["target_os"].include?("darwin")
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def windows?
|
|
198
|
+
RbConfig::CONFIG["target_os"].match?(/mingw|mswin/)
|
|
199
|
+
end
|
|
200
|
+
|
|
172
201
|
def print_help
|
|
173
202
|
print(<<~TEXT)
|
|
174
203
|
USAGE: ruby #{$PROGRAM_NAME} [options]
|
|
@@ -223,17 +252,23 @@ module Sqlite3
|
|
|
223
252
|
|
|
224
253
|
Flags only used when building and using the packaged libraries:
|
|
225
254
|
|
|
255
|
+
--with-sqlite-cflags=CFLAGS
|
|
256
|
+
Explicitly pass compiler flags to the sqlite library build. These flags will
|
|
257
|
+
appear on the commandline before any flags set in the CFLAGS environment
|
|
258
|
+
variable. This is useful for setting compilation options in your project's
|
|
259
|
+
bundler config. See INSTALLATION.md for more information.
|
|
260
|
+
|
|
226
261
|
--enable-cross-build
|
|
227
262
|
Enable cross-build mode. (You probably do not want to set this manually.)
|
|
228
263
|
|
|
229
264
|
|
|
230
|
-
Environment variables used for compiling the C extension:
|
|
265
|
+
Environment variables used for compiling the gem's C extension:
|
|
231
266
|
|
|
232
267
|
CC
|
|
233
268
|
Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`
|
|
234
269
|
|
|
235
270
|
|
|
236
|
-
Environment variables passed through to the compilation of
|
|
271
|
+
Environment variables passed through to the compilation of sqlite:
|
|
237
272
|
|
|
238
273
|
CC
|
|
239
274
|
CPPFLAGS
|