为 moto g(40) fusion 编译 twrp 时出现构建错误

Build error while compiling twrp for moto g(40) fusion

我正在使用内核源代码为代号为 hanoip 的 moto g40 fusion 编译 twrp,但出现此错误 /bin/bash: -c: 第 0 行:寻找匹配项时出现意外的 EOF`"'

/bin/bash: -c: 第 1 行:语法错误:文件意外结束

我在

时遇到了这个错误

BOARD_USES_RECOVERY_AS_BOOT := true

但将值更改为 false 后一切正常。

这里的问题是 BOARD_USES_RECOVERY_AS_BOOT 必须 true twrp 才能启动。

这是 BOARD_USES_RECOVERY_AS_BOOT := true

时的构建日志
20:48:30 You are building on a machine with 7.69GB of RAM
20:48:30 
20:48:30 The minimum required amount of free memory is around 16GB,
20:48:30 and even with that, some configurations may not work.
20:48:30 
20:48:30 If you run into segfaults or other errors, try reducing your
20:48:30 -j value.
20:48:30 ************************************************************
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=127
TARGET_PRODUCT=twrp_hanoip
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=cortex-a9
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.10.60.1-microsoft-standard-WSL2-x86_64-Ubuntu-20.04-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=RQ1A.210205.004
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/motorola/hanoip
============================================
ninja: no work to do.
ninja: no work to do.
No need to regenerate ninja file
No need to regenerate ninja file
No need to regenerate ninja file
Starting ninja...
[  0% 1/3773] target  C++: recovery <= bootable/recovery/twrp.cpp
FAILED: out/target/product/hanoip/obj/EXECUTABLES/recovery_intermediates/twrp.o
/bin/bash -c "PWD=/proc/self/cwd  prebuilts/clang/host/linux-x86/clang-r383902b/bin/clang++ -I system/core/fs_mgr/libfs_avb/include -I system/core/fs_mgr/include_fstab -I system/core/fs_mgr/include -I system/core/fs_mgr/libdm/include -I system/core/fs_mgr/liblp/include -I system/gsid/include -I system/core/init -I system/extras/ext4_utils/include -I bionic -I system/extras -I system/core/adb -I system/core/libmodprobe/include -I system/core/libsparse -I external/zlib -I system/core/libziparchive/include -I external/freetype/include -I external/boringssl/include -I external/libcxx/include -I external/libselinux/include -I external/libpng -I bootable/recovery/gui/include -I bootable/recovery/recovery_ui/include -I bootable/recovery/otautil/include -I bootable/recovery/install/include -I bootable/recovery/fuse_sideload/include -I bootable/recovery/install/include -I bootable/recovery/twrpinstall/include -I bootable/recovery/recovery_utils/include -I bootable/recovery/libpixelflinger/include -I bootable/recovery/minuitwrp/include -I bootable/recovery/twinstall/include -I system/extras/ext4_utils -I external/boringssl/src/include -I bootable/recovery/crypto -I bootable/recovery/crypto/fscrypt -I system/vold -I bootable/recovery -I out/target/product/hanoip/obj/EXECUTABLES/recovery_intermediates -I out/target/product/hanoip/gen/EXECUTABLES/recovery_intermediates -I libnativehelper/include_jni -Isystem/core/fs_mgr/include -Isystem/core/fs_mgr/include -Isystem/core/fs_mgr/libfiemap/include -Isystem/core/logwrapper/include -Isystem/core/fs_mgr/libdm/include -Iexternal/e2fsprogs/lib/uuid -Iexternal/e2fsprogs/lib -Isystem/extras/libfscrypt/include -Isystem/core/fs_mgr/include_fstab -Isystem/core/fs_mgr/libfs_avb/include -Isystem/core/fs_mgr/liblp/include -Ihardware/libhardware/include -Isystem/media/audio/include -Isystem/core/libcutils/include -Isystem/core/libsystem/include -Isystem/bt/types -Isystem/libhidl/base/include -Isystem/libhidl/transport/include -Isystem/libhwbinder/include -Isystem/core/base/include -Iexternal/fmtlib/include -Isystem/core/libutils/include -Isystem/core/libbacktrace/include -Isystem/core/liblog/include -Isystem/core/libsystem/include -Isystem/core/libcutils/include -Isystem/core/libprocessgroup/include -Iout/soong/.intermediates/system/libhidl/transport/manager/1.0/android.hidl.manager@1.0_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.1/android.hidl.manager@1.1_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.2/android.hidl.manager@1.2_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/base/1.0/android.hidl.base@1.0_genc++_headers/gen -Iout/soong/.intermediates/hardware/interfaces/boot/1.0/android.hardware.boot@1.0_genc++_headers/gen -Isystem/libhidl/base/include -Isystem/libhidl/transport/include -Isystem/libhwbinder/include -Isystem/core/base/include -Iexternal/fmtlib/include -Isystem/core/libutils/include -Isystem/core/libbacktrace/include -Isystem/core/liblog/include -Isystem/core/libsystem/include -Isystem/core/libcutils/include -Isystem/core/libprocessgroup/include -Iout/soong/.intermediates/system/libhidl/transport/manager/1.0/android.hidl.manager@1.0_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.1/android.hidl.manager@1.1_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.2/android.hidl.manager@1.2_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/base/1.0/android.hidl.base@1.0_genc++_headers/gen -Iout/soong/.intermediates/hardware/interfaces/boot/1.0/android.hardware.boot@1.0_genc++_headers/gen -Iout/soong/.intermediates/hardware/interfaces/boot/1.1/android.hardware.boot@1.1_genc++_headers/gen -Iexternal/protobuf/src -Iexternal/protobuf/src -Isystem/core/fs_mgr/liblp/include -Isystem/core/fs_mgr/liblp/include -Isystem/core/libutils/include -Isystem/core/libbacktrace/include -Isystem/core/liblog/include -Isystem/core/libsystem/include -Isystem/core/libcutils/include -Isystem/core/libprocessgroup/include -Isystem/libhidl/base/include -Isystem/libhidl/transport/include -Isystem/libhidl/base/include -Isystem/libhidl/transport/include -Isystem/libhwbinder/include -Isystem/core/base/include -Iexternal/fmtlib/include -Isystem/core/libutils/include -Isystem/core/libbacktrace/include -Isystem/core/liblog/include -Isystem/core/libsystem/include -Isystem/core/libcutils/include -Isystem/core/libprocessgroup/include -Iout/soong/.intermediates/system/libhidl/transport/manager/1.0/android.hidl.manager@1.0_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.1/android.hidl.manager@1.1_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.2/android.hidl.manager@1.2_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/base/1.0/android.hidl.base@1.0_genc++_headers/gen -Iexternal/zlib -Iexternal/zlib -Isystem/core/libcutils/include -Isystem/core/libprocessgroup/include       -Ibootable/recovery/bootloader_message/include -Ibootable/recovery/bootloader_message/include   -Iexternal/libcxx/include -Iexternal/libcxxabi/include  -Iexternal/boringssl/src/include -Isystem/core/base/include -Iexternal/fmtlib/include -Isystem/core/libziparchive/include -Isystem/core/libziparchive/include -Iexternal/googletest/googletest/include -Isystem/core/base/include -Iexternal/fmtlib/include -Iexternal/selinux/libselinux/include     -Isystem/core/libstats/socket/include  -Isystem/libhidl/base/include -Isystem/libhidl/transport/include -Isystem/libhwbinder/include -Isystem/core/base/include -Iexternal/fmtlib/include -Isystem/core/libutils/include -Isystem/core/libbacktrace/include -Isystem/core/liblog/include -Isystem/core/libsystem/include -Isystem/core/libcutils/include -Isystem/core/libprocessgroup/include -Iout/soong/.intermediates/system/libhidl/transport/manager/1.0/android.hidl.manager@1.0_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.1/android.hidl.manager@1.1_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.2/android.hidl.manager@1.2_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/base/1.0/android.hidl.base@1.0_genc++_headers/gen -Iout/soong/.intermediates/frameworks/hardware/interfaces/stats/1.0/android.frameworks.stats@1.0_genc++_headers/gen -Isystem/libhidl/base/include -Isystem/libhidl/transport/include -Isystem/libhwbinder/include -Isystem/core/base/include -Iexternal/fmtlib/include -Isystem/core/libutils/include -Isystem/core/libbacktrace/include -Isystem/core/liblog/include -Isystem/core/libsystem/include -Isystem/core/libcutils/include -Isystem/core/libprocessgroup/include -Iout/soong/.intermediates/system/libhidl/transport/manager/1.0/android.hidl.manager@1.0_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.1/android.hidl.manager@1.1_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.2/android.hidl.manager@1.2_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/base/1.0/android.hidl.base@1.0_genc++_headers/gen -Iout/soong/.intermediates/hardware/interfaces/authsecret/1.0/android.hardware.authsecret@1.0_genc++_headers/gen -Isystem/libhidl/base/include -Isystem/libhidl/transport/include -Isystem/libhwbinder/include -Isystem/core/base/include -Iexternal/fmtlib/include -Isystem/core/libutils/include -Isystem/core/libbacktrace/include -Isystem/core/liblog/include -Isystem/core/libsystem/include -Isystem/core/libcutils/include -Isystem/core/libprocessgroup/include -Iout/soong/.intermediates/system/libhidl/transport/manager/1.0/android.hidl.manager@1.0_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.1/android.hidl.manager@1.1_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/manager/1.2/android.hidl.manager@1.2_genc++_headers/gen -Iout/soong/.intermediates/system/libhidl/transport/base/1.0/android.hidl.base@1.0_genc++_headers/gen -Iout/soong/.intermediates/hardware/interfaces/oemlock/1.0/android.hardware.oemlock@1.0_genc++_headers/gen -Iexternal/libcxx/include -Iexternal/libcxxabi/include -D__LIBC_API__=10000 -Ibionic/libc/include -D__LIBM_API__=10000 -D__LIBM_API__=10000 -D__LIBDL_API__=10000 -Iexternal/avb -Ibootable/recovery/twrpinstall/include -Ibootable/recovery/recovery_ui/include  -Iexternal/libcap/libcap/include -Iout/soong/.intermediates/system/apex/apexd/sysprop/libcom.android.sysprop.apex/android_arm64_armv8-a_static/gen/sysprop/include -Iout/soong/.intermediates/system/core/init/sysprop/libcom.android.sysprop.init/android_arm64_armv8-a_static/gen/sysprop/include -Iexternal/protobuf/src -Iout/soong/.intermediates/system/core/init/libinit/android_arm64_armv8-a_static/gen/proto/system/core/init -Iout/soong/.intermediates/system/core/init/libinit/android_arm64_armv8-a_static/gen/proto -Isystem/core/fs_mgr/libsnapshot/include -Isystem/core/fs_mgr/libfiemap/include -Iexternal/e2fsprogs/lib/uuid -Iexternal/e2fsprogs/lib -Isystem/extras/ext4_utils/include -Isystem/core/fs_mgr/include_fstab -Iexternal/protobuf/src -Iout/soong/.intermediates/system/update_engine/update_metadata-protos/android_arm64_armv8-a_static/gen/proto -Iout/soong/.intermediates/system/core/fs_mgr/libsnapshot/libsnapshot_nobinder/android_arm64_armv8-a_static/gen/proto  -Isystem/core/libmodprobe/include -Iexternal/libcxxabi/include   -I system/core/include -I system/media/audio/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I frameworks/native/include -I frameworks/native/opengl/include -isystem out/target/product/hanoip/obj/include -isystem bionic/libc/include -isystem bionic/libc/kernel/uapi -isystem bionic/libc/kernel/uapi/asm-arm64 -isystem bionic/libc/kernel/android/scsi -isystem bionic/libc/kernel/android/uapi -c  -Werror=implicit-function-declaration -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 -Werror=date-time -Werror=pragma-pack -Werror=pragma-pack-suspicious-include -fdebug-prefix-map=/proc/self/cwd= -D__compiler_offsetof=__builtin_offsetof -faddrsig -Werror=int-conversion -fexperimental-new-pass-manager -Wno-reserved-id-macro -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-sign-compare -Wno-defaulted-function-deleted -Wno-inconsistent-missing-override -Wno-c99-designator -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang -ffunction-sections -fdata-sections -fno-short-enums -funwind-tables -fstack-protector-strong -Wa,--noexecstack -D_FORTIFY_SOURCE=2 -Wstrict-aliasing=2 -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=format-security -nostdlibinc -march=armv8-a  -Bprebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin  -Wsign-promo -Wimplicit-fallthrough -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wno-gnu-include-next -fvisibility-inlines-hidden  -std=gnu++17   -fno-rtti -Wall -Werror -DTW_DEVICE_VERSION='\"-0\"' -DPLATFORM_SDK_VERSION=30 -DRECOVERY_API_VERSION=3 -Wno-unused-parameter -Wno-unused-function -DAB_OTA_UPDATER=1 -DPRODUCT_USE_DYNAMIC_PARTITIONS=1 -DTW_GIT_REVISION='\"45a8d148\"' -DBOARD_USES_RECOVERY_AS_BOOT -DTW_HAS_MTP -DRECOVERY_SDCARD_ON_DATA -DCUSTOM_LUN_FILE=\\"/config/usb_gadget/g1/functions/mass_storage.0/lun.%d/file\\" -DTW_HAS_EDL_MODE -DTW_LOAD_VENDOR_MODULES=\"mpq-adapter.ko mpq-dmx-hw-plugin.ko qca_cld3_wlan.ko rdbg.ko exfat.ko mmi_sys_temp.ko sensors_class.ko utags.ko moto_f_usbnet.ko watchdogtest.ko mmi_info.ko mmi_annotate.ko tzlog_dump.ko watchdog_cpu_ctx.ko fpsensor_spi_tee.ko fpc1020_mmi.ko ilitek_v3_mmi.ko sx933x_sar.ko snd_smartpa_aw882xx.ko qpnp_adaptive_charge.ko \\" -DTW_INCLUDE_CRYPTO -DUSE_FSCRYPT -Wno-macro-redefined -DTW_INCLUDE_FBE -DTW_INCLUDE_FBE_METADATA_DECRYPT -DTW_BRIGHTNESS_PATH=\"/sys/class/backlight/panel0-backlight/brightness\" -DTW_MAX_BRIGHTNESS=2047 -DTW_DEFAULT_BRIGHTNESS=1000fo -DTW_EXCLUDE_ENCRYPTED_BACKUPS -DQCOM_RTC_FIX -DHAVE_CAPABILITIES -DTW_USE_NEW_MINADBD -DTW_DEFAULT_LANGUAGE=en -fPIE -DANDROID_STRICT -target aarch64-linux-android10000   -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=fortify-source -Werror=address-of-temporary -Werror=return-type -Wno-tautological-constant-compare -Wno-tautological-type-limit-compare -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-int-in-bool-context -Wno-sizeof-array-div -Wno-tautological-overlap-compare -Wno-deprecated-copy -Wno-range-loop-construct -Wno-misleading-indentation -Wno-zero-as-null-pointer-constant -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-string-compare -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-pessimizing-move  -MD -MF out/target/product/hanoip/obj/EXECUTABLES/recovery_intermediates/twrp.d -o out/target/product/hanoip/obj/EXECUTABLES/recovery_intermediates/twrp.o bootable/recovery/twrp.cpp"
/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/bin/bash: -c: line 1: syntax error: unexpected end of file
[  0% 2/3773] target  C++: recovery <= bootable/recovery/twrpTar.cpp
FAILED: out/target/product/hanoip/obj/EXECUTABLES/recovery_intermediates/twrpTar.o
/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/bin/bash: -c: line 1: syntax error: unexpected end of file
ninja: build stopped: subcommand failed.
20:48:34 ninja failed with: exit status 1

[0;31m#### failed to build some targets (4 seconds) ####[00m

无法确定,但(根据过去的经验)这听起来像是以下组合:

可能原因 #1:

  • 脚本在访问时无法将 $PWD 之类的内容正确包装在 double-quotes 中。
  • 从目录中调用的脚本,其中包含需要引用的字符(例如 space 或引号)。由于您使用的是 WSL,我经常会怀疑您的项目可能位于 Windows 驱动器上。

可能原因 #2:

  • 脚本在修改时未能将 $PATH 正确包装在 double-quotes 中。
  • 而且,由于您有此标记的 WSL,Windows 路径中的字符(如 spaces)始终需要引用。
  • 并且,WSL 的互操作功能会在启动时自动将 Windows 路径附加到 Linux 路径,以便您可以 运行 Windows 命令(假设.exe 包括)例如 powershell.exe、Visual Studio 代码,以及(当然)许多其他代码。

在第一种情况下,尝试在不同的目录中构建,最好是 ~/src.

第二种情况...

通常我会建议第一步找到并解决引用问题,但是:

  1. 这些不是您的脚本
  2. 您不需要在 永久性 基础上修复此问题,只需在构建时即可。

所以在这种情况下,我建议尝试在 Windows 路径传播关闭(暂时)的情况下进行构建。为此:

sudo -e /etc/wsl.conf

并添加以下内容:

[interop]
appendWindowsPath=false

保存,退出编辑器,退出WSL。

从 PowerShell,问题:

wsl --shutdown # or wsl --terminate <distro>

然后重启WSL。

echo $PATH 确认 Windows 路径没有被附加,然后再次尝试构建。

无论如何,我建议您在完成该功能后将 appendWindowsPath 设置回 true(默认值)。

这个错误一般在使用wsl时出现。我没有在 virual-box 或安装 ubuntu 上遇到此错误。 最好使用实际 linux 发行版而不是使用 wsl 或 virtual-box 来编译 twrp、内核或任何 aosp