From f987c58ccd3c5ed5958e1a30161071dffd7ab902 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 13 Nov 2011 15:13:49 -0800 Subject: [PATCH] scons: better test for rtree support --- SConstruct | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index f566c6007..d757f0237 100644 --- a/SConstruct +++ b/SConstruct @@ -874,18 +874,34 @@ def sqlite_has_rtree(context): ret = context.TryRun(""" -extern "C" { - #include -} +#include +#include int main() { - sqlite3_rtree_geometry *p; - //sqlite3_compileoption_used("ENABLE_RTREE"); - return 0; + sqlite3* db; + int rc; + rc = sqlite3_open(":memory:", &db); + if (rc != SQLITE_OK) + { + printf("error 1: %s\\n", sqlite3_errmsg(db)); + } + const char * sql = "create virtual table foo using rtree(pkid, xmin, xmax, ymin, ymax)"; + rc = sqlite3_exec(db, sql, 0, 0, 0); + if (rc != SQLITE_OK) + { + printf("error 2: %s\\n", sqlite3_errmsg(db)); + } + else + { + printf("yes, has rtree!\\n"); + return 0; + } + + return -1; } -""", '.cpp') +""", '.c') context.Message('Checking if SQLite supports RTREE... ') context.Result(ret[0]) if ret[0]: