美文网首页
使用WSL搭建AOSP环境

使用WSL搭建AOSP环境

作者: andy_shx | 来源:发表于2020-07-12 21:35 被阅读0次

    使用WSL搭建环境需要特别注意的几点

    如下几点需要在解压完“aosp-latest.tar”之后和repo sync之前操作。

    • 设置aosp源码所在路径为大小写敏感,win10系统支持新建的子目录继承父目录的大小写敏感特性,所以只需要设置aosp根目录大小写敏感,参考命令如下(在cmd窗口执行,路径替换为自己实际的aosp路径):
      fsutil.exe file SetCaseSensitiveInfo D:\07.workspace\aosp enable
    • 设置D:\07.workspace\aosp的所有用户为“完全控制”权限


      image.png

    主要参考以下博文

    Ubentu编译Android源码(AOSP)

    win10搭建阅读Android源码环境

    编译命令和过程如下

    • 切换到aosp主目录执行初始化环境命令:
    andy@andy-PC:/mnt/d/07.workspace$ cd aosp/
    andy@andy-PC:/mnt/d/07.workspace/aosp$ source build/envsetup.sh
    
    • 执行lunch并选择编译的目标版本,这里选择25,即“25. aosp_x86_64-eng”
      说明:如果你的电脑是64位的话,选择25,因为x86版本的虚拟机运行比较快。不要编译arm 版本的了,运行起来太慢,而且运行不起来。
    andy@andy-PC:/mnt/d/07.workspace/aosp$ lunch
    You're building on Linux
    
    Lunch menu... pick a combo:
         1. aosp_arm-eng
         2. aosp_arm64-eng
         3. aosp_blueline-userdebug
         4. aosp_bonito-userdebug
         5. aosp_car_arm-userdebug
         6. aosp_car_arm64-userdebug
         7. aosp_car_x86-userdebug
         8. aosp_car_x86_64-userdebug
         9. aosp_cf_arm64_auto-userdebug
         10. aosp_cf_arm64_phone-userdebug
         11. aosp_cf_x86_64_phone-userdebug
         12. aosp_cf_x86_auto-userdebug
         13. aosp_cf_x86_phone-userdebug
         14. aosp_cf_x86_tv-userdebug
         15. aosp_coral-userdebug
         16. aosp_coral_car-userdebug
         17. aosp_crosshatch-userdebug
         18. aosp_crosshatch_car-userdebug
         19. aosp_flame-userdebug
         20. aosp_sargo-userdebug
         21. aosp_taimen-userdebug
         22. aosp_walleye-userdebug
         23. aosp_walleye_test-userdebug
         24. aosp_x86-eng
         25. aosp_x86_64-eng
         26. arm_krait-eng
         27. arm_v7_v8-eng
         28. armv8-eng
         29. armv8_kryo385-eng
         30. beagle_x15-userdebug
         31. beagle_x15_auto-userdebug
         32. car_x86_64-userdebug
         33. db845c-userdebug
         34. fuchsia_arm64-eng
         35. fuchsia_x86_64-eng
         36. hikey-userdebug
         37. hikey64_only-userdebug
         38. hikey960-userdebug
         39. hikey960_tv-userdebug
         40. hikey_tv-userdebug
         41. pixel3_mainline-userdebug
         42. poplar-eng
         43. poplar-user
         44. poplar-userdebug
         45. qemu_trusty_arm64-userdebug
         46. silvermont-eng
         47. uml-userdebug
         48. yukawa-userdebug
         49. yukawa_sei510-userdebug
    
    Which would you like? [aosp_arm-eng] 25
    ============================================
    PLATFORM_VERSION_CODENAME=S
    PLATFORM_VERSION=S
    TARGET_PRODUCT=aosp_arm
    TARGET_BUILD_VARIANT=eng
    TARGET_BUILD_TYPE=release
    TARGET_ARCH=arm
    TARGET_ARCH_VARIANT=armv7-a-neon
    TARGET_CPU_VARIANT=generic
    HOST_ARCH=x86_64
    HOST_2ND_ARCH=x86
    HOST_OS=linux
    HOST_OS_EXTRA=Linux-4.19.104-microsoft-standard-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=AOSP.MASTER
    OUT_DIR=out
    PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl device/generic/goldfish device/generic/goldfish-opengl
    ============================================
    
    • 执行编译命令make -j8
    andy@andy-PC:/mnt/d/07.workspace/aosp$ make -j8
    23:30:00 ************************************************************
    23:30:00 You are building on a machine with 12.4GB of RAM
    23:30:00
    23:30:00 The minimum required amount of free memory is around 16GB,
    23:30:00 and even with that, some configurations may not work.
    23:30:00
    23:30:00 If you run into segfaults or other errors, try reducing your
    23:30:00 -j value.
    23:30:00 ************************************************************
    ============================================
    PLATFORM_VERSION_CODENAME=S
    PLATFORM_VERSION=S
    TARGET_PRODUCT=aosp_arm
    TARGET_BUILD_VARIANT=eng
    TARGET_BUILD_TYPE=release
    TARGET_ARCH=arm
    TARGET_ARCH_VARIANT=armv7-a-neon
    TARGET_CPU_VARIANT=generic
    HOST_ARCH=x86_64
    HOST_2ND_ARCH=x86
    HOST_OS=linux
    HOST_OS_EXTRA=Linux-4.19.104-microsoft-standard-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=AOSP.MASTER
    OUT_DIR=out
    PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl device/generic/goldfish device/generic/goldfish-opengl
    ============================================
    
    • 编译成功的日志打印和截图如下
      说明:编译成功用时 (06:08:37 (hh:mm:ss)),这是在多次编译情况下成功的耗时,若首次的话(经过多次长时间的编译才成功,中间遇到了很多坑),时间应该会更长。。。
    frameworks/base/services/usb/java/com/android/server/usb/UsbPortManager.java:50: info: Unresolved import: `android.hardware.usb.V1_2.PortStatus` [UnresolvedImport]
    frameworks/base/services/usb/java/com/android/server/usb/UsbPortManager.java:51: info: Unresolved import: `android.hidl.manager.V1_0.IServiceManager` [UnresolvedImport]
    frameworks/base/services/usb/java/com/android/server/usb/UsbPortManager.java:52: info: Unresolved import: `android.hidl.manager.V1_0.IServiceNotification` [UnresolvedImport]metalava detected access to files that are not explicitly specified. See /mnt/d/07.workspace/aosp/out/soong/.intermediates/frameworks/base/services/services-stubs.sources/android_common/services-stubs.sources-violations.txt for details.
    [ 99% 2301/2319] Target Java: out/target/common/obj/APPS/Dialer_intermediates/classes-full-debug.jar
    Note: Generating a Provider for com.android.dialer.glidephotomanager.impl.GlidePhotoManagerImpl. Prefer to run the dagger processor over that class instead.
    Note: [1] Wrote GeneratedAppGlideModule with: []
    [ 99% 2304/2319] R8: out/target/common/obj/APPS/Dialer_intermediates/dex/classes.dex
    Stripped invalid locals information from 1 method.
    In ./out/target/common/obj/APPS/Dialer_intermediates/classes.jar:android/support/v7/widget/Toolbar.class:
      Methods with invalid locals information:
      void android.support.v7.widget.Toolbar.onLayout(boolean, int, int, int, int)
      Type information in locals-table is inconsistent. Cannot constrain type: INT for value: v419 by constraint OBJECT.
    Some warnings are typically a sign of using an outdated Java toolchain. To fix, recompile the source with an updated toolchain.
    [100% 2319/2319] Target vbmeta image: out/target/product/generic/vbmeta.img
    
    #### build completed successfully (06:08:37 (hh:mm:ss)) ####
    
    andy@andy-PC:/mnt/d/07.workspace/aosp$
    
    image.png

    相关文章

      网友评论

          本文标题:使用WSL搭建AOSP环境

          本文链接:https://www.haomeiwen.com/subject/hgbncktx.html