關於build/envsetup.sh及grep指令

來源:互聯網
上載者:User

下文轉載至 Kimihong的部落格 原文在 
http://blog.csdn.net/kimihong/article/details/7523892 

    這個檔案在編譯android系統時首先要執行一下,除了配置了android編譯的環境外,在它代碼的前幾行可以看到這些文字:

Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- 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.
- mmm: Builds all of the modules in the supplied directories.
- 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.

以上幾個命令也是本文主要說明。

在android原始碼根目錄下執行

# source /build/envsetup.sh 或者

#. ./build/envsetup.sh

後就可以使用croot/m/mm/mmm/cgrep/jgrep/resgrep/godir這幾個在android原始碼目錄下編譯和搜字元的命令;

1.croot 到android根目錄下

#:~/MyAndroid$ cd frameworks/base/

#:~/MyAndroid/frameworks/base$ croot
#:~/MyAndroid$ 

2.m 編譯android原始碼 與make一樣吧,還沒試過


3.mm 編譯目前的目錄下的所有模組,包括遞迴的目錄,這個目錄下的所包含Android.mk檔案


4.mmm 編譯目前的目錄下的模組,不包括其他目錄,就這個目錄下的Android.mk檔案

#:~/MyAndroid$ mmm  /packages/apps/Settings/     //模組編譯Settings.apk


下面幾個命令是對find + grep命令的組合封裝

find搜尋檔案+grep使用Regex搜尋文本,並把匹配的行列印出來

5.cgrep 在本地目錄下的C/C++檔案中搜尋相應文本,並列印出來

#:~/MyAndroid/$ cgrep 'unsupported pixel format'
./device/samsung/crespo/libcamera/SecCamera.cpp:316:        LOGE("unsupported pixel format\n");


6.jgrep 在本地目錄下的Java檔案中搜尋相應文本,並列印出來

#:~/MyAndroid$ jgrep 'Set app display size: '

./frameworks/base/services/java/com/android/server/wm/WindowManagerService.java:6075:            Slog.i(TAG, "Set app display size: " + mAppDisplayWidth
#:~/MyAndroid$ 


7.resgrep 在本地目錄下的res/*.xml檔案中搜尋相應文本,並列印出來

#:~/MyAndroid/frameworks/base/packages/SystemUI$ resgrep 'status_bar_background'
./res/values-large/colors.xml:3:    <drawable name="status_bar_background">#000000</drawable>
./res/layout-sw600dp/status_bar_notification_peek.xml:37:        android:background="@drawable/status_bar_background"
./res/layout-sw600dp/status_bar.xml:22:    android:background="@drawable/status_bar_background"
./res/values-sw600dp/colors.xml:3:    <drawable name="status_bar_background">#000000</drawable>
./res/values/colors.xml:24:    <drawable name="status_bar_background">#ff000000</drawable>
./res/layout/status_bar.xml:25:    android:background="@drawable/status_bar_background"
#:~/MyAndroid/frameworks/base/packages/SystemUI$ 


8.godir 定位到包含某檔案的目錄

#:~/MyAndroid$ godir envsetup.sh
Creating index... Done
#:~/MyAndroid/build$

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.