forked from ApolloAuto/apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qt.bzl
53 lines (47 loc) · 1.68 KB
/
qt.bzl
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
def _file_name(filePathName):
if '/' in filePathName:
return filePathName.rsplit('/', -1)[1]
else:
return filePathName
def _base_name(fileName):
return fileName.split('.')[0]
def qt_cc_library(name, src, hdr, uis = [], res = [], normal_hdrs = [], deps = None, **kwargs):
srcs = src
for hItem in hdr:
base_name = _base_name(_file_name(hItem))
native.genrule(
name = "%s_moc" % base_name,
srcs = [hItem],
outs = [ "moc_%s.cpp" % base_name ],
cmd = "if [[ `grep 'Q_OBJECT' $(location %s)` ]] ; \
then /usr/local/Qt5.5.1/5.5/gcc_64/bin/moc $(location %s) -o $@ -f'%s'; \
else echo '' > $@ ; fi" % (hItem, hItem, '%s/%s' % (PACKAGE_NAME, hItem))
)
srcs.append("moc_%s.cpp" % base_name)
for uitem in uis:
base_name = _base_name(_file_name(uitem))
native.genrule(
name = "%s_ui" % base_name,
srcs = [uitem],
outs = ["ui_%s.h" % base_name],
cmd = "/usr/local/Qt5.5.1/5.5/gcc_64/bin/uic $(locations %s) -o $@" % uitem,
)
hdr.append("ui_%s.h" % base_name)
for ritem in res:
base_name = _base_name(_file_name(ritem))
native.genrule(
name = "%s_res" % base_name,
srcs = [ritem] + deps,
outs = ["res_%s.cpp" % base_name],
cmd = "/usr/local/Qt5.5.1/5.5/gcc_64/bin/rcc --name res --output $(OUTS) $(location %s)" % ritem,
)
srcs.append("res_%s.cpp" % base_name)
hdrs = hdr + normal_hdrs
native.cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,
deps = deps,
alwayslink = 1,
**kwargs
)