-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·130 lines (110 loc) · 2.49 KB
/
build.sh
File metadata and controls
executable file
·130 lines (110 loc) · 2.49 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -xe
# Default version must come first.
SSH_VERSIONS=( 8.4 8.3 )
ncpus=$(getconf _NPROCESSORS_ONLN || echo 2)
DEBUG=0
for i in $@; do
case $i in
"--debug")
DEBUG=1
;;
*)
echo "usage: $0 [--debug]"
exit 1
;;
esac
done
cd "$(dirname "$0")"
mkdir -p output
# Build the toolchain packages.
pkgs=(
# Build tools.
gnuconfig
mandoc
bazel-0.17
# NaCl toolchain.
naclsdk
glibc-compat
# WASM toolchain.
binaryen
wabt
wasi-sdk
wasmtime
)
for pkg in "${pkgs[@]}"; do
./third_party/${pkg}/build
done
# The plugin packages.
pkgs=(
zlib
openssl
ldns
$(printf 'openssh-%s ' "${SSH_VERSIONS[@]}")
)
# Build the NaCl packages.
for pkg in "${pkgs[@]}"; do
./third_party/${pkg}/build --toolchain pnacl
done
./third_party/mosh-chrome/build
./wassh-libc-sup/build
# Build the WASM packages.
for pkg in "${pkgs[@]}"; do
./third_party/${pkg}/build --toolchain wasm
done
# Install the WASM programs.
#
# We use -O2 as that seems to provide good enough shrinkage. -O3/-O4 take
# much longer but don't produce singificnatly larger/smaller files. -Os/-Oz
# also aren't that much smaller than -O2. So use this pending more testing.
#
# Only use single core here due to known bug in 89 release:
# https://github.com/WebAssembly/binaryen/issues/2273
export BINARYEN_CORES=1
PATH+=":${PWD}/output/bin"
WASM_OPTS=()
if [[ ${DEBUG} == 1 ]]; then
WASM_OPTS+=( -O0 )
else
WASM_OPTS+=( -O2 )
fi
pushd output >/dev/null
first="true"
for version in "${SSH_VERSIONS[@]}"; do
dir="plugin/wasm"
if [[ "${first}" == "true" ]]; then
first=
else
dir+="-openssh-${version}"
fi
mkdir -p "${dir}"
for prog in scp sftp ssh ssh-keygen; do
wasm-opt \
"${WASM_OPTS[@]}" \
build/wasm/openssh-${version}*/work/openssh-*/${prog} \
-o "${dir}/${prog}.wasm"
done
done
popd >/dev/null
# Build the PNaCl programs.
BUILD_ARGS=()
if [[ $DEBUG == 1 ]]; then
BUILD_ARGS+=( DEBUG=1 )
tarname="debug.tar"
else
tarname="release.tar"
fi
first="true"
for version in "${SSH_VERSIONS[@]}"; do
make -C src -j${ncpus} "${BUILD_ARGS[@]}" \
SSH_VERSION="${version}" DEFAULT_VERSION="${first}"
first=
done
cd output
tar cf - \
`find plugin/ -type f | LC_ALL=C sort` \
`find build/pnacl* -name '*.pexe' -o -name '*.dbg.nexe' | LC_ALL=C sort` \
| xz -T0 -9 >"${tarname}.xz"