summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/build_tools/make_pnacl_component.sh
blob: 4674ac6e327153b659488b9efe6957362012aa72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This script builds out/pnacl_multicrx_<rev>.zip for upload to the Chrome
# Web Store. It runs gyp + ninja once for each architecture and assembles
# the results along with a manifest file.

# TODO(sbc): rewrite this in python

set -o errexit
set -o nounset

SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
CHROME_SRC=$(dirname $(dirname $(dirname ${SCRIPT_DIR})))
cd ${CHROME_SRC}

run_gyp() {
  # The original version of the script ran 'gclient runhooks' which run turn
  # runs gyp_chromium. However its a lot faster and quieter to just run the
  # gyp file containing the target we need.
  gyp_dir=ppapi/native_client/src/untrusted/pnacl_support_extension
  build/gyp_chromium --depth=. $gyp_dir/pnacl_support_extension.gyp
}

individual_packages() {
  export GYP_GENERATOR_FLAGS="output_dir=out_pnacl"
  local base_out_dir=out

  # arm
  rm -rf out_pnacl/
  GYP_DEFINES="target_arch=arm" run_gyp
  ninja -C out_pnacl/Release/ pnacl_support_extension
  local target_dir=${base_out_dir}/pnacl_arm
  mkdir -p ${target_dir}
  cp out_pnacl/Release/pnacl/* ${target_dir}/.

  # ia32
  rm -rf out_pnacl/
  GYP_DEFINES="target_arch=ia32" run_gyp
  ninja -C out_pnacl/Release/ pnacl_support_extension
  target_dir=${base_out_dir}/pnacl_x86_32
  mkdir -p ${target_dir}
  cp out_pnacl/Release/pnacl/* ${target_dir}/.

  # x64
  rm -rf out_pnacl/
  GYP_DEFINES="target_arch=x64" run_gyp
  ninja -C out_pnacl/Release/ pnacl_support_extension
  target_dir=${base_out_dir}/pnacl_x86_64
  mkdir -p ${target_dir}
  cp out_pnacl/Release/pnacl/* ${target_dir}/.
}

multi_crx() {
  local outfile=$1
  local version=$2
  local base_out_dir=out
  local target_dir=${base_out_dir}/pnacl_multicrx
  mkdir -p ${target_dir}
  cat > ${target_dir}/manifest.json <<EOF
{
  "description": "Portable Native Client Translator Multi-CRX",
  "name": "PNaCl Translator Multi-CRX",
  "manifest_version": 2,
  "minimum_chrome_version": "30.0.0.0",
  "version": "${version}",
  "platforms": [
    {
      "nacl_arch": "x86-32",
      "sub_package_path": "_platform_specific/x86_32/"
    },
    {
      "nacl_arch": "x86-64",
      "sub_package_path": "_platform_specific/x86_64/"
    },
    {
      "nacl_arch": "arm",
      "sub_package_path": "_platform_specific/arm/"
    }
  ]
}
EOF

  for arch in x86_32 x86_64 arm; do
    local sub_dir="${target_dir}/_platform_specific/${arch}"
    local src_dir="${base_out_dir}/pnacl_${arch}"
    mkdir -p ${sub_dir}
    cp ${src_dir}/pnacl_public_* ${sub_dir}/.
  done
  (cd ${target_dir} && zip -r ../${outfile} . && ls -l ../${outfile})
  echo "DONE: created ${outfile} -- upload that!"
  echo "You can also delete ${target_dir} later (the pre-zipped contents)."
}

if [ $# != 2 ]; then
  echo "Usage: $0 <outfile> <rev_number>"
  exit 1
fi

outfile="$1"
version="$2"
echo "Building file ${outfile} version=${version}"
individual_packages
multi_crx ${outfile} ${version}