ROM Android: Tentang Envsetup

From OnnoWiki
Jump to navigation Jump to search

This page explains what happens when you run the the "$ . build/envsetup.sh" or "$ source build/envsetup.sh" script from the ~android/system/ directory.

Template:Note


At a glance

Invoking "$ source build/envsetup.sh" or "$ . build/envsetup.sh" from your shell runs the envsetup.sh script in the build directory. envsetup.sh adds many functions to the build environment, the most important of which are listed below. For a full list of functions see All commands.

mka Builds using SCHED_BATCH on all processors
lunch lunch <vendor_name>_<product_name>-<build_variant>
breakfast breakfast <product_name>
brunch brunch <product_name>
omnom omnom <product_name>
tapas tapas [<App1> <App2> ...] [arm|x86|mips] [eng|userdebug|user]
croot Changes directory to the top of the tree
m Makes from the top of the tree
mm Builds all of the modules in the current directory
mmp Builds all of the modules in the current directory and pushes them to the device
mmm Builds all of the modules in the supplied directories
mmmp Builds all of the modules in the supplied directories and pushes them to the device
cgrep Greps on all local C/C++ files
jgrep Greps on all local Java files
resgrep Greps on all local res/*.xml files
godir Go to the directory containing a file
cmremote Add git remote for CM Gerrit Review
cmgerrit A Git wrapper that fetches/pushes patch from/to CM Gerrit Review
cmrebase Rebase a Gerrit change and push it again
aospremote Add git remote for matching AOSP repository
mkap Builds the module(s) using mka and pushes them to the device
cmka Cleans and builds using mka
reposync Parallel repo sync using ionice and SCHED_BATCH
installboot Installs a boot.img to the connected device
installrecovery Installs a recovery.img to the connected device

We will look at a few important functions that "$ . build/envsetup.sh" adds to the build environment in detail below.

Template:Tip

mka

This little gem of a command is basically equivalent to a super-charged version of make. make is the program that gets called to build our source, choosing the correct compiler for each part of the Android OS that we are making. Problem is, make is SLOW in its default configuration. It can take hours longer depending on your hardware. So what did they do? They mated make with a cheetah, and took their child mka. mka improves upon make by using the program sched_tool to make full use of all the threads available on your machine (For AMD, this is equivalent to the number of cores your processor has; For Intel, this is usually equivalent to twice the number of cores your processor has, due to HyperThreading). What this means is that ALL of your processor is working, not just one small part of it.

breakfast

You may not ever use this command, but in order to explain brunch, we have to explain breakfast first. Breakfast is a function used to configure your build. It keeps track of a list of officially-supported devices to build for, and allows you to choose one. You can do this two ways,

$ breakfast [device name]

or

$ breakfast (no device name)

The first method is like a shortcut to select your device. If you do not put a device, the script will output a list of available devices to build for (limited to those CM builds nightlies for, which isn't necessarily complete), and you can then choose yours. breakfast then goes on to configure your build environment with the correct variables to create your device-specific rom.

brunch

Defined simply, brunch is equivalent to

$ breakfast [device name] && mka bacon

This means that it sets up your build environment to be configured for your device, and then commences the build process. mka bacon is just CyanogenMods’s way of saying build the code for your device. It’s generally only used for officially supported devices (those for which a public CyanogenMod-maintained device repository exists).

lunch

This one's also pretty simple to explain. It’s used EXACTLY like breakfast, the only difference being the choices you have to build with it, and how it configures the device. Using lunch, you can choose non-official or non-standard builds for your device. This includes special debug versions and also allows you to build CyanogenMod for use on the Android Emulator. Unlike breakfast, lunch makes no assumptions with regard to device configuration locations and formats, so it will scan the entire tree for matching options (depending on the number of locally available devices, this may take a significant amount of time). To build after running lunch, simply issue the command mka. No bacon here… sorry.

List of all commands in envsetup.sh

  1. addcompletions
  2. add_lunch_combo
  3. aospremote
  4. breakfast
  5. brunch
  6. cgrep
  7. check_product
  8. check_variant
  9. choosecombo
  10. chooseproduct
  11. choosetype
  12. choosevariant
  13. cmgerrit
  14. cmka
  15. cmrebase
  16. cmremote
  17. cproj
  18. croot
  19. dopush
  20. eat
  21. findmakefile
  22. gdbclient
  23. get_abs_build_var
  24. getbugreports
  25. get_build_var
  26. getlastscreenshot
  27. getprebuilt
  28. getscreenshotpath
  29. getsdcardpath
  30. gettargetarch
  31. gettop
  32. godir
  33. hmm
  34. installboot
  35. installrecovery
  36. isviewserverstarted
  37. jgrep
  38. key_back
  39. key_home
  40. key_menu
  41. lunch
  42. _lunch
  43. m
  44. makerecipe
  45. mka
  46. mm
  47. mmm
  48. omnom
  49. pid
  50. printconfig
  51. print_lunch_menu
  52. repodiff
  53. reposync
  54. resgrep
  55. runhat
  56. runtest
  57. set_java_home
  58. setpaths
  59. set_sequence_number
  60. set_stuff_for_environment
  61. settitle
  62. smoketest
  63. startviewserver
  64. stopviewserver
  65. systemstack
  66. tapas
  67. tracedmdump


Referensi