From f5addf22327ac38b09e022a6f2a81443de9eec47 Mon Sep 17 00:00:00 2001 From: Sandeep Patil Date: Wed, 3 May 2017 07:04:18 -0700 Subject: [PATCH] refactor: move common parts of libselinux builds into defaults Bug: 37343404 Bug: 37919668 Test: Build and boot (cherry-picked from commit 51428ba055e581461e440331d3ccdb1bc4ac41c8) Change-Id: If42d24d381839c2a39f8cff3fc82ce5d3073eeb7 Merged-In: I375a4a2926326a5f733f4a49348e1ffae086ffd6 --- libselinux/Android.bp | 132 +++++------------- .../{android_seapp.c => android_platform.c} | 0 2 files changed, 35 insertions(+), 97 deletions(-) rename libselinux/src/android/{android_seapp.c => android_platform.c} (100%) diff --git a/libselinux/Android.bp b/libselinux/Android.bp index 9d324876..edd4eba9 100644 --- a/libselinux/Android.bp +++ b/libselinux/Android.bp @@ -1,4 +1,3 @@ -common_LIBRARIES = ["libpcre2"] common_CFLAGS = [ "-DUSE_PCRE2", @@ -15,24 +14,10 @@ common_CFLAGS = [ ] cc_defaults { - name: "libselinux_flags", + name: "libselinux_defaults", cflags: common_CFLAGS, - target: { - host: { - cflags: [ - "-DBUILD_HOST", - ], - }, - }, -} - -cc_library { - name: "libselinux_vendor", - defaults: ["libselinux_flags"], - vendor: true, - srcs: [ "src/booleans.c", "src/callbacks.c", @@ -48,6 +33,12 @@ cc_library { ], target: { + host: { + cflags: [ + "-DBUILD_HOST", + ], + }, + android: { srcs: [ "src/android/android.c", @@ -90,45 +81,44 @@ cc_library { local_include_dirs: [ "src" ], - version_script: "exported_vendor.map", - // 1003 corresponds to auditd, from system/core/logd/event.logtags cflags: [ "-DAUDITD_LOG_TAG=1003", ], - }, - }, - static: { - whole_static_libs: common_LIBRARIES, - }, - shared: { - shared_libs: common_LIBRARIES, + // mapping.c has redundant check of array p_in->perms. + clang_cflags: ["-Wno-pointer-bool-conversion"], + } }, local_include_dirs: ["include"], export_include_dirs: ["include"], + + static: { + whole_static_libs: ["libpcre2"], + }, + shared: { + shared_libs: ["libpcre2"], + }, +} + +cc_library { + name: "libselinux_vendor", + defaults: ["libselinux_defaults"], + vendor: true, + + target: { + android: { + version_script: "exported_vendor.map", + }, + }, } cc_library { name: "libselinux", - defaults: ["libselinux_flags"], + defaults: ["libselinux_defaults"], host_supported: true, - srcs: [ - "src/booleans.c", - "src/callbacks.c", - "src/freecon.c", - "src/label_backends_android.c", - "src/label.c", - "src/label_file.c", - "src/label_support.c", - "src/matchpathcon.c", - "src/regex.c", - "src/setrans_client.c", - "src/sha1.c", - ], - target: { linux: { srcs: [ @@ -174,82 +164,30 @@ cc_library { "src/setexecfilecon.c", "src/stringrep.c", ], - }, + android: { srcs: [ - "src/android/android.c", - "src/android/android_seapp.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/sestatus.c", - "src/setenforce.c", - "src/setfilecon.c", - "src/stringrep.c", + "src/android/android_platform.c", ], - shared_libs: [ - "libcrypto", - "liblog", - ], static: { whole_static_libs: ["libpackagelistparser"], }, + shared: { shared_libs: ["libpackagelistparser"], }, - local_include_dirs: ["src"], - version_script: "exported.map", - - // 1003 corresponds to auditd, from system/core/logd/event.logtags - cflags: [ - "-DAUDITD_LOG_TAG=1003", - ], - // mapping.c has redundant check of array p_in->perms. - clang_cflags: ["-Wno-pointer-bool-conversion"], }, }, - - static: { - whole_static_libs: common_LIBRARIES, - }, - shared: { - shared_libs: common_LIBRARIES, - }, - - local_include_dirs: ["include"], - export_include_dirs: ["include"], } cc_binary_host { name: "sefcontext_compile", - defaults: ["libselinux_flags"], + defaults: ["libselinux_defaults"], + cflags: ["-DUSE_PCRE2"], srcs: ["utils/sefcontext_compile.c"], static_libs: [ diff --git a/libselinux/src/android/android_seapp.c b/libselinux/src/android/android_platform.c similarity index 100% rename from libselinux/src/android/android_seapp.c rename to libselinux/src/android/android_platform.c