File: check-padding

package info (click to toggle)
mapnik 3.0.12%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 17,084 kB
  • ctags: 18,454
  • sloc: cpp: 142,516; python: 1,416; sh: 769; makefile: 170; xml: 140; lisp: 13
file content (63 lines) | stat: -rwxr-xr-x 1,177 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
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
#!/usr/bin/env bash

set -eu
set -o pipefail

cpp="/tmp/alignment.cpp"
app="/tmp/alignment"

function usage() {
    echo "Usage:"
    echo ""
    echo "./scripts/rebuild.sh [header] [class name]"
    echo ""
    echo "Please pass a header file and a class name"
    echo ""
    echo "    ./scripts/check-padding include/mapnik/attribute.hpp mapnik::attribute"
    echo ""
    exit 1

}

function add() {
    echo $1 >> ${cpp}
}

CXX=${CXX:-clang++}

function compile() {
    ${CXX} -o ${app} ${cpp} -Wpadded -I./ -isystem ./mason_packages/.link/include `mapnik-config --all-flags` -Ideps -Lsrc -Ideps/agg/include -Iinclude
}

if [[ ${1:-unset} == "unset" ]] || [[ ${2:-unset} == "unset" ]] || [[ $@ == '-h' ]] || [[ $@ == '--help' ]]; then
    usage
fi

echo '' > ${cpp}

add "#include <iostream>"
add "#include <vector>"

add "#include \"$1\""

add ""

add '#define REPORT(type) std::clog << "sizeof(" #type ") " << sizeof(type) << "\n";'

add "int main() {"
add ""

add "REPORT(std::string)"
add "REPORT(unsigned int)"
add "REPORT(int)"
add "REPORT(bool)"
add "REPORT(std::vector<double>)"
add "REPORT(std::size_t)"

add "REPORT($2)"

add "return 0;"
add "}"

compile
${app}