forked from capnramses/pro_programming_tools_c_cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_all_gcc.sh
executable file
·146 lines (113 loc) · 3 KB
/
build_all_gcc.sh
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# Author: Anton Gerdelan
# Folders with deliberate errors have builds commented out so that this script can be used for CI checks.
# any error code causes script to exit with error code
set -e
# echo everything
set -x
echo on
CC=gcc
CPP=g++
FLAGS="-Wall -Wextra -Werror -pedantic -fsanitize=address -fsanitize=undefined"
echo "cd ch00_00_c/"
cd ch00_00_c/
$CC $FLAGS main.c
echo "cd ../ch00_01_cpp_malloc/"
cd ../ch00_01_cpp_malloc/
$CPP $FLAGS main.cpp
echo "cd ../ch00_02_cpp_new_delete/"
cd ../ch00_02_cpp_new_delete/
$CPP $FLAGS main.cpp
echo "cd ../ch01_00_assertions/"
cd ../ch01_00_assertions/
$CC $FLAGS main.c
echo "cd ../ch01_01_unit_test/"
cd ../ch01_01_unit_test/
$CC $FLAGS main.c
echo "cd ../ch02_00_image_output/"
cd ../ch02_00_image_output/
$CC $FLAGS main.c
echo "cd ../ch02_01_image_pixel_functions/"
cd ../ch02_01_image_pixel_functions/
$CC $FLAGS main.c
echo "cd ../ch02_02_image_write_chart/"
cd ../ch02_02_image_write_chart/
$CC $FLAGS main.c image.c
echo "cd ../ch03_00_read_binary/"
cd ../ch03_00_read_binary/
$CC $FLAGS main.c
echo "cd ../ch03_01_read_write_ppm_binary/"
cd ../ch03_01_read_write_ppm_binary/
$CC $FLAGS main.c
echo "cd ../ch03_02_read_entire_file/"
cd ../ch03_02_read_entire_file/
$CC $FLAGS main.c
echo "cd ../ch03_03_struct_padding/"
cd ../ch03_03_struct_padding/
$CC $FLAGS main.c
echo "cd ../ch04_00_deliberate_crash/"
cd ../ch04_00_deliberate_crash/
$CC $FLAGS main.c
echo "cd ../ch05_00_gprof/"
cd ../ch05_00_gprof/
$CC $FLAGS main.c
echo "cd ../ch05_01_timers/"
cd ../ch05_01_timers/
$CC $FLAGS main.c
echo "cd ../ch06_00_multi_file/"
cd ../ch06_00_multi_file/
$CC $FLAGS main.c second.c
echo "cd ../ch06_01_static_lib/"
cd ../ch06_01_static_lib/
bash build.sh
echo "cd ../ch06_02_dynamic_lib/"
cd ../ch06_02_dynamic_lib/
# -fPIC to let us call printf() from the library with Clang
$CC $FLAGS -fPIC -c second.c -o second.o
$CC $FLAGS -shared second.o -o lib/libsecond.so
# basic version
$CC $FLAGS main.c -Llib/ -lsecond
# flag rpath version
$CC $FLAGS main.c -Llib/ -lsecond -Wl,-rpath,\$ORIGIN/lib/
# export rpath version
export LD_RUN_PATH=\$ORIGIN/lib/
$CC $FLAGS main.c -lsecond -Llib/
echo "cd ../ch06_03_makefile/"
cd ../ch06_03_makefile/
make
echo "cd ../ch06_04_cmake/"
cd ../ch06_04_cmake/
rm -rf build/
mkdir build/
cd build/
cmake ..
cmake --build .
cd ..
echo "cd ../ch07_00_clang_format/"
cd ../ch07_00_clang_format/
$CC $FLAGS main.c second.c
echo "cd ../ch08_00_scan_build/"
#cd ../ch08_00_scan_build/
#$CC $FLAGS main.c
echo "cd ../ch08_01_clang_tidy/"
#cd ../ch08_01_clang_tidy/
#$CC $FLAGS main.c
echo "cd ../ch09_00_fuzzing/"
cd ../ch09_00_fuzzing/
$CC $FLAGS main.c my_ppm_stuff.c
echo "cd ../ch10_00_asm/"
cd ../ch10_00_asm/
$CC $FLAGS -S my_file.c
echo "cd ../ch11_00_valgrind_asan/"
cd ../ch11_00_valgrind_asan/
$CC $FLAGS main.c
echo "cd ../ch11_01_ubsan/"
#cd ../ch11_01_ubsan/
#$CC $FLAGS main.c
echo "cd ../ch11_03_cachegrind/"
cd ../ch11_03_cachegrind/
$CC $FLAGS main.c
echo "cd ../ch13_00_streams/"
cd ../ch13_00_streams/
$CC $FLAGS main.c
cd ..