Debian Codegraph @

tests/manual/mkspecs/test.sh

raw
1 #!/bin/bash
2 # Copyright (C) 2016 The Qt Company Ltd.
3 # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
4
5
6 if [ "$1" == "--help" ]; then
7 echo "Init a clean git repository somewhere and run this test script from that directory. The first run will"
8 echo "produce a bunch of specs. This is your baseline. Run 'git add specs' and commit the baseline. Then run"
9 echo "this script again, after making changes to the mkspecs. You should see any diffs you produced."
10 exit 0
11 fi
12
13
14 QMAKE_ARGS="-nocache -d"
15 SPECS_DIR=$(qmake -query QMAKE_MKSPECS)
16 SPECS=$(find -L $SPECS_DIR | grep "qmake.conf" | grep -Ev "common|default" | grep "$1")
17
18 SEDI="sed -i"
19 if [ $(uname) == "Darwin" ]; then
20 # Mac OS X requires an extension, Linux will barf on it being present
21 SEDI='sed -i .backup'
22 fi
23
24 if [ ! -d tmp ]; then
25 mkdir tmp
26 touch tmp/empty.pro
27 fi
28
29 if [ ! -d specs ]; then
30 mkdir specs
31 fi
32
33 git checkout -- specs > /dev/null 2>&1
34
35 cd tmp
36 for spec in $SPECS; do
37 spec=$(echo $spec | sed "s|$SPECS_DIR/||" | sed "s|/qmake.conf||")
38 output_file=$(echo "$spec.txt" | sed "s|/|-|g")
39 echo "Dumping qmake variables for spec '$spec' to 'specs/$output_file'..."
40 qmake $QMAKE_ARGS -spec $spec empty.pro 2>&1 |
41 sed -n '/Dumping all variables/,$p' |
42 grep -Ev "(QMAKE_INTERNAL_INCLUDED_FILES|DISTFILES) ===" > ../specs/$output_file
43
44 if [ -n $QTDIR ]; then
45 $SEDI "s|$QTDIR|\$QTDIR|g" ../specs/$output_file
46 fi
47
48 if [ -n $QTSRCDIR ]; then
49 $SEDI "s|$QTSRCDIR|\$QTDIR|g" ../specs/$output_file
50 fi
51 done
52 cd ..
53
54 rm -f specs/*.backup
55
56 git diff --exit-code -- specs > /dev/null
57 exit_code=$?
58
59 if [ $exit_code -eq 0 ]; then
60 echo -e "\nNo diff produced (you did good)"
61 else
62 # Show the resulting diff
63 git diff -- specs
64 fi
65
66 exit $exit_code
67