-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_gccxml.py
81 lines (62 loc) · 1.86 KB
/
find_gccxml.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
# -*- 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(opt):
opt.load('hwaf-base', tooldir=_heptooldir)
opt.add_option(
'--with-gccxml',
default=None,
help="Look for GCCXML at the given path")
return
def configure(conf):
conf.load('hwaf-base', tooldir=_heptooldir)
return
@conf
def find_gccxml(ctx, **kwargs):
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
# find gccxml
gccxml_bin = "gccxml"
path_list = waflib.Utils.to_list(kwargs.get('path_list', []))
if getattr(ctx.options, 'with_gccxml', None):
topdir = ctx.options.with_gccxml
topdir = ctx.hwaf_subst_vars(topdir)
gccxml_bin = osp.join(topdir, "bin", "gccxml")
path_list.append(osp.join(topdir, "bin"))
pass
kwargs['path_list']=path_list
ctx.find_program(
gccxml_bin,
var="GCCXML",
**kwargs)
gccxml_bin = ctx.env['GCCXML']
version="N/A"
cmd = [ctx.env.GCCXML, "--version"]
lines=ctx.cmd_and_log(cmd).splitlines()
for l in lines:
l = l.lower()
if "version" in l:
version=l[l.find("version")+len("version"):].strip()
break
pass
ctx.start_msg("GCCXML version")
ctx.end_msg(version)
ctx.env.GCCXML_VERSION = version
ctx.env.GCCXML_BINDIR = osp.dirname(ctx.env.GCCXML)
ctx.env.GCCXML_HOME = osp.dirname(ctx.env.GCCXML_BINDIR)
ctx.declare_runtime_env('GCCXML')
ctx.declare_runtime_env('GCCXML_BINDIR')
ctx.env.HWAF_FOUND_GCCXML = 1
return
## EOF ##