• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2010 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
16# This script is used to convert a dependency file generated by a cygwin-less
17# GCC compiler program into something that can be parsed into a cygwin-based
18# GNU Make program.
19#
20# More specifically, it's going to translate stuff like:
21#
22# D:/Stuff/source.o: \
23#  D:/Stuff/source.h \
24#  C:/NDK/sysroot/include/string.h \
25#  C:/NDK/sysroot/include/malloc.h
26#
27# into
28#
29# /cygdrive/d/Stuff/source.o: \
30#  /cygdrive/d/Stuff/source.h \
31#  /cygdrive/c/NDK/sysroot/include/string.h \
32#  /cygdrive/c/NDK/sysroot/include/malloc.h
33#
34
35BEGIN {
36    # TODO: We could determine this dynamically before calling this script
37    CYGDRIVE_PREFIX = "/cygdrive/"
38}
39
40{
41    LINE=""
42    SEP=""
43    for (nn = 1; nn <= NF; nn++) {
44        if ($nn ~ /^[A-Za-z]:/) {
45            LINE = LINE SEP CYGDRIVE_PREFIX tolower(substr($nn,1,1)) "/" substr($nn,4)
46        } else {
47            LINE = LINE SEP $nn
48        }
49        SEP=" "
50    }
51    # Any leading space on the original line should be preserved
52    MARGIN=""
53    if (match($0,"^[[:space:]]+")) {
54        MARGIN=substr($0,RSTART,RLENGTH)
55    }
56    printf("%s%s\n", MARGIN, LINE)
57}
58