OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client 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 """Recipes for NativeClient toolchain packages. | 6 """Recipes for NativeClient toolchain packages. |
7 | 7 |
8 The real entry plumbing is in toolchain_main.py. | 8 The real entry plumbing is in toolchain_main.py. |
9 """ | 9 """ |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 '--disable-shared', | 55 '--disable-shared', |
56 '--prefix=', | 56 '--prefix=', |
57 ] | 57 ] |
58 | 58 |
59 CONFIGURE_HOST_TOOL = CONFIGURE_HOST_LIB + [ | 59 CONFIGURE_HOST_TOOL = CONFIGURE_HOST_LIB + [ |
60 '--with-pkgversion=' + PACKAGE_NAME, | 60 '--with-pkgversion=' + PACKAGE_NAME, |
61 '--with-bugurl=' + BUG_URL, | 61 '--with-bugurl=' + BUG_URL, |
62 '--without-zlib', | 62 '--without-zlib', |
63 ] | 63 ] |
64 | 64 |
| 65 |
| 66 def NewlibLibcScript(arch): |
| 67 template = """/* |
| 68 * This is a linker script that gets installed as libc.a for the |
| 69 * newlib-based NaCl toolchain. It brings in the constituent |
| 70 * libraries that make up what -lc means semantically. |
| 71 */ |
| 72 OUTPUT_FORMAT(%s) |
| 73 GROUP ( libcrt_common.a libnacl.a ) |
| 74 """ |
| 75 if arch == 'arm': |
| 76 # Listing three formats instead of one makes -EL/-EB switches work |
| 77 # for the endian-switchable ARM backend. |
| 78 format_list = ['elf32-littlearm-nacl', |
| 79 'elf32-bigarm-nacl', |
| 80 'elf32-littlearm-nacl'] |
| 81 else: |
| 82 raise Exception('TODO(mcgrathr): OUTPUT_FORMAT for %s' % arch) |
| 83 return template % ', '.join(['"' + fmt + '"' for fmt in format_list]) |
| 84 |
| 85 |
65 def ConfigureTargetArgs(arch): | 86 def ConfigureTargetArgs(arch): |
66 config_target = arch + '-nacl' | 87 config_target = arch + '-nacl' |
67 return ['--target=' + config_target, '--with-sysroot=/' + config_target] | 88 return ['--target=' + config_target, '--with-sysroot=/' + config_target] |
68 | 89 |
| 90 |
69 def CommandsInBuild(command_lines): | 91 def CommandsInBuild(command_lines): |
70 return [command.Mkdir('build')] + [command.Command(cmd, cwd='build') | 92 return [command.Mkdir('build')] + [command.Command(cmd, cwd='build') |
71 for cmd in command_lines] | 93 for cmd in command_lines] |
72 | 94 |
73 def UnpackSrc(is_gzip): | 95 def UnpackSrc(is_gzip): |
74 if is_gzip: | 96 if is_gzip: |
75 extract = EXTRACT_STRIP_TGZ | 97 extract = EXTRACT_STRIP_TGZ |
76 else: | 98 else: |
77 extract = EXTRACT_STRIP_TBZ2 | 99 extract = EXTRACT_STRIP_TBZ2 |
78 return [ | 100 return [ |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 for dirname in ['bits', 'sys', 'machine']] | 280 for dirname in ['bits', 'sys', 'machine']] |
259 newlib_unpack.append(command.Command([ | 281 newlib_unpack.append(command.Command([ |
260 'python', | 282 'python', |
261 os.path.join('%(top_srcdir)s', | 283 os.path.join('%(top_srcdir)s', |
262 'src', 'trusted', 'service_runtime', 'export_header.py'), | 284 'src', 'trusted', 'service_runtime', 'export_header.py'), |
263 os.path.join('%(top_srcdir)s', | 285 os.path.join('%(top_srcdir)s', |
264 'src', 'trusted', 'service_runtime', 'include'), | 286 'src', 'trusted', 'service_runtime', 'include'), |
265 newlib_sys_nacl, | 287 newlib_sys_nacl, |
266 ])) | 288 ])) |
267 | 289 |
| 290 def NewlibFile(subdir, name): |
| 291 return os.path.join('%(output)s', target + '-nacl', subdir, name) |
| 292 |
268 libs = { | 293 libs = { |
269 'newlib_' + target: { | 294 'newlib_' + target: { |
270 'dependencies': lib_deps, | 295 'dependencies': lib_deps, |
271 'git_url': GIT_BASE_URL + '/nacl-newlib.git', | 296 'git_url': GIT_BASE_URL + '/nacl-newlib.git', |
272 'git_revision': GIT_REVISIONS['newlib'], | 297 'git_revision': GIT_REVISIONS['newlib'], |
273 'unpack_commands': newlib_unpack, | 298 'unpack_commands': newlib_unpack, |
274 'commands': TargetCommands(target, [ | 299 'commands': TargetCommands(target, [ |
275 CONFIGURE_CMD + | 300 CONFIGURE_CMD + |
276 CONFIGURE_HOST_TOOL + | 301 CONFIGURE_HOST_TOOL + |
277 ConfigureTargetArgs(target) + [ | 302 ConfigureTargetArgs(target) + [ |
278 '--disable-libgloss', | 303 '--disable-libgloss', |
279 '--enable-newlib-iconv', | 304 '--enable-newlib-iconv', |
280 '--enable-newlib-io-long-long', | 305 '--enable-newlib-io-long-long', |
281 '--enable-newlib-io-long-double', | 306 '--enable-newlib-io-long-double', |
282 '--enable-newlib-io-c99-formats', | 307 '--enable-newlib-io-c99-formats', |
283 '--enable-newlib-mb', | 308 '--enable-newlib-mb', |
284 'CFLAGS=-O2', | 309 'CFLAGS=-O2', |
285 'CFLAGS_FOR_TARGET=' + NewlibTargetCflags(target), | 310 'CFLAGS_FOR_TARGET=' + NewlibTargetCflags(target), |
286 ], | 311 ], |
287 MAKE_PARALLEL_CMD, | 312 MAKE_PARALLEL_CMD, |
288 MAKE_DESTDIR_CMD + ['install-strip'], | 313 MAKE_DESTDIR_CMD + ['install-strip'], |
289 # TODO(mcgrathr): Needs some additional steps: | 314 ]) + [ |
290 # rm pthread.h | 315 command.Remove(NewlibFile('include', 'pthread.h')), |
291 # mv libc.a libcrt_common.a | 316 command.Rename(NewlibFile('lib', 'libc.a'), |
292 # Write libc.a with linker script text. | 317 NewlibFile('lib', 'libcrt_common.a')), |
293 ]), | 318 command.WriteData(NewlibLibcScript(target), |
| 319 NewlibFile('lib', 'libc.a')), |
| 320 ], |
294 }, | 321 }, |
295 | 322 |
296 # TODO(mcgrathr): gcc_libs | 323 # TODO(mcgrathr): gcc_libs |
297 } | 324 } |
298 return libs | 325 return libs |
299 | 326 |
300 | 327 |
301 def CollectPackages(targets): | 328 def CollectPackages(targets): |
302 packages = HOST_GCC_LIBS.copy() | 329 packages = HOST_GCC_LIBS.copy() |
303 for target in targets: | 330 for target in targets: |
304 packages.update(HostTools(target)) | 331 packages.update(HostTools(target)) |
305 # TODO(mcgrathr): Eventually build target libraries on only one host type. | 332 # TODO(mcgrathr): Eventually build target libraries on only one host type. |
306 packages.update(TargetLibs(target)) | 333 packages.update(TargetLibs(target)) |
307 return packages | 334 return packages |
308 | 335 |
309 | 336 |
310 PACKAGES = CollectPackages(TARGET_LIST) | 337 PACKAGES = CollectPackages(TARGET_LIST) |
311 | 338 |
312 | 339 |
313 if __name__ == '__main__': | 340 if __name__ == '__main__': |
314 tb = toolchain_main.PackageBuilder(PACKAGES, sys.argv[1:]) | 341 tb = toolchain_main.PackageBuilder(PACKAGES, sys.argv[1:]) |
315 # TODO(mcgrathr): The bot ought to run some native_client tests | 342 # TODO(mcgrathr): The bot ought to run some native_client tests |
316 # using the new toolchain, like the old x86 toolchain bots do. | 343 # using the new toolchain, like the old x86 toolchain bots do. |
317 tb.Main() | 344 tb.Main() |
OLD | NEW |