forked from fte-team/fteqw
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dounifdef.sh
59 lines (46 loc) · 1.96 KB
/
dounifdef.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
#!/bin/sh
#this script is DANGEROUS
#be sure to have committed *BEFORE* running this script.
#Note: This script does not understand dead files (including botlib).
#expect '-Wmisleading-indentation' warnings (that were previously muted by nearby ifdefs).
#DO NOT COMMIT THE RESULTS TO FTE'S TRUNK
CONFIG=wastes
#must have trailing slashes
SRCDIR=./
NEWDIR=/tmp/fte-$CONFIG/
echo "WARNING: This script will lock-in a build config upon your C files."
echo "The resulting files will support only your choice of feature set, instead of having lots of unused code mixed in."
echo "THIS IS DESTRUCTIVE SO MUST ONLY BE USED FOR FORKS."
read -p "Press name the build config (or ctrl+c to abort)" CONFIG
if [ "$foo" == "" ]; then
echo "no config specified."
exit 1
fi
mkdir -p $NEWDIR
cat $SRCDIR/engine/common/config_$CONFIG.h | grep "#define" | sed "s/\/\/#define/#undef/g" > $NEWDIR/unifdefrules
cat $SRCDIR/engine/common/config_$CONFIG.h | grep "#undef" >> $NEWDIR/unifdefrules
if [ "$SRCDIR" != "$NEWDIR" ]; then
echo "Copying files to strip to $NEWDIR."
cp -r $SRCDIR* $NEWDIR
else
echo "WARNING: WRITING FILES IN PLACE MUST ONLY BE USED FOR FORKS."
read -p "Press y<enter> to confirm (or ctrl+c to abort)" foo
if [ "$foo" != "y" ]; then
exit 1
fi
fi
cd $NEWDIR
for FILENAME in engine/*/*.c; do
unifdef -f unifdefrules -m $FILENAME
done
#headers keep any defines that will be expanded in code.
cat $NEWDIR/unifdefrules | grep -v FULLENGINENAME | grep -v DISTRIBUTION | grep -v ENGINEWEBSITE | grep -v MAX_SPLITS | grep GAME_SHORTNAME > $NEWDIR/unifdefhrules
for FILENAME in engine/*/*.h; do
unifdef -f unifdefhrules -m $FILENAME
done
rm $NEWDIR/unifdefrules
echo "Files in $NEWDIR have now been stripped down."
echo "Some things may require hand-editing to remove warnings (or just compile with CFLAGS=-Wno-misleading-indentation)."
echo "You still need to set FTE_CONFIG too."
read -p "Press enter to test-compile" foo
cd $NEWDIR/engine && make sv-rel m-rel -j8 FTE_CONFIG=$CONFIG -k