1. 程式人生 > >Android原始碼編譯如何新增eng 或者userdebug等lunch選項

Android原始碼編譯如何新增eng 或者userdebug等lunch選項

我們從Google或者github上下載完程式碼,就進入編譯階段

首先進入到原始碼根目錄

/data/projects/cm$ 

第一步,執行初始化命令

. build/envsetup.sh
第二步,選擇命令
lunch
顯示結果
You're building on Linux

Lunch menu... pick a combo:
 1. aosp_arm-eng 		 60. cm_jfltecsp-userdebug 
 2. aosp_x86-eng 		 61. cm_jfltespr-userdebug 
 3. aosp_mips-eng 		 62. cm_jfltetmo-userdebug 
 4. vbox_x86-eng 		 63. cm_jflteusc-userdebug 
 5. mini_armv7a_neon-userdebug 	 64. cm_jfltevzw-userdebug 
 6. cm_goldfish-eng 		 65. cm_jfltexx-userdebug 
 7. cm_goldfish-userdebug 	 66. cm_l900-userdebug 
 8. cm_goldfish-user 		 67. cm_ls970-userdebug 
 9. mini_mips-userdebug 	 68. cm_ls980-userdebug 
 10. mini_x86-userdebug 	 69. cm_m7-userdebug 
 11. cm_a700-userdebug 		 70. cm_m7spr-userdebug 
 12. cm_acclaim-userdebug 	 71. cm_m7vzw-userdebug 
 13. cm_apexqtmo-userdebug 	 72. cm_maguro-userdebug 
 14. cm_captivatemtd-userdebug 	 73. cm_mako-userdebug 
 15. cm_crespo-userdebug 	 74. cm_manta-userdebug 
 16. cm_d2att-userdebug 	 75. cm_maserati-userdebug 
 17. cm_d2cri-userdebug 	 76. cm_mb886-userdebug 
 18. cm_d2mtr-userdebug 	 77. cm_mint-userdebug 
 19. cm_d2spr-userdebug 	 78. cm_n5100-userdebug 
 20. cm_d2tmo-userdebug 	 79. cm_n5110-userdebug 
 21. cm_d2usc-userdebug 	 80. cm_odin-userdebug 
 22. cm_d2vzw-userdebug 	 81. cm_otter-userdebug 
 23. cm_d800-userdebug 		 82. cm_otter2-userdebug 
 24. cm_d801-userdebug 		 83. cm_ovation-userdebug 
 25. cm_d802-userdebug 		 84. cm_p1-userdebug 
 26. cm_deb-userdebug 		 85. cm_p3100-userdebug 
 27. cm_dlx-userdebug 		 86. cm_p3110-userdebug 
 28. cm_dogo-userdebug 		 87. cm_p5100-userdebug 
 29. cm_e970-userdebug 		 88. cm_p5110-userdebug 
 30. cm_e973-userdebug 		 89. cm_p880-userdebug 
 31. cm_e975-userdebug 		 90. cm_p930-userdebug 
 32. cm_e980-userdebug 		 91. cm_pollux-userdebug 
 33. cm_endeavoru-userdebug 	 92. cm_pollux_windy-userdebug 
 34. cm_enrc2b-userdebug 	 93. cm_r950-userdebug 
 35. cm_epicmtd-userdebug 	 94. cm_serrano3gxx-userdebug 
 36. cm_evita-userdebug 	 95. cm_serranoltexx-userdebug 
 37. cm_exhilarate-userdebug 	 96. cm_skyrocket-userdebug 
 38. cm_expressatt-userdebug 	 97. cm_spyder-userdebug 
 39. cm_fireball-userdebug 	 98. cm_superior-userdebug 
 40. cm_flo-userdebug 		 99. cm_t0lte-userdebug 
 41. cm_galaxysbmtd-userdebug 	 100. cm_t769-userdebug 
 42. cm_galaxysmtd-userdebug 	 101. cm_targa-userdebug 
 43. cm_grouper-userdebug 	 102. cm_tf300t-userdebug 
 44. cm_hammerhead-userdebug 	 103. cm_tf700t-userdebug 
 45. cm_hercules-userdebug 	 104. cm_tilapia-userdebug 
 46. cm_hltespr-userdebug 	 105. cm_toroplus-userdebug 
 47. cm_hltetmo-userdebug 	 106. cm_toro-userdebug 
 48. cm_hltevzw-userdebug 	 107. cm_tsubasa-userdebug 
 49. cm_hltexx-userdebug 	 108. cm_umts_spyder-userdebug 
 50. cm_hummingbird-userdebug 	 109. cm_ville-userdebug 
 51. cm_i605-userdebug 		 110. cm_v500-userdebug 
 52. cm_i9100g-userdebug 	 111. cm_vs920-userdebug 
 53. cm_i925-userdebug 		 112. cm_vs980-userdebug 
 54. cm_i9300-userdebug 	 113. cm_xt897-userdebug 
 55. cm_i9305-userdebug 	 114. cm_xt907-userdebug 
 56. cm_jewel-userdebug 	 115. cm_xt925-userdebug 
 57. cm_jflteatt-userdebug 	 116. cm_xt926-userdebug 
 58. cm_jfltecan-userdebug 	 117. cm_yuga-userdebug 
 59. cm_jfltecri-userdebug 	  

Which would you like? [aosp_arm-eng] 

這裡就可以選擇需要編譯的版本了。

問題來了,如果希望編譯hammerhead的eng版本,怎麼辦呢?

進入到vendor/cm/目錄

用gedit開啟vendorsetup.sh檔案,在最後新增一行

add_lunch_combo cm_hammerhead-eng
然後重新執行第一步和第二步,顯示效果如下
You're building on Linux

Lunch menu... pick a combo:
 1. aosp_arm-eng 		 60. cm_jfltecsp-userdebug 
 2. aosp_x86-eng 		 61. cm_jfltespr-userdebug 
 3. aosp_mips-eng 		 62. cm_jfltetmo-userdebug 
 4. vbox_x86-eng 		 63. cm_jflteusc-userdebug 
 5. mini_armv7a_neon-userdebug 	 64. cm_jfltevzw-userdebug 
 6. cm_goldfish-eng 		 65. cm_jfltexx-userdebug 
 7. cm_goldfish-userdebug 	 66. cm_l900-userdebug 
 8. cm_goldfish-user 		 67. cm_ls970-userdebug 
 9. mini_mips-userdebug 	 68. cm_ls980-userdebug 
 10. mini_x86-userdebug 	 69. cm_m7-userdebug 
 11. cm_a700-userdebug 		 70. cm_m7spr-userdebug 
 12. cm_acclaim-userdebug 	 71. cm_m7vzw-userdebug 
 13. cm_apexqtmo-userdebug 	 72. cm_maguro-userdebug 
 14. cm_captivatemtd-userdebug 	 73. cm_mako-userdebug 
 15. cm_crespo-userdebug 	 74. cm_manta-userdebug 
 16. cm_d2att-userdebug 	 75. cm_maserati-userdebug 
 17. cm_d2cri-userdebug 	 76. cm_mb886-userdebug 
 18. cm_d2mtr-userdebug 	 77. cm_mint-userdebug 
 19. cm_d2spr-userdebug 	 78. cm_n5100-userdebug 
 20. cm_d2tmo-userdebug 	 79. cm_n5110-userdebug 
 21. cm_d2usc-userdebug 	 80. cm_odin-userdebug 
 22. cm_d2vzw-userdebug 	 81. cm_otter-userdebug 
 23. cm_d800-userdebug 		 82. cm_otter2-userdebug 
 24. cm_d801-userdebug 		 83. cm_ovation-userdebug 
 25. cm_d802-userdebug 		 84. cm_p1-userdebug 
 26. cm_deb-userdebug 		 85. cm_p3100-userdebug 
 27. cm_dlx-userdebug 		 86. cm_p3110-userdebug 
 28. cm_dogo-userdebug 		 87. cm_p5100-userdebug 
 29. cm_e970-userdebug 		 88. cm_p5110-userdebug 
 30. cm_e973-userdebug 		 89. cm_p880-userdebug 
 31. cm_e975-userdebug 		 90. cm_p930-userdebug 
 32. cm_e980-userdebug 		 91. cm_pollux-userdebug 
 33. cm_endeavoru-userdebug 	 92. cm_pollux_windy-userdebug 
 34. cm_enrc2b-userdebug 	 93. cm_r950-userdebug 
 35. cm_epicmtd-userdebug 	 94. cm_serrano3gxx-userdebug 
 36. cm_evita-userdebug 	 95. cm_serranoltexx-userdebug 
 37. cm_exhilarate-userdebug 	 96. cm_skyrocket-userdebug 
 38. cm_expressatt-userdebug 	 97. cm_spyder-userdebug 
 39. cm_fireball-userdebug 	 98. cm_superior-userdebug 
 40. cm_flo-userdebug 		 99. cm_t0lte-userdebug 
 41. cm_galaxysbmtd-userdebug 	 100. cm_t769-userdebug 
 42. cm_galaxysmtd-userdebug 	 101. cm_targa-userdebug 
 43. cm_grouper-userdebug 	 102. cm_tf300t-userdebug 
 44. cm_hammerhead-userdebug 	 103. cm_tf700t-userdebug 
 45. cm_hercules-userdebug 	 104. cm_tilapia-userdebug 
 46. cm_hltespr-userdebug 	 105. cm_toroplus-userdebug 
 47. cm_hltetmo-userdebug 	 106. cm_toro-userdebug 
 48. cm_hltevzw-userdebug 	 107. cm_tsubasa-userdebug 
 49. cm_hltexx-userdebug 	 108. cm_umts_spyder-userdebug 
 50. cm_hummingbird-userdebug 	 109. cm_ville-userdebug 
 51. cm_i605-userdebug 		 110. cm_v500-userdebug 
 52. cm_i9100g-userdebug 	 111. cm_vs920-userdebug 
 53. cm_i925-userdebug 		 112. cm_vs980-userdebug 
 54. cm_i9300-userdebug 	 113. cm_xt897-userdebug 
 55. cm_i9305-userdebug 	 114. cm_xt907-userdebug 
 56. cm_jewel-userdebug 	 115. cm_xt925-userdebug 
 57. cm_jflteatt-userdebug 	 116. cm_xt926-userdebug 
 58. cm_jfltecan-userdebug 	 117. cm_yuga-userdebug 
 59. cm_jfltecri-userdebug 	 118. cm_hammerhead-eng 

Which would you like? [aosp_arm-eng] 

這是就可以輸入118,就是我們想要的hammerhead的eng版本。