Reland refactoring of sources in Android.bp

Move sources files to the default libselinux rule so that other binaries
may reuse the same defaults (i.e., unittests). The majority of sources
can be compiled for the host.

Bug: 234313751
Test: local build for aosp_bramble-userdebug
Test: TH
Change-Id: I0b76bf79ceabd6096ab4ef03f0c8648d0636a310
This commit is contained in:
Thiébaud Weksteen 2022-04-19 15:10:52 +10:00
parent 4e23d89b61
commit 5cfe912553
3 changed files with 78 additions and 116 deletions

View file

@ -45,6 +45,9 @@ common_CFLAGS = [
"-Wno-error=missing-noreturn", "-Wno-error=missing-noreturn",
"-Wno-error=unused-function", "-Wno-error=unused-function",
"-Wno-error=unused-variable", "-Wno-error=unused-variable",
"-DUSE_PCRE2",
// 1003 corresponds to auditd, from system/core/logd/event.logtags
"-DAUDITD_LOG_TAG=1003",
] ]
cc_defaults { cc_defaults {
@ -53,15 +56,49 @@ cc_defaults {
cflags: common_CFLAGS, cflags: common_CFLAGS,
srcs: [ srcs: [
"src/android/android.c",
"src/avc.c",
"src/avc_internal.c",
"src/avc_sidtab.c",
"src/booleans.c", "src/booleans.c",
"src/callbacks.c", "src/callbacks.c",
"src/canonicalize_context.c",
"src/checkAccess.c",
"src/check_context.c",
"src/compute_av.c",
"src/compute_create.c",
"src/compute_member.c",
"src/context.c",
"src/deny_unknown.c",
"src/disable.c",
"src/enabled.c",
"src/fgetfilecon.c",
"src/freecon.c", "src/freecon.c",
"src/label_backends_android.c", "src/fsetfilecon.c",
"src/get_initial_context.c",
"src/getenforce.c",
"src/getfilecon.c",
"src/getpeercon.c",
"src/init.c",
"src/label.c", "src/label.c",
"src/label_backends_android.c",
"src/label_file.c",
"src/label_support.c", "src/label_support.c",
"src/lgetfilecon.c",
"src/load_policy.c",
"src/lsetfilecon.c",
"src/mapping.c",
"src/matchpathcon.c", "src/matchpathcon.c",
"src/policyvers.c",
"src/procattr.c",
"src/regex.c",
"src/reject_unknown.c",
"src/sestatus.c",
"src/setenforce.c",
"src/setfilecon.c",
"src/setrans_client.c", "src/setrans_client.c",
"src/sha1.c", "src/sha1.c",
"src/stringrep.c",
], ],
target: { target: {
@ -70,60 +107,46 @@ cc_defaults {
"-DBUILD_HOST", "-DBUILD_HOST",
], ],
}, },
android: { android: {
srcs: [ srcs: [
"src/android/android.c", "src/android/android_platform.c",
"src/avc.c",
"src/avc_internal.c",
"src/avc_sidtab.c",
"src/canonicalize_context.c",
"src/checkAccess.c",
"src/check_context.c",
"src/compute_av.c",
"src/compute_create.c",
"src/compute_member.c",
"src/context.c",
"src/deny_unknown.c",
"src/disable.c",
"src/enabled.c",
"src/fgetfilecon.c",
"src/fsetfilecon.c",
"src/getenforce.c",
"src/getfilecon.c",
"src/get_initial_context.c",
"src/getpeercon.c",
"src/init.c",
"src/lgetfilecon.c",
"src/load_policy.c",
"src/lsetfilecon.c",
"src/mapping.c",
"src/policyvers.c",
"src/procattr.c",
"src/reject_unknown.c",
"src/sestatus.c",
"src/setenforce.c",
"src/setfilecon.c",
"src/stringrep.c",
], ],
static: {
whole_static_libs: [
"libpackagelistparser",
],
},
shared_libs: [ shared: {
"liblog", shared_libs: [
], "libpackagelistparser",
],
},
system_shared_libs: ["libc"], system_shared_libs: ["libc"],
},
header_libs: ["libcutils_headers"],
local_include_dirs: [ "src" ],
// 1003 corresponds to auditd, from system/core/logd/event.logtags
cflags: [
"-DAUDITD_LOG_TAG=1003",
],
}
}, },
local_include_dirs: ["include"], static: {
whole_static_libs: [
"libpcre2",
"liblog",
],
},
shared: {
shared_libs: [
"libpcre2",
"liblog",
],
},
header_libs: [
"libbase_headers",
"libcutils_headers",
"liblog_headers",
],
local_include_dirs: [
"include",
"src",
],
export_include_dirs: ["include"], export_include_dirs: ["include"],
stl: "none", stl: "none",
@ -140,76 +163,18 @@ cc_library {
ramdisk_available: true, ramdisk_available: true,
vendor_ramdisk_available: true, vendor_ramdisk_available: true,
recovery_available: true, recovery_available: true,
host_supported: true, host_supported: true,
cflags: ["-DUSE_PCRE2"],
srcs: [
"src/label_file.c",
"src/regex.c",
],
target: { target: {
host_linux: {
srcs: [
"src/avc.c",
"src/avc_internal.c",
"src/avc_sidtab.c",
"src/compute_av.c",
"src/compute_create.c",
"src/compute_member.c",
"src/context.c",
"src/deny_unknown.c",
"src/enabled.c",
"src/getenforce.c",
"src/getfilecon.c",
"src/get_initial_context.c",
"src/init.c",
"src/load_policy.c",
"src/mapping.c",
"src/procattr.c",
"src/reject_unknown.c",
"src/sestatus.c",
"src/setexecfilecon.c",
"src/stringrep.c",
],
},
linux_glibc: {
srcs: [
"src/fgetfilecon.c",
"src/lgetfilecon.c",
"src/lsetfilecon.c",
"src/setfilecon.c",
],
},
linux_bionic: { linux_bionic: {
enabled: true, enabled: true,
}, },
android: { android: {
srcs: [
"src/android/android_platform.c",
],
static: {
whole_static_libs: ["libpackagelistparser"],
},
shared: {
shared_libs: ["libpackagelistparser"],
},
version_script: "exported.map.txt", version_script: "exported.map.txt",
}, },
}, },
static: {
whole_static_libs: ["libpcre2"],
},
shared: {
shared_libs: ["libpcre2"],
},
stubs: { stubs: {
symbol_file: "exported.map.txt", symbol_file: "exported.map.txt",
versions: ["30"], versions: ["30"],
@ -219,14 +184,14 @@ cc_library {
cc_binary_host { cc_binary_host {
name: "sefcontext_compile", name: "sefcontext_compile",
defaults: ["libselinux_defaults"], defaults: ["libselinux_defaults"],
cflags: ["-DUSE_PCRE2"],
srcs: ["utils/sefcontext_compile.c"], srcs: ["utils/sefcontext_compile.c"],
static_libs: [ static_libs: [
"libselinux", "libselinux",
"libsepol", "libsepol",
], ],
whole_static_libs: ["libpcre2"],
stl: "",
} }
rust_bindgen { rust_bindgen {

View file

@ -13,14 +13,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/xattr.h> #include <sys/xattr.h>
#include <fcntl.h> #include <fcntl.h>
#include <fts.h>
#include <selinux/selinux.h> #include <selinux/selinux.h>
#include <selinux/context.h> #include <selinux/context.h>
#include <selinux/android.h> #include <selinux/android.h>
#include <selinux/label.h> #include <selinux/label.h>
#ifndef __ANDROID_VNDK__
#include <private/android_filesystem_config.h>
#endif
#include <log/log.h> #include <log/log.h>
#include "policy.h" #include "policy.h"
#include "callbacks.h" #include "callbacks.h"
@ -32,9 +28,6 @@
#include <linux/magic.h> #include <linux/magic.h>
#include <libgen.h> #include <libgen.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define FC_DIGEST_SIZE SHA_DIGEST_LENGTH #define FC_DIGEST_SIZE SHA_DIGEST_LENGTH

View file

@ -1,6 +1,10 @@
#include "android_common.h"
#include "android_internal.h" #include "android_internal.h"
#include <fts.h>
#include <packagelistparser/packagelistparser.h> #include <packagelistparser/packagelistparser.h>
#include <private/android_filesystem_config.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
/* Locations for the file_contexts files. For each partition, only the first /* Locations for the file_contexts files. For each partition, only the first
* existing entry will be used (for example, if * existing entry will be used (for example, if