Android envsetup 环境设置

Androidenvsetup环境设置


Android源码根目录

androidroot




为了更好、更快、更便捷的学习或开发Android系统,我有必要先熟练掌握跟源代码相关的工具,它们可以在任意目录下编译系统,编译当前目录下所有模块,编译指定目录下所有模块,快速返回androidroot目录,在多种或一种文件中查找指定字符串。要想使用这些工具,我首先需要将androidenvsetup脚本加载到工作环境中。具体加载方法如下:

1envsetup.sh脚本文件在androidroot/build目录下

eg:

drjiang@drjiangISS:~/work/android/code/android4.0/build$ls -l envsetup.sh

-rwxrwxr-x1 drjiang drjiang 28590 1115 2011 envsetup.sh

2.加载方法

执行命令:source./build/envsetup.sh.build/envsetup.sh

eg:

drjiang@drjiangISS:~/work/android/code/android4.0$source ./build/envsetup.sh

includingdevice/samsung/maguro/vendorsetup.sh

includingdevice/samsung/tuna/vendorsetup.sh

includingdevice/ti/panda/vendorsetup.sh

includingsdk/bash_completion/adb.bash

3.通过help命令,我就可以看到有很多工具。

drjiang@drjiangISS:~/work/android/code/android4.0$help

Invoke". build/envsetup.sh" from your shell to add the followingfunctions 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.

Lookat the source to view more functions. The complete list is:

addcompletionsadd_lunch_combo cgrep check_product check_variant choosecombochooseproduct choosetype choosevariant cproj croot findmakefilegdbclient get_abs_build_var getbugreports get_build_var getprebuiltgettop godir help isviewserverstarted jgrep key_back key_homekey_menu lunch _lunch m mm mmm pid printconfig print_lunch_menuresgrep runhat runtest set_java_home setpaths set_sequence_numberset_stuff_for_environment settitle smoketest startviewserverstopviewserver systemstack tapas tracedmdump


4.我常用到的工具大概分类(编译相关和字符串查找)

1、编译

1m

相当于在 当前 androidroot 目录 下执行make 命令。 可以在目录树任意目录下执行。
eg:
drjiang@drjiangISS:~/work/android/code/android4.0/cts$m
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ITL41D
============================================

2 mm
编译当前目录下所有模块
eg:
drjiang@drjiangISS:~/work/android/code/android4.0/cts$mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ITL41D
============================================

3 mmm
编译指定的目录下所有模块, 必须使用相对目录。
eg:
drjiang@drjiangISS:~/work/android/code/android4.0/packages/apps/C alendar/src/com$ mmm ../../../Camera
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ITL41D
============================================

4 croot
目录树内任意目录,执行该命令,可以返回 androidroot 目录。
eg:
drjiang@drjiangISS:~/work/android/code/android4.0/out/target$croot
drjiang@drjiangISS:~/work/android/code/android4.0$

5 findmakefile
查找当前或最接近自己的祖辈路径上的Android.mk,返回Android.mk的路径。
eg
drjiang@drjiangISS:~/work/android/code/android4.0/packages/apps/Calendar/src/com$findmakefile
/home/drjiang/work/android/code/android4.0/packages/apps/Calendar/Android.mk
2 、在文件查找字符串
1 cgrep
在当前目录及其子目录下的C/C++ 文件中,查找指定的字符串。
eg:
drjiang@drjiangISS:~/work/android/code/android4.0/frameworks$cgrep stdlib
./base/drm/libdrmframework/plugins/forward-lock/internal-format/common/FwdLockGlue.c:21:#include
./base/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.c:22:#include
./base/drm/common/ReadWriteUtils.cpp:27:#include
./base/libs/ui/GraphicLog.cpp:18:#include
./base/libs/ui/FramebufferNativeWindow.cpp:20:#include
./base/libs/ui/VirtualKeyMap.cpp:19:#include
./base/libs/ui/KeyLayoutMap.cpp:19:#include
./base/libs/ui/Input.cpp:23:#include
./base/libs/ui/Keyboard.cpp:19:#include
./base/libs/ui/KeyCharacterMap.cpp:19:#include
2 jgrep
在当前目录及其子目录下的 java 文件中,查找指定的字符串。
eg:
drjiang@drjiangISS:~/work/android/code/android4.0/frameworks/base/core/java/android/app$jgrep android.view.View
./Dialog.java:42:importandroid.view.View;
./Dialog.java:43:importandroid.view.View.OnCreateContextMenuListener;
./Dialog.java:44:importandroid.view.ViewGroup;
./Dialog.java:45:importandroid.view.ViewGroup.LayoutParams;
./ActionBar.java:24:importandroid.view.View;
./ActionBar.java:25:importandroid.view.ViewDebug;
./ActionBar.java:26:importandroid.view.ViewGroup;
./ActionBar.java:27:importandroid.view.ViewGroup.MarginLayoutParams;
./TimePickerDialog.java:26:importandroid.view.View;

3 resgrep
在当前目录及其子目录下的 res/*.xml 文件中,查找指定的字符串。
eg
drjiang@drjiangISS:~/work/android/code/android4.0/packages$resgrep xmlns:android
./wallpapers/Basic/res/values-bg/strings.xml:20:
./wallpapers/Basic/res/values-rm/strings.xml:20:
./wallpapers/Basic/res/xml/grass.xml:23:
./wallpapers/Basic/res/xml/polar_clock_prefs.xml:17:
./wallpapers/Basic/res/xml/galaxy.xml:23:


4 mgrep
在当前目录及其子目录下的 res/*.xml 文件中,查找指定的字符串。
eg
drjiang@drjiangISS:~/work/android/code/android4.0/packages$mgrep LOCAL_PATH
./wallpapers/Basic/Android.mk:17:LOCAL_PATH:= $(call my-dir)
./wallpapers/PhaseBeam/Android.mk:17:LOCAL_PATH:= $(call my-dir)
./wallpapers/HoloSpiral/Android.mk:17:LOCAL_PATH:= $(call my-dir)
./wallpapers/MagicSmoke/Android.mk:17:LOCAL_PATH:= $(call my-dir)
./wallpapers/LivePicker/Android.mk:17:LOCAL_PATH:= $(call my-dir)
./wallpapers/MusicVisualization/Android.mk:17:LOCAL_PATH:= $(call my-dir)
./wallpapers/Galaxy4/Android.mk:17:LOCAL_PATH:= $(call my-dir)
./wallpapers/NoiseField/Android.mk:17:LOCAL_PATH:= $(call my-dir)
./providers/TelephonyProvider/Android.mk:1:LOCAL_PATH:=$(call my-dir)
./providers/DownloadProvider/ui/Android.mk:1:LOCAL_PATH:=$(call my-dir)
./providers/DownloadProvider/tests/permission/Android.mk:1:

5sgrep

查找当前目录及子目录中所有.c.h.cpp.S.java.mk.xml.sh文件

eg:

drjiang@drjiangISS:~/work/android/code/android4.0/packages/apps/Calendar/src/com$sgrep Calendar

./android/calendar/EventInfoFragment.java:19:importstatic android.provider.CalendarContract.EXTRA_EVENT_BEGIN_TIME;

./android/calendar/EventInfoFragment.java:20:importstatic android.provider.CalendarContract.EXTRA_EVENT_END_TIME;

./android/calendar/EventInfoFragment.java:21:importstatic com.android.calendar.CalendarController.EVENT_EDIT_ON_LAUNCH;

./android/calendar/EventInfoFragment.java:23:importcom.android.calendar.CalendarController.EventInfo;

./android/calendar/EventInfoFragment.java:24:importcom.android.calendar.CalendarController.EventType;

./android/calendar/EventInfoFragment.java:25:importcom.android.calendar.CalendarEventModel.Attendee;

./android/calendar/EventInfoFragment.java:26:importcom.android.calendar.CalendarEventModel.ReminderEntry;

./android/calendar/EventInfoFragment.java:53:importandroid.provider.CalendarContract;

./android/calendar/EventInfoFragment.java:54:importandroid.provider.CalendarContract.Attendees;

./android/calendar/EventInfoFragment.java:55:importandroid.provider.CalendarContract.Calendars;

./android/calendar/EventInfoFragment.java:56:importandroid.provider.CalendarContract.Events;

./android/calendar/EventInfoFragment.java:57:importandroid.provider.CalendarContract.Reminders;

./android/calendar/EventInfoFragment.java:115: CalendarController.EventHandler, OnClickListener {

./android/calendar/EventInfoFragment.java:157: Calendars.CALENDAR_ACCESS_LEVEL, // 10

./android/calendar/EventInfoFragment.java:158: Calendars.CALENDAR_COLOR, // 11

./android/calendar/EventInfoFragment.java:162: Calendars.MAX_REMINDERS, //15

./android/calendar/EventInfoFragment.java:163: Calendars.ALLOWED_REMINDERS, //

你可能感兴趣的:(android)