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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/linux/unbundle/remove_bundled_libraries.py
diff --git a/build/linux/unbundle/remove_bundled_libraries.py b/build/linux/unbundle/remove_bundled_libraries.py
new file mode 100755
index 0000000000000000000000000000000000000000..7a61e4c7ac81309cbdd071a904195c1edc91a376
--- /dev/null
+++ b/build/linux/unbundle/remove_bundled_libraries.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+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?
+"""
+
+
+import os.path
+import sys
+
+
+def DoMain(argv):
+ my_dirname = os.path.dirname(__file__)
+ source_tree_root = os.path.abspath(
+ os.path.join(my_dirname, '..', '..', '..'))
+
+ status_dict = {}
+ for exclusion in argv[1:]:
Lei Zhang 2013/08/20 23:41:10 Document what argv[1:] is?
+ 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.
+
+ for root, dirs, files in os.walk(source_tree_root, topdown=False):
+ for f in files:
+ path = os.path.join(root, f)
+ relpath = os.path.relpath(path, source_tree_root)
+
+ # Only look at paths which contain a "third_party" component
+ # (note that e.g. third_party.png doesn't count).
+ 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.
+ continue
+
+ excluded = False
+ 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.
+ if relpath.startswith(exclusion):
+ # Multiple exclusions can match the same path. Go through all of them
+ # and mark each one as used.
+ status_dict[exclusion]['exists'] = True
+ excluded = True
+ if excluded:
+ continue
+
+ # Deleting gyp files almost always leads to gyp failures.
+ # These files come from Chromium project, and can be replaced if needed.
+ if f.endswith('.gyp') or f.endswith('.gypi'):
+ continue
+
+ # Delete the file - best way to ensure it's not used during build.
+ 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
+
+ exit_code = 0
+
+ # Fail if exclusion list contains stale entries - this helps keep it
+ # up to date.
+ for exclusion, status in status_dict.iteritems():
+ if not status['exists']:
+ print '%s does not exist' % exclusion
+ exit_code = 1
+
+ return exit_code
+
+
+if __name__ == '__main__':
+ sys.exit(DoMain(sys.argv))
« 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