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

Side by Side Diff: native_client_sdk/src/build_tools/build_sdk.py

Issue 11280256: [NaCl SDK] Add arm gcc toolchain support to the SDK (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « no previous file | native_client_sdk/src/build_tools/generate_make.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Entry point for both build and try bots 6 """Entry point for both build and try bots
7 7
8 This script is invoked from XXX, usually without arguments 8 This script is invoked from XXX, usually without arguments
9 to package an SDK. It automatically determines whether 9 to package an SDK. It automatically determines whether
10 this SDK is for mac, win, linux. 10 this SDK is for mac, win, linux.
(...skipping 28 matching lines...) Expand all
39 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 39 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
40 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) 40 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR)
41 SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples') 41 SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples')
42 SDK_LIBRARY_DIR = os.path.join(SDK_SRC_DIR, 'libraries') 42 SDK_LIBRARY_DIR = os.path.join(SDK_SRC_DIR, 'libraries')
43 SDK_DIR = os.path.dirname(SDK_SRC_DIR) 43 SDK_DIR = os.path.dirname(SDK_SRC_DIR)
44 SRC_DIR = os.path.dirname(SDK_DIR) 44 SRC_DIR = os.path.dirname(SDK_DIR)
45 NACL_DIR = os.path.join(SRC_DIR, 'native_client') 45 NACL_DIR = os.path.join(SRC_DIR, 'native_client')
46 OUT_DIR = os.path.join(SRC_DIR, 'out') 46 OUT_DIR = os.path.join(SRC_DIR, 'out')
47 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi') 47 PPAPI_DIR = os.path.join(SRC_DIR, 'ppapi')
48 48
49
50 # Add SDK make tools scripts to the python path. 49 # Add SDK make tools scripts to the python path.
51 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) 50 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools'))
52 sys.path.append(os.path.join(NACL_DIR, 'build')) 51 sys.path.append(os.path.join(NACL_DIR, 'build'))
53 52
54 import getos 53 import getos
55 import http_download 54 import http_download
56 import oshelpers 55 import oshelpers
57 56
58 GSTORE = 'https://commondatastorage.googleapis.com/nativeclient-mirror/nacl/' 57 GSTORE = 'https://commondatastorage.googleapis.com/nativeclient-mirror/nacl/'
59 MAKE = 'nacl_sdk/make_3_81/make.exe' 58 MAKE = 'nacl_sdk/make_3_81/make.exe'
60 CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py') 59 CYGTAR = os.path.join(NACL_DIR, 'build', 'cygtar.py')
61 60
62
63 options = None 61 options = None
64 62
65 63
66 def GetGlibcToolchain(platform, arch): 64 def GetGlibcToolchain(platform, arch):
67 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') 65 tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars')
68 tcname = 'toolchain_%s_%s.tar.bz2' % (platform, arch) 66 tcname = 'toolchain_%s_%s.tar.bz2' % (platform, arch)
69 return os.path.join(tcdir, tcname) 67 return os.path.join(tcdir, tcname)
70 68
71 69
72 def GetNewlibToolchain(platform, arch): 70 def GetNewlibToolchain(platform, arch):
(...skipping 18 matching lines...) Expand all
91 if xarch: 89 if xarch:
92 return arch + '-' + str(xarch) 90 return arch + '-' + str(xarch)
93 return arch 91 return arch
94 92
95 93
96 def GetToolchainNaClInclude(tcname, tcpath, arch, xarch=None): 94 def GetToolchainNaClInclude(tcname, tcpath, arch, xarch=None):
97 if arch == 'x86': 95 if arch == 'x86':
98 if tcname == 'pnacl': 96 if tcname == 'pnacl':
99 return os.path.join(tcpath, 'newlib', 'sdk', 'include') 97 return os.path.join(tcpath, 'newlib', 'sdk', 'include')
100 return os.path.join(tcpath, 'x86_64-nacl', 'include') 98 return os.path.join(tcpath, 'x86_64-nacl', 'include')
99 elif arch == 'arm':
100 return os.path.join(tcpath, 'arm-nacl', 'include')
101 else: 101 else:
102 buildbot_common.ErrorExit('Unknown architecture.') 102 buildbot_common.ErrorExit('Unknown architecture: %s' % arch)
103 103
104 104
105 def GetToolchainNaClLib(tcname, tcpath, arch, xarch): 105 def GetToolchainNaClLib(tcname, tcpath, arch, xarch):
106 if arch == 'x86': 106 if arch == 'x86':
107 if tcname == 'pnacl': 107 if tcname == 'pnacl':
108 return os.path.join(tcpath, 'newlib', 'sdk', 'lib') 108 return os.path.join(tcpath, 'newlib', 'sdk', 'lib')
109 if str(xarch) == '32': 109 if str(xarch) == '32':
110 return os.path.join(tcpath, 'x86_64-nacl', 'lib32') 110 return os.path.join(tcpath, 'x86_64-nacl', 'lib32')
111 if str(xarch) == '64': 111 if str(xarch) == '64':
112 return os.path.join(tcpath, 'x86_64-nacl', 'lib') 112 return os.path.join(tcpath, 'x86_64-nacl', 'lib')
113 buildbot_common.ErrorExit('Unknown architecture.') 113 if str(xarch) == 'arm':
114 return os.path.join(tcpath, 'arm-nacl', 'lib')
115 buildbot_common.ErrorExit('Unknown architecture: %s' % arch)
114 116
115 117
116 def GetPNaClNativeLib(tcpath, arch): 118 def GetPNaClNativeLib(tcpath, arch):
117 if arch not in ['arm', 'x86-32', 'x86-64']: 119 if arch not in ['arm', 'x86-32', 'x86-64']:
118 buildbot_common.ErrorExit('Unknown architecture %s.' % arch) 120 buildbot_common.ErrorExit('Unknown architecture %s.' % arch)
119 return os.path.join(tcpath, 'lib-' + arch) 121 return os.path.join(tcpath, 'lib-' + arch)
120 122
121 123
122 def GetBuildArgs(tcname, tcpath, outdir, arch, xarch=None): 124 def GetBuildArgs(tcname, tcpath, outdir, arch, xarch=None):
123 """Return list of scons build arguments to generate user libraries.""" 125 """Return list of scons build arguments to generate user libraries."""
124 scons = GetScons() 126 scons = GetScons()
125 mode = '--mode=opt-host,nacl' 127 mode = '--mode=opt-host,nacl'
126 arch_name = GetArchName(arch, xarch) 128 arch_name = GetArchName(arch, xarch)
127 plat = 'platform=' + arch_name 129 plat = 'platform=' + arch_name
128 binarg = 'bindir=' + os.path.join(outdir, 'tools') 130 binarg = 'bindir=' + os.path.join(outdir, 'tools')
129 lib = 'libdir=' + GetToolchainNaClLib(tcname, tcpath, arch, xarch) 131 lib = 'libdir=' + GetToolchainNaClLib(tcname, tcpath, arch, xarch)
130 args = [scons, mode, plat, binarg, lib, '-j10', 132 args = [scons, mode, plat, binarg, lib, '-j10',
131 'install_bin', 'install_lib'] 133 'install_bin', 'install_lib']
132 if tcname == 'glibc': 134 if tcname == 'glibc':
133 args.append('--nacl_glibc') 135 args.append('--nacl_glibc')
134 136
135 if tcname == 'pnacl': 137 if tcname == 'pnacl':
136 args.append('bitcode=1') 138 args.append('bitcode=1')
137 139
138 print "Building %s (%s): %s" % (tcname, arch, ' '.join(args)) 140 print "Building %s (%s): %s" % (tcname, arch, ' '.join(args))
139 return args 141 return args
140 142
141 143
142 def BuildStepDownloadToolchains(platform): 144 def BuildStepDownloadToolchains(platform):
143 buildbot_common.BuildStep('Rerun hooks to get toolchains') 145 buildbot_common.BuildStep('Running download_toolchains.py')
144 buildbot_common.Run(['gclient', 'runhooks'], 146 download_script = os.path.join('build', 'download_toolchains.py')
145 cwd=SRC_DIR, shell=(platform == 'win')) 147 buildbot_common.Run([sys.executable, download_script,
148 '--no-arm-trusted', '--arm-untrusted', '--keep'],
149 cwd=NACL_DIR)
146 150
147 151
148 def BuildStepCleanPepperDirs(pepperdir, pepperdir_old): 152 def BuildStepCleanPepperDirs(pepperdir, pepperdir_old):
149 buildbot_common.BuildStep('Clean Pepper Dirs') 153 buildbot_common.BuildStep('Clean Pepper Dirs')
150 buildbot_common.RemoveDir(pepperdir_old) 154 buildbot_common.RemoveDir(pepperdir_old)
151 buildbot_common.RemoveDir(pepperdir) 155 buildbot_common.RemoveDir(pepperdir)
152 buildbot_common.MakeDir(pepperdir) 156 buildbot_common.MakeDir(pepperdir)
153 157
154 158
155 def BuildStepMakePepperDirs(pepperdir, subdirs): 159 def BuildStepMakePepperDirs(pepperdir, subdirs):
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 # Untar the newlib toolchains 191 # Untar the newlib toolchains
188 tarfile = GetNewlibToolchain(platform, arch) 192 tarfile = GetNewlibToolchain(platform, arch)
189 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], 193 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile],
190 cwd=NACL_DIR) 194 cwd=NACL_DIR)
191 195
192 # Then rename/move it to the pepper toolchain directory 196 # Then rename/move it to the pepper toolchain directory
193 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk') 197 srcdir = os.path.join(tmpdir, 'sdk', 'nacl-sdk')
194 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') 198 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
195 buildbot_common.Move(srcdir, newlibdir) 199 buildbot_common.Move(srcdir, newlibdir)
196 200
201 if 'arm' in toolchains:
202 # Copy the existing arm toolchain from native_client tree
203 arm_toolchain = os.path.join(NACL_DIR, 'toolchain', 'linux_arm_newlib')
204 arm_toolchain_sdk = os.path.join(pepperdir, 'toolchain',
205 os.path.basename(arm_toolchain))
206 buildbot_common.CopyDir(arm_toolchain, arm_toolchain_sdk)
207
197 if 'glibc' in toolchains: 208 if 'glibc' in toolchains:
198 # Untar the glibc toolchains 209 # Untar the glibc toolchains
199 tarfile = GetGlibcToolchain(platform, arch) 210 tarfile = GetGlibcToolchain(platform, arch)
200 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], 211 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile],
201 cwd=NACL_DIR) 212 cwd=NACL_DIR)
202 213
203 # Then rename/move it to the pepper toolchain directory 214 # Then rename/move it to the pepper toolchain directory
204 srcdir = os.path.join(tmpdir, 'toolchain', tcname) 215 srcdir = os.path.join(tmpdir, 'toolchain', tcname)
205 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') 216 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
206 buildbot_common.Move(srcdir, glibcdir) 217 buildbot_common.Move(srcdir, glibcdir)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 'irt.h': 'src/untrusted/irt/irt.h', 269 'irt.h': 'src/untrusted/irt/irt.h',
259 'irt_ppapi.h': 'src/untrusted/irt/irt_ppapi.h', 270 'irt_ppapi.h': 'src/untrusted/irt/irt_ppapi.h',
260 }, 271 },
261 'libs': { 272 'libs': {
262 }, 273 },
263 } 274 }
264 275
265 276
266 def InstallHeaders(tc_dst_inc, pepper_ver, tc_name): 277 def InstallHeaders(tc_dst_inc, pepper_ver, tc_name):
267 """Copies NaCl headers to expected locations in the toolchain.""" 278 """Copies NaCl headers to expected locations in the toolchain."""
279 if tc_name == 'arm':
280 # arm toolchain header should be the same as the x86 newlib
281 # ones
282 tc_name = 'newlib'
268 tc_map = HEADER_MAP[tc_name] 283 tc_map = HEADER_MAP[tc_name]
269 for filename in tc_map: 284 for filename in tc_map:
270 src = os.path.join(NACL_DIR, tc_map[filename]) 285 src = os.path.join(NACL_DIR, tc_map[filename])
271 dst = os.path.join(tc_dst_inc, filename) 286 dst = os.path.join(tc_dst_inc, filename)
272 buildbot_common.MakeDir(os.path.dirname(dst)) 287 buildbot_common.MakeDir(os.path.dirname(dst))
273 buildbot_common.CopyFile(src, dst) 288 buildbot_common.CopyFile(src, dst)
274 289
275 # Clean out per toolchain ppapi directory 290 # Clean out per toolchain ppapi directory
276 ppapi = os.path.join(tc_dst_inc, 'ppapi') 291 ppapi = os.path.join(tc_dst_inc, 'ppapi')
277 buildbot_common.RemoveDir(ppapi) 292 buildbot_common.RemoveDir(ppapi)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 355
341 # Copy the lib files 356 # Copy the lib files
342 buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib'), 357 buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib'),
343 os.path.join(tc_dst_inc, 'ppapi')) 358 os.path.join(tc_dst_inc, 'ppapi'))
344 359
345 360
346 def MakeNinjaRelPath(path): 361 def MakeNinjaRelPath(path):
347 return os.path.join(os.path.relpath(OUT_DIR, SRC_DIR), path) 362 return os.path.join(os.path.relpath(OUT_DIR, SRC_DIR), path)
348 363
349 364
350 def GypNinjaBuild_X86(pepperdir, platform, toolchains): 365 def GypNinjaInstall(pepperdir, platform, toolchains):
351 build_dir = 'gypbuild' 366 build_dir = 'gypbuild'
352 GypNinjaBuild_X86_Nacl(platform, build_dir)
353 GypNinjaBuild_X86_Chrome(build_dir)
354
355 ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release') 367 ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release')
356 # src_file, dst_file, is_host_exe? 368 # src_file, dst_file, is_host_exe?
357 tools_files = [ 369 tools_files = [
358 ('sel_ldr', 'sel_ldr_x86_32', True), 370 ('sel_ldr', 'sel_ldr_x86_32', True),
359 ('ncval_x86_32', 'ncval_x86_32', True), 371 ('ncval_x86_32', 'ncval_x86_32', True),
360 ('ncval_arm', 'ncval_arm', True), 372 ('ncval_arm', 'ncval_arm', True),
361 ('irt_core_newlib_x32.nexe', 'irt_core_newlib_x32.nexe', False), 373 ('irt_core_newlib_x32.nexe', 'irt_core_newlib_x32.nexe', False),
362 ('irt_core_newlib_x64.nexe', 'irt_core_newlib_x64.nexe', False), 374 ('irt_core_newlib_x64.nexe', 'irt_core_newlib_x64.nexe', False),
363 ] 375 ]
364 if platform != 'mac': 376 if platform != 'mac':
(...skipping 11 matching lines...) Expand all
376 for src, dst, host_exe in tools_files: 388 for src, dst, host_exe in tools_files:
377 if platform == 'win' and host_exe: 389 if platform == 'win' and host_exe:
378 src += '.exe' 390 src += '.exe'
379 dst += '.exe' 391 dst += '.exe'
380 392
381 buildbot_common.CopyFile( 393 buildbot_common.CopyFile(
382 os.path.join(ninja_out_dir, src), 394 os.path.join(ninja_out_dir, src),
383 os.path.join(pepperdir, 'tools', dst)) 395 os.path.join(pepperdir, 'tools', dst))
384 396
385 for tc in set(toolchains) & set(['newlib', 'glibc']): 397 for tc in set(toolchains) & set(['newlib', 'glibc']):
386 for bits in '32', '64': 398 for archname in ('arm', '32', '64'):
399 if tc == 'glibc' and archname == 'arm':
400 continue
387 tc_dir = 'tc_' + tc 401 tc_dir = 'tc_' + tc
388 lib_dir = 'lib' + bits 402 lib_dir = 'lib' + archname
403 if archname == 'arm':
404 build_dir = 'gypbuild-arm'
405 tcdir = '%s_arm_%s' % (platform, tc)
406 else:
407 build_dir = 'gypbuild'
408 tcdir = '%s_x86_%s' % (platform, tc)
409
410 ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release')
389 src_dir = os.path.join(ninja_out_dir, 'gen', tc_dir, lib_dir) 411 src_dir = os.path.join(ninja_out_dir, 'gen', tc_dir, lib_dir)
390 tcpath = os.path.join(pepperdir, 'toolchain', 412 tcpath = os.path.join(pepperdir, 'toolchain', tcdir)
391 '%s_x86_%s' % (platform, tc)) 413 dst_dir = GetToolchainNaClLib(tc, tcpath, 'x86', archname)
392 dst_dir = GetToolchainNaClLib(tc, tcpath, 'x86', bits)
393 414
394 buildbot_common.MakeDir(dst_dir) 415 buildbot_common.MakeDir(dst_dir)
395 buildbot_common.CopyDir(os.path.join(src_dir, '*.a'), dst_dir) 416 buildbot_common.CopyDir(os.path.join(src_dir, '*.a'), dst_dir)
396 if tc == 'newlib': 417 if tc == 'newlib':
397 buildbot_common.CopyDir(os.path.join(src_dir, '*.o'), dst_dir) 418 buildbot_common.CopyDir(os.path.join(src_dir, '*.o'), dst_dir)
398 419
399 if tc == 'glibc': 420 if tc == 'glibc':
400 buildbot_common.CopyDir(os.path.join(src_dir, '*.so'), dst_dir) 421 buildbot_common.CopyDir(os.path.join(src_dir, '*.so'), dst_dir)
401 422
402 # TODO(binji): temporary hack; copy crt1.o from sdk toolchain directory. 423 ninja_tcpath = os.path.join(ninja_out_dir, 'gen', 'sdk', 'toolchain',
403 lib_dir = os.path.join(ninja_out_dir, 'gen', 'sdk', 'toolchain', 424 tcdir)
404 '%s_x86_%s' % (platform, tc), 'x86_64-nacl', 'lib') 425 lib_dir = GetToolchainNaClLib(tc, ninja_tcpath, 'x86', archname)
405 if bits == '32':
406 lib_dir += '32'
407 buildbot_common.CopyFile(os.path.join(lib_dir, 'crt1.o'), dst_dir) 426 buildbot_common.CopyFile(os.path.join(lib_dir, 'crt1.o'), dst_dir)
408 427
409 428
410 def GypNinjaBuild_X86_Nacl(platform, rel_out_dir): 429 def GypNinjaBuild_Nacl(platform, rel_out_dir):
411 gyp_py = os.path.join(NACL_DIR, 'build', 'gyp_nacl') 430 gyp_py = os.path.join(NACL_DIR, 'build', 'gyp_nacl')
412 nacl_core_sdk_gyp = os.path.join(NACL_DIR, 'build', 'nacl_core_sdk.gyp') 431 nacl_core_sdk_gyp = os.path.join(NACL_DIR, 'build', 'nacl_core_sdk.gyp')
413 all_gyp = os.path.join(NACL_DIR, 'build', 'all.gyp') 432 all_gyp = os.path.join(NACL_DIR, 'build', 'all.gyp')
414 433
415 out_dir = MakeNinjaRelPath(rel_out_dir) 434 out_dir = MakeNinjaRelPath(rel_out_dir)
435 out_dir_arm = MakeNinjaRelPath(rel_out_dir + '-arm')
416 GypNinjaBuild('ia32', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir) 436 GypNinjaBuild('ia32', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir)
437 GypNinjaBuild('arm', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir_arm)
417 GypNinjaBuild('ia32', gyp_py, all_gyp, 'ncval_x86_32', out_dir) 438 GypNinjaBuild('ia32', gyp_py, all_gyp, 'ncval_x86_32', out_dir)
418 GypNinjaBuild(None, gyp_py, all_gyp, 'ncval_arm', out_dir) 439 GypNinjaBuild(None, gyp_py, all_gyp, 'ncval_arm', out_dir)
419 440
420 if platform == 'win': 441 if platform == 'win':
421 NinjaBuild('sel_ldr64', out_dir) 442 NinjaBuild('sel_ldr64', out_dir)
422 NinjaBuild('ncval_x86_64', out_dir) 443 NinjaBuild('ncval_x86_64', out_dir)
423 elif platform == 'linux': 444 elif platform == 'linux':
424 out_dir_64 = MakeNinjaRelPath(rel_out_dir + '_64') 445 out_dir_64 = MakeNinjaRelPath(rel_out_dir + '-64')
425 GypNinjaBuild('x64', gyp_py, nacl_core_sdk_gyp, 'sel_ldr', out_dir_64) 446 GypNinjaBuild('x64', gyp_py, nacl_core_sdk_gyp, 'sel_ldr', out_dir_64)
426 GypNinjaBuild('x64', gyp_py, all_gyp, 'ncval_x86_64', out_dir_64) 447 GypNinjaBuild('x64', gyp_py, all_gyp, 'ncval_x86_64', out_dir_64)
427 448
428 # We only need sel_ldr and ncval_x86_64 from the 64-bit out directory. 449 # We only need sel_ldr and ncval_x86_64 from the 64-bit out directory.
429 # sel_ldr needs to be renamed, so we'll call it sel_ldr64. 450 # sel_ldr needs to be renamed, so we'll call it sel_ldr64.
430 files_to_copy = [ 451 files_to_copy = [
431 ('sel_ldr', 'sel_ldr64'), 452 ('sel_ldr', 'sel_ldr64'),
432 ('ncval_x86_64', 'ncval_x86_64'), 453 ('ncval_x86_64', 'ncval_x86_64'),
433 ] 454 ]
434 files_to_copy.append(('nacl_helper_bootstrap', 'nacl_helper_bootstrap64')) 455 files_to_copy.append(('nacl_helper_bootstrap', 'nacl_helper_bootstrap64'))
435 456
436 for src, dst in files_to_copy: 457 for src, dst in files_to_copy:
437 buildbot_common.CopyFile( 458 buildbot_common.CopyFile(
438 os.path.join(SRC_DIR, out_dir_64, 'Release', src), 459 os.path.join(SRC_DIR, out_dir_64, 'Release', src),
439 os.path.join(SRC_DIR, out_dir, 'Release', dst)) 460 os.path.join(SRC_DIR, out_dir, 'Release', dst))
440 461
441 462
442 def GypNinjaBuild_X86_Chrome(rel_out_dir): 463 def GypNinjaBuild_Chrome(arch, rel_out_dir):
443 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium') 464 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
444 465
445 out_dir = MakeNinjaRelPath(rel_out_dir) 466 out_dir = MakeNinjaRelPath(rel_out_dir)
446 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'ppapi_untrusted.gyp') 467 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'ppapi_untrusted.gyp')
447 targets = ['ppapi_cpp_lib', 'ppapi_gles2_lib'] 468 targets = ['ppapi_cpp_lib', 'ppapi_gles2_lib']
448 GypNinjaBuild('ia32', gyp_py, gyp_file, targets, out_dir) 469 GypNinjaBuild(arch, gyp_py, gyp_file, targets, out_dir)
449 470
450 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client', 471 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client',
451 'native_client.gyp') 472 'native_client.gyp')
452 GypNinjaBuild('ia32', gyp_py, gyp_file, 'ppapi_lib', out_dir) 473 GypNinjaBuild(arch, gyp_py, gyp_file, 'ppapi_lib', out_dir)
453 474
454 475
455 def GypNinjaBuild_Pnacl(rel_out_dir, target_arch): 476 def GypNinjaBuild_Pnacl(rel_out_dir, target_arch):
456 # TODO(binji): This will build the pnacl_irt_shim twice; once as part of the 477 # TODO(binji): This will build the pnacl_irt_shim twice; once as part of the
457 # Chromium build, and once here. When we move more of the SDK build process 478 # Chromium build, and once here. When we move more of the SDK build process
458 # to gyp, we can remove this. 479 # to gyp, we can remove this.
459 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium') 480 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
460 481
461 out_dir = MakeNinjaRelPath(rel_out_dir) 482 out_dir = MakeNinjaRelPath(rel_out_dir)
462 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client', 'src', 483 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client', 'src',
463 'untrusted', 'pnacl_irt_shim', 'pnacl_irt_shim.gyp') 484 'untrusted', 'pnacl_irt_shim', 'pnacl_irt_shim.gyp')
464 targets = ['pnacl_irt_shim'] 485 targets = ['pnacl_irt_shim']
465 GypNinjaBuild(target_arch, gyp_py, gyp_file, targets, out_dir) 486 GypNinjaBuild(target_arch, gyp_py, gyp_file, targets, out_dir, False)
466 487
467 488
468 def GypNinjaBuild(arch, gyp_py_script, gyp_file, targets, out_dir): 489 def GypNinjaBuild(arch, gyp_py_script, gyp_file, targets,
490 out_dir, force_arm_gcc=True):
469 gyp_env = copy.copy(os.environ) 491 gyp_env = copy.copy(os.environ)
470 gyp_env['GYP_GENERATORS'] = 'ninja' 492 gyp_env['GYP_GENERATORS'] = 'ninja'
471 gyp_defines = [] 493 gyp_defines = []
472 if options.mac_sdk: 494 if options.mac_sdk:
473 gyp_defines.append('mac_sdk=%s' % options.mac_sdk) 495 gyp_defines.append('mac_sdk=%s' % options.mac_sdk)
474 if arch: 496 if arch:
475 gyp_defines.append('target_arch=%s' % arch) 497 gyp_defines.append('target_arch=%s' % arch)
498 if arch == 'arm':
499 gyp_defines += ['armv7=1', 'arm_thumb=0', 'arm_neon=1']
500 if force_arm_gcc:
501 gyp_defines += ['build_newlib_arm_gcc=1']
502 gyp_defines += ['build_newlib_arm_pnacl=0']
476 503
477 gyp_env['GYP_DEFINES'] = ' '.join(gyp_defines) 504 gyp_env['GYP_DEFINES'] = ' '.join(gyp_defines)
505 for key in ['GYP_GENERATORS', 'GYP_DEFINES']:
506 value = gyp_env[key]
507 print '%s="%s"' % (key, value)
Sam Clegg 2012/11/30 19:05:11 I added more logging here, which I found useful bu
478 gyp_generator_flags = ['-G', 'output_dir=%s' % (out_dir,)] 508 gyp_generator_flags = ['-G', 'output_dir=%s' % (out_dir,)]
479 gyp_depth = '--depth=.' 509 gyp_depth = '--depth=.'
480 buildbot_common.Run( 510 buildbot_common.Run(
481 [sys.executable, gyp_py_script, gyp_file, gyp_depth] + \ 511 [sys.executable, gyp_py_script, gyp_file, gyp_depth] + \
482 gyp_generator_flags, 512 gyp_generator_flags,
483 cwd=SRC_DIR, 513 cwd=SRC_DIR,
484 env=gyp_env) 514 env=gyp_env)
485 NinjaBuild(targets, out_dir) 515 NinjaBuild(targets, out_dir)
486 516
487 517
488 def NinjaBuild(targets, out_dir): 518 def NinjaBuild(targets, out_dir):
489 if type(targets) is not list: 519 if type(targets) is not list:
490 targets = [targets] 520 targets = [targets]
491 out_config_dir = os.path.join(out_dir, 'Release') 521 out_config_dir = os.path.join(out_dir, 'Release')
492 buildbot_common.Run(['ninja', '-C', out_config_dir] + targets, cwd=SRC_DIR) 522 buildbot_common.Run(['ninja', '-C', out_config_dir] + targets, cwd=SRC_DIR)
493 523
494 524
495 def BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, 525 def BuildStepBuildToolchains(pepperdir, platform, pepper_ver, toolchains):
496 toolchains):
497 buildbot_common.BuildStep('SDK Items') 526 buildbot_common.BuildStep('SDK Items')
498 527
499 tcname = platform + '_' + arch 528 GypNinjaBuild_Nacl(platform, 'gypbuild')
529
530 tcname = platform + '_x86'
500 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') 531 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
501 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') 532 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
502 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') 533 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl')
503 534
504 # Run scons TC build steps 535 # Run scons TC build steps
505 if arch == 'x86': 536 if set(toolchains) & set(['glibc', 'newlib']):
506 if set(toolchains) & set(['newlib', 'glibc']): 537 GypNinjaBuild_Chrome('ia32', 'gypbuild')
507 GypNinjaBuild_X86(pepperdir, platform, toolchains)
508 538
509 if 'newlib' in toolchains: 539 if 'arm' in toolchains:
510 InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'), 540 GypNinjaBuild_Chrome('arm', 'gypbuild-arm')
511 pepper_ver,
512 'newlib')
513 541
514 if 'glibc' in toolchains: 542 GypNinjaInstall(pepperdir, platform, toolchains)
515 InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'),
516 pepper_ver,
517 'glibc')
518 543
519 if 'pnacl' in toolchains: 544 if 'newlib' in toolchains:
520 shell = platform == 'win' 545 InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'),
521 buildbot_common.Run( 546 pepper_ver,
522 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '32'), 547 'newlib')
523 cwd=NACL_DIR, shell=shell)
524 buildbot_common.Run(
525 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '64'),
526 cwd=NACL_DIR, shell=shell)
527 548
528 for arch in ('ia32', 'arm'): 549 if 'glibc' in toolchains:
529 # Fill in the latest native pnacl shim library from the chrome build. 550 InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'),
530 GypNinjaBuild_Pnacl('gypbuild-' + arch, arch) 551 pepper_ver,
531 pnacl_libdir_map = { 'ia32': 'x86-64', 'arm': 'arm' } 552 'glibc')
532 release_build_dir = os.path.join(OUT_DIR, 'gypbuild-' + arch,
533 'Release', 'gen', 'tc_pnacl_translate',
534 'lib-' + pnacl_libdir_map[arch])
535 buildbot_common.CopyFile(
536 os.path.join(release_build_dir, 'libpnacl_irt_shim.a'),
537 GetPNaClNativeLib(pnacldir, pnacl_libdir_map[arch]))
538 553
539 InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), 554 if 'arm' in toolchains:
540 pepper_ver, 555 tcname = platform + '_arm_newlib'
541 'newlib') 556 armdir = os.path.join(pepperdir, 'toolchain', tcname)
542 else: 557 InstallHeaders(GetToolchainNaClInclude('newlib', armdir, 'arm'),
543 buildbot_common.ErrorExit('Missing arch %s' % arch) 558 pepper_ver, 'arm')
559
560 if 'pnacl' in toolchains:
561 shell = platform == 'win'
562 buildbot_common.Run(
563 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '32'),
564 cwd=NACL_DIR, shell=shell)
565 buildbot_common.Run(
566 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '64'),
567 cwd=NACL_DIR, shell=shell)
568
569 for arch in ('ia32', 'arm'):
570 # Fill in the latest native pnacl shim library from the chrome build.
571 build_dir = 'gypbuild-pnacl-' + arch
572 GypNinjaBuild_Pnacl(build_dir, arch)
573 pnacl_libdir_map = { 'ia32': 'x86-64', 'arm': 'arm' }
574 release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release',
575 'gen', 'tc_pnacl_translate',
576 'lib-' + pnacl_libdir_map[arch])
577
578 buildbot_common.CopyFile(
579 os.path.join(release_build_dir, 'libpnacl_irt_shim.a'),
580 GetPNaClNativeLib(pnacldir, pnacl_libdir_map[arch]))
581
582 InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'),
583 pepper_ver,
584 'newlib')
544 585
545 586
546 def BuildStepCopyBuildHelpers(pepperdir, platform): 587 def BuildStepCopyBuildHelpers(pepperdir, platform):
547 buildbot_common.BuildStep('Copy build helpers') 588 buildbot_common.BuildStep('Copy build helpers')
548 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), 589 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
549 os.path.join(pepperdir, 'tools')) 590 os.path.join(pepperdir, 'tools'))
550 if platform == 'win': 591 if platform == 'win':
551 buildbot_common.BuildStep('Add MAKE') 592 buildbot_common.BuildStep('Add MAKE')
552 http_download.HttpDownload(GSTORE + MAKE, 593 http_download.HttpDownload(GSTORE + MAKE,
553 os.path.join(pepperdir, 'tools', 'make.exe')) 594 os.path.join(pepperdir, 'tools', 'make.exe'))
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 661
621 MakeDirectoryOrClobber(pepperdir, 'src', clobber) 662 MakeDirectoryOrClobber(pepperdir, 'src', clobber)
622 663
623 # Copy individual files 664 # Copy individual files
624 files = ['favicon.ico', 'httpd.cmd'] 665 files = ['favicon.ico', 'httpd.cmd']
625 for filename in files: 666 for filename in files:
626 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir]) 667 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir])
627 668
628 args = ['--dstroot=%s' % pepperdir, '--master'] 669 args = ['--dstroot=%s' % pepperdir, '--master']
629 for toolchain in toolchains: 670 for toolchain in toolchains:
630 args.append('--' + toolchain) 671 if toolchain != 'arm':
672 args.append('--' + toolchain)
631 673
632 for example in EXAMPLE_LIST: 674 for example in EXAMPLE_LIST:
633 dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc') 675 dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc')
634 args.append(dsc) 676 args.append(dsc)
635 677
636 for library in LIBRARY_LIST: 678 for library in LIBRARY_LIST:
637 dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc') 679 dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc')
638 args.append(dsc) 680 args.append(dsc)
639 681
640 if build_experimental: 682 if build_experimental:
641 args.append('--experimental') 683 args.append('--experimental')
642 684
685 print "Generting Makefiles: %s" % str(args)
Sam Clegg 2012/11/30 19:05:11 Extra logging, maybe not needed? This is another
binji 2012/12/03 19:52:44 I half agree with this -- on the one hand, it is u
643 if generate_make.main(args): 686 if generate_make.main(args):
644 buildbot_common.ErrorExit('Failed to build examples.') 687 buildbot_common.ErrorExit('Failed to build examples.')
645 688
646 689
647 def GetWindowsEnvironment(): 690 def GetWindowsEnvironment():
648 sys.path.append(os.path.join(NACL_DIR, 'buildbot')) 691 sys.path.append(os.path.join(NACL_DIR, 'buildbot'))
649 import buildbot_standard 692 import buildbot_standard
650 693
651 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll 694 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll
652 # fake enough of that here to work. 695 # fake enough of that here to work.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 parser.add_option('--archive', help='Force the archive step.', 857 parser.add_option('--archive', help='Force the archive step.',
815 action='store_true') 858 action='store_true')
816 parser.add_option('--gyp', 859 parser.add_option('--gyp',
817 help='Use gyp to build examples/libraries/Makefiles.', 860 help='Use gyp to build examples/libraries/Makefiles.',
818 action='store_true') 861 action='store_true')
819 parser.add_option('--release', help='PPAPI release version.', 862 parser.add_option('--release', help='PPAPI release version.',
820 dest='release', default=None) 863 dest='release', default=None)
821 parser.add_option('--experimental', 864 parser.add_option('--experimental',
822 help='build experimental examples and libraries', action='store_true', 865 help='build experimental examples and libraries', action='store_true',
823 dest='build_experimental') 866 dest='build_experimental')
824 parser.add_option('--skip-toolchain', help='Skip toolchain download/untar', 867 parser.add_option('--skip-toolchain', help='Skip toolchain untar',
825 action='store_true') 868 action='store_true')
826 parser.add_option('--mac_sdk', 869 parser.add_option('--mac_sdk',
827 help='Set the mac_sdk (e.g. 10.6) to use when building with ninja.', 870 help='Set the mac_sdk (e.g. 10.6) to use when building with ninja.',
828 dest='mac_sdk') 871 dest='mac_sdk')
829 872
830 global options 873 global options
831 options, args = parser.parse_args(args[1:]) 874 options, args = parser.parse_args(args[1:])
832 platform = getos.GetPlatform() 875 platform = getos.GetPlatform()
833 arch = 'x86' 876 arch = 'x86'
834 877
835 generate_make.use_gyp = options.gyp 878 generate_make.use_gyp = options.gyp
836 879
837 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build 880 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build
838 # pyauto Chrome. 881 # pyauto Chrome.
839 if buildbot_common.IsSDKBuilder(): 882 if buildbot_common.IsSDKBuilder():
840 options.run_tests = True 883 options.run_tests = True
841 options.run_pyauto_tests = True 884 options.run_pyauto_tests = True
842 options.archive = True 885 options.archive = True
843 886
844 if buildbot_common.IsSDKTrybot(): 887 if buildbot_common.IsSDKTrybot():
845 options.run_tests = True 888 options.run_tests = True
846 889
847 toolchains = ['newlib', 'glibc', 'pnacl', 'host'] 890 toolchains = ['newlib', 'glibc', 'arm', 'pnacl', 'host']
848 print 'Building: ' + ' '.join(toolchains) 891 print 'Building: ' + ' '.join(toolchains)
849 892
850 if options.archive and options.skip_tar: 893 if options.archive and options.skip_tar:
851 parser.error('Incompatible arguments with archive.') 894 parser.error('Incompatible arguments with archive.')
852 895
853 pepper_ver = str(int(build_utils.ChromeMajorVersion())) 896 pepper_ver = str(int(build_utils.ChromeMajorVersion()))
854 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) 897 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1)
855 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) 898 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
856 pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old) 899 pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old)
857 clnumber = build_utils.ChromeRevision() 900 clnumber = build_utils.ChromeRevision()
858 tarname = 'naclsdk_' + platform + '.tar.bz2' 901 tarname = 'naclsdk_' + platform + '.tar.bz2'
859 tarfile = os.path.join(OUT_DIR, tarname) 902 tarfile = os.path.join(OUT_DIR, tarname)
860 903
861 if options.release: 904 if options.release:
862 pepper_ver = options.release 905 pepper_ver = options.release
863 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) 906 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)
864 907
865 if 'NACL_SDK_ROOT' in os.environ: 908 if 'NACL_SDK_ROOT' in os.environ:
866 # We don't want the currently configured NACL_SDK_ROOT to have any effect 909 # We don't want the currently configured NACL_SDK_ROOT to have any effect
867 # of the build. 910 # of the build.
868 del os.environ['NACL_SDK_ROOT'] 911 del os.environ['NACL_SDK_ROOT']
869 912
913 BuildStepCleanPepperDirs(pepperdir, pepperdir_old)
914 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools'])
915
870 if not options.skip_toolchain: 916 if not options.skip_toolchain:
871 BuildStepDownloadToolchains(platform) 917 BuildStepDownloadToolchains(platform)
872 BuildStepCleanPepperDirs(pepperdir, pepperdir_old) 918 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
873 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools']) 919
874 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber) 920 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber)
875 if not options.skip_toolchain: 921 BuildStepBuildToolchains(pepperdir, platform, pepper_ver, toolchains)
876 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
877 BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains)
878 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs') 922 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs')
879 BuildStepCopyBuildHelpers(pepperdir, platform) 923 BuildStepCopyBuildHelpers(pepperdir, platform)
880 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, True) 924 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, True)
881 925
882 # Ship with libraries prebuilt, so run that first. 926 # Ship with libraries prebuilt, so run that first.
883 BuildStepBuildLibraries(pepperdir, platform, 'src') 927 BuildStepBuildLibraries(pepperdir, platform, 'src')
884 BuildStepGenerateNotice(pepperdir) 928 BuildStepGenerateNotice(pepperdir)
885 929
886 if not options.skip_tar: 930 if not options.skip_tar:
887 BuildStepTarBundle(pepper_ver, tarfile) 931 BuildStepTarBundle(pepper_ver, tarfile)
888 932
889 if options.run_tests: 933 if options.run_tests:
890 BuildStepRunTests() 934 BuildStepRunTests()
891 935
892 # Archive on non-trybots. 936 # Archive on non-trybots.
893 if options.archive: 937 if options.archive:
894 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile) 938 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
895 BuildStepArchiveSDKTools() 939 BuildStepArchiveSDKTools()
896 940
897 return 0 941 return 0
898 942
899 943
900 if __name__ == '__main__': 944 if __name__ == '__main__':
901 sys.exit(main(sys.argv)) 945 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/build_tools/generate_make.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698