File: gen-qt-priv-mod-includes.sh

package info (click to toggle)
ciborium 1.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,928 kB
  • sloc: cpp: 2,199; sh: 75; makefile: 20
file content (36 lines) | stat: -rw-r--r-- 957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

qt_priv_cppflags () {
    version="$(pkg-config --modversion "$1")"
    set -- $(pkg-config --cflags-only-I "$1")
    for flag; do
        path="${flag#-I}"
        path="${path%/}"
        [ -d "${path}/${version}" ] || continue
        printf ' -isystem %s' "${path}/${version}"
        [ -d "${path}/${version}/${path##*/}" ] || continue
        printf ' -isystem %s' "${path}/${version}/${path##*/}"
    done
}

args="$0 $*"
[ $# -ge 2 ] || exit 1
src="$1"
dest="$2"
shift 2
all_flags=""
for pkg; do
    all_flags="${all_flags} $(qt_priv_cppflags "${pkg}")"
done

printf "// Code generated by \"%s\"; DO NOT EDIT.\n" "${args}" > "${dest}"
while read -r line; do
    set -- $line
    if [ "$1" = "//" ] && [ "$2" = "#cgo" ]; then
        if [ "$3" = "CPPFLAGS:" ] || [ "$4" = "CPPFLAGS:" ]; then
            printf "%s%s\n" "${line}" "${all_flags}"
            continue
        fi
    fi
    printf "%s\n" "${line}"
done <"${src}" >>"${dest}"