-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathamalgamate.in
executable file
·73 lines (58 loc) · 2.13 KB
/
amalgamate.in
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
#!/bin/bash
OUTPUT_HEADER=gamelink_single.hpp
# These must be topologically sorted. Generally this means that
# serialization.h, envelope.h, then subscription.h followed by all other files.
INPUT_HEADERS=(
./schema/serialization.h
./schema/envelope.h
./schema/subscription.h
./schema/consts.h
./schema/authentication.h
./schema/broadcast.h
./schema/datastream.h
./schema/poll.h
./schema/purchase.h
./schema/schema.h
./schema/state.h
./schema/game_config.h
./schema/drops.h
./schema/matches.h
./schema/matchmaking.h
./schema/game_metadata.h
./include/gamelink.h
./include/gateway.h
)
INPUT_SOURCES=(@AMALGAM_PUBLIC_SOURCES@)
echo "/* This file is automatically generated from multiple sources. Do not modify */" > $OUTPUT_HEADER
echo "" >> $OUTPUT_HEADER
echo "" >> $OUTPUT_HEADER
echo "#ifndef MUXY_GAMELINK_SINGLE_HPP" >> $OUTPUT_HEADER
echo "#define MUXY_GAMELINK_SINGLE_HPP" >> $OUTPUT_HEADER
echo "" >> $OUTPUT_HEADER
# Config begin
echo "#ifndef MUXY_GAMELINK_CONFIG_H" >> $OUTPUT_HEADER
echo "#define MUXY_GAMELINK_CONFIG_H" >> $OUTPUT_HEADER
echo "" >> $OUTPUT_HEADER
cat ./include/config.h | sed 's/#include ".*"//g' | sed 's/#pragma once//g' >> $OUTPUT_HEADER
echo "#ifndef MUXY_NO_JSON_INCLUDE" >> $OUTPUT_HEADER
cat ./third_party/nlohmann/json.hpp >> $OUTPUT_HEADER
echo "" >> $OUTPUT_HEADER
echo "#endif" >> $OUTPUT_HEADER
cat ./include/config_footer.h | sed 's/#include ".*"//g' | sed 's/#pragma once//g' >> $OUTPUT_HEADER
echo "" >> $OUTPUT_HEADER
echo "#endif" >> $OUTPUT_HEADER
# Config end
for file in ${INPUT_HEADERS[@]}; do
# Remove any includes in quotes, and pragma once before amalgamating.
cat $file | sed 's/#include ".*"//g' | sed 's/#pragma once//g' >> $OUTPUT_HEADER
echo "" >> $OUTPUT_HEADER
done
echo "#endif" >> $OUTPUT_HEADER
echo "#ifdef MUXY_GAMELINK_SINGLE_IMPL" >> $OUTPUT_HEADER
for file in ${INPUT_SOURCES[@]}; do
# Remove any includes in quotes before amalgamating
cat $file | sed 's/#include ".*"//g' >> $OUTPUT_HEADER
echo "" >> $OUTPUT_HEADER
done
echo "#endif" >> $OUTPUT_HEADER
sed -i '' '/^$/N;/^\n$/D' $OUTPUT_HEADER