OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Script for building our own custom Chrome | 7 # Script for building our own custom Chrome |
8 | 8 |
9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
11 . "$(dirname "$0")/common.sh" | 11 . "$(dirname "$0")/common.sh" |
12 | 12 |
13 # Script must be run outside the chroot | 13 # Script must be run outside the chroot |
14 assert_outside_chroot | 14 assert_outside_chroot |
15 | 15 |
16 # This script defaults Chrome source is in ~/chrome | 16 # This script defaults Chrome source is in ~/chrome |
17 # You may override the Chrome source dir via the --chrome_dir option or by | 17 # You may override the Chrome source dir via the --chrome_dir option or by |
18 # setting CHROMEOS_CHROME_DIR (for example, in ./.chromeos_dev) | 18 # setting CHROMEOS_CHROME_DIR (for example, in ./.chromeos_dev) |
19 DEFAULT_CHROME_DIR="${CHROMEOS_CHROME_DIR:-/home/$USER/chrome}" | 19 DEFAULT_CHROME_DIR="${CHROMEOS_CHROME_DIR:-/home/$USER/chrome}" |
20 | 20 |
| 21 # The number of jobs to pass to tools that can run in parallel (such as make |
| 22 # and dpkg-buildpackage |
| 23 NUM_JOBS=`cat /proc/cpuinfo | grep processor | awk '{a++} END {print a}'` |
| 24 |
21 # Flags | 25 # Flags |
22 DEFINE_string chrome_dir "$DEFAULT_CHROME_DIR" \ | 26 DEFINE_string chrome_dir "$DEFAULT_CHROME_DIR" \ |
23 "Directory to Chrome source" | 27 "Directory to Chrome source" |
24 DEFINE_string mode "Release" \ | 28 DEFINE_string mode "Release" \ |
25 "The mode to build Chrome in (Debug or Release)" | 29 "The mode to build Chrome in (Debug or Release)" |
| 30 DEFINE_string num_jobs "$NUM_JOBS" \ |
| 31 "The number of jobs to run in parallel" |
26 | 32 |
27 # Parse command line | 33 # Parse command line |
28 FLAGS "$@" || exit 1 | 34 FLAGS "$@" || exit 1 |
29 eval set -- "${FLAGS_ARGV}" | 35 eval set -- "${FLAGS_ARGV}" |
30 | 36 |
31 # Die on error; print commands | 37 # Die on error; print commands |
32 set -e | 38 set -e |
33 | 39 |
34 # Convert args to paths. Need eval to un-quote the string so that shell | 40 # Convert args to paths. Need eval to un-quote the string so that shell |
35 # chars like ~ are processed; just doing FOO=`readlink -f $FOO` won't work. | 41 # chars like ~ are processed; just doing FOO=`readlink -f $FOO` won't work. |
36 FLAGS_chrome_dir=`eval readlink -f $FLAGS_chrome_dir` | 42 FLAGS_chrome_dir=`eval readlink -f $FLAGS_chrome_dir` |
37 | 43 |
38 # Build Chrome | 44 # Build Chrome |
39 echo Building Chrome in mode $FLAGS_mode | 45 echo Building Chrome in mode $FLAGS_mode |
40 # The number of jobs to pass to tools that can run in parallel (such as make | |
41 # and dpkg-buildpackage | |
42 NUM_JOBS=`cat /proc/cpuinfo | grep processor | awk '{a++} END {print a}'` | |
43 export GYP_GENERATORS="make" | 46 export GYP_GENERATORS="make" |
44 export GYP_DEFINES="chromeos=1 target_arch=ia32" | 47 export GYP_DEFINES="chromeos=1 target_arch=ia32" |
45 CHROME_DIR=$FLAGS_chrome_dir | 48 CHROME_DIR=$FLAGS_chrome_dir |
46 cd "$CHROME_DIR/src" | 49 cd "$CHROME_DIR/src" |
47 gclient runhooks --force | 50 gclient runhooks --force |
48 make BUILDTYPE=$FLAGS_mode -j$NUM_JOBS -r chrome | 51 make BUILDTYPE=$FLAGS_mode -j$FLAGS_num_jobs -r chrome |
49 | 52 |
50 # Zip into chrome-chromeos.zip and put in local_assets | 53 # Zip into chrome-chromeos.zip and put in local_assets |
51 BUILD_DIR="$CHROME_DIR/src/out" | 54 BUILD_DIR="$CHROME_DIR/src/out" |
52 CHROME_LINUX_DIR="$BUILD_DIR/chrome-chromeos" | 55 CHROME_LINUX_DIR="$BUILD_DIR/chrome-chromeos" |
53 OUTPUT_DIR="${SRC_ROOT}/build/x86/local_assets" | 56 OUTPUT_DIR="${SRC_ROOT}/build/x86/local_assets" |
54 OUTPUT_ZIP="$BUILD_DIR/chrome-chromeos.zip" | 57 OUTPUT_ZIP="$BUILD_DIR/chrome-chromeos.zip" |
55 if [ -n "$OUTPUT_DIR" ] | 58 if [ -n "$OUTPUT_DIR" ] |
56 then | 59 then |
57 mkdir -p $OUTPUT_DIR | 60 mkdir -p $OUTPUT_DIR |
58 fi | 61 fi |
59 # create symlink so that we can create the zip file with prefix chrome-chromeos | 62 # create symlink so that we can create the zip file with prefix chrome-chromeos |
60 rm -f $CHROME_LINUX_DIR | 63 rm -f $CHROME_LINUX_DIR |
61 ln -s $BUILD_DIR/$FLAGS_mode $CHROME_LINUX_DIR | 64 ln -s $BUILD_DIR/$FLAGS_mode $CHROME_LINUX_DIR |
62 | 65 |
63 echo Zipping $CHROME_LINUX_DIR to $OUTPUT_ZIP | 66 echo Zipping $CHROME_LINUX_DIR to $OUTPUT_ZIP |
64 cd $BUILD_DIR | 67 cd $BUILD_DIR |
65 rm -f $OUTPUT_ZIP | 68 rm -f $OUTPUT_ZIP |
66 zip -r9 $OUTPUT_ZIP chrome-chromeos -i "chrome-chromeos/chrome*" \ | 69 zip -r9 $OUTPUT_ZIP chrome-chromeos -i "chrome-chromeos/chrome*" \ |
67 "chrome-chromeos/libffmpegsumo.so" "chrome-chromeos/xdg-settings" \ | 70 "chrome-chromeos/libffmpegsumo.so" "chrome-chromeos/xdg-settings" \ |
68 "chrome-chromeos/locales/*" "chrome-chromeos/resources/*" \ | 71 "chrome-chromeos/locales/*" "chrome-chromeos/resources/*" \ |
69 "chrome-chromeos/*.png" -x "*.d" | 72 "chrome-chromeos/*.png" -x "*.d" |
70 cp -f $OUTPUT_ZIP $OUTPUT_DIR | 73 cp -f $OUTPUT_ZIP $OUTPUT_DIR |
71 echo Done. | 74 echo Done. |
OLD | NEW |