简体   繁体   中英

Android soong has no android.PathForSourceRelaxed and ctx.Config().BuildOSTarget

I am trying to compile pure aosp sourceand keep getting theese two errors. I am using the lineage vendor files and am using aosp device trees PS I'm using a live system but the issue is that there are two undefined methods

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=10
TARGET_PRODUCT=aosp_trlte
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=krait
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.4.0-7634-generic-x86_64-Pop!_OS-20.04-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=QP1A.190711.019
OUT_DIR=out
============================================
[ 43% 49/113] compile out/soong/.bootstrap/soong-lineage-generator/pkg/lineage/soong/generator.a
FAILED: out/soong/.bootstrap/soong-lineage-generator/pkg/lineage/soong/generator.a
GOROOT='prebuilts/go/linux-x86' prebuilts/go/linux-x86/pkg/tool/linux_amd64/compile -c 8 -o out/soong/.bootstrap/soong-lineage-generator/pkg/lineage/soong/generator.a.tmp -p lineage/soong/generator -complete -I out/soong/.bootstrap/blueprint-parser/pkg -I out/soong/.bootstrap/blueprint-deptools/pkg -I out/soong/.bootstrap/blueprint-pathtools/pkg -I out/soong/.bootstrap/blueprint-proptools/pkg -I out/soong/.bootstrap/blueprint/pkg -I out/soong/.bootstrap/soong/pkg -I out/soong/.bootstrap/blueprint-bootstrap-bpdoc/pkg -I out/soong/.bootstrap/blueprint-bootstrap/pkg -I out/soong/.bootstrap/soong-env/pkg -I out/soong/.bootstrap/soong-android/pkg -I out/soong/.bootstrap/soong-shared/pkg -pack vendor/lineage/build/soong/generator/generator.go vendor/lineage/build/soong/generator/variables.go && if cmp --quiet out/soong/.bootstrap/soong-lineage-generator/pkg/lineage/soong/generator.a.tmp out/soong/.bootstrap/soong-lineage-generator/pkg/lineage/soong/generator.a; then rm out/soong/.bootstrap/soong-lineage-generator/pkg/lineage/soong/generator.a.tmp; else mv -f out/soong/.bootstrap/soong-lineage-generator/pkg/lineage/soong/generator.a.tmp out/soong/.bootstrap/soong-lineage-generator/pkg/lineage/soong/generator.a; fi
vendor/lineage/build/soong/generator/generator.go:124:48: ctx.Config().BuildOSTarget undefined (type android.Config has no field or method BuildOSTarget)
vendor/lineage/build/soong/generator/generator.go:229:38: undefined: android.PathForSourceRelaxed
03:19:35 soong bootstrap failed with: exit status 1

#### failed to build some targets (2 seconds) ####

I'm building with similar parameters (AOSP base, LOS device, common board and kernel trees and using vendor/lineage to get some configs). I faced this error only:

vendor/lineage/build/soong/generator/generator.go:229:38: undefined: android.PathForSourceRelaxed

After some investigation, I've found out that PathForSourceRelaxed is a function defined on LOS build/soong/android/paths.go in this commit .

About BuildOSTarget , I've found it defined on build/soong/android/config.go , included on this commit . However, when I look at AOSP 11.0.0_r24 tag source code, it's already there (it's the tag I'm using as base).

EDIT:

One possible way to include these commits in your AOSP base would be to follow this gist . Basically, you'll do this:

  • cd project_you_need_fixes so you go to the correct project;
  • git remote add to add the remote for the project (personally I like to use it like this: git remote add git@github:someone/somerepo -t branch_i_wish_to_clone because you can track just one branch if you wish with the -t flag) ;
  • git fetch --all to make sure you fetch everything;
  • git branch --track local_branch_name_of_the_one_you_want_to_track remote_you_just_added/branch_you_want_to_track to create the branch;
  • git pull so you merge the fetched changes if any.

Then you need to cherry-pick the commit(s) you need to solve your issues. In case of PathForSourceRelaxed , it would need to cherry-pick from LOS repo:

  • git status or git branch to make sure you're at your branch, not the one you fetched from LOS;
  • git cherry-pick 191bf4e250d097995a2d55e5ca464ffd022b5baa (considering you fetched lineage-18.1 branch.

I had the same issue too, and fixed it like 10 Minuites ago. I am still learning about porting Android ROMs and because I still need to do some other Error fixing (for my first Port) i am not able to verify wether this is the complete fix for this Problem or not.

So now let's get to the solution I found.

My guess is, that you probably somehow figured out, that you need some files in /vendor. You searched these files and used the LinegeOS vendor files for your ROM. That is perfectly fine. But now look at the downloaded files and folders. Now look at the root of your source tree (the folder where you downloaded AOSP). See any similaties?(Spoiler: Many Folders are in Both directories, ie build) You basically downloaded many things from the Lineage Source Tree(ie files to build Lineage), which are not compatible and not needed in AOSP. You really just need the config folder from the lineage vendor you downloaded. You can safely delete the rest and the Error should go away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM