Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: build/linux/unbundle/remove_bundled_libraries.py

Issue 23037005: Linux: add script to remove bundled libraries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """
7 Removes bundled libraries to make sure they are not used.
Lei Zhang 2013/08/20 23:41:10 Can you elaborate on what this means exactly?
Paweł Hajdan Jr. 2013/08/21 00:42:40 See README updates. Further feedback is welcome.
Lei Zhang 2013/08/21 01:27:03 Can you write "See README for more details." here?
8 """
9
10
11 import os.path
12 import sys
13
14
15 def DoMain(argv):
16 my_dirname = os.path.dirname(__file__)
17 source_tree_root = os.path.abspath(
18 os.path.join(my_dirname, '..', '..', '..'))
19
20 status_dict = {}
21 for exclusion in argv[1:]:
Lei Zhang 2013/08/20 23:41:10 Document what argv[1:] is?
22 status_dict[exclusion] = {'exists': False}
Lei Zhang 2013/08/20 23:41:10 Why do the values in |status_dict| have to be a di
Paweł Hajdan Jr. 2013/08/21 00:42:40 Done.
23
24 for root, dirs, files in os.walk(source_tree_root, topdown=False):
25 for f in files:
26 path = os.path.join(root, f)
27 relpath = os.path.relpath(path, source_tree_root)
28
29 # Only look at paths which contain a "third_party" component
30 # (note that e.g. third_party.png doesn't count).
31 if 'third_party' not in relpath.split(os.sep):
Lei Zhang 2013/08/20 23:41:10 You don't have to do this on a per-file basis. fo
Paweł Hajdan Jr. 2013/08/21 00:42:40 Done.
32 continue
33
34 excluded = False
35 for exclusion in argv:
Lei Zhang 2013/08/20 23:41:10 Shouldn't you skip argv[0] ?
Paweł Hajdan Jr. 2013/08/21 00:42:40 Done.
36 if relpath.startswith(exclusion):
37 # Multiple exclusions can match the same path. Go through all of them
38 # and mark each one as used.
39 status_dict[exclusion]['exists'] = True
40 excluded = True
41 if excluded:
42 continue
43
44 # Deleting gyp files almost always leads to gyp failures.
45 # These files come from Chromium project, and can be replaced if needed.
46 if f.endswith('.gyp') or f.endswith('.gypi'):
47 continue
48
49 # Delete the file - best way to ensure it's not used during build.
50 os.remove(path)
Lei Zhang 2013/08/20 23:41:10 No dry run mode? Seems dangerous.
Paweł Hajdan Jr. 2013/08/21 00:42:40 I don't think dry run would be useful given how th
Lei Zhang 2013/08/21 01:27:03 How about dry run by default (print what is to be
51
52 exit_code = 0
53
54 # Fail if exclusion list contains stale entries - this helps keep it
55 # up to date.
56 for exclusion, status in status_dict.iteritems():
57 if not status['exists']:
58 print '%s does not exist' % exclusion
59 exit_code = 1
60
61 return exit_code
62
63
64 if __name__ == '__main__':
65 sys.exit(DoMain(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698