This repository has been archived by the owner on Mar 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbake.sh
executable file
·51 lines (41 loc) · 1.56 KB
/
bake.sh
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
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
set -eufo pipefail
input="cdp"
output="cdp-baked"
# Do a fresh build to ensure that all the source files we'll need are generated.
if [[ "${1:-}" != "--skip-build" ]]; then
cargo clean -p "${input}"
cargo build -p "${input}"
fi
# Find the generated sources.
generated_rs="$(find target/ -type f -name generated.rs -printf "%T+\t%p\n" | sort -r | head -n1 | cut -f2)"
# Initialize the output directory.
rm -rf "${output}/"
mkdir -p "${output}/"
# Set up the baked Cargo.toml.
sed '/build/d' "${input}/Cargo.toml" > "${output}/Cargo.toml"
# Copy over the relevant files.
cp "${input}/LICENSE.md" "${output}/"
cp "${input}/LICENSE-MPL" "${output}/"
cp "${input}/LICENSE-CHROMIUM" "${output}/"
cp "${input}/README.md" "${output}/"
mkdir "${output}/src/"
cp "${input}/src/lib.rs" "${output}/src/"
cp "${input}/src/generated.rs" "${output}/src/"
cp -r "${input}/tests/" "${output}/"
# Bake in the generated source.
sed -i '/include/d' "${output}/src/generated.rs"
echo "
// The following code is automatically generated using a JSON specification of
// the Chrome DevTools Protocol published by the Chromium project. The JSON
// files themselves are covered by their own BSD 3-Clause license. Please see
// the LICENSE-CHROMIUM file for more information.
" >> "${output}/src/generated.rs"
cat "${generated_rs}" >> "${output}/src/generated.rs"
echo
echo
echo
find "${output}" -type f