]> git.pld-linux.org Git - packages/chromium-browser.git/blob - clean-source.sh
- merge in cleanups from ubuntu's debian/rules file
[packages/chromium-browser.git] / clean-source.sh
1 #!/bin/sh
2 set -e
3 set -x
4
5 # import options
6 eval "$@"
7
8 # drop bundled libs, from gentoo
9 gyp_clean() {
10         local l lib=$1
11         echo "Removing bundled library $lib ..."
12         l=$(find "$lib" -mindepth 1 ! -iname '*.gyp*' -print -delete | wc -l)
13         if [ $l -eq 0 ]; then
14                 echo >&2 "No files matched when removing bundled library $1"
15                 exit 1
16         fi
17 }
18
19 # https://code.google.com/p/chromium/wiki/LinuxPackaging
20 # initial list from src/tools/export_tarball/export_tarball.py
21 remove_nonessential_dirs() {
22         local dir
23         for dir in \
24     chrome/common/extensions/docs \
25     chrome/test/data \
26     chrome/tools/test/reference_build \
27     courgette/testdata \
28     data \
29     native_client/src/trusted/service_runtime/testdata \
30     src/chrome/test/data \
31     o3d/documentation \
32     o3d/samples \
33     o3d/tests \
34     third_party/angle/samples/gles2_book \
35     third_party/hunspell_dictionaries \
36     third_party/hunspell/tests \
37     third_party/lighttpd \
38     third_party/sqlite/test \
39     third_party/vc_80 \
40     third_party/xdg-utils/tests \
41     third_party/yasm/source/patched-yasm/modules/arch/x86/tests \
42     third_party/yasm/source/patched-yasm/modules/dbgfmts/dwarf2/tests \
43     third_party/yasm/source/patched-yasm/modules/objfmts/bin/tests \
44     third_party/yasm/source/patched-yasm/modules/objfmts/coff/tests \
45     third_party/yasm/source/patched-yasm/modules/objfmts/elf/tests \
46     third_party/yasm/source/patched-yasm/modules/objfmts/macho/tests \
47     third_party/yasm/source/patched-yasm/modules/objfmts/rdf/tests \
48     third_party/yasm/source/patched-yasm/modules/objfmts/win32/tests \
49     third_party/yasm/source/patched-yasm/modules/objfmts/win64/tests \
50     third_party/yasm/source/patched-yasm/modules/objfmts/xdf/tests \
51     third_party/WebKit/Source/JavaScriptCore/tests \
52     third_party/WebKit/LayoutTests \
53     v8/test \
54     webkit/data/layout_tests \
55     webkit/tools/test/reference_build \
56         \
57         tools/site_compare \
58         tools/stats_viewer \
59         tools/symsrc \
60         tools/valgrind \
61         ; do
62                 rm -vfr "$dir"
63         done
64 }
65
66 # Strip tarball from some big directories not needed on the linux platform
67 strip_dirs() {
68         # prefix with _ those that we can't remove (just yet) because of the gclient
69         # hooks (see build/all.gyp) or of some unneeded deps/includes
70
71         local dir
72         for dir in \
73                 chrome/test/data/safe_browsing/old \
74                 chrome/test/data/firefox2_nss_mac \
75                 chrome/third_party/wtl/ \
76                 gears \
77                 google_update \
78                 o3d \
79                 third_party/boost \
80                 third_party/bsdiff \
81                 third_party/bspatch \
82                 third_party/ffmpeg/binaries \
83                 third_party/fuzzymatch \
84                 third_party/gles_book_examples \
85                 third_party/hunspell/dictionaries \
86                 third_party/icu/mac \
87                 third_party/lcov \
88                 third_party/lighttpd \
89                 third_party/nspr \
90                 third_party/nss \
91                 third_party/ocmock \
92                 third_party/pthread \
93                 third_party/pyftpdlib \
94                 third_party/simplejson \
95                 third_party/scons \
96                 _third_party/tcmalloc \
97                 tools/symsrc \
98                 tools/site_compare \
99                 tools/stats_viewer \
100                 tools/valgrind \
101                 tools/wine_valgrind \
102                 v8/test/cctest \
103                 webkit/data/layout_tests \
104         ; do
105                 rm -vfr "$dir"
106         done
107 }
108
109 # parts based on ubuntu debian/rules
110 # http://bazaar.launchpad.net/~chromium-team/chromium-browser/chromium-browser.head/view/head:/debian/rules
111
112 remove_bin_only() {
113         find . -type f \( \
114                 -iname \*.exe -o \
115                 -iname \*.dll -o \
116                 -iname \*.pdb -o \
117                 -name \*.o -o \
118                 -name \*.a -o \
119                 -name \*.dylib \
120         \) -exec rm -fv {} \;
121 }
122
123 # removes dir, if the bcond is not turned off
124 strip_system_dirs() {
125         local dir lib bcond
126         for dir in "$@"; do
127                 lib=${dir##*/}
128                 bcond=$(eval echo \$$lib)
129                 [ "$bcond" = 0 ] && continue
130
131                 # skip already removed dirs
132                 test -d $dir || continue
133
134                 # here we ignore errors, as some dirs contain README.chromium after removal
135                 find $dir -depth -mindepth 1 \! \( -name \*.gyp -o -name \*.gypi -o -name README.chromium -o -name \*.patch \) -print -delete || :
136         done
137 }
138
139 # There are directories we want to strip, but that are unnecessarily required by the build-system
140 # So we drop everything but the gyp/gypi files and README.chromium (to see what that dir contained)
141 almost_strip_dirs() {
142         local dir
143         for dir in "$@"; do
144                 echo >&2 "almost strip dir: $dir"
145                 find $dir -depth -mindepth 1 \! \( -name \*.gyp -o -name \*.gypi -o -name README.chromium \) -print -delete || :
146         done
147 }
148
149 remove_nonessential_dirs | tee -a REMOVED-nonessential_dirs.txt
150 remove_bin_only | tee -a REMOVED-bin_only.txt
151
152 strip_dirs | tee -a REMOVED-stripped.txt
153
154 almost_strip_dirs \
155         courgette \
156         third_party/gles2_book \
157 | tee -a REMOVED-stripped.txt
158
159 strip_system_dirs \
160         third_party/bzip2 \
161         third_party/icu \
162         third_party/libevent \
163         third_party/libjpeg \
164         third_party/libpng \
165         third_party/libxml \
166         third_party/libxslt \
167         third_party/zlib \
168         third_party/libwebp \
169         v8 \
170 | tee -a REMOVED-stripped.txt
171
172 # third_party/libvpx/libvpx.h should be kept
173 #gyp_clean third_party/libvpx
174 # third_party/yasm/source/patched-yasm/modules/arch/x86/gen_x86_insn.py', needed by `out/Release/obj/gen/third_party/yasm/x86insns.c'.  Stop.
175 #gyp_clean third_party/yasm
176
177 rm -vf third_party/expat/files/lib/expat.h
178
179 if [ "$v8" = 1 ]; then
180         # The implementation files include v8 headers with full path,
181         # like #include "v8/include/v8.h". Make sure the system headers
182         # will be used.
183         rm -rf v8/include
184         ln -s /usr/include v8/include
185 fi
186
187 if [ "$nacl" = 1 ]; then
188         # NOTE: here is always x86_64
189         rm -rf native_client/toolchain/linux_x86_newlib
190         ln -s /usr/x86_64-nacl-newlib native_client/toolchain/linux_x86_newlib
191 fi
This page took 0.066925 seconds and 3 git commands to generate.