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

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',
204 platform + '_arm_newlib')
205 arm_toolchain_sdk = os.path.join(pepperdir, 'toolchain',
206 os.path.basename(arm_toolchain))
207 buildbot_common.CopyDir(arm_toolchain, arm_toolchain_sdk)
208
197 if 'glibc' in toolchains: 209 if 'glibc' in toolchains:
198 # Untar the glibc toolchains 210 # Untar the glibc toolchains
199 tarfile = GetGlibcToolchain(platform, arch) 211 tarfile = GetGlibcToolchain(platform, arch)
200 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile], 212 buildbot_common.Run([sys.executable, CYGTAR, '-C', tmpdir, '-xf', tarfile],
201 cwd=NACL_DIR) 213 cwd=NACL_DIR)
202 214
203 # Then rename/move it to the pepper toolchain directory 215 # Then rename/move it to the pepper toolchain directory
204 srcdir = os.path.join(tmpdir, 'toolchain', tcname) 216 srcdir = os.path.join(tmpdir, 'toolchain', tcname)
205 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc') 217 glibcdir = os.path.join(pepperdir, 'toolchain', tcname + '_glibc')
206 buildbot_common.Move(srcdir, glibcdir) 218 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', 270 'irt.h': 'src/untrusted/irt/irt.h',
259 'irt_ppapi.h': 'src/untrusted/irt/irt_ppapi.h', 271 'irt_ppapi.h': 'src/untrusted/irt/irt_ppapi.h',
260 }, 272 },
261 'libs': { 273 'libs': {
262 }, 274 },
263 } 275 }
264 276
265 277
266 def InstallHeaders(tc_dst_inc, pepper_ver, tc_name): 278 def InstallHeaders(tc_dst_inc, pepper_ver, tc_name):
267 """Copies NaCl headers to expected locations in the toolchain.""" 279 """Copies NaCl headers to expected locations in the toolchain."""
280 if tc_name == 'arm':
281 # arm toolchain header should be the same as the x86 newlib
282 # ones
283 tc_name = 'newlib'
268 tc_map = HEADER_MAP[tc_name] 284 tc_map = HEADER_MAP[tc_name]
269 for filename in tc_map: 285 for filename in tc_map:
270 src = os.path.join(NACL_DIR, tc_map[filename]) 286 src = os.path.join(NACL_DIR, tc_map[filename])
271 dst = os.path.join(tc_dst_inc, filename) 287 dst = os.path.join(tc_dst_inc, filename)
272 buildbot_common.MakeDir(os.path.dirname(dst)) 288 buildbot_common.MakeDir(os.path.dirname(dst))
273 buildbot_common.CopyFile(src, dst) 289 buildbot_common.CopyFile(src, dst)
274 290
275 # Clean out per toolchain ppapi directory 291 # Clean out per toolchain ppapi directory
276 ppapi = os.path.join(tc_dst_inc, 'ppapi') 292 ppapi = os.path.join(tc_dst_inc, 'ppapi')
277 buildbot_common.RemoveDir(ppapi) 293 buildbot_common.RemoveDir(ppapi)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 356
341 # Copy the lib files 357 # Copy the lib files
342 buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib'), 358 buildbot_common.CopyDir(os.path.join(PPAPI_DIR, 'lib'),
343 os.path.join(tc_dst_inc, 'ppapi')) 359 os.path.join(tc_dst_inc, 'ppapi'))
344 360
345 361
346 def MakeNinjaRelPath(path): 362 def MakeNinjaRelPath(path):
347 return os.path.join(os.path.relpath(OUT_DIR, SRC_DIR), path) 363 return os.path.join(os.path.relpath(OUT_DIR, SRC_DIR), path)
348 364
349 365
350 def GypNinjaBuild_X86(pepperdir, platform, toolchains): 366 def GypNinjaInstall(pepperdir, platform, toolchains):
351 build_dir = 'gypbuild' 367 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') 368 ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release')
356 # src_file, dst_file, is_host_exe? 369 # src_file, dst_file, is_host_exe?
357 tools_files = [ 370 tools_files = [
358 ('sel_ldr', 'sel_ldr_x86_32', True), 371 ('sel_ldr', 'sel_ldr_x86_32', True),
359 ('ncval_x86_32', 'ncval_x86_32', True), 372 ('ncval_x86_32', 'ncval_x86_32', True),
360 ('ncval_arm', 'ncval_arm', True), 373 ('ncval_arm', 'ncval_arm', True),
361 ('irt_core_newlib_x32.nexe', 'irt_core_newlib_x32.nexe', False), 374 ('irt_core_newlib_x32.nexe', 'irt_core_newlib_x32.nexe', False),
362 ('irt_core_newlib_x64.nexe', 'irt_core_newlib_x64.nexe', False), 375 ('irt_core_newlib_x64.nexe', 'irt_core_newlib_x64.nexe', False),
363 ] 376 ]
364 if platform != 'mac': 377 if platform != 'mac':
(...skipping 11 matching lines...) Expand all
376 for src, dst, host_exe in tools_files: 389 for src, dst, host_exe in tools_files:
377 if platform == 'win' and host_exe: 390 if platform == 'win' and host_exe:
378 src += '.exe' 391 src += '.exe'
379 dst += '.exe' 392 dst += '.exe'
380 393
381 buildbot_common.CopyFile( 394 buildbot_common.CopyFile(
382 os.path.join(ninja_out_dir, src), 395 os.path.join(ninja_out_dir, src),
383 os.path.join(pepperdir, 'tools', dst)) 396 os.path.join(pepperdir, 'tools', dst))
384 397
385 for tc in set(toolchains) & set(['newlib', 'glibc']): 398 for tc in set(toolchains) & set(['newlib', 'glibc']):
386 for bits in '32', '64': 399 for archname in ('arm', '32', '64'):
400 if tc == 'glibc' and archname == 'arm':
401 continue
387 tc_dir = 'tc_' + tc 402 tc_dir = 'tc_' + tc
388 lib_dir = 'lib' + bits 403 lib_dir = 'lib' + archname
404 if archname == 'arm':
405 build_dir = 'gypbuild-arm'
406 tcdir = '%s_arm_%s' % (platform, tc)
407 else:
408 build_dir = 'gypbuild'
409 tcdir = '%s_x86_%s' % (platform, tc)
410
411 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) 412 src_dir = os.path.join(ninja_out_dir, 'gen', tc_dir, lib_dir)
390 tcpath = os.path.join(pepperdir, 'toolchain', 413 tcpath = os.path.join(pepperdir, 'toolchain', tcdir)
391 '%s_x86_%s' % (platform, tc)) 414 dst_dir = GetToolchainNaClLib(tc, tcpath, 'x86', archname)
392 dst_dir = GetToolchainNaClLib(tc, tcpath, 'x86', bits)
393 415
394 buildbot_common.MakeDir(dst_dir) 416 buildbot_common.MakeDir(dst_dir)
395 buildbot_common.CopyDir(os.path.join(src_dir, '*.a'), dst_dir) 417 buildbot_common.CopyDir(os.path.join(src_dir, '*.a'), dst_dir)
396 if tc == 'newlib': 418 if tc == 'newlib':
397 buildbot_common.CopyDir(os.path.join(src_dir, '*.o'), dst_dir) 419 buildbot_common.CopyDir(os.path.join(src_dir, '*.o'), dst_dir)
398 420
399 if tc == 'glibc': 421 if tc == 'glibc':
400 buildbot_common.CopyDir(os.path.join(src_dir, '*.so'), dst_dir) 422 buildbot_common.CopyDir(os.path.join(src_dir, '*.so'), dst_dir)
401 423
402 # TODO(binji): temporary hack; copy crt1.o from sdk toolchain directory. 424 ninja_tcpath = os.path.join(ninja_out_dir, 'gen', 'sdk', 'toolchain',
403 lib_dir = os.path.join(ninja_out_dir, 'gen', 'sdk', 'toolchain', 425 tcdir)
404 '%s_x86_%s' % (platform, tc), 'x86_64-nacl', 'lib') 426 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) 427 buildbot_common.CopyFile(os.path.join(lib_dir, 'crt1.o'), dst_dir)
408 428
409 429
410 def GypNinjaBuild_X86_Nacl(platform, rel_out_dir): 430 def GypNinjaBuild_Nacl(platform, rel_out_dir):
411 gyp_py = os.path.join(NACL_DIR, 'build', 'gyp_nacl') 431 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') 432 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') 433 all_gyp = os.path.join(NACL_DIR, 'build', 'all.gyp')
414 434
415 out_dir = MakeNinjaRelPath(rel_out_dir) 435 out_dir = MakeNinjaRelPath(rel_out_dir)
436 out_dir_arm = MakeNinjaRelPath(rel_out_dir + '-arm')
416 GypNinjaBuild('ia32', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir) 437 GypNinjaBuild('ia32', gyp_py, nacl_core_sdk_gyp, 'nacl_core_sdk', out_dir)
438 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) 439 GypNinjaBuild('ia32', gyp_py, all_gyp, 'ncval_x86_32', out_dir)
418 GypNinjaBuild(None, gyp_py, all_gyp, 'ncval_arm', out_dir) 440 GypNinjaBuild(None, gyp_py, all_gyp, 'ncval_arm', out_dir)
419 441
420 if platform == 'win': 442 if platform == 'win':
421 NinjaBuild('sel_ldr64', out_dir) 443 NinjaBuild('sel_ldr64', out_dir)
422 NinjaBuild('ncval_x86_64', out_dir) 444 NinjaBuild('ncval_x86_64', out_dir)
423 elif platform == 'linux': 445 elif platform == 'linux':
424 out_dir_64 = MakeNinjaRelPath(rel_out_dir + '_64') 446 out_dir_64 = MakeNinjaRelPath(rel_out_dir + '-64')
425 GypNinjaBuild('x64', gyp_py, nacl_core_sdk_gyp, 'sel_ldr', out_dir_64) 447 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) 448 GypNinjaBuild('x64', gyp_py, all_gyp, 'ncval_x86_64', out_dir_64)
427 449
428 # We only need sel_ldr and ncval_x86_64 from the 64-bit out directory. 450 # 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. 451 # sel_ldr needs to be renamed, so we'll call it sel_ldr64.
430 files_to_copy = [ 452 files_to_copy = [
431 ('sel_ldr', 'sel_ldr64'), 453 ('sel_ldr', 'sel_ldr64'),
432 ('ncval_x86_64', 'ncval_x86_64'), 454 ('ncval_x86_64', 'ncval_x86_64'),
433 ] 455 ]
434 files_to_copy.append(('nacl_helper_bootstrap', 'nacl_helper_bootstrap64')) 456 files_to_copy.append(('nacl_helper_bootstrap', 'nacl_helper_bootstrap64'))
435 457
436 for src, dst in files_to_copy: 458 for src, dst in files_to_copy:
437 buildbot_common.CopyFile( 459 buildbot_common.CopyFile(
438 os.path.join(SRC_DIR, out_dir_64, 'Release', src), 460 os.path.join(SRC_DIR, out_dir_64, 'Release', src),
439 os.path.join(SRC_DIR, out_dir, 'Release', dst)) 461 os.path.join(SRC_DIR, out_dir, 'Release', dst))
440 462
441 463
442 def GypNinjaBuild_X86_Chrome(rel_out_dir): 464 def GypNinjaBuild_Chrome(arch, rel_out_dir):
443 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium') 465 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
444 466
445 out_dir = MakeNinjaRelPath(rel_out_dir) 467 out_dir = MakeNinjaRelPath(rel_out_dir)
446 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'ppapi_untrusted.gyp') 468 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'ppapi_untrusted.gyp')
447 targets = ['ppapi_cpp_lib', 'ppapi_gles2_lib'] 469 targets = ['ppapi_cpp_lib', 'ppapi_gles2_lib']
448 GypNinjaBuild('ia32', gyp_py, gyp_file, targets, out_dir) 470 GypNinjaBuild(arch, gyp_py, gyp_file, targets, out_dir)
449 471
450 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client', 472 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client',
451 'native_client.gyp') 473 'native_client.gyp')
452 GypNinjaBuild('ia32', gyp_py, gyp_file, 'ppapi_lib', out_dir) 474 GypNinjaBuild(arch, gyp_py, gyp_file, 'ppapi_lib', out_dir)
453 475
454 476
455 def GypNinjaBuild_Pnacl(rel_out_dir, target_arch): 477 def GypNinjaBuild_Pnacl(rel_out_dir, target_arch):
456 # TODO(binji): This will build the pnacl_irt_shim twice; once as part of the 478 # 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 479 # Chromium build, and once here. When we move more of the SDK build process
458 # to gyp, we can remove this. 480 # to gyp, we can remove this.
459 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium') 481 gyp_py = os.path.join(SRC_DIR, 'build', 'gyp_chromium')
460 482
461 out_dir = MakeNinjaRelPath(rel_out_dir) 483 out_dir = MakeNinjaRelPath(rel_out_dir)
462 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client', 'src', 484 gyp_file = os.path.join(SRC_DIR, 'ppapi', 'native_client', 'src',
463 'untrusted', 'pnacl_irt_shim', 'pnacl_irt_shim.gyp') 485 'untrusted', 'pnacl_irt_shim', 'pnacl_irt_shim.gyp')
464 targets = ['pnacl_irt_shim'] 486 targets = ['pnacl_irt_shim']
465 GypNinjaBuild(target_arch, gyp_py, gyp_file, targets, out_dir) 487 GypNinjaBuild(target_arch, gyp_py, gyp_file, targets, out_dir, False)
466 488
467 489
468 def GypNinjaBuild(arch, gyp_py_script, gyp_file, targets, out_dir): 490 def GypNinjaBuild(arch, gyp_py_script, gyp_file, targets,
491 out_dir, force_arm_gcc=True):
469 gyp_env = copy.copy(os.environ) 492 gyp_env = copy.copy(os.environ)
470 gyp_env['GYP_GENERATORS'] = 'ninja' 493 gyp_env['GYP_GENERATORS'] = 'ninja'
471 gyp_defines = [] 494 gyp_defines = []
472 if options.mac_sdk: 495 if options.mac_sdk:
473 gyp_defines.append('mac_sdk=%s' % options.mac_sdk) 496 gyp_defines.append('mac_sdk=%s' % options.mac_sdk)
474 if arch: 497 if arch:
475 gyp_defines.append('target_arch=%s' % arch) 498 gyp_defines.append('target_arch=%s' % arch)
499 if arch == 'arm':
500 gyp_defines += ['armv7=1', 'arm_thumb=0', 'arm_neon=1']
501 if force_arm_gcc:
502 gyp_defines += ['nacl_enable_arm_gcc=1']
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)
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 663
623 MakeDirectoryOrClobber(pepperdir, 'src', clobber) 664 MakeDirectoryOrClobber(pepperdir, 'src', clobber)
624 665
625 # Copy individual files 666 # Copy individual files
626 files = ['favicon.ico', 'httpd.cmd'] 667 files = ['favicon.ico', 'httpd.cmd']
627 for filename in files: 668 for filename in files:
628 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir]) 669 oshelpers.Copy(['-v', os.path.join(SDK_EXAMPLE_DIR, filename), exampledir])
629 670
630 args = ['--dstroot=%s' % pepperdir, '--master'] 671 args = ['--dstroot=%s' % pepperdir, '--master']
631 for toolchain in toolchains: 672 for toolchain in toolchains:
632 args.append('--' + toolchain) 673 if toolchain != 'arm':
674 args.append('--' + toolchain)
633 675
634 for example in EXAMPLE_LIST: 676 for example in EXAMPLE_LIST:
635 dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc') 677 dsc = os.path.join(SDK_EXAMPLE_DIR, example, 'example.dsc')
636 args.append(dsc) 678 args.append(dsc)
637 679
638 for library in LIBRARY_LIST: 680 for library in LIBRARY_LIST:
639 dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc') 681 dsc = os.path.join(SDK_LIBRARY_DIR, library, 'library.dsc')
640 args.append(dsc) 682 args.append(dsc)
641 683
642 if build_experimental: 684 if build_experimental:
643 args.append('--experimental') 685 args.append('--experimental')
644 686
687 print "Generting Makefiles: %s" % str(args)
645 if generate_make.main(args): 688 if generate_make.main(args):
646 buildbot_common.ErrorExit('Failed to build examples.') 689 buildbot_common.ErrorExit('Failed to build examples.')
647 690
648 691
649 def GetWindowsEnvironment(): 692 def GetWindowsEnvironment():
650 sys.path.append(os.path.join(NACL_DIR, 'buildbot')) 693 sys.path.append(os.path.join(NACL_DIR, 'buildbot'))
651 import buildbot_standard 694 import buildbot_standard
652 695
653 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll 696 # buildbot_standard.SetupWindowsEnvironment expects a "context" object. We'll
654 # fake enough of that here to work. 697 # fake enough of that here to work.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 parser.add_option('--archive', help='Force the archive step.', 859 parser.add_option('--archive', help='Force the archive step.',
817 action='store_true') 860 action='store_true')
818 parser.add_option('--gyp', 861 parser.add_option('--gyp',
819 help='Use gyp to build examples/libraries/Makefiles.', 862 help='Use gyp to build examples/libraries/Makefiles.',
820 action='store_true') 863 action='store_true')
821 parser.add_option('--release', help='PPAPI release version.', 864 parser.add_option('--release', help='PPAPI release version.',
822 dest='release', default=None) 865 dest='release', default=None)
823 parser.add_option('--experimental', 866 parser.add_option('--experimental',
824 help='build experimental examples and libraries', action='store_true', 867 help='build experimental examples and libraries', action='store_true',
825 dest='build_experimental') 868 dest='build_experimental')
826 parser.add_option('--skip-toolchain', help='Skip toolchain download/untar', 869 parser.add_option('--skip-toolchain', help='Skip toolchain untar',
827 action='store_true') 870 action='store_true')
828 parser.add_option('--mac_sdk', 871 parser.add_option('--mac_sdk',
829 help='Set the mac_sdk (e.g. 10.6) to use when building with ninja.', 872 help='Set the mac_sdk (e.g. 10.6) to use when building with ninja.',
830 dest='mac_sdk') 873 dest='mac_sdk')
831 874
832 global options 875 global options
833 options, args = parser.parse_args(args[1:]) 876 options, args = parser.parse_args(args[1:])
834 platform = getos.GetPlatform() 877 platform = getos.GetPlatform()
835 arch = 'x86' 878 arch = 'x86'
836 879
837 generate_make.use_gyp = options.gyp 880 generate_make.use_gyp = options.gyp
838 881
839 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build 882 # TODO(binji) for now, only test examples on non-trybots. Trybots don't build
840 # pyauto Chrome. 883 # pyauto Chrome.
841 if buildbot_common.IsSDKBuilder(): 884 if buildbot_common.IsSDKBuilder():
842 options.run_tests = True 885 options.run_tests = True
843 options.run_pyauto_tests = True 886 options.run_pyauto_tests = True
844 options.archive = True 887 options.archive = True
845 888
846 if buildbot_common.IsSDKTrybot(): 889 if buildbot_common.IsSDKTrybot():
847 options.run_tests = True 890 options.run_tests = True
848 891
849 toolchains = ['newlib', 'glibc', 'pnacl', 'host'] 892 toolchains = ['newlib', 'glibc', 'arm', 'pnacl', 'host']
850 print 'Building: ' + ' '.join(toolchains) 893 print 'Building: ' + ' '.join(toolchains)
851 894
852 if options.archive and options.skip_tar: 895 if options.archive and options.skip_tar:
853 parser.error('Incompatible arguments with archive.') 896 parser.error('Incompatible arguments with archive.')
854 897
855 pepper_ver = str(int(build_utils.ChromeMajorVersion())) 898 pepper_ver = str(int(build_utils.ChromeMajorVersion()))
856 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1) 899 pepper_old = str(int(build_utils.ChromeMajorVersion()) - 1)
857 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver) 900 pepperdir = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_ver)
858 pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old) 901 pepperdir_old = os.path.join(SRC_DIR, 'out', 'pepper_' + pepper_old)
859 clnumber = build_utils.ChromeRevision() 902 clnumber = build_utils.ChromeRevision()
860 tarname = 'naclsdk_' + platform + '.tar.bz2' 903 tarname = 'naclsdk_' + platform + '.tar.bz2'
861 tarfile = os.path.join(OUT_DIR, tarname) 904 tarfile = os.path.join(OUT_DIR, tarname)
862 905
863 if options.release: 906 if options.release:
864 pepper_ver = options.release 907 pepper_ver = options.release
865 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber) 908 print 'Building PEPPER %s at %s' % (pepper_ver, clnumber)
866 909
867 if 'NACL_SDK_ROOT' in os.environ: 910 if 'NACL_SDK_ROOT' in os.environ:
868 # We don't want the currently configured NACL_SDK_ROOT to have any effect 911 # We don't want the currently configured NACL_SDK_ROOT to have any effect
869 # of the build. 912 # of the build.
870 del os.environ['NACL_SDK_ROOT'] 913 del os.environ['NACL_SDK_ROOT']
871 914
915 BuildStepCleanPepperDirs(pepperdir, pepperdir_old)
916 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools'])
917
872 if not options.skip_toolchain: 918 if not options.skip_toolchain:
873 BuildStepDownloadToolchains(platform) 919 BuildStepDownloadToolchains(platform)
874 BuildStepCleanPepperDirs(pepperdir, pepperdir_old) 920 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
875 BuildStepMakePepperDirs(pepperdir, ['include', 'toolchain', 'tools']) 921
876 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber) 922 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber)
877 if not options.skip_toolchain: 923 BuildStepBuildToolchains(pepperdir, platform, pepper_ver, toolchains)
878 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
879 BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains)
880 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs') 924 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs')
881 BuildStepCopyBuildHelpers(pepperdir, platform) 925 BuildStepCopyBuildHelpers(pepperdir, platform)
882 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, True) 926 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, True)
883 927
884 # Ship with libraries prebuilt, so run that first. 928 # Ship with libraries prebuilt, so run that first.
885 BuildStepBuildLibraries(pepperdir, platform, 'src') 929 BuildStepBuildLibraries(pepperdir, platform, 'src')
886 BuildStepGenerateNotice(pepperdir) 930 BuildStepGenerateNotice(pepperdir)
887 931
888 if not options.skip_tar: 932 if not options.skip_tar:
889 BuildStepTarBundle(pepper_ver, tarfile) 933 BuildStepTarBundle(pepper_ver, tarfile)
890 934
891 if options.run_tests: 935 if options.run_tests:
892 BuildStepRunTests() 936 BuildStepRunTests()
893 937
894 # Archive on non-trybots. 938 # Archive on non-trybots.
895 if options.archive: 939 if options.archive:
896 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile) 940 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
897 BuildStepArchiveSDKTools() 941 BuildStepArchiveSDKTools()
898 942
899 return 0 943 return 0
900 944
901 945
902 if __name__ == '__main__': 946 if __name__ == '__main__':
903 sys.exit(main(sys.argv)) 947 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