File: headers_test.sh

package info (click to toggle)
kdb 3.2.0-9.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,284 kB
  • sloc: cpp: 38,360; yacc: 940; python: 779; sh: 711; ansic: 440; lex: 367; xml: 182; sql: 51; makefile: 10
file content (122 lines) | stat: -rwxr-xr-x 2,990 bytes parent folder | download | duplicates (4)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
#
# Generates a full project for a HeadersTest app.
# This is a compile-time test checking if all the installed headers can be included individually.
#
# Example for KDb:
# % ./headers_test.sh ~/kde/build/kdb ~/kde/src/kdb KDb kdb .
#
# It is assumed that this script is executed from the current build subdirectory.
# Source dir goes to the app/ subdirectory, build dir goes to the app-build subdirectory.
# Nothing is cached, both dirs are fully recreated on each run.

set -e
builddir="$1"
current_builddir="`pwd`"
shift
srcdir="$1"

if [ ! -d "$builddir" -o ! -d "$srcdir" -o $# -lt 4 ] ; then
    echo "Usage: $me <project_binary_dir> <project_source_dir> <libraries_to_link> <project_name_prefix> <subdirs_to_find>..."
    exit 1
fi

test_app_dir="$current_builddir/app"
rm -rf "$test_app_dir"
mkdir -p "$test_app_dir"

test_app_builddir="$current_builddir/app-build"
rm -rf "$test_app_builddir"
mkdir -p "$test_app_builddir"

me=headers_test.sh
current_srcdir="`dirname \"$0\"`"

shift
link_libs="$1"
shift
prefix="$1"
shift

cd "$srcdir"

cat <<EOT > "$test_app_dir/CMakeLists.txt"
# Generated by $current_srcdir/$me
# prefix: $prefix
# link_libs: $link_libs
# subdirs: $@
#
# WARNING! All changes made in this file will be lost!
#
# Test if all the installed headers can be included individually.
# This is a compile-time test.

cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
find_package(ECM 1.8.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "$current_srcdir" "$srcdir/cmake/modules" \${ECM_MODULE_PATH} \${ECM_KDE_MODULE_DIR})

project(HeadersTest)
include(HeadersTestInclude NO_POLICY_SCOPE)

add_executable(
    HeadersTest
    HeadersTest.cpp
EOT

cat <<EOT > "$test_app_dir/HeadersTest.cpp"
// Generated by $me
// WARNING! All changes made in this file will be lost!

// Nothing to do here
int main(int, char**)
{
    return 0;
}
EOT

manifest=$builddir/install_manifest.txt

find_headers()
{
    for f in $(grep -E "/include/.*/[[:alpha:]]+\.h$" "$manifest") ; do
        basename $f
    done
}

find_forwarding_headers()
{
    for f in $(grep -E "/include/.*/[[:alpha:]]+$" "$manifest") ; do
        if grep -Eq "^#include \"[[:alpha:]]+\.h\"$" $f ; then
            basename $f
        fi
    done
}

for f in $(find_forwarding_headers; find_headers | sort); do
    fname=${f}_HeaderTest.cpp
    echo "#include <$f>" > $test_app_dir/$fname
    echo "    $fname" >> $test_app_dir/CMakeLists.txt
done

cat <<EOT >> "$test_app_dir/CMakeLists.txt"
)

target_link_libraries(HeadersTest
    PUBLIC
        $link_libs
)

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
EOT

# Finally, build:
cd "$test_app_builddir"

CXXCOMPILER=`cmake -LA ../../.. | grep CMAKE_CXX_COMPILER || true`
if [ -n "$CXXCOMPILER" ] ; then CXXCOMPILER=-D$CXXCOMPILER ; fi
CCOMPILER=`cmake -LA ../../.. | grep CMAKE_C_COMPILER || true`
if [ -n "$CCOMPILER" ] ; then CCOMPILER=-D$CCOMPILER ; fi

echo cmake $CXXCOMPILER $CCOMPILER ../app
cmake $CXXCOMPILER $CCOMPILER ../app
make