android_packages_modules_Co.../Android.bp
Hungming Chen 98e86faad9 [RFCLAT#14] replace "libcutils" with "libcutils_headers"
replacing "libcutils" with "libcutils_headers" can save the apex size
~356KiB (libbase.so + libcutils.so). clatd only needs the definition
AID_CLAT in the libcutils exported headers. It would be more
appropriate for using libcutils_headers.

before:
$ deapexer extract out/target/product/raven/system/apex/com.google.android.tethering.apex apex_with_clat_uses_libcutils
$ ls -all out/target/product/raven/system/apex/com.google.android.tethering.apex
-rw-r--r-- 1 nuccachen primarygroup 4083712 Jan  3 21:51 out/target/product/raven/system/apex/com.google.android.tethering.apex

after:
$ deapexer extract out/target/product/raven/system/apex/com.google.android.tethering.apex apex_with_clat_uses_libcutils_headers
$ ls -all out/target/product/raven/system/apex/com.google.android.tethering.apex
-rw-r--r-- 1 nuccachen primarygroup 3719168 Jan  5 18:40 out/target/product/raven/system/apex/com.google.android.tethering.apex

Both libbase.so and libcutils.so are removed from the apex
which is using clatd with libcutils_headers:
$ diff -r apex_with_clat_uses_libcutils apex_with_clat_uses_libcutils_headers
Only in apex_with_clat_uses_libcutils/lib64: libbase.so (263.4 kB)
Only in apex_with_clat_uses_libcutils/lib64: libcutils.so (91.0 kB)

Bug: 212345928
Test: atest clatd_test
Change-Id: Ia286c1d50be758685e92a6e86faa57b675e9cc54
2022-01-05 13:32:49 +00:00

119 lines
2.6 KiB
Text

package {
default_applicable_licenses: ["external_android-clat_license"],
}
// Added automatically by a large-scale-change
//
// large-scale-change included anything that looked like it might be a license
// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
//
// Please consider removing redundant or irrelevant files from 'license_text:'.
// See: http://go/android-license-faq
license {
name: "external_android-clat_license",
visibility: [":__subpackages__"],
license_kinds: [
"SPDX-license-identifier-Apache-2.0",
],
license_text: [
"LICENSE",
"NOTICE",
],
}
cc_defaults {
name: "clatd_defaults",
cflags: [
"-Wall",
"-Werror",
"-Wunused-parameter",
// Bug: http://b/33566695
"-Wno-address-of-packed-member",
],
}
// Code used both by the daemon and by unit tests.
filegroup {
name: "clatd_common",
srcs: [
"clatd.c",
"dump.c",
"getaddr.c",
"icmp.c",
"ipv4.c",
"ipv6.c",
"logging.c",
"translate.c",
],
}
// The clat daemon.
cc_binary {
name: "clatd",
defaults: ["clatd_defaults"],
// TODO: remove once drop_root_and_caps() is removed.
header_libs: [
"libcutils_headers", // for AID_CLAT
],
srcs: [
":clatd_common",
"main.c"
],
static_libs: [
"libip_checksum",
],
shared_libs: [
"liblog",
],
// Only enable clang-tidy for the daemon, not the tests, because enabling it for the
// tests substantially increases build/compile cycle times and doesn't really provide a
// security benefit.
tidy: true,
tidy_checks: [
"-*",
"cert-*",
"clang-analyzer-security*",
"android-*",
],
tidy_flags: [
"-warnings-as-errors=clang-analyzer-security*,cert-*,android-*",
],
// Actually not required for clatd itself. See comments in the rc file.
init_rc: [
"vendor-464xlat.rc",
],
sanitize: {
memtag_heap: true,
},
apex_available: [
"com.android.tethering",
"//apex_available:platform",
],
min_sdk_version: "30",
}
// Unit tests.
cc_test {
name: "clatd_test",
defaults: ["clatd_defaults"],
srcs: [
":clatd_common",
"clatd_test.cpp"
],
static_libs: [
"libbase",
"libip_checksum",
"libnetd_test_tun_interface",
],
shared_libs: [
"libcutils",
"liblog",
"libnetutils",
],
test_suites: ["device-tests"],
require_root: true,
}