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

Side by Side Diff: tools/gn/bootstrap/bootstrap.py

Issue 2807463004: GN: aix port along with linux_s390x, linux_ppc64 and linux_ppc64le support. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 'cxx = ' + cxx, 216 'cxx = ' + cxx,
216 'ar = ' + ar, 217 'ar = ' + ar,
217 'ld = ' + ld, 218 'ld = ' + ld,
218 '', 219 '',
219 ] 220 ]
220 221
221 if is_win: 222 if is_win:
222 template_filename = 'build_vs.ninja.template' 223 template_filename = 'build_vs.ninja.template'
223 elif is_mac: 224 elif is_mac:
224 template_filename = 'build_mac.ninja.template' 225 template_filename = 'build_mac.ninja.template'
226 elif is_aix:
227 template_filename = 'build_aix.ninja.template'
225 else: 228 else:
226 template_filename = 'build.ninja.template' 229 template_filename = 'build.ninja.template'
227 230
228 with open(os.path.join(GN_ROOT, 'bootstrap', template_filename)) as f: 231 with open(os.path.join(GN_ROOT, 'bootstrap', template_filename)) as f:
229 ninja_template = f.read() 232 ninja_template = f.read()
230 233
231 if is_win: 234 if is_win:
232 executable_ext = '.exe' 235 executable_ext = '.exe'
233 library_ext = '.lib' 236 library_ext = '.lib'
234 object_ext = '.obj' 237 object_ext = '.obj'
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 f.write('\n'.join(ninja_header_lines)) 293 f.write('\n'.join(ninja_header_lines))
291 f.write(ninja_template) 294 f.write(ninja_template)
292 f.write('\n'.join(ninja_lines)) 295 f.write('\n'.join(ninja_lines))
293 296
294 def write_gn_ninja(path, root_gen_dir, options): 297 def write_gn_ninja(path, root_gen_dir, options):
295 if is_win: 298 if is_win:
296 cc = os.environ.get('CC', 'cl.exe') 299 cc = os.environ.get('CC', 'cl.exe')
297 cxx = os.environ.get('CXX', 'cl.exe') 300 cxx = os.environ.get('CXX', 'cl.exe')
298 ld = os.environ.get('LD', 'link.exe') 301 ld = os.environ.get('LD', 'link.exe')
299 ar = os.environ.get('AR', 'lib.exe') 302 ar = os.environ.get('AR', 'lib.exe')
303 elif is_aix:
304 cc = os.environ.get('CC', 'gcc')
305 cxx = os.environ.get('CXX', 'c++')
306 ld = os.environ.get('LD', cxx)
307 ar = os.environ.get('AR', 'ar -X64')
300 else: 308 else:
301 cc = os.environ.get('CC', 'cc') 309 cc = os.environ.get('CC', 'cc')
302 cxx = os.environ.get('CXX', 'c++') 310 cxx = os.environ.get('CXX', 'c++')
303 ld = cxx 311 ld = cxx
304 ar = os.environ.get('AR', 'ar') 312 ar = os.environ.get('AR', 'ar')
305 313
306 cflags = os.environ.get('CFLAGS', '').split() 314 cflags = os.environ.get('CFLAGS', '').split()
307 cflags_cc = os.environ.get('CXXFLAGS', '').split() 315 cflags_cc = os.environ.get('CXXFLAGS', '').split()
308 ldflags = os.environ.get('LDFLAGS', '').split() 316 ldflags = os.environ.get('LDFLAGS', '').split()
309 include_dirs = [root_gen_dir, SRC_ROOT] 317 include_dirs = [root_gen_dir, SRC_ROOT]
310 libs = [] 318 libs = []
311 319
312 # //base/allocator/allocator_extension.cc needs this macro defined, 320 # //base/allocator/allocator_extension.cc needs this macro defined,
313 # otherwise there would be link errors. 321 # otherwise there would be link errors.
314 cflags.extend(['-DNO_TCMALLOC', '-D__STDC_FORMAT_MACROS']) 322 cflags.extend(['-DNO_TCMALLOC', '-D__STDC_FORMAT_MACROS'])
315 323
316 if is_posix: 324 if is_posix:
317 if options.debug: 325 if options.debug:
318 cflags.extend(['-O0', '-g']) 326 cflags.extend(['-O0', '-g'])
319 else: 327 else:
328 # The linux::ppc64 BE binary doesn't "work" when
329 # optimization level is set to 2 (0 works fine).
Dirk Pranke 2017/04/14 01:19:33 This comment confuses me. If this is true, doesn't
rayb 2017/04/19 19:51:50 The current bootstrap script has no way of detecti
320 cflags.extend(['-O2', '-g0']) 330 cflags.extend(['-O2', '-g0'])
321 331
322 cflags.extend([ 332 cflags.extend([
323 '-D_FILE_OFFSET_BITS=64', 333 '-D_FILE_OFFSET_BITS=64',
324 '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS', 334 '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS',
325 '-pthread', 335 '-pthread',
326 '-pipe', 336 '-pipe',
327 '-fno-exceptions' 337 '-fno-exceptions'
328 ]) 338 ])
329 cflags_cc.extend(['-std=c++11', '-Wno-c++11-narrowing']) 339 cflags_cc.extend(['-std=c++11', '-Wno-c++11-narrowing'])
340 if is_aix:
341 cflags.extend(['-maix64'])
342 ldflags.extend([ '-maix64 -Wl,-bbigtoc' ])
330 elif is_win: 343 elif is_win:
331 if not options.debug: 344 if not options.debug:
332 cflags.extend(['/Ox', '/DNDEBUG', '/GL']) 345 cflags.extend(['/Ox', '/DNDEBUG', '/GL'])
333 ldflags.extend(['/LTCG', '/OPT:REF', '/OPT:ICF']) 346 ldflags.extend(['/LTCG', '/OPT:REF', '/OPT:ICF'])
334 347
335 cflags.extend([ 348 cflags.extend([
336 '/FS', 349 '/FS',
337 '/Gy', 350 '/Gy',
338 '/W3', '/wd4244', 351 '/W3', '/wd4244',
339 '/Zi', 352 '/Zi',
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 'base/third_party/libevent/poll.c', 602 'base/third_party/libevent/poll.c',
590 'base/third_party/libevent/select.c', 603 'base/third_party/libevent/select.c',
591 'base/third_party/libevent/signal.c', 604 'base/third_party/libevent/signal.c',
592 'base/third_party/libevent/strlcpy.c', 605 'base/third_party/libevent/strlcpy.c',
593 ], 606 ],
594 'tool': 'cc', 607 'tool': 'cc',
595 'include_dirs': [], 608 'include_dirs': [],
596 'cflags': cflags + ['-DHAVE_CONFIG_H'], 609 'cflags': cflags + ['-DHAVE_CONFIG_H'],
597 } 610 }
598 611
599 if is_linux: 612 if is_linux or is_aix:
600 libs.extend(['-lrt', '-latomic'])
601 ldflags.extend(['-pthread']) 613 ldflags.extend(['-pthread'])
602 614
603 static_libraries['xdg_user_dirs'] = { 615 static_libraries['xdg_user_dirs'] = {
604 'sources': [ 616 'sources': [
605 'base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc', 617 'base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
606 ], 618 ],
607 'tool': 'cxx', 619 'tool': 'cxx',
608 } 620 }
609 static_libraries['base']['sources'].extend([ 621 static_libraries['base']['sources'].extend([
610 'base/allocator/allocator_shim.cc', 622 'base/allocator/allocator_shim.cc',
611 'base/allocator/allocator_shim_default_dispatch_to_glibc.cc', 623 'base/allocator/allocator_shim_default_dispatch_to_glibc.cc',
612 'base/memory/shared_memory_posix.cc', 624 'base/memory/shared_memory_posix.cc',
613 'base/memory/shared_memory_tracker.cc', 625 'base/memory/shared_memory_tracker.cc',
614 'base/nix/xdg_util.cc', 626 'base/nix/xdg_util.cc',
615 'base/process/internal_linux.cc', 627 'base/process/internal_linux.cc',
616 'base/process/memory_linux.cc', 628 'base/process/memory_linux.cc',
617 'base/process/process_handle_linux.cc', 629 'base/process/process_handle_linux.cc',
618 'base/process/process_info_linux.cc', 630 'base/process/process_info_linux.cc',
619 'base/process/process_iterator_linux.cc', 631 'base/process/process_iterator_linux.cc',
620 'base/process/process_linux.cc', 632 'base/process/process_linux.cc',
621 'base/process/process_metrics_linux.cc', 633 'base/process/process_metrics_linux.cc',
622 'base/strings/sys_string_conversions_posix.cc', 634 'base/strings/sys_string_conversions_posix.cc',
623 'base/sys_info_linux.cc', 635 'base/sys_info_linux.cc',
624 'base/threading/platform_thread_linux.cc', 636 'base/threading/platform_thread_linux.cc',
625 'base/trace_event/malloc_dump_provider.cc', 637 'base/trace_event/malloc_dump_provider.cc',
626 ]) 638 ])
627 static_libraries['libevent']['include_dirs'].extend([ 639 if is_linux:
628 os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'linux') 640 libs.extend(['-lrt', '-latomic'])
629 ]) 641 static_libraries['libevent']['include_dirs'].extend([
630 static_libraries['libevent']['sources'].extend([ 642 os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'linux')
631 'base/third_party/libevent/epoll.c', 643 ])
632 ]) 644 static_libraries['libevent']['sources'].extend([
633 645 'base/third_party/libevent/epoll.c',
646 ])
647 else:
648 libs.extend(['-lrt'])
649 static_libraries['base']['sources'].extend([
650 'base/process/internal_aix.cc'
651 ])
652 static_libraries['libevent']['include_dirs'].extend([
653 os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'aix')
654 ])
655 static_libraries['libevent']['include_dirs'].extend([
656 os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'compat')
657 ])
634 658
635 if is_mac: 659 if is_mac:
636 static_libraries['base']['sources'].extend([ 660 static_libraries['base']['sources'].extend([
637 'base/base_paths_mac.mm', 661 'base/base_paths_mac.mm',
638 'base/build_time.cc', 662 'base/build_time.cc',
639 'base/rand_util.cc', 663 'base/rand_util.cc',
640 'base/rand_util_posix.cc', 664 'base/rand_util_posix.cc',
641 'base/files/file_util_mac.mm', 665 'base/files/file_util_mac.mm',
642 'base/mac/bundle_locations.mm', 666 'base/mac/bundle_locations.mm',
643 'base/mac/call_with_eh_frame.cc', 667 'base/mac/call_with_eh_frame.cc',
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 cmd.append('-v') 802 cmd.append('-v')
779 cmd.append('gn') 803 cmd.append('gn')
780 check_call(cmd) 804 check_call(cmd)
781 805
782 if not options.debug and not is_win: 806 if not options.debug and not is_win:
783 check_call(['strip', os.path.join(build_dir, 'gn')]) 807 check_call(['strip', os.path.join(build_dir, 'gn')])
784 808
785 809
786 if __name__ == '__main__': 810 if __name__ == '__main__':
787 sys.exit(main(sys.argv[1:])) 811 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698