| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 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 #@ This script builds the (trusted) cross toolchain for arm. | 6 #@ This script builds the (trusted) cross toolchain for arm. |
| 7 #@ It must be run from the native_client/ directory. | 7 #@ It must be run from the native_client/ directory. |
| 8 #@ | 8 #@ |
| 9 #@ The toolchain consists primarily of a jail with arm header and libraries. | 9 #@ The toolchain consists primarily of a jail with arm header and libraries. |
| 10 #@ It also provides additional tools such as QEMU. | 10 #@ It also provides additional tools such as QEMU. |
| 11 #@ It does NOT provide the actual cross compiler anymore. | 11 #@ It does NOT provide the actual cross compiler anymore. |
| 12 #@ The cross compiler is now comming straight from a debian package. | 12 #@ The cross compiler is now coming straight from a Debian package. |
| 13 #@ So there is a one-time step required for all machines using this TC. | 13 #@ So there is a one-time step required for all machines using this TC: |
| 14 #@ Which is especially true for build-bots: | |
| 15 #@ | 14 #@ |
| 16 #@ tools/trusted_cross_toolchains/trusted-toolchain-creator.armhf.trusty.sh In
stallCrossArmBasePackages | 15 #@ tools/trusted_cross_toolchains/trusted-toolchain-creator.armhf.trusty.sh Ins
tallCrossArmBasePackages |
| 17 #@ | 16 #@ |
| 17 #@ Generally this script is invoked as: |
| 18 #@ | 18 #@ |
| 19 #@ Generally this script is invoked as: | |
| 20 #@ tools/trusted_cross_toolchains/trusted-toolchain-creator.armhf.trusty.sh <mo
de> <args>* | 19 #@ tools/trusted_cross_toolchains/trusted-toolchain-creator.armhf.trusty.sh <mo
de> <args>* |
| 21 #@ Available modes are shown below. | |
| 22 #@ | |
| 23 #@ This Toolchain was tested with Ubuntu Precise | |
| 24 #@ | |
| 25 #@ Usage of this TC: | |
| 26 #@ compile: arm-linux-gnueabihf-gcc -march=armv7-a -isystem ${JAIL}/usr/include | |
| 27 #@ link: arm-linux-gnueabihf-gcc -L${JAIL}/usr/lib -L${JAIL}/usr/lib/arm-lin
ux-gnueabihf | |
| 28 #@ -L${JAIL}/lib -L${JAIL}/lib/arm-linux-gnueabi
hf | |
| 29 #@ | |
| 30 #@ Usage of QEMU | |
| 31 #@ TBD | |
| 32 #@ | 20 #@ |
| 33 #@ List of modes: | 21 #@ List of modes: |
| 34 | 22 |
| 35 ###################################################################### | 23 ###################################################################### |
| 36 # Config | 24 # Config |
| 37 ###################################################################### | 25 ###################################################################### |
| 38 | 26 |
| 39 set -o nounset | 27 set -o nounset |
| 40 set -o errexit | 28 set -o errexit |
| 41 | 29 |
| 30 readonly DIST=trusty |
| 42 readonly SCRIPT_DIR=$(dirname $0) | 31 readonly SCRIPT_DIR=$(dirname $0) |
| 43 | 32 readonly NACL_ROOT=$(pwd) |
| 44 # this where we create the ARMHF "jail" | 33 # this where we create the ARMHF sysroot |
| 45 readonly INSTALL_ROOT=$(pwd)/toolchain/linux_x86/arm_trusted | 34 readonly INSTALL_ROOT=${NACL_ROOT}/toolchain/linux_x86/arm_trusted |
| 46 | 35 readonly TAR_ARCHIVE=$(dirname ${NACL_ROOT})/out/sysroot_arm_trusted_${DIST}.tgz |
| 47 readonly TMP=/tmp/armhf-crosstool-trusty | 36 readonly TMP=$(dirname ${NACL_ROOT})/out/sysroot_arm_trusted_${DIST} |
| 48 | |
| 49 readonly REQUIRED_TOOLS="wget" | 37 readonly REQUIRED_TOOLS="wget" |
| 50 | |
| 51 readonly MAKE_OPTS="-j8" | 38 readonly MAKE_OPTS="-j8" |
| 52 | 39 |
| 53 ###################################################################### | 40 ###################################################################### |
| 54 # Package Config | 41 # Package Config |
| 55 ###################################################################### | 42 ###################################################################### |
| 56 | 43 |
| 57 # this where we get the cross toolchain from for the manual install: | 44 # this where we get the cross toolchain from for the manual install: |
| 58 readonly CROSS_ARM_TC_REPO=http://archive.ubuntu.com/ubuntu | 45 readonly CROSS_ARM_TC_REPO=http://archive.ubuntu.com/ubuntu |
| 59 # this is where we get all the armhf packages from | 46 # this is where we get all the armhf packages from |
| 60 readonly ARMHF_REPO=http://ports.ubuntu.com/ubuntu-ports | 47 readonly ARMHF_REPO=http://ports.ubuntu.com/ubuntu-ports |
| 61 | 48 |
| 62 readonly PACKAGE_LIST="${ARMHF_REPO}/dists/trusty/main/binary-armhf/Packages.bz2
" | 49 readonly PACKAGE_LIST="${ARMHF_REPO}/dists/${DIST}/main/binary-armhf/Packages.bz
2" |
| 63 readonly PACKAGE_LIST2="${ARMHF_REPO}/dists/trusty-security/main/binary-armhf/Pa
ckages.bz2" | 50 readonly PACKAGE_LIST2="${ARMHF_REPO}/dists/${DIST}-security/main/binary-armhf/P
ackages.bz2" |
| 64 | 51 |
| 65 # Packages for the host system | 52 # Packages for the host system |
| 66 readonly CROSS_ARM_TC_PACKAGES="\ | 53 readonly CROSS_ARM_TC_PACKAGES="\ |
| 67 g++-arm-linux-gnueabihf" | 54 g++-arm-linux-gnueabihf" |
| 68 | 55 |
| 69 # Jail packages: these are good enough for native client | 56 # Jail packages: these are good enough for native client |
| 70 # NOTE: the package listing here should be updated using the | 57 # NOTE: the package listing here should be updated using the |
| 71 # GeneratePackageListXXX() functions below | 58 # GeneratePackageListXXX() functions below |
| 72 readonly ARMHF_BASE_PACKAGES="\ | 59 readonly ARMHF_BASE_PACKAGES="\ |
| 73 libssl-dev \ | 60 libssl-dev \ |
| 74 libssl1.0.0 \ | 61 libssl1.0.0 \ |
| 75 libgcc1 \ | 62 libgcc1 \ |
| 76 libc6 \ | 63 libc6 \ |
| 77 libc6-dev \ | 64 libc6-dev \ |
| 78 libstdc++6 \ | 65 libstdc++6 \ |
| 79 libx11-dev \ | 66 libx11-dev \ |
| 80 libx11-6 \ | 67 libx11-6 \ |
| 81 x11proto-core-dev \ | 68 x11proto-core-dev \ |
| 82 libxt-dev \ | 69 libxt-dev \ |
| 83 libxt6 \ | 70 libxt6 \ |
| 84 zlib1g \ | 71 zlib1g \ |
| 85 zlib1g-dev" | 72 zlib1g-dev" |
| 86 | 73 |
| 87 # Additional jail packages needed to build chrome | 74 # Additional jail packages needed to build chrome |
| 88 # NOTE: the package listing here should be updated using the | 75 # NOTE: the package listing here should be updated using the |
| 89 # GeneratePackageListXXX() functions below | 76 # GeneratePackageListXXX() functions below |
| 90 readonly ARMHF_BASE_DEP_LIST="${SCRIPT_DIR}/packagelist.trusty.armhf.base" | 77 readonly ARMHF_BASE_DEP_LIST="${SCRIPT_DIR}/packagelist.${DIST}.armhf.base" |
| 91 readonly ARMHF_BASE_DEP_FILES="$(cat ${ARMHF_BASE_DEP_LIST})" | 78 readonly ARMHF_BASE_DEP_FILES="$(cat ${ARMHF_BASE_DEP_LIST})" |
| 92 | 79 |
| 93 readonly ARMHF_EXTRA_PACKAGES="\ | 80 readonly ARMHF_EXTRA_PACKAGES="\ |
| 94 comerr-dev \ | 81 comerr-dev \ |
| 95 krb5-multidev \ | 82 krb5-multidev \ |
| 96 libasound2 \ | 83 libasound2 \ |
| 97 libasound2-dev \ | 84 libasound2-dev \ |
| 98 libatk1.0-0 \ | 85 libatk1.0-0 \ |
| 99 libatk1.0-dev \ | 86 libatk1.0-dev \ |
| 100 libcairo2 \ | 87 libcairo2 \ |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 x11proto-input-dev \ | 199 x11proto-input-dev \ |
| 213 x11proto-kb-dev \ | 200 x11proto-kb-dev \ |
| 214 x11proto-randr-dev \ | 201 x11proto-randr-dev \ |
| 215 x11proto-record-dev \ | 202 x11proto-record-dev \ |
| 216 x11proto-render-dev \ | 203 x11proto-render-dev \ |
| 217 x11proto-scrnsaver-dev \ | 204 x11proto-scrnsaver-dev \ |
| 218 x11proto-xext-dev" | 205 x11proto-xext-dev" |
| 219 | 206 |
| 220 # NOTE: the package listing here should be updated using the | 207 # NOTE: the package listing here should be updated using the |
| 221 # GeneratePackageListXXX() functions below | 208 # GeneratePackageListXXX() functions below |
| 222 readonly ARMHF_EXTRA_DEP_LIST="${SCRIPT_DIR}/packagelist.trusty.armhf.extra" | 209 readonly ARMHF_EXTRA_DEP_LIST="${SCRIPT_DIR}/packagelist.${DIST}.armhf.extra" |
| 223 readonly ARMHF_EXTRA_DEP_FILES="$(cat ${ARMHF_EXTRA_DEP_LIST})" | 210 readonly ARMHF_EXTRA_DEP_FILES="$(cat ${ARMHF_EXTRA_DEP_LIST})" |
| 224 | 211 |
| 225 ###################################################################### | 212 ###################################################################### |
| 226 # Helper | 213 # Helper |
| 227 ###################################################################### | 214 ###################################################################### |
| 228 | 215 |
| 229 Banner() { | 216 Banner() { |
| 230 echo "######################################################################" | 217 echo "######################################################################" |
| 231 echo $* | 218 echo $* |
| 232 echo "######################################################################" | 219 echo "######################################################################" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 283 |
| 297 | 284 |
| 298 # TODO(robertm): consider wiping all of ${BASE_DIR} | 285 # TODO(robertm): consider wiping all of ${BASE_DIR} |
| 299 ClearInstallDir() { | 286 ClearInstallDir() { |
| 300 Banner "clearing dirs in ${INSTALL_ROOT}" | 287 Banner "clearing dirs in ${INSTALL_ROOT}" |
| 301 rm -rf ${INSTALL_ROOT}/* | 288 rm -rf ${INSTALL_ROOT}/* |
| 302 } | 289 } |
| 303 | 290 |
| 304 | 291 |
| 305 CreateTarBall() { | 292 CreateTarBall() { |
| 306 local tarball=$1 | 293 Banner "creating tar ball ${TAR_ARCHIVE}" |
| 307 Banner "creating tar ball ${tarball}" | 294 tar cfz ${TAR_ARCHIVE} -C ${INSTALL_ROOT} . |
| 308 tar cfz ${tarball} -C ${INSTALL_ROOT} . | |
| 309 } | 295 } |
| 310 | 296 |
| 311 ###################################################################### | 297 ###################################################################### |
| 312 # One of these has to be run ONCE per machine | 298 # One of these has to be run ONCE per machine |
| 313 ###################################################################### | 299 ###################################################################### |
| 314 | 300 |
| 315 #@ | 301 #@ |
| 316 #@ InstallCrossArmBasePackages | 302 #@ InstallCrossArmBasePackages |
| 317 #@ | 303 #@ |
| 318 #@ Install packages needed for arm cross compilation. | 304 #@ Install packages needed for arm cross compilation. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 done | 376 done |
| 391 popd | 377 popd |
| 392 } | 378 } |
| 393 | 379 |
| 394 #@ | 380 #@ |
| 395 #@ BuildAndInstallQemu | 381 #@ BuildAndInstallQemu |
| 396 #@ | 382 #@ |
| 397 #@ Build ARM emulator including some patches for better tracing | 383 #@ Build ARM emulator including some patches for better tracing |
| 398 # | 384 # |
| 399 # Historic Notes: | 385 # Historic Notes: |
| 400 # Traditionally we were builidng static 32 bit images of qemu on a | 386 # Traditionally we were building static 32 bit images of qemu on a |
| 401 # 64bit system which would run then on both x86-32 and x86-64 systems. | 387 # 64bit system which would run then on both x86-32 and x86-64 systems. |
| 402 # The latest version of qemu contains new dependencies which | 388 # The latest version of qemu contains new dependencies which |
| 403 # currently make it impossible to build such images on 64bit systems | 389 # currently make it impossible to build such images on 64bit systems |
| 404 # We can build a static 64bit qemu but it does not work with | 390 # We can build a static 64bit qemu but it does not work with |
| 405 # the sandboxed translators for unknown reason. | 391 # the sandboxed translators for unknown reason. |
| 406 # So instead we chose to build 32bit shared images. | 392 # So instead we chose to build 32bit shared images. |
| 407 # | 393 # |
| 408 | 394 |
| 409 readonly QEMU_TARBALL=qemu-1.0.1.tar.gz | 395 readonly QEMU_TARBALL=qemu-1.0.1.tar.gz |
| 410 readonly QEMU_SHA=4d08b5a83538fcd7b222bec6f1c584da8d12497a | 396 readonly QEMU_SHA=4d08b5a83538fcd7b222bec6f1c584da8d12497a |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 # --static | 465 # --static |
| 480 | 466 |
| 481 SubBanner "Make" | 467 SubBanner "Make" |
| 482 env -i PATH=/usr/bin/:/bin make MAKE_OPTS=${MAKE_OPTS} | 468 env -i PATH=/usr/bin/:/bin make MAKE_OPTS=${MAKE_OPTS} |
| 483 | 469 |
| 484 SubBanner "Install ${INSTALL_ROOT}" | 470 SubBanner "Install ${INSTALL_ROOT}" |
| 485 cp arm-linux-user/qemu-arm ${INSTALL_ROOT} | 471 cp arm-linux-user/qemu-arm ${INSTALL_ROOT} |
| 486 cd ${saved_dir} | 472 cd ${saved_dir} |
| 487 cp tools/trusted_cross_toolchains/qemu_tool_arm.sh ${INSTALL_ROOT} | 473 cp tools/trusted_cross_toolchains/qemu_tool_arm.sh ${INSTALL_ROOT} |
| 488 ln -sf qemu_tool_arm.sh ${INSTALL_ROOT}/run_under_qemu_arm | 474 ln -sf qemu_tool_arm.sh ${INSTALL_ROOT}/run_under_qemu_arm |
| 475 set +x |
| 489 } | 476 } |
| 490 | 477 |
| 491 #@ | 478 #@ |
| 492 #@ BuildJail <tarball-name> | 479 #@ BuildJail |
| 493 #@ | 480 #@ |
| 494 #@ Build everything and package it | 481 #@ Build everything and package it |
| 495 BuildJail() { | 482 BuildJail() { |
| 496 ClearInstallDir | 483 ClearInstallDir |
| 497 InstallMissingArmLibrariesAndHeadersIntoJail \ | 484 InstallMissingArmLibrariesAndHeadersIntoJail \ |
| 498 ${ARMHF_BASE_DEP_FILES} \ | 485 ${ARMHF_BASE_DEP_FILES} \ |
| 499 ${ARMHF_EXTRA_DEP_FILES} | 486 ${ARMHF_EXTRA_DEP_FILES} |
| 500 CleanupJailSymlinks | 487 CleanupJailSymlinks |
| 501 HacksAndPatches | 488 HacksAndPatches |
| 502 BuildAndInstallQemu | 489 BuildAndInstallQemu |
| 503 CreateTarBall $1 | 490 CreateTarBall |
| 504 } | 491 } |
| 505 | 492 |
| 506 # | 493 # |
| 507 # GeneratePackageList | 494 # GeneratePackageList |
| 508 # | 495 # |
| 509 # Looks up package names in ${TMP}/Packages and write list of URLs | 496 # Looks up package names in ${TMP}/Packages and write list of URLs |
| 510 # to output file. | 497 # to output file. |
| 511 # | 498 # |
| 512 GeneratePackageList() { | 499 GeneratePackageList() { |
| 513 local output_file=$1 | 500 local output_file=$1 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 526 sort $output_file -o $output_file | 513 sort $output_file -o $output_file |
| 527 } | 514 } |
| 528 | 515 |
| 529 #@ | 516 #@ |
| 530 #@ UpdatePackageLists | 517 #@ UpdatePackageLists |
| 531 #@ | 518 #@ |
| 532 #@ Regenerate the armhf package lists such that they contain an up-to-date | 519 #@ Regenerate the armhf package lists such that they contain an up-to-date |
| 533 #@ list of URLs within the ubuntu archive. | 520 #@ list of URLs within the ubuntu archive. |
| 534 #@ | 521 #@ |
| 535 UpdatePackageLists() { | 522 UpdatePackageLists() { |
| 536 local package_list="${TMP}/Packages.trusty.bz2" | 523 local package_list="${TMP}/Packages.${DIST}.bz2" |
| 537 local package_list2="${TMP}/Packages.trusty-security.bz2" | 524 local package_list2="${TMP}/Packages.${DIST}-security.bz2" |
| 538 DownloadOrCopy ${PACKAGE_LIST} ${package_list} | 525 DownloadOrCopy ${PACKAGE_LIST} ${package_list} |
| 539 DownloadOrCopy ${PACKAGE_LIST2} ${package_list2} | 526 DownloadOrCopy ${PACKAGE_LIST2} ${package_list2} |
| 540 bzcat ${package_list} ${package_list2} | egrep '^(Package:|Filename:)' > ${TMP
}/Packages | 527 bzcat ${package_list} ${package_list2} | egrep '^(Package:|Filename:)' > ${TMP
}/Packages |
| 541 | 528 |
| 542 GeneratePackageList ${ARMHF_BASE_DEP_LIST} "${ARMHF_BASE_PACKAGES}" | 529 GeneratePackageList ${ARMHF_BASE_DEP_LIST} "${ARMHF_BASE_PACKAGES}" |
| 543 GeneratePackageList ${ARMHF_EXTRA_DEP_LIST} "${ARMHF_EXTRA_PACKAGES}" | 530 GeneratePackageList ${ARMHF_EXTRA_DEP_LIST} "${ARMHF_EXTRA_PACKAGES}" |
| 544 } | 531 } |
| 545 | 532 |
| 546 if [[ $# -eq 0 ]] ; then | 533 if [[ $# -eq 0 ]] ; then |
| 547 echo "ERROR: you must specify a mode on the commandline" | 534 echo "ERROR: you must specify a mode on the commandline" |
| 548 echo | 535 echo |
| 549 Usage | 536 Usage |
| 550 exit -1 | 537 exit -1 |
| 551 elif [[ "$(type -t $1)" != "function" ]]; then | 538 elif [[ "$(type -t $1)" != "function" ]]; then |
| 552 echo "ERROR: unknown function '$1'." >&2 | 539 echo "ERROR: unknown function '$1'." >&2 |
| 553 echo "For help, try:" | 540 echo "For help, try:" |
| 554 echo " $0 help" | 541 echo " $0 help" |
| 555 exit 1 | 542 exit 1 |
| 556 else | 543 else |
| 557 ChangeDirectory | 544 ChangeDirectory |
| 558 SanityCheck | 545 SanityCheck |
| 559 "$@" | 546 "$@" |
| 560 fi | 547 fi |
| OLD | NEW |