Fossil SCM
Add an SQLite compatibility test program and run that program during the "./configure" if the --disable-internal-sqlite option is used in order to verify that the system SQLite library has all of the capabilities that we need.
Commit
350c627a52908458a2c598f3134ce76266f3479545c5b2484aa46b2868aa3628
Parent
92dc1021580c8c6…
2 files changed
+34
-6
+25
M
auto.def
+34
-6
| --- auto.def | ||
| +++ auto.def | ||
| @@ -116,11 +116,11 @@ | ||
| 116 | 116 | } |
| 117 | 117 | return $found |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | if {![opt-bool internal-sqlite]} { |
| 121 | - proc find_internal_sqlite {} { | |
| 121 | + proc find_system_sqlite {} { | |
| 122 | 122 | |
| 123 | 123 | # On some systems (slackware), libsqlite3 requires -ldl to link. So |
| 124 | 124 | # search for the system SQLite once with -ldl, and once without. If |
| 125 | 125 | # the library can only be found with $extralibs set to -ldl, then |
| 126 | 126 | # the code below will append -ldl to LIBS. |
| @@ -131,14 +131,10 @@ | ||
| 131 | 131 | # if sqlite3_stmt_isexplain can be found as well. If we can find open() but |
| 132 | 132 | # not stmt_isexplain(), then the system SQLite is too old to link against |
| 133 | 133 | # fossil. |
| 134 | 134 | # |
| 135 | 135 | if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} { |
| 136 | - if {![check-function-in-lib sqlite3_stmt_isexplain sqlite3 $extralibs]} { | |
| 137 | - user-error "system sqlite3 too old (require >= 3.28.0)" | |
| 138 | - } | |
| 139 | - | |
| 140 | 136 | # Success. Update symbols and return. |
| 141 | 137 | # |
| 142 | 138 | define USE_SYSTEM_SQLITE 1 |
| 143 | 139 | define-append LIBS -lsqlite3 |
| 144 | 140 | define-append LIBS $extralibs |
| @@ -146,11 +142,43 @@ | ||
| 146 | 142 | } |
| 147 | 143 | } |
| 148 | 144 | user-error "system sqlite3 not found" |
| 149 | 145 | } |
| 150 | 146 | |
| 151 | - find_internal_sqlite | |
| 147 | + find_system_sqlite | |
| 148 | + | |
| 149 | + proc test_system_sqlite {} { | |
| 150 | + # Check compatibility of the system SQLite library by running the sqlcompttest.c | |
| 151 | + # program in the source tree | |
| 152 | + # | |
| 153 | + set cmdline {} | |
| 154 | + lappend cmdline {*}[get-define CCACHE] | |
| 155 | + lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS] | |
| 156 | + lappend cmdline $::autosetup(dir)/../src/sqlcompattest.c -o conftest__ | |
| 157 | + lappend cmdline {*}[get-define LIBS] | |
| 158 | + set ok 1 | |
| 159 | + set err [catch {exec-with-stderr {*}$cmdline} result errinfo] | |
| 160 | + if {$err} { | |
| 161 | + configlog "Failed: [join $cmdline]" | |
| 162 | + if {[string length $result]>0} {configlog $result} | |
| 163 | + configlog "============" | |
| 164 | + set ok 0 | |
| 165 | + } elseif {$::autosetup(debug)} { | |
| 166 | + configlog "Compiled OK: [join $cmdline]" | |
| 167 | + configlog "============" | |
| 168 | + } | |
| 169 | + if {!$ok} { | |
| 170 | + user-error "unable to compile SQLite compatibility test program" | |
| 171 | + } | |
| 172 | + set err [catch {exec-with-stderr ./conftest__} result errinfo] | |
| 173 | + if {$err} { | |
| 174 | + user-error $result | |
| 175 | + } | |
| 176 | + file delete ./conftest__ | |
| 177 | + } | |
| 178 | + test_system_sqlite | |
| 179 | + | |
| 152 | 180 | } |
| 153 | 181 | |
| 154 | 182 | proc is_mingw {} { |
| 155 | 183 | return [string match *mingw* [get-define host]] |
| 156 | 184 | } |
| 157 | 185 | |
| 158 | 186 | ADDED src/sqlcompattest.c |
| --- auto.def | |
| +++ auto.def | |
| @@ -116,11 +116,11 @@ | |
| 116 | } |
| 117 | return $found |
| 118 | } |
| 119 | |
| 120 | if {![opt-bool internal-sqlite]} { |
| 121 | proc find_internal_sqlite {} { |
| 122 | |
| 123 | # On some systems (slackware), libsqlite3 requires -ldl to link. So |
| 124 | # search for the system SQLite once with -ldl, and once without. If |
| 125 | # the library can only be found with $extralibs set to -ldl, then |
| 126 | # the code below will append -ldl to LIBS. |
| @@ -131,14 +131,10 @@ | |
| 131 | # if sqlite3_stmt_isexplain can be found as well. If we can find open() but |
| 132 | # not stmt_isexplain(), then the system SQLite is too old to link against |
| 133 | # fossil. |
| 134 | # |
| 135 | if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} { |
| 136 | if {![check-function-in-lib sqlite3_stmt_isexplain sqlite3 $extralibs]} { |
| 137 | user-error "system sqlite3 too old (require >= 3.28.0)" |
| 138 | } |
| 139 | |
| 140 | # Success. Update symbols and return. |
| 141 | # |
| 142 | define USE_SYSTEM_SQLITE 1 |
| 143 | define-append LIBS -lsqlite3 |
| 144 | define-append LIBS $extralibs |
| @@ -146,11 +142,43 @@ | |
| 146 | } |
| 147 | } |
| 148 | user-error "system sqlite3 not found" |
| 149 | } |
| 150 | |
| 151 | find_internal_sqlite |
| 152 | } |
| 153 | |
| 154 | proc is_mingw {} { |
| 155 | return [string match *mingw* [get-define host]] |
| 156 | } |
| 157 | |
| 158 | DDED src/sqlcompattest.c |
| --- auto.def | |
| +++ auto.def | |
| @@ -116,11 +116,11 @@ | |
| 116 | } |
| 117 | return $found |
| 118 | } |
| 119 | |
| 120 | if {![opt-bool internal-sqlite]} { |
| 121 | proc find_system_sqlite {} { |
| 122 | |
| 123 | # On some systems (slackware), libsqlite3 requires -ldl to link. So |
| 124 | # search for the system SQLite once with -ldl, and once without. If |
| 125 | # the library can only be found with $extralibs set to -ldl, then |
| 126 | # the code below will append -ldl to LIBS. |
| @@ -131,14 +131,10 @@ | |
| 131 | # if sqlite3_stmt_isexplain can be found as well. If we can find open() but |
| 132 | # not stmt_isexplain(), then the system SQLite is too old to link against |
| 133 | # fossil. |
| 134 | # |
| 135 | if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} { |
| 136 | # Success. Update symbols and return. |
| 137 | # |
| 138 | define USE_SYSTEM_SQLITE 1 |
| 139 | define-append LIBS -lsqlite3 |
| 140 | define-append LIBS $extralibs |
| @@ -146,11 +142,43 @@ | |
| 142 | } |
| 143 | } |
| 144 | user-error "system sqlite3 not found" |
| 145 | } |
| 146 | |
| 147 | find_system_sqlite |
| 148 | |
| 149 | proc test_system_sqlite {} { |
| 150 | # Check compatibility of the system SQLite library by running the sqlcompttest.c |
| 151 | # program in the source tree |
| 152 | # |
| 153 | set cmdline {} |
| 154 | lappend cmdline {*}[get-define CCACHE] |
| 155 | lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS] |
| 156 | lappend cmdline $::autosetup(dir)/../src/sqlcompattest.c -o conftest__ |
| 157 | lappend cmdline {*}[get-define LIBS] |
| 158 | set ok 1 |
| 159 | set err [catch {exec-with-stderr {*}$cmdline} result errinfo] |
| 160 | if {$err} { |
| 161 | configlog "Failed: [join $cmdline]" |
| 162 | if {[string length $result]>0} {configlog $result} |
| 163 | configlog "============" |
| 164 | set ok 0 |
| 165 | } elseif {$::autosetup(debug)} { |
| 166 | configlog "Compiled OK: [join $cmdline]" |
| 167 | configlog "============" |
| 168 | } |
| 169 | if {!$ok} { |
| 170 | user-error "unable to compile SQLite compatibility test program" |
| 171 | } |
| 172 | set err [catch {exec-with-stderr ./conftest__} result errinfo] |
| 173 | if {$err} { |
| 174 | user-error $result |
| 175 | } |
| 176 | file delete ./conftest__ |
| 177 | } |
| 178 | test_system_sqlite |
| 179 | |
| 180 | } |
| 181 | |
| 182 | proc is_mingw {} { |
| 183 | return [string match *mingw* [get-define host]] |
| 184 | } |
| 185 | |
| 186 | DDED src/sqlcompattest.c |
+25
| --- a/src/sqlcompattest.c | ||
| +++ b/src/sqlcompattest.c | ||
| @@ -0,0 +1,25 @@ | ||
| 1 | +/* | |
| 2 | +** Copyright (c) 201/* | |
| 3 | +** Copyright (c) 2019 D. Richard Hipp | |
| 4 | +** | |
| 5 | +** This program is free software; you can redistribute it and/or | |
| 6 | +** modify it under the terms of the Simplified BSD License (also | |
| 7 | +** known as the "2-Clause License" or "FreeBSD License".) | |
| 8 | +** | |
| 9 | +** This program is distributed in the hope that it will be useful, | |
| 10 | +** but without any warranty; without even the implied warranty of | |
| 11 | +** merchantability or fitness for a particular purpose. | |
| 12 | +** | |
| 13 | +** Author contact information: | |
| 14 | +** [email protected] | |
| 15 | +** http://www.hwaci.com/drh/ | |
| 16 | +** | |
| 17 | +********************d Hipp | |
| 18 | +** | |
| 19 | +** This program is free software; you can redistribute it and/or | |
| 20 | +** modify it uied BSD License (also | |
| 21 | +** known as the "2-Clause License" or "FreeBSD License".) | |
| 22 | +** | |
| 23 | +** This program is distributed in the hope that it will be useful, | |
| 24 | +** but without any warranty; without even the implied warope that it will be useful, | |
| 25 | +** but without any warranty; without eve "ENABLE_DBPAGE_VTAB", /* Required by the .recover command in "fossil sql"dumpthe "fossil sql" command */ |
| --- a/src/sqlcompattest.c | |
| +++ b/src/sqlcompattest.c | |
| @@ -0,0 +1,25 @@ | |
| --- a/src/sqlcompattest.c | |
| +++ b/src/sqlcompattest.c | |
| @@ -0,0 +1,25 @@ | |
| 1 | /* |
| 2 | ** Copyright (c) 201/* |
| 3 | ** Copyright (c) 2019 D. Richard Hipp |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or |
| 6 | ** modify it under the terms of the Simplified BSD License (also |
| 7 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 8 | ** |
| 9 | ** This program is distributed in the hope that it will be useful, |
| 10 | ** but without any warranty; without even the implied warranty of |
| 11 | ** merchantability or fitness for a particular purpose. |
| 12 | ** |
| 13 | ** Author contact information: |
| 14 | ** [email protected] |
| 15 | ** http://www.hwaci.com/drh/ |
| 16 | ** |
| 17 | ********************d Hipp |
| 18 | ** |
| 19 | ** This program is free software; you can redistribute it and/or |
| 20 | ** modify it uied BSD License (also |
| 21 | ** known as the "2-Clause License" or "FreeBSD License".) |
| 22 | ** |
| 23 | ** This program is distributed in the hope that it will be useful, |
| 24 | ** but without any warranty; without even the implied warope that it will be useful, |
| 25 | ** but without any warranty; without eve "ENABLE_DBPAGE_VTAB", /* Required by the .recover command in "fossil sql"dumpthe "fossil sql" command */ |