OLD | NEW |
1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 Tool module for adding, to a construction environment, Chromium-specific | 6 Tool module for adding, to a construction environment, Chromium-specific |
7 wrappers around Hammer builders. This gives us a central place for any | 7 wrappers around Hammer builders. This gives us a central place for any |
8 customization we need to make to the different things we build. | 8 customization we need to make to the different things we build. |
9 """ | 9 """ |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 pass | 45 pass |
46 def Replace(self, old, new): | 46 def Replace(self, old, new): |
47 for top, lists, nonlists in MSVS.FileListWalk(self, topdown=False): | 47 for top, lists, nonlists in MSVS.FileListWalk(self, topdown=False): |
48 try: | 48 try: |
49 i = top.index(old) | 49 i = top.index(old) |
50 except ValueError: | 50 except ValueError: |
51 pass | 51 pass |
52 else: | 52 else: |
53 top[i] = new | 53 top[i] = new |
54 | 54 |
| 55 |
| 56 def FilterOut(self, **kw): |
| 57 """Removes values from existing construction variables in an Environment. |
| 58 |
| 59 The values to remove should be a list. For example: |
| 60 |
| 61 self.FilterOut(CPPDEFINES=['REMOVE_ME', 'ME_TOO']) |
| 62 |
| 63 Args: |
| 64 self: Environment to alter. |
| 65 kw: (Any other named arguments are values to remove). |
| 66 """ |
| 67 |
| 68 kw = SCons.Environment.copy_non_reserved_keywords(kw) |
| 69 for key, val in kw.items(): |
| 70 envval = self.get(key, None) |
| 71 if envval is None: |
| 72 # No existing variable in the environment, so nothing to delete. |
| 73 continue |
| 74 |
| 75 for vremove in val: |
| 76 # Use while not if, so we can handle duplicates. |
| 77 while vremove in envval: |
| 78 envval.remove(vremove) |
| 79 |
| 80 self[key] = envval |
| 81 |
| 82 # TODO(sgk): SCons.Environment.Append() has much more logic to deal |
| 83 # with various types of values. We should handle all those cases in here |
| 84 # too. (If variable is a dict, etc.) |
| 85 |
| 86 |
55 import __builtin__ | 87 import __builtin__ |
56 __builtin__.ChromeFileList = ChromeFileList | 88 __builtin__.ChromeFileList = ChromeFileList |
57 | 89 |
58 non_compilable_suffixes = { | 90 non_compilable_suffixes = { |
59 'LINUX' : set([ | 91 'LINUX' : set([ |
60 '.bdic', | 92 '.bdic', |
61 '.css', | 93 '.css', |
62 '.dat', | 94 '.dat', |
63 '.h', | 95 '.h', |
64 '.html', | 96 '.html', |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 144 |
113 def ChromeLibrary(env, target, source, *args, **kw): | 145 def ChromeLibrary(env, target, source, *args, **kw): |
114 source = compilable_files(env, source) | 146 source = compilable_files(env, source) |
115 if env.get('_GYP'): | 147 if env.get('_GYP'): |
116 lib = env.Library(target, source, *args, **kw) | 148 lib = env.Library(target, source, *args, **kw) |
117 result = env.Install('$DESTINATION_ROOT/$BUILD_TYPE/lib', lib) | 149 result = env.Install('$DESTINATION_ROOT/$BUILD_TYPE/lib', lib) |
118 else: | 150 else: |
119 result = env.ComponentLibrary(target, source, *args, **kw) | 151 result = env.ComponentLibrary(target, source, *args, **kw) |
120 return result | 152 return result |
121 | 153 |
| 154 def ChromeLoadableModule(env, target, source, *args, **kw): |
| 155 source = compilable_files(env, source) |
| 156 if env.get('_GYP'): |
| 157 result = env.LoadableModule(target, source, *args, **kw) |
| 158 else: |
| 159 kw['COMPONENT_STATIC'] = True |
| 160 result = env.LoadableModule(target, source, *args, **kw) |
| 161 return result |
| 162 |
122 def ChromeStaticLibrary(env, target, source, *args, **kw): | 163 def ChromeStaticLibrary(env, target, source, *args, **kw): |
123 source = compilable_files(env, source) | 164 source = compilable_files(env, source) |
124 if env.get('_GYP'): | 165 if env.get('_GYP'): |
125 lib = env.StaticLibrary(target, source, *args, **kw) | 166 lib = env.StaticLibrary(target, source, *args, **kw) |
126 result = env.Install('$DESTINATION_ROOT/$BUILD_TYPE/lib', lib) | 167 result = env.Install('$DESTINATION_ROOT/$BUILD_TYPE/lib', lib) |
127 else: | 168 else: |
128 kw['COMPONENT_STATIC'] = True | 169 kw['COMPONENT_STATIC'] = True |
129 result = env.ComponentLibrary(target, source, *args, **kw) | 170 result = env.ComponentLibrary(target, source, *args, **kw) |
130 return result | 171 return result |
131 | 172 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 env.AlwaysBuild(result) | 223 env.AlwaysBuild(result) |
183 if dest: | 224 if dest: |
184 i = env.Command(dest, result, Copy('$TARGET', '$SOURCE')) | 225 i = env.Command(dest, result, Copy('$TARGET', '$SOURCE')) |
185 Alias('msvs', i) | 226 Alias('msvs', i) |
186 return result | 227 return result |
187 | 228 |
188 def generate(env): | 229 def generate(env): |
189 env.AddMethod(ChromeProgram) | 230 env.AddMethod(ChromeProgram) |
190 env.AddMethod(ChromeTestProgram) | 231 env.AddMethod(ChromeTestProgram) |
191 env.AddMethod(ChromeLibrary) | 232 env.AddMethod(ChromeLibrary) |
| 233 env.AddMethod(ChromeLoadableModule) |
192 env.AddMethod(ChromeStaticLibrary) | 234 env.AddMethod(ChromeStaticLibrary) |
193 env.AddMethod(ChromeSharedLibrary) | 235 env.AddMethod(ChromeSharedLibrary) |
194 env.AddMethod(ChromeObject) | 236 env.AddMethod(ChromeObject) |
195 env.AddMethod(ChromeMSVSFolder) | 237 env.AddMethod(ChromeMSVSFolder) |
196 env.AddMethod(ChromeMSVSProject) | 238 env.AddMethod(ChromeMSVSProject) |
197 env.AddMethod(ChromeMSVSSolution) | 239 env.AddMethod(ChromeMSVSSolution) |
198 | 240 |
| 241 env.AddMethod(FilterOut) |
| 242 |
199 # Add the grit tool to the base environment because we use this a lot. | 243 # Add the grit tool to the base environment because we use this a lot. |
200 sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath) | 244 sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/grit').abspath) |
201 env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/grit/grit')]) | 245 env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/grit/grit')]) |
202 | 246 |
203 # Add the repack python script tool that we use in multiple places. | 247 # Add the repack python script tool that we use in multiple places. |
204 sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/data_pack').abspath) | 248 sys.path.append(env.Dir('$CHROME_SRC_DIR/tools/data_pack').abspath) |
205 env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/data_pack/')]) | 249 env.Tool('scons', toolpath=[env.Dir('$CHROME_SRC_DIR/tools/data_pack/')]) |
206 | 250 |
207 def exists(env): | 251 def exists(env): |
208 return True | 252 return True |
OLD | NEW |