| 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 # This file isn't officially supported by the Chromium project. It's maintained | 6 # This file isn't officially supported by the Chromium project. It's maintained |
| 7 # on a best-effort basis by volunteers, so some things may be broken from time | 7 # on a best-effort basis by volunteers, so some things may be broken from time |
| 8 # to time. If you encounter errors, it's most often due to files in base that | 8 # to time. If you encounter errors, it's most often due to files in base that |
| 9 # have been added or moved since somebody last tried this script. Generally | 9 # have been added or moved since somebody last tried this script. Generally |
| 10 # such errors are easy to diagnose. | 10 # such errors are easy to diagnose. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 import sys | 25 import sys |
| 26 import tempfile | 26 import tempfile |
| 27 | 27 |
| 28 BOOTSTRAP_DIR = os.path.dirname(os.path.abspath(__file__)) | 28 BOOTSTRAP_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 29 GN_ROOT = os.path.dirname(BOOTSTRAP_DIR) | 29 GN_ROOT = os.path.dirname(BOOTSTRAP_DIR) |
| 30 SRC_ROOT = os.path.dirname(os.path.dirname(GN_ROOT)) | 30 SRC_ROOT = os.path.dirname(os.path.dirname(GN_ROOT)) |
| 31 | 31 |
| 32 is_win = sys.platform.startswith('win') | 32 is_win = sys.platform.startswith('win') |
| 33 is_linux = sys.platform.startswith('linux') | 33 is_linux = sys.platform.startswith('linux') |
| 34 is_mac = sys.platform.startswith('darwin') | 34 is_mac = sys.platform.startswith('darwin') |
| 35 is_posix = is_linux or is_mac | 35 is_aix = sys.platform.startswith('aix') |
| 36 is_posix = is_linux or is_mac or is_aix |
| 36 | 37 |
| 37 def check_call(cmd, **kwargs): | 38 def check_call(cmd, **kwargs): |
| 38 logging.debug('Running: %s', ' '.join(cmd)) | 39 logging.debug('Running: %s', ' '.join(cmd)) |
| 39 | 40 |
| 40 # With shell=False, subprocess expects an executable on Windows | 41 # With shell=False, subprocess expects an executable on Windows |
| 41 if is_win and cmd and cmd[0].endswith('.py'): | 42 if is_win and cmd and cmd[0].endswith('.py'): |
| 42 cmd.insert(0, sys.executable) | 43 cmd.insert(0, sys.executable) |
| 43 | 44 |
| 44 subprocess.check_call(cmd, cwd=GN_ROOT, **kwargs) | 45 subprocess.check_call(cmd, cwd=GN_ROOT, **kwargs) |
| 45 | 46 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 'cxx = ' + cxx, | 217 'cxx = ' + cxx, |
| 217 'ar = ' + ar, | 218 'ar = ' + ar, |
| 218 'ld = ' + ld, | 219 'ld = ' + ld, |
| 219 '', | 220 '', |
| 220 ] | 221 ] |
| 221 | 222 |
| 222 if is_win: | 223 if is_win: |
| 223 template_filename = 'build_vs.ninja.template' | 224 template_filename = 'build_vs.ninja.template' |
| 224 elif is_mac: | 225 elif is_mac: |
| 225 template_filename = 'build_mac.ninja.template' | 226 template_filename = 'build_mac.ninja.template' |
| 227 elif is_aix: |
| 228 template_filename = 'build_aix.ninja.template' |
| 226 else: | 229 else: |
| 227 template_filename = 'build.ninja.template' | 230 template_filename = 'build.ninja.template' |
| 228 | 231 |
| 229 with open(os.path.join(GN_ROOT, 'bootstrap', template_filename)) as f: | 232 with open(os.path.join(GN_ROOT, 'bootstrap', template_filename)) as f: |
| 230 ninja_template = f.read() | 233 ninja_template = f.read() |
| 231 | 234 |
| 232 if is_win: | 235 if is_win: |
| 233 executable_ext = '.exe' | 236 executable_ext = '.exe' |
| 234 library_ext = '.lib' | 237 library_ext = '.lib' |
| 235 object_ext = '.obj' | 238 object_ext = '.obj' |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 f.write('\n'.join(ninja_header_lines)) | 294 f.write('\n'.join(ninja_header_lines)) |
| 292 f.write(ninja_template) | 295 f.write(ninja_template) |
| 293 f.write('\n'.join(ninja_lines)) | 296 f.write('\n'.join(ninja_lines)) |
| 294 | 297 |
| 295 def write_gn_ninja(path, root_gen_dir, options): | 298 def write_gn_ninja(path, root_gen_dir, options): |
| 296 if is_win: | 299 if is_win: |
| 297 cc = os.environ.get('CC', 'cl.exe') | 300 cc = os.environ.get('CC', 'cl.exe') |
| 298 cxx = os.environ.get('CXX', 'cl.exe') | 301 cxx = os.environ.get('CXX', 'cl.exe') |
| 299 ld = os.environ.get('LD', 'link.exe') | 302 ld = os.environ.get('LD', 'link.exe') |
| 300 ar = os.environ.get('AR', 'lib.exe') | 303 ar = os.environ.get('AR', 'lib.exe') |
| 304 elif is_aix: |
| 305 cc = os.environ.get('CC', 'gcc') |
| 306 cxx = os.environ.get('CXX', 'c++') |
| 307 ld = os.environ.get('LD', cxx) |
| 308 ar = os.environ.get('AR', 'ar -X64') |
| 301 else: | 309 else: |
| 302 cc = os.environ.get('CC', 'cc') | 310 cc = os.environ.get('CC', 'cc') |
| 303 cxx = os.environ.get('CXX', 'c++') | 311 cxx = os.environ.get('CXX', 'c++') |
| 304 ld = cxx | 312 ld = cxx |
| 305 ar = os.environ.get('AR', 'ar') | 313 ar = os.environ.get('AR', 'ar') |
| 306 | 314 |
| 307 cflags = os.environ.get('CFLAGS', '').split() | 315 cflags = os.environ.get('CFLAGS', '').split() |
| 308 cflags_cc = os.environ.get('CXXFLAGS', '').split() | 316 cflags_cc = os.environ.get('CXXFLAGS', '').split() |
| 309 ldflags = os.environ.get('LDFLAGS', '').split() | 317 ldflags = os.environ.get('LDFLAGS', '').split() |
| 310 include_dirs = [root_gen_dir, SRC_ROOT] | 318 include_dirs = [root_gen_dir, SRC_ROOT] |
| 311 libs = [] | 319 libs = [] |
| 312 | 320 |
| 313 # //base/allocator/allocator_extension.cc needs this macro defined, | 321 # //base/allocator/allocator_extension.cc needs this macro defined, |
| 314 # otherwise there would be link errors. | 322 # otherwise there would be link errors. |
| 315 cflags.extend(['-DNO_TCMALLOC', '-D__STDC_FORMAT_MACROS']) | 323 cflags.extend(['-DNO_TCMALLOC', '-D__STDC_FORMAT_MACROS']) |
| 316 | 324 |
| 317 if is_posix: | 325 if is_posix: |
| 318 if options.debug: | 326 if options.debug: |
| 319 cflags.extend(['-O0', '-g']) | 327 cflags.extend(['-O0', '-g']) |
| 320 else: | 328 else: |
| 329 # The linux::ppc64 BE binary doesn't "work" when |
| 330 # optimization level is set to 2 (0 works fine). |
| 321 cflags.extend(['-O2', '-g0']) | 331 cflags.extend(['-O2', '-g0']) |
| 322 | 332 |
| 323 cflags.extend([ | 333 cflags.extend([ |
| 324 '-D_FILE_OFFSET_BITS=64', | 334 '-D_FILE_OFFSET_BITS=64', |
| 325 '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS', | 335 '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS', |
| 326 '-pthread', | 336 '-pthread', |
| 327 '-pipe', | 337 '-pipe', |
| 328 '-fno-exceptions' | 338 '-fno-exceptions' |
| 329 ]) | 339 ]) |
| 330 cflags_cc.extend(['-std=c++11', '-Wno-c++11-narrowing']) | 340 cflags_cc.extend(['-std=c++11', '-Wno-c++11-narrowing']) |
| 341 if is_aix: |
| 342 cflags.extend(['-maix64']) |
| 343 ldflags.extend([ '-maix64 -Wl,-bbigtoc' ]) |
| 331 elif is_win: | 344 elif is_win: |
| 332 if not options.debug: | 345 if not options.debug: |
| 333 cflags.extend(['/Ox', '/DNDEBUG', '/GL']) | 346 cflags.extend(['/Ox', '/DNDEBUG', '/GL']) |
| 334 ldflags.extend(['/LTCG', '/OPT:REF', '/OPT:ICF']) | 347 ldflags.extend(['/LTCG', '/OPT:REF', '/OPT:ICF']) |
| 335 | 348 |
| 336 cflags.extend([ | 349 cflags.extend([ |
| 337 '/FS', | 350 '/FS', |
| 338 '/Gy', | 351 '/Gy', |
| 339 '/W3', '/wd4244', | 352 '/W3', '/wd4244', |
| 340 '/Zi', | 353 '/Zi', |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 'base/third_party/libevent/poll.c', | 603 'base/third_party/libevent/poll.c', |
| 591 'base/third_party/libevent/select.c', | 604 'base/third_party/libevent/select.c', |
| 592 'base/third_party/libevent/signal.c', | 605 'base/third_party/libevent/signal.c', |
| 593 'base/third_party/libevent/strlcpy.c', | 606 'base/third_party/libevent/strlcpy.c', |
| 594 ], | 607 ], |
| 595 'tool': 'cc', | 608 'tool': 'cc', |
| 596 'include_dirs': [], | 609 'include_dirs': [], |
| 597 'cflags': cflags + ['-DHAVE_CONFIG_H'], | 610 'cflags': cflags + ['-DHAVE_CONFIG_H'], |
| 598 } | 611 } |
| 599 | 612 |
| 600 if is_linux: | 613 if is_linux or is_aix: |
| 601 libs.extend(['-lrt', '-latomic']) | |
| 602 ldflags.extend(['-pthread']) | 614 ldflags.extend(['-pthread']) |
| 603 | 615 |
| 604 static_libraries['xdg_user_dirs'] = { | 616 static_libraries['xdg_user_dirs'] = { |
| 605 'sources': [ | 617 'sources': [ |
| 606 'base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc', | 618 'base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc', |
| 607 ], | 619 ], |
| 608 'tool': 'cxx', | 620 'tool': 'cxx', |
| 609 } | 621 } |
| 610 static_libraries['base']['sources'].extend([ | 622 static_libraries['base']['sources'].extend([ |
| 611 'base/allocator/allocator_shim.cc', | |
| 612 'base/allocator/allocator_shim_default_dispatch_to_glibc.cc', | |
| 613 'base/memory/shared_memory_posix.cc', | 623 'base/memory/shared_memory_posix.cc', |
| 614 'base/memory/shared_memory_tracker.cc', | 624 'base/memory/shared_memory_tracker.cc', |
| 615 'base/nix/xdg_util.cc', | 625 'base/nix/xdg_util.cc', |
| 616 'base/process/internal_linux.cc', | 626 'base/process/internal_linux.cc', |
| 617 'base/process/memory_linux.cc', | 627 'base/process/memory_linux.cc', |
| 618 'base/process/process_handle_linux.cc', | 628 'base/process/process_handle_linux.cc', |
| 619 'base/process/process_info_linux.cc', | 629 'base/process/process_info_linux.cc', |
| 620 'base/process/process_iterator_linux.cc', | 630 'base/process/process_iterator_linux.cc', |
| 621 'base/process/process_linux.cc', | 631 'base/process/process_linux.cc', |
| 622 'base/process/process_metrics_linux.cc', | 632 'base/process/process_metrics_linux.cc', |
| 623 'base/strings/sys_string_conversions_posix.cc', | 633 'base/strings/sys_string_conversions_posix.cc', |
| 624 'base/sys_info_linux.cc', | 634 'base/sys_info_linux.cc', |
| 625 'base/threading/platform_thread_linux.cc', | 635 'base/threading/platform_thread_linux.cc', |
| 626 'base/trace_event/malloc_dump_provider.cc', | 636 'base/trace_event/malloc_dump_provider.cc', |
| 627 ]) | 637 ]) |
| 628 static_libraries['libevent']['include_dirs'].extend([ | 638 if is_linux: |
| 629 os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'linux') | 639 static_libraries['base']['sources'].extend([ |
| 630 ]) | 640 'base/allocator/allocator_shim.cc', |
| 631 static_libraries['libevent']['sources'].extend([ | 641 'base/allocator/allocator_shim_default_dispatch_to_glibc.cc', |
| 632 'base/third_party/libevent/epoll.c', | 642 ]) |
| 633 ]) | 643 libs.extend(['-lrt', '-latomic']) |
| 634 | 644 static_libraries['libevent']['include_dirs'].extend([ |
| 645 os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'linux') |
| 646 ]) |
| 647 static_libraries['libevent']['sources'].extend([ |
| 648 'base/third_party/libevent/epoll.c', |
| 649 ]) |
| 650 else: |
| 651 libs.extend(['-lrt']) |
| 652 static_libraries['base']['sources'].extend([ |
| 653 'base/process/internal_aix.cc' |
| 654 ]) |
| 655 static_libraries['libevent']['include_dirs'].extend([ |
| 656 os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'aix') |
| 657 ]) |
| 658 static_libraries['libevent']['include_dirs'].extend([ |
| 659 os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'compat') |
| 660 ]) |
| 635 | 661 |
| 636 if is_mac: | 662 if is_mac: |
| 637 static_libraries['base']['sources'].extend([ | 663 static_libraries['base']['sources'].extend([ |
| 638 'base/base_paths_mac.mm', | 664 'base/base_paths_mac.mm', |
| 639 'base/build_time.cc', | 665 'base/build_time.cc', |
| 640 'base/rand_util.cc', | 666 'base/rand_util.cc', |
| 641 'base/rand_util_posix.cc', | 667 'base/rand_util_posix.cc', |
| 642 'base/files/file_util_mac.mm', | 668 'base/files/file_util_mac.mm', |
| 643 'base/mac/bundle_locations.mm', | 669 'base/mac/bundle_locations.mm', |
| 644 'base/mac/call_with_eh_frame.cc', | 670 'base/mac/call_with_eh_frame.cc', |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 cmd.append('-v') | 805 cmd.append('-v') |
| 780 cmd.append('gn') | 806 cmd.append('gn') |
| 781 check_call(cmd) | 807 check_call(cmd) |
| 782 | 808 |
| 783 if not options.debug and not is_win: | 809 if not options.debug and not is_win: |
| 784 check_call(['strip', os.path.join(build_dir, 'gn')]) | 810 check_call(['strip', os.path.join(build_dir, 'gn')]) |
| 785 | 811 |
| 786 | 812 |
| 787 if __name__ == '__main__': | 813 if __name__ == '__main__': |
| 788 sys.exit(main(sys.argv[1:])) | 814 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |