forked from apple/swift-lldb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXPORT.APPLE
executable file
·48 lines (41 loc) · 1.34 KB
/
EXPORT.APPLE
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
#!/bin/bash
# This script makes a copy of the source directory with certain Apple-internal
# portions of the code removed.
origsrc=$(pwd)
SRCROOT=/tmp/$(basename $origsrc)
echo Exporting to $SRCROOT
rm -rf $SRCROOT
mkdir -p $SRCROOT
tar cf - --exclude=.svn --exclude=.git . | \
(cd $SRCROOT; tar xf - )
cd $SRCROOT
# Filter out !_OPEN_SOURCE_ source -- don't modify anything in the llvm/ subdir
find . -path ./llvm -prune -o -type f -print | while read file
do
rm -f "${file}.temp"
case "$file" in
*.h | *.c | *.cpp)
unifdef -D__OPEN_SOURCE__ -D_OPEN_SOURCE_ "$file" > "${file}.temp"
if [ $? -ne 0 ]
then
echo Re-doing strip of $file via manual method.
perl -ne 'if (/!__OPEN_SOURCE__/) { $skip = 0; } elsif (/__OPEN_SOURCE__/) { $skip = 1; } elsif (! $skip) { print; }' < "$file" > "${file}.temp"
fi
;;
*)
perl -ne 'if (/!__OPEN_SOURCE__/) { $skip = 0; } elsif (/__OPEN_SOURCE__/) { $skip = 1; } elsif (! $skip) { print; }' < "$file" > "${file}.temp"
;;
esac
if cmp "$file" "${file}.temp" >/dev/null
then
:
else
cat "${file}.temp" > "$file"
fi
rm "${file}".temp
done
echo Running llvm sanitize script
cd $SRCROOT/llvm && MODIFY_LLVM_IN_PLACE=1 ./EXPORT.APPLE
cd $SRCROOT
find . -type f -name '*.APPLE' -exec rm -rf {} \;
exit 0