[GUIDE] How to build LineageOS on Windows 10 (WSL 2.0)

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
Requirements
https://source.android.com/setup/build/requirements#hardware-requirements
https://docs.microsoft.com/en-us/windows/wsl/install-win10#install-the-windows-subsystem-for-linux
https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2

You may want to expand the default virtual disk size:
https://docs.microsoft.com/en-us/wi...-the-size-of-your-wsl-2-virtual-hardware-disk

Setting up a Windows Subsystem for Linux (WSL 2.0) build environment
  1. Open Microsoft Store
  2. Search for and install the Ubuntu app
  3. Open the app and follow the first-time setup steps
  4. Update packages and install the following (if building lineage-17.1, please refer to their documentation for other versions):
    Code:
    sudo apt update && sudo apt full-upgrade -y && sudo apt install -y build-essential ccache libncurses5 libssl-dev m4 unzip zip
  5. Make a directory for the source code (and go to it):
    Code:
    mkdir -p ~/android/lineage && cd android/lineage
  6. Initialize the LineageOS source repository:
    Code:
    repo init -u https://github.com/LineageOS/android.git -b lineage-17.1
  7. Sync the sources:
    Code:
    repo sync
  8. (Optional; Recommended) https://wiki.lineageos.org/devices/klte/build#turn-on-caching-to-speed-up-build
  9. Run
    Code:
    source build/envsetup.sh
  10. Prepare the device-specific code:
    Code:
    breakfast [I]your device codename[/I]
  11. Add the following to .repo/local_manifests/roomservice.xml:
    Code:
    <project name="TheMuppets/proprietary_vendor_[I]your device brand[/I]" path="vendor/[I]your device brand[/I]" remote="github" />
  12. Sync the sources again:
    Code:
    repo sync
  13. Start the build:
    Code:
    brunch [I]your device codename[/I]

For future builds, you need to repeat steps 13 -> 10 -> 14 at the root of the tree
 
Last edited:

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
Useful resources

Running a Desktop Environment
https://github.com/microsoft/WSL/issues/4106#issuecomment-636446405

Using mnt (consider performance https://github.com/microsoft/WSL/issues/4197):
1. Create /etc/wsl.conf
2. Add
Code:
[automount] options = "metadata"
3. Run
Code:
wsl --shutdown
from PowerShell
After restarting wsl, make sure
Code:
mount -l | grep metadata
shows your drvfs mounts with the metadata tag added.

WSL2 install location: https://github.com/MicrosoftDocs/WSL/issues/412#issuecomment-575923176
 
Last edited:

1a2a3a4aq

Member
Feb 11, 2018
5
2
0
Hello, Thanks for your great guide. I was able to finish the build nearly successfully.

USE_HOST_BISON is opt-in, so you don't need to set it false unless you've exported USE_HOST_BISON=true before.

I've seen the change 196115, but is this change really needed for WSL build?
It seems like change for non-WSL build. (whose don't need to use prebuilt FLEX)
 
Last edited:
  • Like
Reactions: Vmb265 and Uldiniad

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
Hello, Thanks for your great guide. I was able to finish the build nearly successfully.

USE_HOST_BISON is opt-in, so you don't need to set it false unless you've exported USE_HOST_BISON=true before.

I've seen the change 196115, but is this change really needed for WSL build?
It seems like change for non-WSL build. (whose don't need to use prebuilt FLEX)
Thanks for your feedback.
As you pointed out, I made a mistake in the number of the commit to be cherrypicked. I've corrected the OP, so, the command should now work and you can also see the code that is added by the commit by following the link. Thanks for pointing that out.
WSL only supports 64-bit binaries. That is why I've left out bison and flex from the packages to be installed for the build environment and instead have put the code to my forked repos which have prebuilt 64-bit bison and flex. Then I've set USE_HOST_BISON and USE_HOST_FLEX to false in bashrc so that it doesn't go looking for the packages that would typically be installed with apt-get and makes sure the 64-bit prebuilts are used (but as you said, it might be an unnecessary precaution but it doesn't hurt to have it).

Hope that helps. And if you have more questions, ask away.
 
Last edited:

1a2a3a4aq

Member
Feb 11, 2018
5
2
0
Thanks for your feedback.
As you pointed out, I made a mistake in the number of the commit to be cherrypicked. I've corrected the OP, so, the command should now work and you can also see the code that is added by the commit by following the link. Thanks for pointing that out.
WSL only supports 64-bit binaries. That is why I've left out bison and flex from the packages to be installed for the build environment and instead have put the code to my forked repos which have prebuilt 64-bit bison and flex. Then I've set USE_HOST_BISON and USE_HOST_FLEX to false in bashrc so that it doesn't go looking for the packages that would typically be installed with apt-get and makes sure the 64-bit prebuilts are used (but as you said, it might be an unnecessary precaution but it doesn't hurt to have it).

Hope that helps. And if you have more questions, ask away.
btw, using "/bin/bash -c" instead of brunch does not make effect for me.
build stucks while doing dex2oat jobs just like using brunch.
build with WITH_DEXPREOPT=false was successful, but 8.1 must use dexpreopt due to sepolicy changes. still searching on this.
 

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
btw, using "/bin/bash -c" instead of brunch does not make effect for me.
build stucks while doing dex2oat jobs just like using brunch.
build with WITH_DEXPREOPT=false was successful, but 8.1 must use dexpreopt due to sepolicy changes. still searching on this.
Ok, thanks for mentioning this. I had success with the /bin/bash -c command but if this is not universal, then, as you said, we should find another universal workaround or fix and I'll replace mine with it in the OP. I'll look into WITH_DEXPREOPT and other possibilities on my end too.
I've reopened the issue on GitHub while there is no universal fix or workaround: https://github.com/Microsoft/WSL/issues/2948
 
  • Like
Reactions: WinterR

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
btw, using "/bin/bash -c" instead of brunch does not make effect for me.
build stucks while doing dex2oat jobs just like using brunch.
build with WITH_DEXPREOPT=false was successful, but 8.1 must use dexpreopt due to sepolicy changes. still searching on this.
I've opened this page: https://source.android.com/devices/tech/dalvik/configure
I'm thinking of trying out different makefile options instead of disabling dex2oat altogether and see if it makes a difference for the brunch command. Maybe you can do the same and keep us posted
 
  • Like
Reactions: WinterR

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
Thanks for posting the tutorial
@Uldiniad
I'm very thankful to you for this.
One question, is it possible to download the whole source somewhere else so that we don't have to download the complete source across windows formats and system restores?
As far as I know, at this point in time it is not (that's why I put up the requirements and warnings on the OP). WSL is made to work mostly within its own environment (somewhat separate from Windows) and intercompatibility/interoperability with the Windows file system is limited. Linux and Windows don't have the same file management systems (which is why manipulating files of the subsystem from Windows Explorer and the mount option are out the window for now). Also, there is no simple way of changing the installation location of lxss as of today (although, you can check WSL's GitHub if you're really determined to move it ;)).
WSL is picky and that is why threads like this exist. If WSL worked like Ubuntu out of the box this thread wouldn't be necessary (LineageOS' guide would suffice).
 

1a2a3a4aq

Member
Feb 11, 2018
5
2
0
Thanks for posting the tutorial
@Uldiniad
I'm very thankful to you for this.
One question, is it possible to download the whole source somewhere else so that we don't have to download the complete source across windows formats and system restores?
Check LxRunOffline on GitHub. It can install WSL distribution to another directory from tar file.
 
G

GuestK00254

Guest
Yep. I'm currently running a build on my s5 that I made myself on the Ubuntu app for Windows 10. We are currently working on fixing the dex2oat issues but other users have suggested workarounds in the mean time.
ok thanks bro. New to rom building, but I did build a DU rom that works for sailfish
 

taxueliuyun

Member
Mar 4, 2018
6
1
0
Hello Uldiniad, thanks your guide. I got a error, When I start the build "brunch gemini":
[1055/1074] including ./vendor/qcom/opensource/cryptfs_hw/Android.mk ...
build/core/binary.mk:40: warning: libcryptfs_hw uses deprecated kernel header dependency path.
[1056/1074] including ./vendor/qcom/opensource/dataservices/Android.mk ...
build/core/binary.mk:40: warning: librmnetctl uses deprecated kernel header dependency path.
build/core/binary.mk:40: warning: sockev uses deprecated kernel header dependency path.
[1074/1074] including ./vendor/xiaomi/scorpio/Android.mk ...
waitpid failed: No child processes
19:40:52 ckati failed with: exit status 1
I have no idea, please help me, thanks. ( I run windows 10 in virtualbox)
 

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
Hello Uldiniad, thanks your guide. I got a error, When I start the build "brunch gemini":
[1055/1074] including ./vendor/qcom/opensource/cryptfs_hw/Android.mk ...
build/core/binary.mk:40: warning: libcryptfs_hw uses deprecated kernel header dependency path.
[1056/1074] including ./vendor/qcom/opensource/dataservices/Android.mk ...
build/core/binary.mk:40: warning: librmnetctl uses deprecated kernel header dependency path.
build/core/binary.mk:40: warning: sockev uses deprecated kernel header dependency path.
[1074/1074] including ./vendor/xiaomi/scorpio/Android.mk ...
waitpid failed: No child processes
19:40:52 ckati failed with: exit status 1
I have no idea, please help me, thanks. ( I run windows 10 in virtualbox)
would you mind running
Code:
breakfast gemini && make bacon showcommands
just based off the snippet you gave above I can't say much about the failure, the "no child processes" failure could be because it is not finding the next tasks (possibly missing some makefiles) to be executed for some reason (which would be strange).
also, are you successfully building on other platforms? and did you follow the OP step-by-step?
note: it shouldn't matter, but I recommend running windows natively if you want to build on lxss. but on vm it shouldn't matter (that I know of). although if you're running windows in a virtual machine, what are you running natively? probably a unix-based system right? because if so, darwin or linux will have more chances of successful builds than wsl guaranteed
 
Last edited:
Oct 7, 2017
8
0
0
hello Uldiniad getting error while building for my kenzo

11. mini_emulator_arm64-userdebug
12. m_e_arm-userdebug
13. mini_emulator_x86_64-userdebug
14. mini_emulator_x86-userdebug
15. uml-userdebug
16. aosp_kenzo-userdebug
17. aosp_kenzo-user
18. aosp_kenzo-eng
19. lineage_angler-userdebug
20. lineage_bullhead-userdebug
21. lineage_capricorn-userdebug
22. lineage_cheeseburger-userdebug
23. lineage_dumpling-userdebug
24. lineage_gemini-userdebug
25. lineage_gts210vewifi-userdebug
26. lineage_gts28vewifi-userdebug
27. lineage_natrium-userdebug
28. lineage_oneplus3-userdebug
29. lineage_zl1-userdebug
Which would you like? [aosp_arm-eng] 16
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
Device kenzo not found. Attempting to retrieve device repository from LineageOS Github (githubcom/LineageOS
).
Found repository: android_device_xiaomi_kenzo
Default revision: lineage-15.1
Checking branch info
Default revision lineage-15.1 not found in android_device_xiaomi_kenzo. Bailing.
Branches found:
cm-13.0
cm-14.
cm-14.1
lineage-15.0
stable/cm-13.0-ZNH5Y
Use the ROOMSERVICE_BRANCHES environment variable to specify a list of fallback branches.
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
** Don't have a product spec for: 'aosp_kenzo'
** Do you have the right repo manifest?
[email protected]:~/los151$
 

taxueliuyun

Member
Mar 4, 2018
6
1
0
would you mind running
Code:
breakfast gemini && make bacon showcommands
just based off the snippet you gave above I can't say much about the failure, the "no child processes" failure could be because it is not finding the next tasks (possibly missing some makefiles) to be executed for some reason (which would be strange).
also, are you successfully building on other platforms? and did you follow the OP step-by-step?
note: it shouldn't matter, but I recommend running windows natively if you want to build on lxss. but on vm it shouldn't matter (that I know of). although if you're running windows in a virtual machine, what are you running natively? probably a unix-based system right? because if so, darwin or linux will have more chances of successful builds than wsl guaranteed
thanks for your reply, my host os is macos, I can compile aosp successfully in my macpro, or ubuntu in my virtualbox, by follow the official guide. But I want to build aosp in wsl for my purpose, so I found your guide. I followed the OP step by step, no error happened until the last step. Just a few warnings and interrupted many times when I called " repo sync", the error message is below:
Shared project LineageOS/android_hardware_qcom_wlan found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_wlan found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_ril found, disabling pruning.
Shared project LineageOS/android_hardware_ril found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_bt found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_bt found, disabling pruning.

I called "make gemini showcommands" just now, the terminal prints some command procedures, but it does not help, it's still the same error.
 

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
11. mini_emulator_arm64-userdebug
12. m_e_arm-userdebug
13. mini_emulator_x86_64-userdebug
14. mini_emulator_x86-userdebug
15. uml-userdebug
16. aosp_kenzo-userdebug
17. aosp_kenzo-user
18. aosp_kenzo-eng
19. lineage_angler-userdebug
20. lineage_bullhead-userdebug
21. lineage_capricorn-userdebug
22. lineage_cheeseburger-userdebug
23. lineage_dumpling-userdebug
24. lineage_gemini-userdebug
25. lineage_gts210vewifi-userdebug
26. lineage_gts28vewifi-userdebug
27. lineage_natrium-userdebug
28. lineage_oneplus3-userdebug
29. lineage_zl1-userdebug
Which would you like? [aosp_arm-eng] 16
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
Device kenzo not found. Attempting to retrieve device repository from LineageOS Github (githubcom/LineageOS
).
Found repository: android_device_xiaomi_kenzo
Default revision: lineage-15.1
Checking branch info
Default revision lineage-15.1 not found in android_device_xiaomi_kenzo. Bailing.
Branches found:
cm-13.0
cm-14.
cm-14.1
lineage-15.0
stable/cm-13.0-ZNH5Y
Use the ROOMSERVICE_BRANCHES environment variable to specify a list of fallback branches.
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
build/core/product_config.mk:237: *** Can not locate config makefile for product "aosp_kenzo". Stop.
** Don't have a product spec for: 'aosp_kenzo'
** Do you have the right repo manifest?
[email protected]:~/los151$
Your device does not have lineage-15.1 yet. check the branches here: https://github.com/LineageOS/android_device_xiaomi_kenzo
 

Uldiniad

Senior Member
Mar 17, 2016
343
266
0
thanks for your reply, my host os is macos, I can compile aosp successfully in my macpro, or ubuntu in my virtualbox, by follow the official guide. But I want to build aosp in wsl for my purpose, so I found your guide. I followed the OP step by step, no error happened until the last step. Just a few warnings and interrupted many times when I called " repo sync", the error message is below:
Shared project LineageOS/android_hardware_qcom_wlan found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_wlan found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_display found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_media found, disabling pruning.
Shared project LineageOS/android_hardware_ril found, disabling pruning.
Shared project LineageOS/android_hardware_ril found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_audio found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_bt found, disabling pruning.
Shared project LineageOS/android_hardware_qcom_bt found, disabling pruning.

I called "make gemini showcommands" just now, the terminal prints some command procedures, but it does not help, it's still the same error.
the pruning is not an error. it is saying that the project is shared (used by other devices potentially) and therefore it does not apply pruning to the tree.
the reason I wanted you to post the showcommands is so that I can see what is the last few commands before the error