Commit | Line | Data |
---|---|---|
aa41282e RSA |
1 | #! /bin/sh |
2 | # | |
3 | # Original script available in the libhybris project: | |
4 | # https://github.com/libhybris/libhybris/blob/master/utils/extract-headers.sh | |
5 | # | |
6 | ||
7 | ANDROID_ROOT=$1 | |
8 | HEADERPATH=$2 | |
9 | MAJOR=$3 | |
10 | MINOR=$4 | |
11 | ||
12 | PATCH=$5 | |
13 | PATCH2=$6 | |
14 | PATCH3=$7 | |
15 | ||
16 | if [ x$ANDROID_ROOT = x -o "x$HEADERPATH" = x ]; then | |
17 | echo "Syntax: extract-headers.sh ANDROID_ROOT HEADERPATH [MAJOR] [MINOR] [PATCH] [PATCH2] [PATCH3]" | |
18 | exit 1 | |
19 | fi | |
20 | ||
21 | ||
22 | if [ x$MAJOR = x -o x$MINOR = x -o x$PATCH = x ]; then | |
23 | VERSION_DEFAULTS=$ANDROID_ROOT/build/core/version_defaults.mk | |
24 | ||
25 | parse_defaults_failed() { | |
26 | echo "Error: Cannot read PLATFORM_VERSION from ${VERSION_DEFAULTS}." | |
27 | echo "Please specify MAJOR, MINOR and PATCH manually to continue." | |
28 | exit 1 | |
29 | } | |
30 | ||
31 | if [ ! -f $VERSION_DEFAULTS ]; then | |
32 | parse_defaults_failed | |
33 | fi | |
34 | ||
35 | PLATFORM_VERSION=$(egrep -o "PLATFORM_VERSION := [0-9.]+" $VERSION_DEFAULTS | awk '{ print $3 }') | |
36 | if [ x$PLATFORM_VERSION = x ]; then | |
37 | parse_defaults_failed | |
38 | fi | |
39 | ||
40 | MAJOR=$(echo $PLATFORM_VERSION | cut -d. -f1) | |
41 | MINOR=$(echo $PLATFORM_VERSION | cut -d. -f2) | |
42 | PATCH=$(echo $PLATFORM_VERSION | cut -d. -f3) | |
43 | PATCH2=$(echo $PLATFORM_VERSION | cut -d. -f4) | |
44 | PATCH3=$(echo $PLATFORM_VERSION | cut -d. -f5) | |
45 | ||
46 | if [ x$MAJOR = x -o x$MINOR = x -o x$PATCH = x ]; then | |
47 | parse_defaults_failed | |
48 | fi | |
49 | ||
50 | echo -n "Auto-detected version: ${MAJOR}.${MINOR}.${PATCH}" | |
51 | if [ x$PATCH3 != x ]; then | |
52 | echo ".${PATCH2}.${PATCH3}" | |
53 | elif [ x$PATCH2 != x ]; then | |
54 | echo ".${PATCH2}" | |
55 | else | |
56 | echo "" | |
57 | fi | |
58 | fi | |
59 | ||
60 | # Make sure that the dir given contains at least some of the assumed structures. | |
61 | if [ ! -d "$ANDROID_ROOT/hardware/libhardware/include/hardware/" ]; then | |
62 | echo "Given Android root dir '$ANDROID_ROOT/hardware/libhardware/include/hardware/' doesn't exist." | |
63 | exit 1 | |
64 | fi | |
65 | ||
66 | mkdir -p $HEADERPATH | |
67 | ||
68 | if [ x$PATCH2 = x ]; then | |
69 | PATCH2=0 | |
70 | fi | |
71 | ||
72 | if [ x$PATCH3 = x ]; then | |
73 | PATCH3=0 | |
74 | fi | |
75 | ||
76 | cat > $HEADERPATH/android-version.h << EOF | |
77 | #ifndef ANDROID_VERSION_H_ | |
78 | #define ANDROID_VERSION_H_ | |
79 | ||
80 | #define ANDROID_VERSION_MAJOR $MAJOR | |
81 | #define ANDROID_VERSION_MINOR $MINOR | |
82 | #define ANDROID_VERSION_PATCH $PATCH | |
83 | #define ANDROID_VERSION_PATCH2 $PATCH2 | |
84 | #define ANDROID_VERSION_PATCH3 $PATCH3 | |
85 | ||
86 | #endif | |
87 | EOF | |
88 | ||
89 | mkdir -p $HEADERPATH/hardware/ | |
90 | cp $ANDROID_ROOT/hardware/libhardware/include/hardware/* $HEADERPATH/hardware/ | |
91 | ||
92 | mkdir -p $HEADERPATH/hardware_legacy/ | |
93 | cp $ANDROID_ROOT/hardware/libhardware_legacy/include/hardware_legacy/audio_policy_conf.h $HEADERPATH/hardware_legacy/ | |
94 | ||
95 | mkdir -p $HEADERPATH/cutils/ | |
96 | cp $ANDROID_ROOT/system/core/include/cutils/* $HEADERPATH/cutils/ | |
97 | ||
98 | mkdir -p $HEADERPATH/system/ | |
99 | cp $ANDROID_ROOT/system/core/include/system/* $HEADERPATH/system/ | |
100 | ||
101 | mkdir -p $HEADERPATH/android/ | |
102 | cp $ANDROID_ROOT/system/core/include/android/* $HEADERPATH/android/ | |
103 | ||
104 | if [ -e $ANDROID_ROOT/external/kernel-headers/original/linux/sync.h ]; then | |
105 | mkdir -p $HEADERPATH/linux | |
106 | cp $ANDROID_ROOT/external/kernel-headers/original/linux/sync.h $HEADERPATH/linux | |
107 | cp $ANDROID_ROOT/external/kernel-headers/original/linux/sw_sync.h $HEADERPATH/linux | |
108 | fi | |
109 | ||
110 | if [ -e $ANDROID_ROOT/system/core/include/sync/sync.h ]; then | |
111 | mkdir -p $HEADERPATH/sync/ | |
112 | cp $ANDROID_ROOT/system/core/include/sync/* $HEADERPATH/sync/ | |
113 | fi | |
114 | ||
115 | if [ -e $ANDROID_ROOT/external/libnfc-nxp/inc/phNfcConfig.h ]; then | |
116 | mkdir -p $HEADERPATH/libnfc-nxp/ | |
117 | cp $ANDROID_ROOT/external/libnfc-nxp/inc/*.h $HEADERPATH/libnfc-nxp/ | |
118 | cp $ANDROID_ROOT/external/libnfc-nxp/src/*.h $HEADERPATH/libnfc-nxp/ | |
119 | fi | |
120 | ||
121 | mkdir -p $HEADERPATH/private | |
122 | cp $ANDROID_ROOT/system/core/include/private/android_filesystem_config.h $HEADERPATH/private | |
123 | ||
124 | exit 0 |