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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
| cc_defaults {
| name: "libext_defaults",
| defaults: ["iptables_defaults"],
|
| header_libs: ["iptables_config_header"],
|
| cflags: [
| "-DNO_SHARED_LIBS=1",
| "-DXTABLES_INTERNAL",
|
| "-Wno-format",
| "-Wno-missing-field-initializers",
| // libxt_recent.c:202:11: error: address of array 'info->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
| "-Wno-pointer-bool-conversion",
| "-Wno-tautological-pointer-compare",
| ],
| }
|
| // All of the extension source files have the same function name (_init). Since we don't support
| // per-file cflags that upstream uses, instead:
| //
| // 1. Rewrite the source files with filter_init to have per-file function names. (libext*_srcs)
| // 2. Create a new source file that defines a function (init_extensions*) with gen_init that calls
| // all of the renamed _init functions (libext*_init)
| //
| // This all happens three times -- once each for libext, libext4, libext6
|
| genrule {
| name: "libext_init",
| cmd: "$(location gen_init) '' $(locations libxt_*.c) > $(out)",
| srcs: [
| "gen_init",
| "libxt_*.c",
| ],
| out: ["initext.c"],
| exclude_srcs: [
| // Exclude some modules that are problematic to compile (types/headers)
| "libxt_TCPOPTSTRIP.c",
| "libxt_connlabel.c",
| "libxt_cgroup.c",
|
| "libxt_dccp.c",
| "libxt_ipvs.c",
| ],
| }
|
| gensrcs {
| name: "libext_srcs",
| tool_files: ["filter_init"],
| cmd: "$(location filter_init) $(in) > $(out)",
| output_extension: "c",
| srcs: ["libxt_*.c"],
| exclude_srcs: [
| // Exclude some modules that are problematic to compile (types/headers)
| "libxt_TCPOPTSTRIP.c",
| "libxt_connlabel.c",
| "libxt_cgroup.c",
|
| "libxt_dccp.c",
| "libxt_ipvs.c",
| ],
| }
|
| cc_library_static {
| name: "libext",
| defaults: ["libext_defaults"],
| srcs: [
| ":libext_init",
| ":libext_srcs",
| ],
| }
|
| ////////////////////////////////////////////////////////////////////////////////////////////////////
|
| genrule {
| name: "libext4_init",
| cmd: "$(location gen_init) '4' $(locations libipt_*.c) > $(out)",
| srcs: [
| "gen_init",
| "libipt_*.c",
| ],
| out: ["initext.c"],
| }
|
| gensrcs {
| name: "libext4_srcs",
| tool_files: ["filter_init"],
| cmd: "$(location filter_init) $(in) > $(out)",
| output_extension: "c",
| srcs: ["libipt_*.c"],
| }
|
| cc_library_static {
| name: "libext4",
| defaults: ["libext_defaults"],
| srcs: [
| ":libext4_init",
| ":libext4_srcs",
| ],
| }
|
| ////////////////////////////////////////////////////////////////////////////////////////////////////
|
| genrule {
| name: "libext6_init",
| cmd: "$(location gen_init) '6' $(locations libip6t_*.c) > $(out)",
| srcs: [
| "gen_init",
| "libip6t_*.c",
| ],
| out: ["initext.c"],
| }
|
| gensrcs {
| name: "libext6_srcs",
| tool_files: ["filter_init"],
| cmd: "$(location filter_init) $(in) > $(out)",
| output_extension: "c",
| srcs: ["libip6t_*.c"],
| }
|
| cc_library_static {
| name: "libext6",
| defaults: ["libext_defaults"],
| srcs: [
| ":libext6_init",
| ":libext6_srcs",
| ],
| }
|
|