1、初始化android P源码编译环境
参见 Ubuntu 18.04编译Android8.1 automotive
源码下载:
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-p-preview-4
2、lunch选择
lunch aosp_cf_x86_auto-userdebug
3、编译出现的问题
(1)device/google/cuttlefish_common/guest/hals/gralloc/legacy/gralloc_vsoc_priv.h:163:3: error: use of undeclared identifier 'memset'
memset(out, 0, sizeof(*out));
^
1 error generated.
[ 7% 4278/60968] target C++: vdc <= system/vold/vdc.cpp
ninja: build stopped: subcommand failed.
缺少 memset 函数定义,修改文件device/google/cuttlefish_common/guest/hals/gralloc/legacy/gralloc_vsoc_priv.h,增加
#include <string.h>
(2)external/f2fs-tools/lib/libf2fs_io.c:302:5: error: incompatible pointer types passing 'int (void *, const void *, int, unsigned int, unsigned int)' to parameter of type 'int (*)(void *, const void *, size_t, unsigned int, unsigned int)' (aka 'int (*)(void *, const void *, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-pointer-types]
sparse_import_segment, NULL);
^~~~~~~~~~~~~~~~~~~~~
system/core/libsparse/include/sparse/sparse.h:227:8: note: passing argument to parameter 'write' here
int (*write)(void *priv, const void *data, size_t len, unsigned int block,
^
1 error generated.
[ 4% 2695/56695] //system/core/bootstat:bootstat clang++ bootstat.cpp
ninja: build stopped: subcommand failed.
与 sparse.h 定义的参数类型不匹配,修改文件external/f2fs-tools/lib/libf2fs_io.c,函数参数 int len 更改为 size len
#static int sparse_import_segment(void *UNUSED(priv), const void *data, int len, unsigned int block, unsigned int nr_blocks)
static int sparse_import_segment(void *UNUSED(priv), const void *data, size_t len, unsigned int block, unsigned int nr_blocks)
(3)external/e2fsprogs/lib/ext2fs/sparse_io.c:114:9: error: incompatible pointer types passing 'int (void *, const void *, int, unsigned int, unsigned int)' to parameter of type 'int (*)(void *, const void *, size_t, unsigned int, unsigned int)' (aka 'int (*)(void *, const void *, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-pointer-types]
sparse_import_segment, sm);
^~~~~~~~~~~~~~~~~~~~~
system/core/libsparse/include/sparse/sparse.h:227:8: note: passing argument to parameter 'write' here
int (*write)(void *priv, const void *data, size_t len, unsigned int block,
^
1 error generated.
[ 8% 4857/54001] //external/e2fsprogs/lib/ext2fs:libext2fs clang unix_io.c
ninja: build stopped: subcommand failed.
与 sparse.h 定义的参数类型不匹配,修改文件external/e2fsprogs/lib/ext2fs/sparse_io.c,函数参数 int len 更改为 size len
#static int sparse_import_segment(void *priv, const void *data, int len, unsigned int block, unsigned int nr_blocks)
static int sparse_import_segment(void *priv, const void *data, size_t len, unsigned int block, unsigned int nr_blocks)
(4)FAILED: out/target/product/vsoc_x86/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows
/bin/bash -c "(rm -f out/target/product/vsoc_x86/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows ) && (ASAN_OPTIONS=detect_leaks=0 out/host/linux-x86/bin/checkpolicy -M -c 30 -o out/target/product/vsoc_x86/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows out/target/product/vsoc_x86/obj/ETC/sepolicy_neverallows_intermediates/policy.conf )"
libsepol.report_failure: neverallow on line 1371 of system/sepolicy/public/domain.te (or line 11662 of policy.conf) violated by allow vendor_init sysfs_usb_priv:dir { write create add_name remove_name rmdir };
libsepol.report_failure: neverallow on line 1371 of system/sepolicy/public/domain.te (or line 11662 of policy.conf) violated by allow init sysfs_usb_priv:dir { write create add_name remove_name rmdir };
libsepol.check_assertions: 2 neverallow failures occurred
Error while expanding policy
out/host/linux-x86/bin/checkpolicy: loading policy configuration from out/target/product/vsoc_x86/obj/ETC/sepolicy_neverallows_intermediates/policy.conf
[ 12% 6193/49145] //external/skia:libskia clang++ src/codec/SkRawCodec.cpp
ninja: build stopped: subcommand failed.
SEAndroid 安全策略冲突,更改system/sepolicy/public/domain.te,更改代码 sysfs_type 为 -sysfs_type 如下:
neverallow domain {
proc_type
-sysfs_type
}:dir { add_name create link remove_name rename reparent rmdir write };