-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_sqlite.py
91 lines (72 loc) · 2.02 KB
/
find_sqlite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- python -*-
# stdlib imports ---
import os
import os.path as osp
# waf imports ---
import waflib.Utils
import waflib.Logs as msg
from waflib.Configure import conf
#
_heptooldir = osp.dirname(osp.abspath(__file__))
def options(ctx):
ctx.load('hwaf-base', tooldir=_heptooldir)
ctx.add_option(
'--with-sqlite',
default=None,
help="Look for SQLite at the given path")
return
def configure(ctx):
ctx.load('hwaf-base', tooldir=_heptooldir)
return
@conf
def find_sqlite(ctx, **kwargs):
ctx.load('hwaf-base', tooldir=_heptooldir)
if not ctx.env.HWAF_FOUND_C_COMPILER:
ctx.fatal('load a C compiler first')
pass
if not ctx.env.HWAF_FOUND_CXX_COMPILER:
ctx.fatal('load a C++ compiler first')
pass
path_list = waflib.Utils.to_list(kwargs.get('path_list', []))
if getattr(ctx.options, 'with_sqlite', None):
topdir = ctx.options.with_sqlite
topdir = ctx.hwaf_subst_vars(topdir)
path_list.append(osp.join(topdir, "bin"))
pass
kwargs['mandatory']=kwargs.get('mandatory', False)
kwargs['path_list']=path_list
ctx.find_program(
'sqlite3',
var='SQLITE',
**kwargs)
ctx.check_with(
ctx.check_cfg,
"sqlite",
package="sqlite3",
uselib_store="sqlite",
args='--cflags --libs',
**kwargs)
# test sqlite
version = ctx.check_cxx(
msg="Checking sqlite version",
okmsg="ok",
fragment='''\
#include "sqlite3.h"
#include <iostream>
int main(int /*argc*/, char** /*argv*/) {
std::cout << SQLITE_VERSION << std::flush;
return 0;
}
''',
use="sqlite",
define_name = "HWAF_SQLITE_VERSION",
define_ret = True,
execute = True,
mandatory= kwargs['mandatory'],
)
ctx.start_msg("sqlite version")
ctx.end_msg(version)
ctx.env.SQLITE_VERSION = version
ctx.env.HWAF_FOUND_SQLITE = 1
return
## EOF ##