xref: /aosp_15_r20/external/iptables/extensions/Android.bp (revision a71a954618bbadd4a345637e5edcf36eec826889)
1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "external_iptables_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-GPL
7    //   SPDX-license-identifier-GPL-2.0
8    default_applicable_licenses: ["external_iptables_license"],
9}
10
11cc_defaults {
12    name: "libext_defaults",
13    defaults: ["iptables_defaults"],
14
15    header_libs: ["iptables_config_header"],
16
17    cflags: [
18        "-DNO_SHARED_LIBS=1",
19        "-DXTABLES_INTERNAL",
20
21        "-Wno-format",
22        "-Wno-missing-field-initializers",
23        "-Wno-tautological-pointer-compare",
24    ],
25}
26
27// All of the extension source files have the same function name (_init). Since we don't support
28// per-file cflags that upstream uses, instead:
29//
30//  1. Rewrite the source files with filter_init to have per-file function names. (libext*_srcs)
31//  2. Create a new source file that defines a function (init_extensions*) with gen_init that calls
32//     all of the renamed _init functions (libext*_init)
33//
34// This all happens three times -- once each for libext, libext4, libext6
35
36genrule {
37    name: "libext_init",
38    cmd: "$(location gen_init) '' $(locations libxt_*.c) > $(out)",
39    srcs: [
40        "gen_init",
41        "libxt_*.c",
42    ],
43    out: ["initext.c"],
44    exclude_srcs: [
45        // Exclude some modules that are problematic to compile (types/headers)
46        "libxt_TCPOPTSTRIP.c",
47        "libxt_connlabel.c",
48        "libxt_cgroup.c",
49
50        "libxt_dccp.c",
51        "libxt_ipvs.c",
52    ],
53}
54
55gensrcs {
56    name: "libext_srcs",
57    tool_files: ["filter_init"],
58    cmd: "$(location filter_init) $(in) > $(out)",
59    output_extension: "c",
60    srcs: ["libxt_*.c"],
61    exclude_srcs: [
62        // Exclude some modules that are problematic to compile (types/headers)
63        "libxt_TCPOPTSTRIP.c",
64        "libxt_connlabel.c",
65        "libxt_cgroup.c",
66
67        "libxt_dccp.c",
68        "libxt_ipvs.c",
69    ],
70}
71
72cc_library_static {
73    name: "libext",
74    defaults: ["libext_defaults"],
75    srcs: [
76        ":libext_init",
77        ":libext_srcs",
78    ],
79}
80
81////////////////////////////////////////////////////////////////////////////////////////////////////
82
83genrule {
84    name: "libext4_init",
85    cmd: "$(location gen_init) '4' $(locations libipt_*.c) > $(out)",
86    srcs: [
87        "gen_init",
88        "libipt_*.c",
89    ],
90    out: ["initext.c"],
91}
92
93gensrcs {
94    name: "libext4_srcs",
95    tool_files: ["filter_init"],
96    cmd: "$(location filter_init) $(in) > $(out)",
97    output_extension: "c",
98    srcs: ["libipt_*.c"],
99}
100
101cc_library_static {
102    name: "libext4",
103    defaults: ["libext_defaults"],
104    srcs: [
105        ":libext4_init",
106        ":libext4_srcs",
107    ],
108}
109
110////////////////////////////////////////////////////////////////////////////////////////////////////
111
112genrule {
113    name: "libext6_init",
114    cmd: "$(location gen_init) '6' $(locations libip6t_*.c) > $(out)",
115    srcs: [
116        "gen_init",
117        "libip6t_*.c",
118    ],
119    out: ["initext.c"],
120}
121
122gensrcs {
123    name: "libext6_srcs",
124    tool_files: ["filter_init"],
125    cmd: "$(location filter_init) $(in) > $(out)",
126    output_extension: "c",
127    srcs: ["libip6t_*.c"],
128}
129
130cc_library_static {
131    name: "libext6",
132    defaults: ["libext_defaults"],
133    srcs: [
134        ":libext6_init",
135        ":libext6_srcs",
136    ],
137}
138