12 if [ x
$ANDROID_ROOT = x
-o "x$HEADERPATH" = x
]; then
13 echo "Syntax: extract-headers.sh ANDROID_ROOT HEADERPATH [MAJOR] [MINOR] [PATCH] [PATCH2] [PATCH3]"
18 if [ x
$MAJOR = x
-o x
$MINOR = x
-o x
$PATCH = x
]; then
19 VERSION_DEFAULTS
=$ANDROID_ROOT/build
/core
/version_defaults.mk
21 parse_defaults_failed
() {
22 echo "Error: Cannot read PLATFORM_VERSION from ${VERSION_DEFAULTS}."
23 echo "Please specify MAJOR, MINOR and PATCH manually to continue."
27 if [ ! -f $VERSION_DEFAULTS ]; then
31 PLATFORM_VERSION
=$
(egrep -o "PLATFORM_VERSION := [0-9.]+" $VERSION_DEFAULTS |
awk '{ print $3 }')
32 if [ x
$PLATFORM_VERSION = x
]; then
36 MAJOR
=$
(echo $PLATFORM_VERSION | cut
-d.
-f1)
37 MINOR
=$
(echo $PLATFORM_VERSION | cut
-d.
-f2)
38 PATCH
=$
(echo $PLATFORM_VERSION | cut
-d.
-f3)
39 PATCH2
=$
(echo $PLATFORM_VERSION | cut
-d.
-f4)
40 PATCH3
=$
(echo $PLATFORM_VERSION | cut
-d.
-f5)
42 if [ x
$MAJOR = x
-o x
$MINOR = x
-o x
$PATCH = x
]; then
46 echo -n "Auto-detected version: ${MAJOR}.${MINOR}.${PATCH}"
47 if [ x
$PATCH3 != x
]; then
48 echo ".${PATCH2}.${PATCH3}"
49 elif [ x
$PATCH2 != x
]; then
57 # require_sources [FILE|DIR] ...
58 # Check if the given paths exist in the Android source
59 while [ $# -gt 0 ]; do
60 SOURCE_PATH
=$ANDROID_ROOT/$1
63 if [ ! -e "$SOURCE_PATH" ]; then
64 echo "Cannot extract headers: '$SOURCE_PATH' does not exist."
70 extract_headers_to
() {
71 # extract_headers_to <TARGET> [FILE|DIR] ...
72 # For each FILE argument, copy it to TARGET
73 # For each DIR argument, copy all its contents to TARGET
74 TARGET_DIRECTORY
=$HEADERPATH/$1
75 if [ ! -d "$TARGET_DIRECTORY" ]; then
76 mkdir
-p "$TARGET_DIRECTORY"
81 while [ $# -gt 0 ]; do
82 SOURCE_PATH
=$ANDROID_ROOT/$1
83 if [ -d $SOURCE_PATH ]; then
84 for file in $SOURCE_PATH/*; do
85 echo " $1/$(basename $file)"
86 cp $file $TARGET_DIRECTORY/
90 cp $SOURCE_PATH $TARGET_DIRECTORY/
96 check_header_exists
() {
97 # check_header_exists <FILENAME>
98 HEADER_FILE
=$ANDROID_ROOT/$1
99 if [ ! -e "$HEADER_FILE" ]; then
107 # Make sure that the dir given contains at least some of the assumed structures.
109 hardware
/libhardware
/include
/hardware
113 if [ x
$PATCH2 = x
]; then
117 if [ x
$PATCH3 = x
]; then
121 cat > $HEADERPATH/android-version.h
<< EOF
122 #ifndef ANDROID_VERSION_H_
123 #define ANDROID_VERSION_H_
125 #define ANDROID_VERSION_MAJOR $MAJOR
126 #define ANDROID_VERSION_MINOR $MINOR
127 #define ANDROID_VERSION_PATCH $PATCH
128 #define ANDROID_VERSION_PATCH2 $PATCH2
129 #define ANDROID_VERSION_PATCH3 $PATCH3
134 extract_headers_to hardware \
135 hardware
/libhardware
/include
/hardware
137 extract_headers_to hardware_legacy \
138 hardware
/libhardware_legacy
/include
/hardware_legacy
/audio_policy_conf.h
140 extract_headers_to cutils \
141 system
/core
/include
/cutils
143 extract_headers_to system \
144 system
/core
/include
/system
146 extract_headers_to android \
147 system
/core
/include
/android
149 check_header_exists external
/kernel-headers
/original
/linux
/sync.h
&& \
150 extract_headers_to linux \
151 external
/kernel-headers
/original
/linux
/sync.h \
152 external
/kernel-headers
/original
/linux
/sw_sync.h
154 check_header_exists system
/core
/include
/sync
/sync.h
&& \
155 extract_headers_to sync \
156 system
/core
/include
/sync
158 check_header_exists external
/libnfc-nxp
/inc
/phNfcConfig.h
&& \
159 extract_headers_to libnfc-nxp \
160 external
/libnfc-nxp
/inc \
161 external
/libnfc-nxp
/src
163 extract_headers_to private \
164 system
/core
/include
/private
/android_filesystem_config.h
167 # In order to make it easier to trace back the origins of headers, fetch
168 # some repository information from the Git source tree (if available).
169 # Tested with AOSP and CM.
172 # Add here all sub-projects of AOSP/CM from which headers are extracted
175 hardware/libhardware_legacy
177 external/kernel-headers
181 echo "Extracting Git revision information"
182 rm -f $HEADERPATH/SOURCE_GIT_REVISION_INFO
183 (for GIT_PROJECT
in $GIT_PROJECTS; do
184 TARGET_DIR
=$ANDROID_ROOT/$GIT_PROJECT
185 echo "================================================"
186 echo "$GIT_PROJECT @ $NOW"
187 echo "================================================"
188 if [ -e $TARGET_DIR/.git
]; then
192 repo status
$GIT_PROJECT
200 echo "WARNING: $GIT_PROJECT does not contain a Git repository"
202 done) > $HEADERPATH/git-revisions.txt
2>&1
204 # Repo manifest that can be used to fetch the sources for re-extracting headers
205 if [ -e $ANDROID_ROOT/.repo
/manifest.xml
]; then
206 cp $ANDROID_ROOT/.repo
/manifest.xml
$HEADERPATH/