Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / build_tools / make_pnacl_component.sh
blob4674ac6e327153b659488b9efe6957362012aa72
1 #!/bin/bash
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # This script builds out/pnacl_multicrx_<rev>.zip for upload to the Chrome
7 # Web Store. It runs gyp + ninja once for each architecture and assembles
8 # the results along with a manifest file.
10 # TODO(sbc): rewrite this in python
12 set -o errexit
13 set -o nounset
15 SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
16 CHROME_SRC=$(dirname $(dirname $(dirname ${SCRIPT_DIR})))
17 cd ${CHROME_SRC}
19 run_gyp() {
20 # The original version of the script ran 'gclient runhooks' which run turn
21 # runs gyp_chromium. However its a lot faster and quieter to just run the
22 # gyp file containing the target we need.
23 gyp_dir=ppapi/native_client/src/untrusted/pnacl_support_extension
24 build/gyp_chromium --depth=. $gyp_dir/pnacl_support_extension.gyp
27 individual_packages() {
28 export GYP_GENERATOR_FLAGS="output_dir=out_pnacl"
29 local base_out_dir=out
31 # arm
32 rm -rf out_pnacl/
33 GYP_DEFINES="target_arch=arm" run_gyp
34 ninja -C out_pnacl/Release/ pnacl_support_extension
35 local target_dir=${base_out_dir}/pnacl_arm
36 mkdir -p ${target_dir}
37 cp out_pnacl/Release/pnacl/* ${target_dir}/.
39 # ia32
40 rm -rf out_pnacl/
41 GYP_DEFINES="target_arch=ia32" run_gyp
42 ninja -C out_pnacl/Release/ pnacl_support_extension
43 target_dir=${base_out_dir}/pnacl_x86_32
44 mkdir -p ${target_dir}
45 cp out_pnacl/Release/pnacl/* ${target_dir}/.
47 # x64
48 rm -rf out_pnacl/
49 GYP_DEFINES="target_arch=x64" run_gyp
50 ninja -C out_pnacl/Release/ pnacl_support_extension
51 target_dir=${base_out_dir}/pnacl_x86_64
52 mkdir -p ${target_dir}
53 cp out_pnacl/Release/pnacl/* ${target_dir}/.
56 multi_crx() {
57 local outfile=$1
58 local version=$2
59 local base_out_dir=out
60 local target_dir=${base_out_dir}/pnacl_multicrx
61 mkdir -p ${target_dir}
62 cat > ${target_dir}/manifest.json <<EOF
64 "description": "Portable Native Client Translator Multi-CRX",
65 "name": "PNaCl Translator Multi-CRX",
66 "manifest_version": 2,
67 "minimum_chrome_version": "30.0.0.0",
68 "version": "${version}",
69 "platforms": [
71 "nacl_arch": "x86-32",
72 "sub_package_path": "_platform_specific/x86_32/"
75 "nacl_arch": "x86-64",
76 "sub_package_path": "_platform_specific/x86_64/"
79 "nacl_arch": "arm",
80 "sub_package_path": "_platform_specific/arm/"
84 EOF
86 for arch in x86_32 x86_64 arm; do
87 local sub_dir="${target_dir}/_platform_specific/${arch}"
88 local src_dir="${base_out_dir}/pnacl_${arch}"
89 mkdir -p ${sub_dir}
90 cp ${src_dir}/pnacl_public_* ${sub_dir}/.
91 done
92 (cd ${target_dir} && zip -r ../${outfile} . && ls -l ../${outfile})
93 echo "DONE: created ${outfile} -- upload that!"
94 echo "You can also delete ${target_dir} later (the pre-zipped contents)."
97 if [ $# != 2 ]; then
98 echo "Usage: $0 <outfile> <rev_number>"
99 exit 1
102 outfile="$1"
103 version="$2"
104 echo "Building file ${outfile} version=${version}"
105 individual_packages
106 multi_crx ${outfile} ${version}