Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> build/envsetup.sh概要學習

build/envsetup.sh概要學習

編輯:關於Android編程

在編譯之前我們的msm8909+android5.1環境需要執行下面兩個命令:

source build/envsetup.sh

source build/envsetup.sh腳本主要是定義一些基本函數、環境變量、配置編譯工具和路徑等,其中source命令就是用於運行shell腳本命令,功能等價於”.”,因此該命令也等價於. build/envsetup.sh。在文件envsetup.sh聲明了當前會話終端可用的命令,這裡需要注意的是當前會話終端,也就意味著每次新打開一個終端都必須再一次執行這些指令。

輸入source build/envsetup.sh回車,回輸出下面的信息

including device/lge/mako/vendorsetup.sh
includingdevice/htc/flounder/vendorsetup.sh
includingdevice/asus/grouper/vendorsetup.sh
including device/asus/fugu/vendorsetup.sh
includingdevice/asus/tilapia/vendorsetup.sh
including device/asus/deb/vendorsetup.sh
includingdevice/qcom/common/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
includingdevice/generic/mini-emulator-arm64/vendorsetup.sh
includingdevice/generic/mini-emulator-mips/vendorsetup.sh
includingdevice/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
includingdevice/samsung/manta/vendorsetup.sh
includingvendor/qcom/proprietary/common/vendorsetup.sh
including sdk/bash_completion/adb.bash

這是envsetup.sh下面的內容輸出的:

表示在device和vendor目錄下查找vendorsetup.sh文件,並加裝和執行。

# Execute the contents of anyvendorsetup.sh files we can find.
for f in `test -d device && find -Ldevice -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
        `test -d vendor && find -L vendor -maxdepth 4 -name'vendorsetup.sh' 2> /dev/null`
do
   echo "including $f"
    .$f//執行這些文件
done
unset f

我們是qcom平台,只包含qcom的vendorsetup.sh也可以正常編譯和正常運行:

including device/qcom/common/vendorsetup.sh

includingvendor/qcom/proprietary/common/vendorsetup.sh

在sdk/bash_completion目錄下的adb.bash文件也會加載到當前終端來,它是用來實現adb命令的bash completion功能的。也就是說,加載了該文件之後,我們在運行adb相關的命令的時候,通過按tab鍵就可以幫助我們自動完成命令的輸入。關於bash completion的知識,可以參考官方文檔: http://www.gnu.org/s/bash/manual/bash.html。

 

including sdk/bash_completion/adb.bash

1.Qcom平台的vendorsetup.sh

1.1 device/qcom/common/vendorsetup.sh

add_lunch_combo msm8909-userdebug

add_lunch_combo msm8909-user

add_lunch_combo msm8909-eng

調用add_lunch_combo函數來增加編譯選項,輸入命令行lunch,輸出:

Lunch menu... pick a combo:

1. msm8909-userdebug

2. msm8909-user

3. msm8909-eng

add_lunch_combo函數定義如下:

# Clear this variable.  It will be built up again when thevendorsetup.sh
# files are included at the end of thisfile.
unset LUNCH_MENU_CHOICES
function add_lunch_combo()
{
   local new_combo=$1 #獲得add_lunch_combo被調用時的參數
   local c # 遍歷LUNCH_MENU_CHOICES裡的值,該函數第一次調用時為空
   for c in ${LUNCH_MENU_CHOICES[@]} ; do
       if [ "$new_combo" = "$c" ] ; then # 如果參數裡的值已經存在於LUNCH_MENU_CHOICES變量裡,則返回
           return
       fi
   done # 如果參數的值不存在,則添加到LUNCH_MENU_CHOICES變量裡
   LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
}

 

1.2 vendor/qcom/proprietary/common/vendorsetup.sh

exportQCPATH="vendor/qcom/proprietary"

此路徑被下面文件引用:


device/qcom/common/base.mk:1058:#skip bootjars check if QCPATH not available device/qcom/common/base.mk:1059:ifeq($(strip $(QCPATH)),) device/qcom/common/common64.mk:6:$(callinherit-product-if-exists, $(QCPATH)/common/config/device-vendor.mk) device/qcom/common/common.mk:8:$(callinherit-product-if-exists, $(QCPATH)/common/config/device-vendor.mk) device/qcom/msm8909/BoardConfig.mk:30:-include$(QCPATH)/common/msm8909/BoardConfigVendor.mk device/qcom/msm8909/msm8909.mk:24:-include$(QCPATH)/common/config/qtic-config.mk device/qcom/msm8909/msm8909.mk:39:-include$(QCPATH)/common/config/rendering-engine.mk device/qcom/msm8909/msm8909.mk:185:PRODUCT_PACKAGE_OVERLAYS:= $(QCPATH)/qrdplus/Extension/res-overlay \ device/qcom/msm8909/msm8909.mk:186: $(QCPATH)/qrdplus/globalization/multi-language/res-overlay\ 2. 環境變量、配置編譯工具和路徑 比如 #set openjdk7 exportJAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 exportJRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre exportCLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH 3. 支持的函數 在envsetup.sh文件開頭有hmm函數,執行hmm命令,輸出 Invoke ". build/envsetup.sh" fromyour shell to add the following functions to your environment: - lunch: lunch - - tapas: tapas [  ...] [arm|x86|mips|armv5|arm64|x86_64|mips64][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, but not theirdependencies. - mmm: Builds all of the modules in the supplied directories, but not theirdependencies. To limit the modules being built use the syntax: mmmdir/:target1,target2. - mma: Builds all of the modules in the current directory, and theirdependencies. - mmma: Builds all of the modules in the supplied directories, and theirdependencies. - cgrep: Greps on all local C/C++ files. - ggrep: Greps on all local Gradle files. - jgrep: Greps on all local Java files. - resgrep: Greps on all local res/*.xmlfiles. - sgrep: Greps on all local source files. - godir: Go to the directory containing a file. Look at the source to view more functions.The complete list is: adb_get_product_device adb_get_traced_byaddcompletions add_lunch_combo cgrep check_multisim check_product check_projectcheck_variant choose choose_ choosecombo chooseproduct chooseproject choosetypechoosevariant core coredump_enable coredump_setup cproj croot findmakefilegdbclient gdbclient_old gdbwrapper get_abs_build_var getbugreports get_build_vargetdriver getlastscreenshot get_make_command getprebuilt getscreenshotpathgetsdcardpath get_symbols_directory gettargetarch gettop ggrep godir hmminitbuildspec is isviewserverstarted jgrep key_back key_home key_menu lunch_lunch m make mangrep mgrep mm mma mmm mmma pez pid printconfigprint_lunch_menu qpid resgrep runhat runtest sepgrep set_java_home setpathsset_sequence_number set_stuff_for_environment settitle sgrep smoketest stacksstartviewserver stopviewserver systemstack tapas tracedmdump treegrep

 

這些就是支持的函數集

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved