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