1# Copyright (C) 2009 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15# A nawk/gawk script used to extract the application's platform name from
16# its project.properties file. It is called from build/core/add-application.mk
17#
18
19# we look for a line that looks like one of:
20#    target=android-<api>
21#    target=<vendor>:<name>:<api>
22#
23# <api> is a number, but can also be "Donut" for the first form,
24# as a special case.
25#
26BEGIN {
27    android_regex="android-[0-9A-Za-z_-]+"
28    vendor_regex=":[0-9]+\\s*$"
29    API=unknown
30}
31
32/^target\s*=\s*.*/ {
33    if (match($0,android_regex)) {
34        API=substr($0,RSTART,RLENGTH)
35    }
36    else if (match($0,vendor_regex)) {
37        API="android-" substr($0,RSTART+1,RLENGTH)
38    }
39}
40
41END {
42    printf("%s", API)
43}
44