android直接找一个文件,部分编译等实用

从网上看的别人的:

在android的顶层目录里,运行下面的命令:

source build/envsetup.sh

运行命令后,就添加了很多命令到sh解释器,具体命令如下:

-croot:   Changes directory to the top ofthe tree.

-m:       Makes from the top of the tree.

-mm:      Builds all of the modules in thecurrent directory.

-mmm:     Builds all of the modules in thesupplied 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 afile.

其中命令croot是改变到顶层目录;m是编译源码树;mm是编译当前目录下所有模块;

mmm是编译所有满足条件编译的模块;cgrep是查找本地所有C/C++文件;jgrep是查找本地所有java文件;resgrep是查找本地所有资源文件res/*.xml;godir是跳到包括这个文件的目录。


可以用mm部分编译

到你该动代码的那个目录下面mm即可。这样就是部分编译。。。

可以用godir找到这个文件所在的位置:
例如:
知道文件的名字为PhoneWindowManager.java
   开始 :

1、去根目录

srx@srx-desktop:~$ cd master/

2、
srx@srx-desktop:~/master$ source build/envsetup.sh
srx@srx-desktop:~/master$ choosecombo 1 1 4 3

3、

srx@srx-desktop:~/master$ godir PhoneWindow.java
srx@srx-desktop:~/master/frameworks/policies/base/phone/com/android/internal/policy/impl$

用ls就可以查看到了。。。。



在Android Source Code中有envsetup.sh檔案,當執行過此檔案後,可以大幅將build的過程簡單化、自動化

此檔案在src(android source code 位置)/build/中

所以可以執行以下指令
cd /src/build/

. envsetup.sh

可以使用help來檢示有哪些指令可以使用

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.
- hgrep:   Greps on all local C/C++ header files.
- jgrep:   Greps on all local Java files.
- mkgrep:  Greps on all local make files.
- rcgrep:  Greps on all local .rc files.
- resgrep: Greps on all local res/*.xml files.
- shgrep:  Greps on all local .sh files.
- godir:   Go to the directory containing a file.

其中對模組的編譯有輔助說明的是tapas、m、mm、mmm這幾個指令

其中mmm后面要跟模組的根目錄,不是所有的目錄下都有子模組,那些含有Android.mk檔案目錄才是模組的根目錄,模組名可以從Android.mk的LOCAL_MODULE或者LOCAL_PACKAGE_NAME變數中得到。

單獨編譯某模組,需要在mmm后面指定模組路徑,例如編譯external 中的jpeg

root@ubuntu:/home/android/src# mmm external/jpeg/
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
make: Entering directory `/home/android/src'
Target buildinfo: out/target/product/generic/root/default.prop
Target buildinfo: out/target/product/generic/system/build.prop
Copy: out/target/product/generic/system/etc/apns-conf.xml
make: Leaving directory `/home/android/src'
root@ubuntu:/home/android/src#


或者可用 mm 再欲編譯的模組目錄下執行
root@ubuntu:/home/android/src/external/jpeg# mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
make: Entering directory `/home/android/src'
Copy: out/target/product/generic/system/etc/apns-conf.xml
make: Leaving directory `/home/android/src'
root@ubuntu:/home/android/src/external/jpeg#


或者可用 m 編譯全部的模組
root@ubuntu:/home/android/src# m

你也可以在src目錄下直接執行make module name:

打開看 ./external/jpeg/Android.mk

看到裡面模組名稱為 libjpeg

LOCAL_MODULE:= libjpeg

這樣你就可以直接打模組名稱編譯

cd ~/android/src
make libjpeg

也可以在登入時自動執行此 script,編輯 ~/.bashrc 或其他 shell 的 rc 檔,加入此 script 即可

# invoke android envsetup.sh
source ~/android/build/envsetup.sh



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值