1

我正在使用 Mac OS Catalina 版本 10.15.7。我正在尝试为 OnePlus 7T 编译 AOSIP 分支 10 的映像,但我无法使用命令make api-stubs-docs-update-current-api完成构建

我有一些报告丢失的模块,按照@TheHardGamer 的建议,我去了 AOSIP 的 Git 页面并为以下模块下载了分支 10。

libsquashfs_util -> placed into systems/extras/squashfs_utils
fec & verity -> placed into systems/extras/verity
libtestUtil -> placed into test/vts-testcase/kernel/testUtil
simpleperf-inferno -> The systems/extras/simpleperf/scripts was not present so i copied the entire scripts folder from Git
libc++_darwin -> I did git clone https://android.googlesource.com/platform/prebuilts/clang/host/darwin-x86 -b android-10.0.0_r40 on the prebuilts/clang/host folder

然后我遇到了以下错误:

internal error: Could not find a supported mac sdk: ["10.10" "10.11" "10.12" "10.13" "10.14"]
internal error: Could not find a supported mac sdk: ["10.10" "10.11" "10.12" "10.13" "10.14"]

所以我听从了Could not find a supported mac sdk: ["10.10" "10.11" "10.12" "10.13"]的建议

编辑了以下文件/Volumes/android/build/soong/cc/config/x86_darwin_host.go

在文件的以下代码段中添加了“11.1”

darwinSupportedSdkVersions = []string{
    "10.10",
    "10.11",
    "10.12",
    "10.13",
    "10.14",
    "11.1",
}

然后出现以下错误

error: system/extras/simpleperf/Android.bp:72:1: module "libsimpleperf_elf_read" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/read_apk.cpp" does not exist
error: system/extras/simpleperf/Android.bp:72:1: module "libsimpleperf_elf_read" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/read_elf.cpp" does not exist
error: system/extras/simpleperf/Android.bp:72:1: module "libsimpleperf_elf_read" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/utils.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/dso.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/event_attr.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/event_type.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/perf_regs.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/read_apk.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/read_elf.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/record.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/record_file_reader.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/report_sample.proto" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/thread_tree.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/tracing.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/utils.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/nonlinux_support/nonlinux_support.cpp" does not exist
error: system/extras/simpleperf/Android.bp:310:1: module "libsimpleperf" variant "darwin_x86_64_static": module source path "system/extras/simpleperf/nonlinux_support/include" does not exist

然后我将整个 simpleperf 文件夹从分支 10 复制到我的 simpleperf 文件夹中。

然后我遇到了以下错误

art/build/Android.common.mk:51: warning: unsupported HOST_ARCH=x86_64
[ 24% 116/481] including device_oneplus_hotdogb/overlay/packages/apps/overlays/NoCutoutOverlay/Android.mk ...
FAILED: 
build/make/core/base_rules.mk:324: error: device_oneplus_hotdogb/overlay/packages/apps/overlays/NoCutoutOverlay: MODULE.TARGET.APPS.NoCutoutOverlay already defined by device/oneplus/hotdogb/overlay/packages/apps/overlays/NoCutoutOverlay.
10:15:54 ckati failed with: exit status 1

我删除了device_oneplus_hotdogb文件夹。

之后我遇到了这个错误。

FAILED: out/soong/.intermediates/system/core/base/libbase/darwin_x86_64_static/obj/system/core/base/cmsg.o
 prebuilts/clang/host/darwin-x86/clang-r353983c1/bin/clang++ -c -Isystem/core/base  -fPIC -funwind-tables -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.8 -DMACOSX_DEPLOYMENT_TARGET=10.8 -m64 -integrated-as -fstack-protector-strong -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -no-canonical-prefixes -DNDEBUG -UDEBUG -fno-exceptions -Wno-multichar -O2 -g -fno-strict-aliasing -D__compiler_offsetof=__builtin_offsetof -faddrsig -Wimplicit-fallthrough -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-zero-as-null-pointer-constant -Wno-sign-compare -Wno-defaulted-function-deleted -Wno-inconsistent-missing-override   -Isystem/core/base/include -Iexternal/libcxx/include -Iexternal/libcxxabi/include -Isystem/core/liblog/include -Isystem/core/include -Isystem/media/audio/include -Ihardware/libhardware/include -Ihardware/libhardware_legacy/include -Ihardware/ril/include -Iframeworks/native/include -Iframeworks/native/opengl/include -Iframeworks/av/include  -Ilibnativehelper/include_jni -Wall -Werror -Wextra -D_FILE_OFFSET_BITS=64 -target x86_64-apple-darwin -B/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -DANDROID_STRICT -fPIC -D_USING_LIBCXX -std=gnu++17 -Wsign-promo -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wno-thread-safety-negative -Wno-gnu-include-next  -Wexit-time-destructors  -D_LIBCPP_DISABLE_AVAILABILITY -nostdinc++ -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type -Wno-tautological-constant-compare -Wno-tautological-type-limit-compare -Wno-tautological-unsigned-enum-zero-compare -Wno-tautological-unsigned-zero-compare -Wno-c++98-compat-extra-semi -Wno-return-std-move-in-c++11 -MD -MF out/soong/.intermediates/system/core/base/libbase/darwin_x86_64_static/obj/system/core/base/cmsg.o.d -o out/soong/.intermediates/system/core/base/libbase/darwin_x86_64_static/obj/system/core/base/cmsg.o system/core/base/cmsg.cpp
system/core/base/cmsg.cpp:36:21: error: use of undeclared identifier 'PAGE_SIZE'
  if (cmsg_space >= PAGE_SIZE) {
                    ^
system/core/base/cmsg.cpp:78:21: error: use of undeclared identifier 'PAGE_SIZE'
  if (cmsg_space >= PAGE_SIZE) {
                    ^

我应该尝试定义 page_size 吗?如果是,我如何决定尺寸?还是我在某处缺少头文件?

谢谢你。

4

3 回答 3

2

我正在尝试在 M1 Mac 上编译 AOSP,我之前遇到过这个问题。我解决它的方法是添加

#ifndef PAGE_SIZE
#define PAGE_SIZE (size_t)(sysconf(_SC_PAGESIZE))
#endif

在 /system/core/base/cmsg.cpp

更新:以防万一其他人试图在 M1 Macs 上编译 Android,这是完全有可能的,而且实现起来并不难。您将遇到的下一个问题与此类似:

external/python/cpython2/Modules/getpath.c:414:50: error: incompatible pointer types passing 'unsigned long *' to parameter of type 'uint32_t *' (aka 'unsigned int *') [-Werror,-Wincompatible-pointer-types]
     else if(0 == _NSGetExecutablePath(progpath, &nsexeclength) && progpath[0] == SEP)
                                                 ^~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach-o/dyld.h:98:54: note: passing argument to parameter 'bufsize' here
extern int _NSGetExecutablePath(char* buf, uint32_t* bufsize)                 __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_2_0);
                                                     ^
1 error generated.
16:29:38 ninja failed with: exit status 1

您可以通过查找在 external/python/cpython2/Modules/getpath.c 中解决此问题

#ifdef __APPLE__
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    uint32_t nsexeclength = MAXPATHLEN;
#else
    unsigned long nsexeclength = MAXPATHLEN;
#endif
#endif

并将其更改为

#ifdef __APPLE__
    uint32_t nsexeclength = MAXPATHLEN;
#endif

接下来你可能会遇到一个关于 sed 的问题。解决方案是从 homebrew 安装 gsed,详见此处如何修复 macOS Sierra Android 版本中的“sed:非法选项 -- r”?.

这些不是可以贡献给 AOSP 的适当解决方案,但它们适用于本地编译。我已经设法使用这些更改编译了 2 个 AOSP 变体。希望这可以帮助 :)

于 2021-01-15T20:12:22.273 回答
0

更新这个答案

代替external/python/cpython2/Modules/getpath.c

#ifdef __APPLE__
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
    uint32_t nsexeclength = MAXPATHLEN;
#else
    unsigned long nsexeclength = MAXPATHLEN;
#endif
#endif

#ifdef __APPLE__
    uint32_t nsexeclength = MAXPATHLEN;
#endif

做同样的事情external/python/cpython3/Modules/getpath.c

#ifdef __APPLE__
    char execpath[MAXPATHLEN + 1];
    uint32_t nsexeclength = Py_ARRAY_LENGTH(execpath) - 1;
#endif
于 2021-05-15T02:56:31.623 回答
0

支持的 Mac sdk 版本列表是有原因的。是的,您可以将自己的问题添加到列表中并希望获得最好的结果,但您可能会像以前那样遇到问题。

由于谷歌在 Linux 上开发 Android,最好的办法是在虚拟机上安装一些 Linux 发行版并在那里编译。不要误会我的意思,我并不是说在 Mac 上构建是不可能的。这只是自找麻烦(如果您是专家,那很好)。

于 2021-01-17T18:19:57.910 回答