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

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)
binji 2012/12/03 19:48:47 nit: align with (
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 += ['nacl_enable_arm_gcc=1']
476 502
477 gyp_env['GYP_DEFINES'] = ' '.join(gyp_defines) 503 gyp_env['GYP_DEFINES'] = ' '.join(gyp_defines)
504 for key in ['GYP_GENERATORS', 'GYP_DEFINES']:
505 value = gyp_env[key]
506 print '%s="%s"' % (key, value)
binji 2012/12/03 19:48:47 useful to keep?
478 gyp_generator_flags = ['-G', 'output_dir=%s' % (out_dir,)] 507 gyp_generator_flags = ['-G', 'output_dir=%s' % (out_dir,)]
479 gyp_depth = '--depth=.' 508 gyp_depth = '--depth=.'
480 buildbot_common.Run( 509 buildbot_common.Run(
481 [sys.executable, gyp_py_script, gyp_file, gyp_depth] + \ 510 [sys.executable, gyp_py_script, gyp_file, gyp_depth] + \
482 gyp_generator_flags, 511 gyp_generator_flags,
483 cwd=SRC_DIR, 512 cwd=SRC_DIR,
484 env=gyp_env) 513 env=gyp_env)
485 NinjaBuild(targets, out_dir) 514 NinjaBuild(targets, out_dir)
486 515
487 516
488 def NinjaBuild(targets, out_dir): 517 def NinjaBuild(targets, out_dir):
489 if type(targets) is not list: 518 if type(targets) is not list:
490 targets = [targets] 519 targets = [targets]
491 out_config_dir = os.path.join(out_dir, 'Release') 520 out_config_dir = os.path.join(out_dir, 'Release')
492 buildbot_common.Run(['ninja', '-C', out_config_dir] + targets, cwd=SRC_DIR) 521 buildbot_common.Run(['ninja', '-C', out_config_dir] + targets, cwd=SRC_DIR)
493 522
494 523
495 def BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, 524 def BuildStepBuildToolchains(pepperdir, platform, pepper_ver, toolchains):
496 toolchains):
497 buildbot_common.BuildStep('SDK Items') 525 buildbot_common.BuildStep('SDK Items')
498 526
499 tcname = platform + '_' + arch 527 GypNinjaBuild_Nacl(platform, 'gypbuild')
528
529 tcname = platform + '_x86'
500 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib') 530 newlibdir = os.path.join(pepperdir, 'toolchain', tcname + '_newlib')
501 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') 531 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
502 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl') 532 pnacldir = os.path.join(pepperdir, 'toolchain', tcname + '_pnacl')
503 533
504 # Run scons TC build steps 534 # Run scons TC build steps
505 if arch == 'x86': 535 if set(toolchains) & set(['glibc', 'newlib']):
506 if set(toolchains) & set(['newlib', 'glibc']): 536 GypNinjaBuild_Chrome('ia32', 'gypbuild')
507 GypNinjaBuild_X86(pepperdir, platform, toolchains)
508 537
509 if 'newlib' in toolchains: 538 if 'arm' in toolchains:
510 InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'), 539 GypNinjaBuild_Chrome('arm', 'gypbuild-arm')
511 pepper_ver,
512 'newlib')
513 540
514 if 'glibc' in toolchains: 541 GypNinjaInstall(pepperdir, platform, toolchains)
515 InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'),
516 pepper_ver,
517 'glibc')
518 542
519 if 'pnacl' in toolchains: 543 if 'newlib' in toolchains:
520 shell = platform == 'win' 544 InstallHeaders(GetToolchainNaClInclude('newlib', newlibdir, 'x86'),
521 buildbot_common.Run( 545 pepper_ver,
522 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '32'), 546 '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 547
528 for arch in ('ia32', 'arm'): 548 if 'glibc' in toolchains:
529 # Fill in the latest native pnacl shim library from the chrome build. 549 InstallHeaders(GetToolchainNaClInclude('glibc', glibcdir, 'x86'),
530 GypNinjaBuild_Pnacl('gypbuild-' + arch, arch) 550 pepper_ver,
531 pnacl_libdir_map = { 'ia32': 'x86-64', 'arm': 'arm' } 551 '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 552
539 InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), 553 if 'arm' in toolchains:
540 pepper_ver, 554 tcname = platform + '_arm_newlib'
541 'newlib') 555 armdir = os.path.join(pepperdir, 'toolchain', tcname)
542 else: 556 InstallHeaders(GetToolchainNaClInclude('newlib', armdir, 'arm'),
543 buildbot_common.ErrorExit('Missing arch %s' % arch) 557 pepper_ver, 'arm')
558
559 if 'pnacl' in toolchains:
560 shell = platform == 'win'
561 buildbot_common.Run(
562 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '32'),
563 cwd=NACL_DIR, shell=shell)
564 buildbot_common.Run(
565 GetBuildArgs('pnacl', pnacldir, pepperdir, 'x86', '64'),
566 cwd=NACL_DIR, shell=shell)
567
568 for arch in ('ia32', 'arm'):
569 # Fill in the latest native pnacl shim library from the chrome build.
570 build_dir = 'gypbuild-pnacl-' + arch
571 GypNinjaBuild_Pnacl(build_dir, arch)
572 pnacl_libdir_map = { 'ia32': 'x86-64', 'arm': 'arm' }
573 release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release',
574 'gen', 'tc_pnacl_translate',
575 'lib-' + pnacl_libdir_map[arch])
576
577 buildbot_common.CopyFile(
578 os.path.join(release_build_dir, 'libpnacl_irt_shim.a'),
579 GetPNaClNativeLib(pnacldir, pnacl_libdir_map[arch]))
580
581 InstallHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'),
582 pepper_ver,
583 'newlib')
544 584
545 585
546 def BuildStepCopyBuildHelpers(pepperdir, platform): 586 def BuildStepCopyBuildHelpers(pepperdir, platform):
547 buildbot_common.BuildStep('Copy build helpers') 587 buildbot_common.BuildStep('Copy build helpers')
548 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), 588 buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'),
549 os.path.join(pepperdir, 'tools')) 589 os.path.join(pepperdir, 'tools'))
550 if platform == 'win': 590 if platform == 'win':
551 buildbot_common.BuildStep('Add MAKE') 591 buildbot_common.BuildStep('Add MAKE')
552 http_download.HttpDownload(GSTORE + MAKE, 592 http_download.HttpDownload(GSTORE + MAKE,
553 os.path.join(pepperdir, 'tools', 'make.exe')) 593 os.path.join(pepperdir, 'tools', 'make.exe'))
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 660
621 MakeDirectoryOrClobber(pepperdir, 'src', clobber) 661 MakeDirectoryOrClobber(pepperdir, 'src', clobber)
622 662
623 # Copy individual files 663 # Copy individual files
624 files = ['favicon.ico', 'httpd.cmd'] 664 files = ['favicon.ico', 'httpd.cmd']
625 for filename in files: 665 for filename in files:
626 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir]) 666 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir])
627 667
628 args = ['--dstroot=%s' % pepperdir, '--master'] 668 args = ['--dstroot=%s' % pepperdir, '--master']
629 for toolchain in toolchains: 669 for toolchain in toolchains:
630 args.append('--' + toolchain) 670 if toolchain != 'arm':
671 args.append('--' + toolchain)
631 672
632 for example in EXAMPLE_LIST: 673 for example in EXAMPLE_LIST:
633 dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc') 674 dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc')
634 args.append(dsc) 675 args.append(dsc)
635 676
636 for library in LIBRARY_LIST: 677 for library in LIBRARY_LIST:
637 dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc') 678 dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc')
638 args.append(dsc) 679 args.append(dsc)
639 680
640 if build_experimental: 681 if build_experimental:
641 args.append('--experimental') 682 args.append('--experimental')
642 683
684 print "Generting Makefiles: %s" % str(args)
binji 2012/12/03 19:48:47 Generating
643 if generate_make.main(args): 685 if generate_make.main(args):
644 buildbot_common.ErrorExit('Failed to build examples.') 686 buildbot_common.ErrorExit('Failed to build examples.')
645 687
646 688
647 def GetWindowsEnvironment(): 689 def GetWindowsEnvironment():
648 sys.path.append(os.path.join(NACL_DIR, 'buildbot')) 690 sys.path.append(os.path.join(NACL_DIR, 'buildbot'))
649 import buildbot_standard 691 import buildbot_standard
650 692
651 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll 693 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll
652 # fake enough of that here to work. 694 # 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.', 856 parser.add_option('--archive', help='Force the archive step.',
815 action='store_true') 857 action='store_true')
816 parser.add_option('--gyp', 858 parser.add_option('--gyp',
817 help='Use gyp to build examples/libraries/Makefiles.', 859 help='Use gyp to build examples/libraries/Makefiles.',
818 action='store_true') 860 action='store_true')
819 parser.add_option('--release', help='PPAPI release version.', 861 parser.add_option('--release', help='PPAPI release version.',
820 dest='release', default=None) 862 dest='release', default=None)
821 parser.add_option('--experimental', 863 parser.add_option('--experimental',
822 help='build experimental examples and libraries', action='store_true', 864 help='build experimental examples and libraries', action='store_true',
823 dest='build_experimental') 865 dest='build_experimental')
824 parser.add_option('--skip-toolchain', help='Skip toolchain download/untar', 866 parser.add_option('--skip-toolchain', help='Skip toolchain untar',
825 action='store_true') 867 action='store_true')
826 parser.add_option('--mac_sdk', 868 parser.add_option('--mac_sdk',
827 help='Set the mac_sdk (e.g. 10.6) to use when building with ninja.', 869 help='Set the mac_sdk (e.g. 10.6) to use when building with ninja.',
828 dest='mac_sdk') 870 dest='mac_sdk')
829 871
830 global options 872 global options
831 options, args = parser.parse_args(args[1:]) 873 options, args = parser.parse_args(args[1:])
832 platform = getos.GetPlatform() 874 platform = getos.GetPlatform()
833 arch = 'x86' 875 arch = 'x86'
834 876
835 generate_make.use_gyp = options.gyp 877 generate_make.use_gyp = options.gyp
836 878
837 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build 879 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build
838 # pyauto Chrome. 880 # pyauto Chrome.
839 if buildbot_common.IsSDKBuilder(): 881 if buildbot_common.IsSDKBuilder():
840 options.run_tests = True 882 options.run_tests = True
841 options.run_pyauto_tests = True 883 options.run_pyauto_tests = True
842 options.archive = True 884 options.archive = True
843 885
844 if buildbot_common.IsSDKTrybot(): 886 if buildbot_common.IsSDKTrybot():
845 options.run_tests = True 887 options.run_tests = True
846 888
847 toolchains = ['newlib', 'glibc', 'pnacl', 'host'] 889 toolchains = ['newlib', 'glibc', 'arm', 'pnacl', 'host']
848 print 'Building: ' + ' '.join(toolchains) 890 print 'Building: ' + ' '.join(toolchains)
849 891
850 if options.archive and options.skip_tar: 892 if options.archive and options.skip_tar:
851 parser.error('Incompatible arguments with archive.') 893 parser.error('Incompatible arguments with archive.')
852 894
853 pepper_ver = str(int(build_utils.ChromeMajorVersion())) 895 pepper_ver = str(int(build_utils.ChromeMajorVersion()))
854 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) 896 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1)
855 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) 897 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
856 pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old) 898 pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old)
857 clnumber = build_utils.ChromeRevision() 899 clnumber = build_utils.ChromeRevision()
858 tarname = 'naclsdk_' + platform + '.tar.bz2' 900 tarname = 'naclsdk_' + platform + '.tar.bz2'
859 tarfile = os.path.join(OUT_DIR, tarname) 901 tarfile = os.path.join(OUT_DIR, tarname)
860 902
861 if options.release: 903 if options.release:
862 pepper_ver = options.release 904 pepper_ver = options.release
863 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) 905 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)
864 906
865 if 'NACL_SDK_ROOT' in os.environ: 907 if 'NACL_SDK_ROOT' in os.environ:
866 # We don't want the currently configured NACL_SDK_ROOT to have any effect 908 # We don't want the currently configured NACL_SDK_ROOT to have any effect
867 # of the build. 909 # of the build.
868 del os.environ['NACL_SDK_ROOT'] 910 del os.environ['NACL_SDK_ROOT']
869 911
912 BuildStepCleanPepperDirs(pepperdir, pepperdir_old)
913 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools'])
914
870 if not options.skip_toolchain: 915 if not options.skip_toolchain:
871 BuildStepDownloadToolchains(platform) 916 BuildStepDownloadToolchains(platform)
872 BuildStepCleanPepperDirs(pepperdir, pepperdir_old) 917 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
873 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools']) 918
874 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber) 919 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber)
875 if not options.skip_toolchain: 920 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') 921 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs')
879 BuildStepCopyBuildHelpers(pepperdir, platform) 922 BuildStepCopyBuildHelpers(pepperdir, platform)
880 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, True) 923 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, True)
881 924
882 # Ship with libraries prebuilt, so run that first. 925 # Ship with libraries prebuilt, so run that first.
883 BuildStepBuildLibraries(pepperdir, platform, 'src') 926 BuildStepBuildLibraries(pepperdir, platform, 'src')
884 BuildStepGenerateNotice(pepperdir) 927 BuildStepGenerateNotice(pepperdir)
885 928
886 if not options.skip_tar: 929 if not options.skip_tar:
887 BuildStepTarBundle(pepper_ver, tarfile) 930 BuildStepTarBundle(pepper_ver, tarfile)
888 931
889 if options.run_tests: 932 if options.run_tests:
890 BuildStepRunTests() 933 BuildStepRunTests()
891 934
892 # Archive on non-trybots. 935 # Archive on non-trybots.
893 if options.archive: 936 if options.archive:
894 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile) 937 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
895 BuildStepArchiveSDKTools() 938 BuildStepArchiveSDKTools()
896 939
897 return 0 940 return 0
898 941
899 942
900 if __name__ == '__main__': 943 if __name__ == '__main__':
901 sys.exit(main(sys.argv)) 944 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