]> git.pld-linux.org Git - packages/chromium-browser.git/blob - clean-source.sh
- revert, it is not controlled here
[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     v8/test \
56     webkit/data/layout_tests \
57     webkit/tools/test/reference_build \
58         \
59         tools/site_compare \
60         tools/stats_viewer \
61         tools/symsrc \
62         tools/valgrind \
63         ; do
64                 rm -vfr "$dir"
65         done
66 }
67
68 # Strip tarball from some big directories not needed on the linux platform
69 strip_dirs() {
70         # prefix with _ those that we can't remove (just yet) because of the gclient
71         # hooks (see build/all.gyp) or of some unneeded deps/includes
72
73         local dir
74         for dir in \
75                 chrome/test/data/safe_browsing/old \
76                 chrome/test/data/firefox2_nss_mac \
77                 chrome/third_party/wtl/ \
78                 gears \
79                 google_update \
80                 o3d \
81                 third_party/boost \
82                 third_party/bsdiff \
83                 third_party/bspatch \
84                 third_party/ffmpeg/binaries \
85                 third_party/fuzzymatch \
86                 third_party/gles_book_examples \
87                 third_party/hunspell/dictionaries \
88                 third_party/icu/mac \
89                 third_party/lcov \
90                 third_party/lighttpd \
91                 third_party/nspr \
92                 third_party/nss \
93                 third_party/ocmock \
94                 third_party/pthread \
95                 third_party/pyftpdlib \
96                 third_party/simplejson \
97                 third_party/scons \
98                 _third_party/tcmalloc \
99                 tools/symsrc \
100                 tools/site_compare \
101                 tools/stats_viewer \
102                 tools/valgrind \
103                 tools/wine_valgrind \
104                 v8/test/cctest \
105                 webkit/data/layout_tests \
106         ; do
107                 rm -vfr "$dir"
108         done
109 }
110
111 # parts based on ubuntu debian/rules
112 # http://bazaar.launchpad.net/~chromium-team/chromium-browser/chromium-browser.head/view/head:/debian/rules
113
114 remove_bin_only() {
115         find . -type f \( \
116                 -iname \*.exe -o \
117                 -iname \*.dll -o \
118                 -iname \*.pdb -o \
119                 -name \*.o -o \
120                 -name \*.a -o \
121                 -name \*.dylib \
122         \) -exec rm -fv {} \;
123 }
124
125 # removes dir, if the bcond is not turned off
126 strip_system_dirs() {
127         local dir lib bcond
128         for dir in "$@"; do
129                 lib=${dir##*/}
130                 bcond=$(eval echo \$$lib)
131                 [ "${bcond:-1}" = 0 ] && continue
132
133                 # skip already removed dirs
134                 test -d $dir || continue
135
136                 # here we ignore errors, as some dirs contain README.chromium after removal
137                 find $dir -depth -mindepth 1 \! \( -name \*.gyp -o -name \*.gypi -o -name README.chromium -o -name \*.patch \) -print -delete || :
138         done
139 }
140
141 # There are directories we want to strip, but that are unnecessarily required by the build-system
142 # So we drop everything but the gyp/gypi files and README.chromium (to see what that dir contained)
143 almost_strip_dirs() {
144         local dir
145         for dir in "$@"; do
146                 find $dir -depth -mindepth 1 \! \( -name \*.gyp -o -name \*.gypi -o -name README.chromium \) -print -delete || :
147         done
148 }
149
150 remove_nonessential_dirs | tee -a REMOVED-nonessential_dirs.txt
151 remove_bin_only | tee -a REMOVED-bin_only.txt
152
153 strip_dirs | tee -a REMOVED-stripped.txt
154
155 almost_strip_dirs \
156         courgette \
157         third_party/gles2_book \
158 | tee -a REMOVED-stripped.txt
159
160 strip_system_dirs \
161         third_party/bzip2 \
162         third_party/icu \
163         third_party/libevent \
164         third_party/libjpeg \
165         third_party/libpng \
166         third_party/libxml \
167         third_party/libxslt \
168         third_party/zlib \
169         third_party/libwebp \
170         v8 \
171 | tee -a REMOVED-stripped.txt
172
173 # third_party/libvpx/libvpx.h should be kept
174 #gyp_clean third_party/libvpx
175 # 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.
176 #gyp_clean third_party/yasm
177
178 rm -vf third_party/expat/files/lib/expat.h
179
180 if [ "${v8:-1}" != "0" ]; then
181         # The implementation files include v8 headers with full path,
182         # like #include "v8/include/v8.h". Make sure the system headers
183         # will be used.
184         rm -rf v8/include
185         ln -s /usr/include v8/include
186 fi
187
188 if [ "${nacl:-1}" != "0" ]; then
189         # NOTE: here is always x86_64
190         rm -rf native_client/toolchain/linux_x86_newlib
191         ln -s /usr/x86_64-nacl-newlib native_client/toolchain/linux_x86_newlib
192 fi
This page took 0.111202 seconds and 4 git commands to generate.