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

Side by Side Diff: build_tools/common.sh

Issue 132343007: Add top level build script for building packages. (Closed) Base URL: https://naclports.googlecode.com/svn/trunk/src
Patch Set: Created 6 years, 11 months 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
OLDNEW
1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 1 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 # 4 #
5 # Environment variable NACL_ARCH should be unset or set to "i686" 5 # Environment variable NACL_ARCH should be unset or set to "i686"
6 # for a 32-bit build. It should be set to "x86_64", "pnacl", or "arm" 6 # for a 32-bit build. It should be set to "x86_64", "pnacl", or "arm"
7 # for a 64-bit, pnacl, or arm builds. 7 # for a 64-bit, pnacl, or arm builds.
8 8
9 9
10 # NAMING CONVENTION 10 # NAMING CONVENTION
11 # ================= 11 # =================
12 # 12 #
13 # This file is source'd by other scripts especially those inside ports/ 13 # This file is source'd by the main naclports build script. Functions
14 # and makes functions env variables available to those scripts. 14 # and variabled defined here are available in the build script for
binji 2014/01/13 23:05:42 sp: variables
Sam Clegg 2014/01/14 01:54:38 Done.
15 # Only variables beginging with "NACL_" are intended to be used by those 15 # individual ports. Only variables beginging with "NACL_" are intended
16 # scripts! 16 # to be used by those scripts.
17 17
18 set -o nounset 18 set -o nounset
19 set -o errexit 19 set -o errexit
20 20
21 # Scripts that source this file must be run from within the naclports src tree.
22 # Note that default build steps reference the packages directory.
23 readonly SAVE_PWD=$(pwd)
24
25 readonly TOOLS_DIR=$(cd "$(dirname "$BASH_SOURCE")" ; pwd) 21 readonly TOOLS_DIR=$(cd "$(dirname "$BASH_SOURCE")" ; pwd)
26 readonly START_DIR=$(cd "$(dirname "$0")" ; pwd) 22 readonly START_DIR=$PWD
27 readonly NACL_SRC=$(dirname ${TOOLS_DIR}) 23 readonly NACL_SRC=$(dirname ${TOOLS_DIR})
28 readonly NACL_PACKAGES=${NACL_SRC} 24 readonly NACL_PACKAGES=${NACL_SRC}
29 readonly NACL_NATIVE_CLIENT_SDK=$(cd ${NACL_SRC} ; pwd) 25 readonly NACL_NATIVE_CLIENT_SDK=$(cd ${NACL_SRC} ; pwd)
30 NACL_DEBUG=${NACL_DEBUG:-0} 26 NACL_DEBUG=${NACL_DEBUG:-0}
31 27
28 NACL_ENV_IMPORT=1
32 . ${TOOLS_DIR}/nacl_env.sh 29 . ${TOOLS_DIR}/nacl_env.sh
33 30
34 # When run by a buildbot force all archives to come from the NaCl mirror 31 # When run by a buildbot force all archives to come from the NaCl mirror
35 # rather than using upstream URL. 32 # rather than using upstream URL.
36 if [ -n ${BUILDBOT_BUILDERNAME:-""} ]; then 33 if [ -n ${BUILDBOT_BUILDERNAME:-""} ]; then
37 FORCE_MIRROR=${FORCE_MIRROR:-"yes"} 34 FORCE_MIRROR=${FORCE_MIRROR:-"yes"}
38 fi 35 fi
39 36
40 # sha1check python script 37 # sha1check python script
41 readonly SHA1CHECK=${TOOLS_DIR}/sha1check.py 38 readonly SHA1CHECK=${TOOLS_DIR}/sha1check.py
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if [ "${NACL_DEBUG}" = "1" ]; then 184 if [ "${NACL_DEBUG}" = "1" ]; then
188 NACL_CONFIG=Debug 185 NACL_CONFIG=Debug
189 else 186 else
190 NACL_CONFIG=Release 187 NACL_CONFIG=Release
191 fi 188 fi
192 189
193 # PACKAGE_DIR (the folder contained within that archive) defaults to 190 # PACKAGE_DIR (the folder contained within that archive) defaults to
194 # the PACKAGE_NAME. Packages with non-standard contents can override 191 # the PACKAGE_NAME. Packages with non-standard contents can override
195 # this before including common.sh 192 # this before including common.sh
196 PACKAGE_DIR=${PACKAGE_DIR:-${PACKAGE_NAME:-}} 193 PACKAGE_DIR=${PACKAGE_DIR:-${PACKAGE_NAME:-}}
194 SRC_DIR=${NACL_PACKAGES_REPOSITORY}/${PACKAGE_DIR}
195 DEFAULT_BUILD_DIR=${SRC_DIR}/${NACL_BUILD_SUBDIR}
196 BUILD_DIR=${NACL_BUILD_DIR:-${DEFAULT_BUILD_DIR}}
197
197 198
198 PUBLISH_DIR="${NACL_PACKAGES_PUBLISH}/${PACKAGE_NAME}" 199 PUBLISH_DIR="${NACL_PACKAGES_PUBLISH}/${PACKAGE_NAME}"
199 if [ "${NACL_ARCH}" = "pnacl" ]; then 200 if [ "${NACL_ARCH}" = "pnacl" ]; then
200 PUBLISH_DIR+=/pnacl 201 PUBLISH_DIR+=/pnacl
201 else 202 else
202 PUBLISH_DIR+=/${NACL_LIBC} 203 PUBLISH_DIR+=/${NACL_LIBC}
203 fi 204 fi
204 205
205 if [ "${NACL_ARCH}" != "pnacl" -a -z "${NACL_SEL_LDR:-}" ]; then 206 if [ "${NACL_ARCH}" != "pnacl" -a -z "${NACL_SEL_LDR:-}" ]; then
206 SKIP_SEL_LDR_TESTS=1 207 SKIP_SEL_LDR_TESTS=1
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 # Helper functions 338 # Helper functions
338 ###################################################################### 339 ######################################################################
339 340
340 Banner() { 341 Banner() {
341 echo "######################################################################" 342 echo "######################################################################"
342 echo $* 343 echo $*
343 echo "######################################################################" 344 echo "######################################################################"
344 } 345 }
345 346
346 347
347 Usage() {
348 egrep "^#@" $0 | cut --bytes=3-
349 }
350
351
352 ReadKey() {
353 read
354 }
355
356
357 # echo a command to stdout and then execute it. 348 # echo a command to stdout and then execute it.
358 LogExecute() { 349 LogExecute() {
359 echo $* 350 echo $*
360 $* 351 $*
361 } 352 }
362 353
363 354
364 # Set the ARCHIVE_NAME variable to the nacl of the upstream 355 # Set the ARCHIVE_NAME variable to the nacl of the upstream
365 # tarball. If ${URL} is not define (when there is no upstream) 356 # tarball. If ${URL} is not define (when there is no upstream)
366 # then leave ARCHIVE_NAME unset. 357 # then leave ARCHIVE_NAME unset.
(...skipping 29 matching lines...) Expand all
396 local FILENAME=$2 387 local FILENAME=$2
397 Banner "Fetching ${PACKAGE_NAME} (${FILENAME})" 388 Banner "Fetching ${PACKAGE_NAME} (${FILENAME})"
398 if which wget > /dev/null ; then 389 if which wget > /dev/null ; then
399 wget ${URL} -O ${FILENAME} 390 wget ${URL} -O ${FILENAME}
400 elif which curl > /dev/null ; then 391 elif which curl > /dev/null ; then
401 curl --fail --location --url ${URL} -o ${FILENAME} 392 curl --fail --location --url ${URL} -o ${FILENAME}
402 else 393 else
403 Banner "Problem encountered" 394 Banner "Problem encountered"
404 echo "Please install curl or wget and rerun this script" 395 echo "Please install curl or wget and rerun this script"
405 echo "or manually download ${URL} to ${FILENAME}" 396 echo "or manually download ${URL} to ${FILENAME}"
406 echo 397 exit 1
407 echo "press any key when done"
408 ReadKey
409 fi 398 fi
410 } 399 }
411 400
412 401
413 # 402 #
414 # Download a file from a given URL 403 # Download a file from a given URL
415 # $1 - URL to fetch 404 # $1 - URL to fetch
416 # $2 - Filename to write to. 405 # $2 - Filename to write to.
417 # 406 #
418 Fetch() { 407 Fetch() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 471
483 cd ${NACL_PACKAGES_REPOSITORY} 472 cd ${NACL_PACKAGES_REPOSITORY}
484 rm -rf ${PACKAGE_DIR} 473 rm -rf ${PACKAGE_DIR}
485 git clone ${GIT_URL} ${PACKAGE_DIR} 474 git clone ${GIT_URL} ${PACKAGE_DIR}
486 cd ${PACKAGE_DIR} 475 cd ${PACKAGE_DIR}
487 git reset --hard ${COMMIT} 476 git reset --hard ${COMMIT}
488 477
489 TouchKeyStamp clone "$URL" 478 TouchKeyStamp clone "$URL"
490 } 479 }
491 480
481
492 Patch() { 482 Patch() {
493 local LOCAL_PATCH_FILE=$1 483 local LOCAL_PATCH_FILE=$1
494 if [ -e "${START_DIR}/${LOCAL_PATCH_FILE}" ]; then 484 if [ -e "${START_DIR}/${LOCAL_PATCH_FILE}" ]; then
495 Banner "Patching $(basename ${PWD})" 485 Banner "Patching $(basename ${PWD})"
496 #git apply ${START_DIR}/${LOCAL_PATCH_FILE} 486 #git apply ${START_DIR}/${LOCAL_PATCH_FILE}
497 patch -p1 -g0 --no-backup-if-mismatch < ${START_DIR}/${LOCAL_PATCH_FILE} 487 patch -p1 -g0 --no-backup-if-mismatch < ${START_DIR}/${LOCAL_PATCH_FILE}
498 git add . 488 git add .
499 git commit -m "Apply naclports patch" 489 git commit -m "Apply naclports patch"
500 fi 490 fi
501 } 491 }
502 492
503 493
504 VerifyPath() { 494 VerifyPath() {
505 # make sure path isn't all slashes (possibly from an unset variable) 495 # make sure path isn't all slashes (possibly from an unset variable)
506 local PATH=$1 496 local PATH=$1
507 local TRIM=${PATH##/} 497 local TRIM=${PATH##/}
508 if [ ${#TRIM} -ne 0 ]; then 498 if [ ${#TRIM} -ne 0 ]; then
509 return 0 499 return 0
510 else 500 else
511 return 1 501 return 1
512 fi 502 fi
513 } 503 }
514 504
515 505
516 ChangeDir() { 506 ChangeDir() {
517 local NAME=$1 507 local NAME=$1
518 if VerifyPath ${NAME}; then 508 if VerifyPath ${NAME}; then
509 echo "chdir ${NAME}"
519 cd ${NAME} 510 cd ${NAME}
520 else 511 else
521 echo "ChangeDir called with bad path." 512 echo "ChangeDir called with bad path."
522 exit -1 513 exit -1
523 fi 514 fi
524 } 515 }
525 516
526 517
527 Remove() { 518 Remove() {
528 local NAME=$1 519 local NAME=$1
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 export AR=${NACLAR} 784 export AR=${NACLAR}
794 export RANLIB=${NACLRANLIB} 785 export RANLIB=${NACLRANLIB}
795 export READELF=${NACLREADELF} 786 export READELF=${NACLREADELF}
796 export PKG_CONFIG_PATH=${NACLPORTS_LIBDIR}/pkgconfig 787 export PKG_CONFIG_PATH=${NACLPORTS_LIBDIR}/pkgconfig
797 export PKG_CONFIG_LIBDIR=${NACLPORTS_LIBDIR} 788 export PKG_CONFIG_LIBDIR=${NACLPORTS_LIBDIR}
798 export FREETYPE_CONFIG=${NACLPORTS_PREFIX_BIN}/freetype-config 789 export FREETYPE_CONFIG=${NACLPORTS_PREFIX_BIN}/freetype-config
799 export CFLAGS=${NACLPORTS_CFLAGS} 790 export CFLAGS=${NACLPORTS_CFLAGS}
800 export CXXFLAGS=${NACLPORTS_CXXFLAGS} 791 export CXXFLAGS=${NACLPORTS_CXXFLAGS}
801 export LDFLAGS=${NACLPORTS_LDFLAGS} 792 export LDFLAGS=${NACLPORTS_LDFLAGS}
802 export PATH=${NACL_BIN_PATH}:${PATH}; 793 export PATH=${NACL_BIN_PATH}:${PATH};
803 local SRC_DIR=${NACL_PACKAGES_REPOSITORY}/${PACKAGE_DIR}
804 local CONFIGURE=${NACL_CONFIGURE_PATH:-${SRC_DIR}/configure} 794 local CONFIGURE=${NACL_CONFIGURE_PATH:-${SRC_DIR}/configure}
805 if [ ! -f "${CONFIGURE}" ]; then 795 if [ ! -f "${CONFIGURE}" ]; then
806 echo "No configure script found at ${CONFIGURE}" 796 echo "No configure script found at ${CONFIGURE}"
807 return 797 return
808 fi 798 fi
809 local DEFAULT_BUILD_DIR=${SRC_DIR}/${NACL_BUILD_SUBDIR} 799 MakeDir ${BUILD_DIR}
810 NACL_BUILD_DIR=${NACL_BUILD_DIR:-${DEFAULT_BUILD_DIR}} 800 ChangeDir ${BUILD_DIR}
811 MakeDir ${NACL_BUILD_DIR}
812 ChangeDir ${NACL_BUILD_DIR}
813 801
814 local conf_host=${NACL_CROSS_PREFIX} 802 local conf_host=${NACL_CROSS_PREFIX}
815 if [ "${NACL_ARCH}" = "pnacl" -o "${NACL_ARCH}" = "emscripten" ]; then 803 if [ "${NACL_ARCH}" = "pnacl" -o "${NACL_ARCH}" = "emscripten" ]; then
816 # The PNaCl tools use "pnacl-" as the prefix, but config.sub 804 # The PNaCl tools use "pnacl-" as the prefix, but config.sub
817 # does not know about "pnacl". It only knows about "le32-nacl". 805 # does not know about "pnacl". It only knows about "le32-nacl".
818 # Unfortunately, most of the config.subs here are so old that 806 # Unfortunately, most of the config.subs here are so old that
819 # it doesn't know about that "le32" either. So we just say "nacl". 807 # it doesn't know about that "le32" either. So we just say "nacl".
820 conf_host="nacl" 808 conf_host="nacl"
821 fi 809 fi
822 810
(...skipping 14 matching lines...) Expand all
837 --${NACL_OPTION}-sse \ 825 --${NACL_OPTION}-sse \
838 --${NACL_OPTION}-sse2 \ 826 --${NACL_OPTION}-sse2 \
839 --${NACL_OPTION}-asm \ 827 --${NACL_OPTION}-asm \
840 --with-x=no \ 828 --with-x=no \
841 "${EXTRA_CONFIGURE_OPTS[@]}" ${EXTRA_CONFIGURE_ARGS:-} 829 "${EXTRA_CONFIGURE_OPTS[@]}" ${EXTRA_CONFIGURE_ARGS:-}
842 } 830 }
843 831
844 832
845 CMakeConfigureStep() { 833 CMakeConfigureStep() {
846 Banner "Configuring ${PACKAGE_NAME}" 834 Banner "Configuring ${PACKAGE_NAME}"
847 local SRC_DIR=${NACL_PACKAGES_REPOSITORY}/${PACKAGE_DIR} 835 MakeDir ${BUILD_DIR}
848 local DEFAULT_BUILD_DIR=${SRC_DIR}/${NACL_BUILD_SUBDIR} 836 ChangeDir ${BUILD_DIR}
849 NACL_BUILD_DIR=${NACL_BUILD_DIR:-${DEFAULT_BUILD_DIR}}
850 MakeDir ${NACL_BUILD_DIR}
851 ChangeDir ${NACL_BUILD_DIR}
852 837
853 CC="${NACLCC}" CXX="${NACLCXX}" LogExecute cmake ..\ 838 CC="${NACLCC}" CXX="${NACLCXX}" LogExecute cmake ..\
854 -DCMAKE_TOOLCHAIN_FILE=${TOOLS_DIR}/XCompile-nacl.cmake \ 839 -DCMAKE_TOOLCHAIN_FILE=${TOOLS_DIR}/XCompile-nacl.cmake \
855 -DNACLAR=${NACLAR} \ 840 -DNACLAR=${NACLAR} \
856 -DNACLLD=${NACLLD} \ 841 -DNACLLD=${NACLLD} \
857 -DNACL_CROSS_PREFIX=${NACL_CROSS_PREFIX} \ 842 -DNACL_CROSS_PREFIX=${NACL_CROSS_PREFIX} \
858 -DNACL_SDK_ROOT=${NACL_SDK_ROOT} \ 843 -DNACL_SDK_ROOT=${NACL_SDK_ROOT} \
859 -DNACL_TOOLCHAIN_ROOT=${NACL_TOOLCHAIN_ROOT} \ 844 -DNACL_TOOLCHAIN_ROOT=${NACL_TOOLCHAIN_ROOT} \
860 -DCMAKE_INSTALL_PREFIX=${NACLPORTS_PREFIX} \ 845 -DCMAKE_INSTALL_PREFIX=${NACLPORTS_PREFIX} \
861 -DCMAKE_BUILD_TYPE=RELEASE ${EXTRA_CMAKE_ARGS:-} 846 -DCMAKE_BUILD_TYPE=RELEASE ${EXTRA_CMAKE_ARGS:-}
862 } 847 }
863 848
864 849
865 DefaultBuildStep() { 850 DefaultBuildStep() {
866 Banner "Build ${PACKAGE_NAME}" 851 Banner "Build ${PACKAGE_NAME}"
867 echo "Directory: $(pwd)" 852 ChangeDir ${BUILD_DIR}
868 # Build ${MAKE_TARGETS} or default target if it is not defined 853 # Build ${MAKE_TARGETS} or default target if it is not defined
869 if [ -n "${MAKEFLAGS:-}" ]; then 854 if [ -n "${MAKEFLAGS:-}" ]; then
870 echo "MAKEFLAGS=${MAKEFLAGS}" 855 echo "MAKEFLAGS=${MAKEFLAGS}"
871 export MAKEFLAGS 856 export MAKEFLAGS
872 fi 857 fi
873 export PATH=${NACL_BIN_PATH}:${PATH}; 858 export PATH=${NACL_BIN_PATH}:${PATH};
874 LogExecute make -j${OS_JOBS} ${MAKE_TARGETS:-} 859 LogExecute make -j${OS_JOBS} ${MAKE_TARGETS:-}
875 } 860 }
876 861
877 862
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 BuildStep 1137 BuildStep
1153 TranslateStep 1138 TranslateStep
1154 ValidateStep 1139 ValidateStep
1155 if [ "${SKIP_SEL_LDR_TESTS}" != "1" ]; then 1140 if [ "${SKIP_SEL_LDR_TESTS}" != "1" ]; then
1156 TestStep 1141 TestStep
1157 fi 1142 fi
1158 InstallStep 1143 InstallStep
1159 } 1144 }
1160 1145
1161 1146
1147 NaclportsMain() {
1148 local COMMAND=PackageInstall
1149 if [[ $# -gt 0 ]]; then
1150 COMMAND=$1
1151 fi
1152 echo ${COMMAND}
1153 ${COMMAND}
1154 }
1155
1156
1162 # Function entry points that packages should override in order 1157 # Function entry points that packages should override in order
1163 # to customize the build process. 1158 # to customize the build process.
1164 PreInstallStep() { DefaultPreInstallStep; } 1159 PreInstallStep() { DefaultPreInstallStep; }
1165 DownloadStep() { DefaultDownloadStep; } 1160 DownloadStep() { DefaultDownloadStep; }
1166 ExtractStep() { DefaultExtractStep; } 1161 ExtractStep() { DefaultExtractStep; }
1167 PatchStep() { DefaultPatchStep; } 1162 PatchStep() { DefaultPatchStep; }
1168 ConfigureStep() { DefaultConfigureStep; } 1163 ConfigureStep() { DefaultConfigureStep; }
1169 BuildStep() { DefaultBuildStep; } 1164 BuildStep() { DefaultBuildStep; }
1170 TranslateStep() { DefaultTranslateStep; } 1165 TranslateStep() { DefaultTranslateStep; }
1171 ValidateStep() { DefaultValidateStep; } 1166 ValidateStep() { DefaultValidateStep; }
1172 TestStep() { DefaultTestStep; } 1167 TestStep() { DefaultTestStep; }
1173 InstallStep() { DefaultInstallStep; } 1168 InstallStep() { DefaultInstallStep; }
1174 PackageInstall() { DefaultPackageInstall; } 1169 PackageInstall() { DefaultPackageInstall; }
1175 1170
1176 1171
1177 ###################################################################### 1172 ######################################################################
1178 # Always run 1173 # Always run
1179 # These functions are called when this script is imported to do 1174 # These functions are called when this script is imported to do
1180 # any essential checking/setup operations. 1175 # any essential checking/setup operations.
1181 ###################################################################### 1176 ######################################################################
1182 CheckToolchain 1177 CheckToolchain
1183 CheckPatchVersion 1178 CheckPatchVersion
1184 CheckSDKVersion 1179 CheckSDKVersion
1185 PatchSpecFile 1180 PatchSpecFile
1186 InjectSystemHeaders 1181 InjectSystemHeaders
1187 InstallConfigSite 1182 InstallConfigSite
OLDNEW
« no previous file with comments | « README.rst ('k') | build_tools/nacl_env.sh » ('j') | build_tools/nacl_env.sh » ('J')

Powered by Google App Engine
This is Rietveld 408576698