OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / ndk / build / tools / dev-generate-api-levels.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2010 The Android Open Source Project
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # This script is used to automatically generate the <android/api-level.h>
18 # header files under development/ndk
19
20 . `dirname $0`/prebuilt-common.sh
21
22 PLATFORMS_DIR=`cd $ANDROID_NDK_ROOT/../development/ndk/platforms && pwd`
23 if [ ! -d "$PLATFORMS_DIR" ] ; then
24     PLATFORMS_DIR=`cd $ANDROID_NDK_ROOT/platforms && pwd`
25 fi
26 register_var_option "--platform-dir=<path>" PLATFORMS_DIR "Specify target platforms directory."
27
28 APIS="$API_LEVELS"
29 register_var_option "--apis=<list>" APIS "Specify list of API levels."
30
31 if [ -z "$PLATFORMS_DIR" ] ; then
32     dump "ERROR: Please specify a platforms directory with --platform-dir=<path>"
33     exit 1
34 fi
35
36 if [ ! -d "$PLATFORMS_DIR" ] ; then
37     dump "ERROR: Your platforms directory does not exist: $PLATFORMS_DIR"
38     exit 1
39 fi
40
41 dump "Target directory: $PLATFORMS_DIR"
42
43 for API in $APIS; do
44     if [ ! -d "$PLATFORMS_DIR/android-$API" ] ; then
45         dump "ERROR: Missing platform directory: $PLATFORMS_DIR/android-$DIR"
46         exit 1
47     fi
48     HEADER="android-$API/include/android/api-level.h"
49     dump "Generating: $HEADER"
50     cat > "$PLATFORMS_DIR/$HEADER" <<EOF
51 /*
52  * Copyright (C) 2008 The Android Open Source Project
53  * All rights reserved.
54  *
55  * Redistribution and use in source and binary forms, with or without
56  * modification, are permitted provided that the following conditions
57  * are met:
58  *  * Redistributions of source code must retain the above copyright
59  *    notice, this list of conditions and the following disclaimer.
60  *  * Redistributions in binary form must reproduce the above copyright
61  *    notice, this list of conditions and the following disclaimer in
62  *    the documentation and/or other materials provided with the
63  *    distribution.
64  *
65  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
66  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
67  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
68  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
69  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
70  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
71  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
72  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
73  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
74  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
75  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
76  * SUCH DAMAGE.
77  */
78 #ifndef ANDROID_API_LEVEL_H
79 #define ANDROID_API_LEVEL_H
80
81 #define __ANDROID_API__ $API
82
83 #endif /* ANDROID_API_LEVEL_H */
84 EOF
85 done
86