-
Notifications
You must be signed in to change notification settings - Fork 6
/
BUCK
70 lines (64 loc) · 1.39 KB
/
BUCK
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
def merge_dicts(x, y):
z = x.copy()
z.update(y)
return z
headers = subdir_glob([
('include/conduit', '*.hpp'),
('include/conduit', 'allocators/default.hpp'),
])
mega_header = '\n'.join([
'#ifndef CONDUIT_HPP',
'#define CONDUIT_HPP',
'',
] + [
'#include <conduit/' + i + '> ' for i, _ in headers.items()
] + [
'',
'#endif',
'',
])
genrule(
name = 'mega-header',
out = 'conduit.hpp',
cmd = 'echo "' + mega_header + '" > $OUT',
)
cxx_library(
name = 'conduit',
header_namespace = 'conduit',
exported_headers = merge_dicts(subdir_glob([
('include/conduit', '**/*.hpp'),
]), {
'conduit.hpp': ':mega-header',
}),
licenses = [
'LICENSE',
],
visibility = [
'PUBLIC',
],
)
cxx_genrule(
name = 'conduit-unity',
srcs = glob(['include/**/*.hpp']),
out = 'conduit-unity.hpp',
cmd = '&&'.join([
'cp -r $SRCDIR/. $TMP',
'cd $TMP',
'find -name \'*.hpp\' -exec sed -i \'/#include\s*<\s*conduit/! s/#include/##include/g\' {} +',
'$(cxx) -E -P -Iinclude $(cppflags) -xc++ $(location :mega-header) > $OUT',
'sed -i \'s/##include/#include/g\' $OUT',
])
)
genrule(
name = 'bundle',
out = 'bundle.zip',
srcs = glob([
'include/conduit/**/*.hpp',
]),
cmd = ' && '.join([
'cp -r $SRCDIR/. $TMP',
'cp $(location :mega-header) $TMP/include/conduit/conduit.hpp',
'cd $TMP',
'zip -r $OUT .',
]),
)