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

Side by Side Diff: site_scons/site_tools/chromium_load_component.py

Issue 11430: Fix use of LOAD= with WantSystemLib()... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """
6 Tool module for managing conditional loading of components in a
7 Chromium build (i.e., the LOAD= command-line argument).
8 """
9
10 from SCons.Script import *
11
12 def generate(env):
13
14 class LoadComponent:
15 """
16 Class for deciding if a given component name is to be included
17 based on a list of included names, optionally prefixed with '-'
18 to exclude the name.
19 """
20 def __init__(self, load=[], names=[]):
21 """
22 Initialize a class with a list of names for possible loading.
23
24 Arguments:
25 load: list of elements in the LOAD= specification
26 names: name(s) that represent this global collection
27 """
28 self.included = set([c for c in load if not c.startswith('-')])
29 self.excluded = set([c[1:] for c in load if c.startswith('-')])
30
31 # Remove the global collection name(s) from the included list.
32 # This supports (e.g.) specifying 'webkit' so the top-level of the
33 # hierarchy will read up the subsystem, and then 'test_shell'
34 # as one specific sub-component within 'webkit'.
35 self.included = self.included - set(names)
36
37 if not self.included:
38 self.included = ['all']
39
40 def __call__(self, component):
41 """
42 Returns True if the specified component should be loaded,
43 based on the initialized included and excluded lists.
44 """
45 return (component in self.included or
46 ('all' in self.included and not component in self.excluded))
47
48 def ChromiumLoadComponentSConscripts(env, *args, **kw):
49 """
50 Returns a list of SConscript files to load, based on LOAD=.
51
52 SConscript files specified without keyword arguments are returned
53 unconditionally. SConscript files specified with a keyword arguments
54 (e.g. chrome = 'chrome.scons') are loaded only if the LOAD= line
55 indicates their keyword argument should be included in the load.
56 """
57 try:
58 load = ARGUMENTS.get('LOAD').split(',')
59 except AttributeError:
60 load = []
61
62 try:
63 names = kw['LOAD_NAMES']
64 except KeyError:
65 names = []
66 else:
67 del kw['LOAD_NAMES']
68
69 load_component = LoadComponent(load, names)
70
71 result = list(args)
72 for module, sconscript in kw.items():
73 if load_component(module):
74 result.append(sconscript)
75
76 return Flatten(result)
77
78 env.AddMethod(ChromiumLoadComponentSConscripts)
79
80 def exists(env):
81 return True
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698