]> git.pld-linux.org Git - packages/chromium-browser.git/blob - clean-source.sh
remove non-linux files: find -name win -o -name mac
[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 # some scanned with find -name tests -o -name test -o -name test_data
24 # also removed non-linux files: find -name win -o -name mac
25 remove_nonessential_dirs() {
26         local dir
27         for dir in \
28         chrome/common/extensions/docs \
29         chrome/tools/test/reference_build \
30         courgette/testdata \
31         data \
32         native_client/src/trusted/service_runtime/testdata \
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         tools/gyp/test \
110         \
111         ash/test \
112         base/android/javatests/src/org/chromium/base/test \
113         base/test \
114         chrome/browser/chromeos/bluetooth/test \
115         chrome/browser/component_updater/test \
116         chrome/browser/printing/cloud_print/test \
117         chrome/browser/resources/gaia_auth/test \
118         chrome/browser/sync/test \
119         chrome/installer/test \
120         chrome/test/webdriver/test \
121         chrome/tools/test \
122         chrome_frame/test \
123         chrome_frame/tools/test \
124         content/browser/worker_host/test \
125         content/public/test \
126         content/test \
127         media/test \
128         media/tools/layout_tests/test_data \
129         native_client_sdk/src/libraries/c_salt/test \
130         net/test \
131         printing/test \
132         rlz/test \
133         sandbox/linux/seccomp-legacy/tests \
134         sandbox/linux/tests \
135         sandbox/win/tests \
136         sync/internal_api/public/test \
137         sync/internal_api/test \
138         sync/test \
139         testing/gmock/scripts/test \
140         testing/gmock/test \
141         testing/gtest/scripts/test \
142         testing/gtest/test \
143         third_party/WebKit/Source/ThirdParty/gtest/scripts/test \
144         third_party/WebKit/Source/ThirdParty/gtest/test \
145         third_party/WebKit/Source/ThirdParty/gyp/test \
146         third_party/WebKit/Source/ThirdParty/qunit/test \
147         third_party/WebKit/Source/WebCore/bindings/scripts/test \
148         third_party/WebKit/Source/WebKit/efl/tests \
149         third_party/WebKit/Source/WebKit2/UIProcess/API/efl/tests \
150         third_party/WebKit/Tools/Scripts/webkitpy/test \
151         third_party/cacheinvalidation/files/src/google/cacheinvalidation/test \
152         third_party/libexif/sources/test \
153         third_party/libjingle/source/talk/app/webrtc/test \
154         third_party/libphonenumber/src/resources/test \
155         third_party/libphonenumber/src/test \
156         third_party/libsrtp/srtp/crypto/test \
157         third_party/libsrtp/srtp/test \
158         third_party/openssl/openssl/crypto/des/t/test \
159         third_party/openssl/openssl/test \
160         third_party/ots/test \
161         third_party/sfntly/cpp/src/test \
162         third_party/sqlite/src/test \
163         third_party/talloc/libreplace/test \
164         third_party/tlslite/test \
165         third_party/trace-viewer/test_data \
166         third_party/v8-i18n/tests \
167         third_party/webdriver/pylib/test \
168         third_party/webdriver/test_data \
169         ui/app_list/test \
170         ui/aura/test \
171         ui/base/test \
172         ui/compositor/test \
173         ui/gfx/test \
174         ui/test \
175         ui/views/test \
176         webkit/plugins/npapi/test \
177         \
178         _base/mac \
179         _base/win \
180         breakpad/src/client/mac \
181         breakpad/src/common/mac \
182         breakpad/src/tools/mac \
183         build/mac \
184         build/win \
185         chrome/app/theme/default_100_percent/mac \
186         chrome/app/theme/default_100_percent/win \
187         chrome/app/theme/default_200_percent/mac \
188         chrome/app/theme/default_200_percent/win \
189         chrome/app/theme/touch_100_percent/win \
190         chrome/app/theme/touch_140_percent/win \
191         chrome/app/theme/touch_180_percent/win \
192         chrome/browser/mac \
193         chrome/common/mac \
194         chrome/installer/mac \
195         chrome/installer/mac/third_party/xz/config/mac \
196         chrome/test/logging/win \
197         chrome/tools/build/mac \
198         chrome/tools/build/win \
199         cloud_print/service/win \
200         cloud_print/virtual_driver/win \
201         _content/common/mac \
202         content/shell/mac \
203         media/audio/mac \
204         media/audio/win \
205         media/video/capture/mac \
206         media/video/capture/win \
207         native_client/build/mac \
208         _native_client/src/include/win \
209         native_client/src/shared/imc/win \
210         native_client/src/shared/platform/win \
211         native_client/src/trusted/debug_stub/win \
212         native_client/src/trusted/desc/win \
213         native_client/src/trusted/nonnacl_util/win \
214         native_client/src/trusted/platform_qualify/win \
215         _native_client/src/trusted/service_runtime/win \
216         native_client_sdk/src/libraries/win \
217         ppapi/native_client/src/trusted/plugin/win \
218         remoting/host/installer/mac \
219         remoting/host/mac \
220         remoting/host/win \
221         rlz/mac \
222         rlz/win \
223         _sandbox/win \
224         sdch/mac \
225         skia/config/win \
226         third_party/WebKit/Source/Platform/chromium/public/mac \
227         third_party/WebKit/Source/Platform/chromium/public/win \
228         third_party/WebKit/Source/WTF/wtf/mac \
229         third_party/WebKit/Source/WTF/wtf/threads/win \
230         third_party/WebKit/Source/WTF/wtf/win \
231         third_party/WebKit/Source/WebCore/WebCore.gyp/mac \
232         third_party/WebKit/Source/WebCore/accessibility/mac \
233         third_party/WebKit/Source/WebCore/accessibility/win \
234         third_party/WebKit/Source/WebCore/editing/mac \
235         third_party/WebKit/Source/WebCore/history/mac \
236         third_party/WebKit/Source/WebCore/loader/mac \
237         third_party/WebKit/Source/WebCore/loader/win \
238         third_party/WebKit/Source/WebCore/page/mac \
239         third_party/WebKit/Source/WebCore/page/scrolling/mac \
240         third_party/WebKit/Source/WebCore/page/win \
241         third_party/WebKit/Source/WebCore/platform/audio/mac \
242         third_party/WebKit/Source/WebCore/platform/cf/win \
243         third_party/WebKit/Source/WebCore/platform/graphics/ca/mac \
244         third_party/WebKit/Source/WebCore/platform/graphics/ca/win \
245         third_party/WebKit/Source/WebCore/platform/graphics/gpu/mac \
246         third_party/WebKit/Source/WebCore/platform/graphics/mac \
247         third_party/WebKit/Source/WebCore/platform/graphics/surfaces/mac \
248         third_party/WebKit/Source/WebCore/platform/graphics/win \
249         third_party/WebKit/Source/WebCore/platform/mac \
250         third_party/WebKit/Source/WebCore/platform/network/mac \
251         third_party/WebKit/Source/WebCore/platform/network/win \
252         third_party/WebKit/Source/WebCore/platform/text/mac \
253         third_party/WebKit/Source/WebCore/platform/text/win \
254         third_party/WebKit/Source/WebCore/platform/win \
255         third_party/WebKit/Source/WebCore/platform/wx/wxcode/mac \
256         third_party/WebKit/Source/WebCore/platform/wx/wxcode/win \
257         third_party/WebKit/Source/WebCore/plugins/mac \
258         third_party/WebKit/Source/WebCore/plugins/win \
259         _third_party/WebKit/Source/WebKit/chromium/public/mac \
260         third_party/WebKit/Source/WebKit/chromium/public/platform/mac \
261         third_party/WebKit/Source/WebKit/chromium/public/platform/win \
262         third_party/WebKit/Source/WebKit/chromium/public/win \
263         third_party/WebKit/Source/WebKit/chromium/src/mac \
264         third_party/WebKit/Source/WebKit/chromium/src/win \
265         third_party/WebKit/Source/WebKit/mac \
266         third_party/WebKit/Source/WebKit/win \
267         third_party/WebKit/Source/WebKit2/Platform/CoreIPC/mac \
268         third_party/WebKit/Source/WebKit2/Platform/CoreIPC/win \
269         third_party/WebKit/Source/WebKit2/Platform/mac \
270         third_party/WebKit/Source/WebKit2/Platform/win \
271         third_party/WebKit/Source/WebKit2/PluginProcess/mac \
272         third_party/WebKit/Source/WebKit2/Shared/API/c/mac \
273         third_party/WebKit/Source/WebKit2/Shared/API/c/win \
274         third_party/WebKit/Source/WebKit2/Shared/Plugins/Netscape/mac \
275         third_party/WebKit/Source/WebKit2/Shared/Plugins/Netscape/win \
276         third_party/WebKit/Source/WebKit2/Shared/Plugins/mac \
277         third_party/WebKit/Source/WebKit2/Shared/cg/win \
278         third_party/WebKit/Source/WebKit2/Shared/mac \
279         third_party/WebKit/Source/WebKit2/Shared/win \
280         third_party/WebKit/Source/WebKit2/UIProcess/API/C/mac \
281         third_party/WebKit/Source/WebKit2/UIProcess/API/C/win \
282         third_party/WebKit/Source/WebKit2/UIProcess/API/mac \
283         third_party/WebKit/Source/WebKit2/UIProcess/Launcher/mac \
284         third_party/WebKit/Source/WebKit2/UIProcess/Launcher/win \
285         third_party/WebKit/Source/WebKit2/UIProcess/Plugins/mac \
286         third_party/WebKit/Source/WebKit2/UIProcess/Plugins/win \
287         third_party/WebKit/Source/WebKit2/UIProcess/mac \
288         third_party/WebKit/Source/WebKit2/UIProcess/win \
289         third_party/WebKit/Source/WebKit2/WebProcess/Authentication/mac \
290         third_party/WebKit/Source/WebKit2/WebProcess/Cookies/mac \
291         third_party/WebKit/Source/WebKit2/WebProcess/Downloads/cf/win \
292         third_party/WebKit/Source/WebKit2/WebProcess/Downloads/mac \
293         third_party/WebKit/Source/WebKit2/WebProcess/FullScreen/mac \
294         third_party/WebKit/Source/WebKit2/WebProcess/FullScreen/win \
295         third_party/WebKit/Source/WebKit2/WebProcess/InjectedBundle/API/c/win \
296         third_party/WebKit/Source/WebKit2/WebProcess/InjectedBundle/mac \
297         third_party/WebKit/Source/WebKit2/WebProcess/InjectedBundle/win \
298         third_party/WebKit/Source/WebKit2/WebProcess/Plugins/Netscape/mac \
299         third_party/WebKit/Source/WebKit2/WebProcess/Plugins/Netscape/win \
300         third_party/WebKit/Source/WebKit2/WebProcess/WebCoreSupport/mac \
301         third_party/WebKit/Source/WebKit2/WebProcess/WebCoreSupport/win \
302         third_party/WebKit/Source/WebKit2/WebProcess/WebPage/ca/mac \
303         third_party/WebKit/Source/WebKit2/WebProcess/WebPage/ca/win \
304         third_party/WebKit/Source/WebKit2/WebProcess/WebPage/mac \
305         third_party/WebKit/Source/WebKit2/WebProcess/WebPage/win \
306         third_party/WebKit/Source/WebKit2/WebProcess/mac \
307         third_party/WebKit/Source/WebKit2/WebProcess/win \
308         third_party/WebKit/Source/WebKit2/mac \
309         third_party/WebKit/Source/WebKit2/win \
310         third_party/WebKit/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/mac \
311         third_party/WebKit/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/win \
312         third_party/WebKit/Tools/DumpRenderTree/TestNetscapePlugIn/mac \
313         third_party/WebKit/Tools/DumpRenderTree/TestNetscapePlugIn/win \
314         third_party/WebKit/Tools/DumpRenderTree/mac \
315         third_party/WebKit/Tools/DumpRenderTree/win \
316         third_party/WebKit/Tools/TestWebKitAPI/Tests/TestWebKitAPI/mac \
317         third_party/WebKit/Tools/TestWebKitAPI/Tests/WebKit/win \
318         third_party/WebKit/Tools/TestWebKitAPI/Tests/WebKit2/mac \
319         third_party/WebKit/Tools/TestWebKitAPI/Tests/WebKit2/win \
320         third_party/WebKit/Tools/TestWebKitAPI/Tests/mac \
321         third_party/WebKit/Tools/TestWebKitAPI/mac \
322         third_party/WebKit/Tools/TestWebKitAPI/win \
323         _third_party/cld/encodings/compact_lang_det/win \
324         third_party/ffmpeg/chromium/binaries/Chromium/win \
325         third_party/ffmpeg/chromium/config/Chrome/mac \
326         third_party/ffmpeg/chromium/config/Chromium/mac \
327         third_party/ffmpeg/chromium/include/win \
328         third_party/leveldatabase/src/port/win \
329         third_party/libjpeg_turbo/mac \
330         third_party/libjpeg_turbo/win \
331         third_party/libvpx/source/config/mac \
332         third_party/libvpx/source/config/win \
333         third_party/libxml/mac \
334         third_party/skia/include/utils/mac \
335         third_party/skia/include/utils/win \
336         third_party/skia/src/gpu/gl/mac \
337         third_party/skia/src/gpu/gl/win \
338         third_party/skia/src/utils/mac \
339         third_party/skia/src/utils/win \
340         third_party/skia/src/views/mac \
341         third_party/skia/src/views/win \
342         third_party/snappy/mac \
343         third_party/webrtc/modules/audio_device/main/source/mac \
344         third_party/webrtc/modules/audio_device/main/source/win \
345         third_party/webrtc/modules/video_render/main/source/mac \
346         third_party/webrtc/test/testsupport/mac \
347         third_party/yasm/source/config/mac \
348         third_party/yasm/source/config/win \
349         tools/mac \
350         tools/win \
351         _ui/base/win \
352         ui/gfx/mac \
353         ui/views/win \
354         webkit/tools/test_shell/mac \
355         ; do
356                 rm -vfr "$dir"
357         done
358 }
359
360 # Strip tarball from some big directories not needed on the linux platform
361 strip_dirs() {
362         # prefix with _ those that we can't remove (just yet) because of the gclient
363         # hooks (see build/all.gyp) or of some unneeded deps/includes
364
365         local dir
366         for dir in \
367                 chrome/test/data/safe_browsing/old \
368                 chrome/test/data/firefox2_nss_mac \
369                 chrome/third_party/wtl/ \
370                 gears \
371                 google_update \
372                 o3d \
373                 third_party/boost \
374                 third_party/bsdiff \
375                 third_party/bspatch \
376                 third_party/ffmpeg/binaries \
377                 third_party/fuzzymatch \
378                 third_party/gles_book_examples \
379                 third_party/hunspell/dictionaries \
380                 third_party/icu/mac \
381                 third_party/lcov \
382                 third_party/lighttpd \
383                 third_party/nspr \
384                 third_party/nss \
385                 third_party/ocmock \
386                 third_party/pthread \
387                 third_party/pyftpdlib \
388                 third_party/simplejson \
389                 third_party/scons \
390                 _third_party/tcmalloc \
391                 tools/symsrc \
392                 tools/site_compare \
393                 tools/stats_viewer \
394                 tools/valgrind \
395                 tools/wine_valgrind \
396                 v8/test/cctest \
397                 webkit/data/layout_tests \
398         ; do
399                 rm -vfr "$dir"
400         done
401 }
402
403 # parts based on ubuntu debian/rules
404 # http://bazaar.launchpad.net/~chromium-team/chromium-browser/chromium-browser.head/view/head:/debian/rules
405
406 remove_bin_only() {
407         find . -type f \( \
408                 -iname \*.exe -o \
409                 -iname \*.dll -o \
410                 -iname \*.pdb -o \
411                 -name \*.o -o \
412                 -name \*.a -o \
413                 -name \*.dylib \
414         \) -exec rm -fv {} \;
415 }
416
417 # removes dir, if the bcond is not turned off
418 strip_system_dirs() {
419         local dir lib bcond
420         for dir in "$@"; do
421                 lib=${dir##*/}
422                 bcond=$(eval echo \$$lib)
423                 [ "${bcond:-1}" = 0 ] && continue
424
425                 # skip already removed dirs
426                 test -d $dir || continue
427
428                 # here we ignore errors, as some dirs contain README.chromium after removal
429                 find $dir -depth -mindepth 1 \! \( -name \*.gyp -o -name \*.gypi -o -name README.chromium -o -name \*.patch \) -print -delete || :
430         done
431 }
432
433 # There are directories we want to strip, but that are unnecessarily required by the build-system
434 # So we drop everything but the gyp/gypi files and README.chromium (to see what that dir contained)
435 almost_strip_dirs() {
436         local dir
437         for dir in "$@"; do
438                 find $dir -depth -mindepth 1 \! \( -name \*.gyp -o -name \*.gypi -o -name README.chromium \) -print -delete || :
439         done
440 }
441
442 remove_nonessential_dirs | tee -a REMOVED-nonessential_dirs.txt
443 remove_bin_only | tee -a REMOVED-bin_only.txt
444
445 strip_dirs | tee -a REMOVED-stripped.txt
446
447 almost_strip_dirs \
448         courgette \
449         chrome/test/data \
450         third_party/gles2_book \
451 | tee -a REMOVED-stripped.txt
452
453 strip_system_dirs \
454         third_party/bzip2 \
455         third_party/icu \
456         third_party/libevent \
457         third_party/libjpeg \
458         third_party/libpng \
459         _third_party/libxml \
460         third_party/libxslt \
461         _third_party/zlib \
462         third_party/libwebp \
463         _third_party/libvpx \
464         v8 \
465 | tee -a REMOVED-stripped.txt
466
467 # vpx can't be cleaned:
468 #make: *** No rule to make target `out/Release/obj.target/libvpx_asm_offsets/third_party/libvpx/source/libvpx/vp8/common/asm_com_offsets.o',
469 #needed by `out/Release/obj.target/third_party/libvpx/libvpx_asm_offsets.a'.  Stop.
470
471 # 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.
472 #gyp_clean third_party/yasm
473
474 rm -vf third_party/expat/files/lib/expat.h
475
476 if [ "${v8:-1}" != "0" ]; then
477         # The implementation files include v8 headers with full path,
478         # like #include "v8/include/v8.h". Make sure the system headers
479         # will be used.
480         rm -rf v8/include
481         ln -s /usr/include v8/include
482 fi
483
484 if [ "${nacl:-1}" != "0" ]; then
485         # NOTE: here is always x86_64
486         rm -rf native_client/toolchain/linux_x86_newlib
487 fi
This page took 0.067332 seconds and 4 git commands to generate.