File tree 1 file changed +63
-0
lines changed
1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -eu
4
+ set -o pipefail
5
+
6
+ cpp=" /tmp/alignment.cpp"
7
+ app=" /tmp/alignment"
8
+
9
+ function usage() {
10
+ echo " Usage:"
11
+ echo " "
12
+ echo " ./scripts/rebuild.sh [header] [class name]"
13
+ echo " "
14
+ echo " Please pass a header file and a class name"
15
+ echo " "
16
+ echo " ./scripts/check-padding include/mapnik/attribute.hpp mapnik::attribute"
17
+ echo " "
18
+ exit 1
19
+
20
+ }
21
+
22
+ function add() {
23
+ echo $1 >> ${cpp}
24
+ }
25
+
26
+ CXX=${CXX:- clang++}
27
+
28
+ function compile() {
29
+ ${CXX} -o ${app} ${cpp} -Wpadded -I./ -isystem ./mason_packages/.link/include ` mapnik-config --all-flags` -Ideps -Lsrc -Ideps/agg/include -Iinclude
30
+ }
31
+
32
+ if [[ ${1:- unset} == " unset" ]] || [[ ${2:- unset} == " unset" ]] || [[ $@ == ' -h' ]] || [[ $@ == ' --help' ]]; then
33
+ usage
34
+ fi
35
+
36
+ echo ' ' > ${cpp}
37
+
38
+ add " #include <iostream>"
39
+ add " #include <vector>"
40
+
41
+ add " #include \" $1 \" "
42
+
43
+ add " "
44
+
45
+ add ' #define REPORT(type) std::clog << "sizeof(" #type ") " << sizeof(type) << "\n";'
46
+
47
+ add " int main() {"
48
+ add " "
49
+
50
+ add " REPORT(std::string)"
51
+ add " REPORT(unsigned int)"
52
+ add " REPORT(int)"
53
+ add " REPORT(bool)"
54
+ add " REPORT(std::vector<double>)"
55
+ add " REPORT(std::size_t)"
56
+
57
+ add " REPORT($2 )"
58
+
59
+ add " return 0;"
60
+ add " }"
61
+
62
+ compile
63
+ ${app}
You can’t perform that action at this time.
0 commit comments