OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Bootstraps gn. | 6 """Bootstraps gn. |
7 | 7 |
8 It is done by first building it manually in a temporary directory, then building | 8 It is done by first building it manually in a temporary directory, then building |
9 it with its own BUILD.gn to the final destination. | 9 it with its own BUILD.gn to the final destination. |
10 """ | 10 """ |
11 | 11 |
12 import contextlib | 12 import contextlib |
13 import logging | 13 import logging |
14 import optparse | 14 import optparse |
15 import os | 15 import os |
16 import shutil | 16 import shutil |
17 import subprocess | 17 import subprocess |
18 import sys | 18 import sys |
19 import tempfile | 19 import tempfile |
20 | 20 |
21 BOOTSTRAP_DIR = os.path.dirname(os.path.abspath(__file__)) | 21 BOOTSTRAP_DIR = os.path.dirname(os.path.abspath(__file__)) |
22 GN_ROOT = os.path.dirname(BOOTSTRAP_DIR) | 22 GN_ROOT = os.path.dirname(BOOTSTRAP_DIR) |
23 SRC_ROOT = os.path.dirname(os.path.dirname(GN_ROOT)) | 23 SRC_ROOT = os.path.dirname(os.path.dirname(GN_ROOT)) |
24 | 24 |
25 | 25 |
26 def is_linux(): | 26 def is_linux(): |
27 return sys.platform.startswith('linux') | 27 return sys.platform.startswith('linux') |
28 | 28 |
| 29 def is_freebsd(): |
| 30 return sys.platform.startswith('freebsd') |
29 | 31 |
30 def check_call(cmd, **kwargs): | 32 def check_call(cmd, **kwargs): |
31 logging.debug('Running: %s', ' '.join(cmd)) | 33 logging.debug('Running: %s', ' '.join(cmd)) |
32 subprocess.check_call(cmd, cwd=GN_ROOT, **kwargs) | 34 subprocess.check_call(cmd, cwd=GN_ROOT, **kwargs) |
33 | 35 |
34 | 36 |
35 @contextlib.contextmanager | 37 @contextlib.contextmanager |
36 def scoped_tempdir(): | 38 def scoped_tempdir(): |
37 path = tempfile.mkdtemp() | 39 path = tempfile.mkdtemp() |
38 try: | 40 try: |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 'base/threading/thread_restrictions.cc', | 197 'base/threading/thread_restrictions.cc', |
196 'base/time/time.cc', | 198 'base/time/time.cc', |
197 'base/timer/elapsed_timer.cc', | 199 'base/timer/elapsed_timer.cc', |
198 'base/timer/timer.cc', | 200 'base/timer/timer.cc', |
199 'base/tracked_objects.cc', | 201 'base/tracked_objects.cc', |
200 'base/tracking_info.cc', | 202 'base/tracking_info.cc', |
201 'base/values.cc', | 203 'base/values.cc', |
202 'base/vlog.cc', | 204 'base/vlog.cc', |
203 ]) | 205 ]) |
204 | 206 |
205 if is_linux(): | 207 if is_linux() or is_freebsd(): |
206 static_libraries['libevent'] = { | 208 static_libraries['libevent'] = { |
207 'sources': [ | 209 'sources': [ |
208 'third_party/libevent/buffer.c', | 210 'third_party/libevent/buffer.c', |
209 'third_party/libevent/epoll.c', | |
210 'third_party/libevent/evbuffer.c', | 211 'third_party/libevent/evbuffer.c', |
211 'third_party/libevent/evdns.c', | 212 'third_party/libevent/evdns.c', |
212 'third_party/libevent/event.c', | 213 'third_party/libevent/event.c', |
213 'third_party/libevent/event_tagging.c', | 214 'third_party/libevent/event_tagging.c', |
214 'third_party/libevent/evrpc.c', | 215 'third_party/libevent/evrpc.c', |
215 'third_party/libevent/evutil.c', | 216 'third_party/libevent/evutil.c', |
216 'third_party/libevent/http.c', | 217 'third_party/libevent/http.c', |
217 'third_party/libevent/log.c', | 218 'third_party/libevent/log.c', |
218 'third_party/libevent/poll.c', | 219 'third_party/libevent/poll.c', |
219 'third_party/libevent/select.c', | 220 'third_party/libevent/select.c', |
220 'third_party/libevent/signal.c', | 221 'third_party/libevent/signal.c', |
221 'third_party/libevent/strlcpy.c', | 222 'third_party/libevent/strlcpy.c', |
222 ], | 223 ], |
223 'tool': 'cc', | 224 'tool': 'cc', |
224 'include_dirs': [ | 225 'include_dirs': [], |
225 os.path.join(SRC_ROOT, 'third_party', 'libevent', 'linux') | |
226 ], | |
227 'cflags': cflags + ['-DHAVE_CONFIG_H'], | 226 'cflags': cflags + ['-DHAVE_CONFIG_H'], |
228 } | 227 } |
229 static_libraries['xdg_user_dirs'] = { | 228 static_libraries['xdg_user_dirs'] = { |
230 'sources': [ | 229 'sources': [ |
231 'base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc', | 230 'base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc', |
232 ], | 231 ], |
233 'tool': 'cxx', | 232 'tool': 'cxx', |
234 } | 233 } |
235 static_libraries['base']['sources'].extend([ | 234 static_libraries['base']['sources'].extend([ |
236 'base/base_paths_posix.cc', | 235 'base/base_paths_posix.cc', |
237 'base/debug/debugger_posix.cc', | 236 'base/debug/debugger_posix.cc', |
238 'base/debug/stack_trace_posix.cc', | 237 'base/debug/stack_trace_posix.cc', |
239 'base/file_util_posix.cc', | 238 'base/file_util_posix.cc', |
240 'base/files/file_enumerator_posix.cc', | 239 'base/files/file_enumerator_posix.cc', |
241 'base/files/file_posix.cc', | 240 'base/files/file_posix.cc', |
242 'base/message_loop/message_pump_glib.cc', | 241 'base/message_loop/message_pump_glib.cc', |
243 'base/message_loop/message_pump_gtk.cc', | 242 'base/message_loop/message_pump_gtk.cc', |
244 'base/message_loop/message_pump_libevent.cc', | 243 'base/message_loop/message_pump_libevent.cc', |
245 'base/nix/xdg_util.cc', | 244 'base/nix/xdg_util.cc', |
246 'base/posix/file_descriptor_shuffle.cc', | 245 'base/posix/file_descriptor_shuffle.cc', |
247 'base/process/internal_linux.cc', | |
248 'base/process/kill_posix.cc', | 246 'base/process/kill_posix.cc', |
249 'base/process/process_handle_linux.cc', | |
250 'base/process/process_handle_posix.cc', | 247 'base/process/process_handle_posix.cc', |
251 'base/process/process_iterator_linux.cc', | |
252 'base/process/process_linux.cc', | |
253 'base/process/process_metrics_linux.cc', | |
254 'base/process/process_metrics_posix.cc', | 248 'base/process/process_metrics_posix.cc', |
255 'base/process/process_posix.cc', | 249 'base/process/process_posix.cc', |
256 'base/safe_strerror_posix.cc', | 250 'base/safe_strerror_posix.cc', |
257 'base/strings/sys_string_conversions_posix.cc', | 251 'base/strings/sys_string_conversions_posix.cc', |
258 'base/synchronization/condition_variable_posix.cc', | 252 'base/synchronization/condition_variable_posix.cc', |
259 'base/synchronization/lock_impl_posix.cc', | 253 'base/synchronization/lock_impl_posix.cc', |
260 'base/synchronization/waitable_event_posix.cc', | 254 'base/synchronization/waitable_event_posix.cc', |
261 'base/sys_info_linux.cc', | |
262 'base/sys_info_posix.cc', | 255 'base/sys_info_posix.cc', |
263 'base/threading/platform_thread_linux.cc', | |
264 'base/threading/platform_thread_posix.cc', | 256 'base/threading/platform_thread_posix.cc', |
265 'base/threading/thread_local_posix.cc', | 257 'base/threading/thread_local_posix.cc', |
266 'base/threading/thread_local_storage_posix.cc', | 258 'base/threading/thread_local_storage_posix.cc', |
267 'base/time/time_posix.cc', | 259 'base/time/time_posix.cc', |
268 ]) | 260 ]) |
| 261 if is_linux(): |
| 262 static_libraries['base']['sources'].extend([ |
| 263 'base/process/internal_linux.cc', |
| 264 'base/process/process_handle_linux.cc', |
| 265 'base/process/process_iterator_linux.cc', |
| 266 'base/process/process_linux.cc', |
| 267 'base/process/process_metrics_linux.cc', |
| 268 'base/sys_info_linux.cc', |
| 269 'base/threading/platform_thread_linux.cc', |
| 270 ]) |
| 271 static_libraries['libevent']['sources'].extend([ |
| 272 'third_party/libevent/epoll.c', |
| 273 ]) |
| 274 static_libraries['libevent']['include_dirs'].extend([ |
| 275 os.path.join(SRC_ROOT, 'third_party', 'libevent', 'linux') |
| 276 ]) |
| 277 elif is_freebsd(): |
| 278 static_libraries['base']['sources'].extend([ |
| 279 'base/process/process_handle_freebsd.cc', |
| 280 'base/process/process_iterator_freebsd.cc', |
| 281 'base/process/process_metrics_freebsd.cc', |
| 282 'base/sys_info_freebsd.cc', |
| 283 'base/threading/platform_thread_freebsd.cc', |
| 284 ]) |
| 285 static_libraries['libevent']['sources'].extend([ |
| 286 'third_party/libevent/kqueue.c', |
| 287 ]) |
| 288 static_libraries['libevent']['include_dirs'].extend([ |
| 289 os.path.join(SRC_ROOT, 'third_party', 'libevent', 'freebsd') |
| 290 ]) |
| 291 ldflags.extend(['-lexecinfo']) |
269 | 292 |
270 cflags.extend(['-O2', '-pthread', '-pipe']) | 293 cflags.extend(['-O2', '-pthread', '-pipe']) |
271 | 294 |
272 static_libraries['base'].setdefault('cflags', []).extend( | 295 static_libraries['base'].setdefault('cflags', []).extend( |
273 subprocess.check_output( | 296 subprocess.check_output( |
274 ['pkg-config', 'gtk+-2.0', 'x11', '--cflags']).split()) | 297 ['pkg-config', 'gtk+-2.0', 'x11', '--cflags']).split()) |
275 ldflags.extend(['-pthread']) | 298 ldflags.extend(['-pthread']) |
276 ldflags.extend(subprocess.check_output( | 299 ldflags.extend(subprocess.check_output( |
277 ['pkg-config', 'gtk+-2.0', 'x11', | 300 ['pkg-config', 'gtk+-2.0', 'x11', |
278 '--libs-only-L', '--libs-only-other']).split()) | 301 '--libs-only-L', '--libs-only-other']).split()) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 if not debug: | 343 if not debug: |
321 cmd.append('--args=is_debug=false') | 344 cmd.append('--args=is_debug=false') |
322 check_call(cmd) | 345 check_call(cmd) |
323 check_call(['ninja', '-C', build_dir, 'gn']) | 346 check_call(['ninja', '-C', build_dir, 'gn']) |
324 if not debug: | 347 if not debug: |
325 check_call(['strip', os.path.join(build_dir, 'gn')]) | 348 check_call(['strip', os.path.join(build_dir, 'gn')]) |
326 | 349 |
327 | 350 |
328 if __name__ == '__main__': | 351 if __name__ == '__main__': |
329 sys.exit(main(sys.argv[1:])) | 352 sys.exit(main(sys.argv[1:])) |
OLD | NEW |