This repository has been archived by the owner on Jan 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.sh
executable file
·52 lines (40 loc) · 1.6 KB
/
generate.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
52
#!/bin/bash
set -eu
TAG=${TAG:-v0.12.0-alpha.6}
TOOLCHAIN="${TOOLCHAIN:-stable}"
PROJECT="${PROJECT:-finchers}"
REPO_URL="${REPO_URL:-"https://github.com/finchers-rs/${PROJECT}.git"}"
BASE_DIR="$(cd $(dirname ${BASH_SOURCE}); pwd)"
SOURCE_DIR="${BASE_DIR}/source/${PROJECT}"
TARGET_DIR="${BASE_DIR}/docs/${PROJECT}/${TAG}"
(set -x; rustup toolchain install "${TOOLCHAIN}")
if [[ -d "${SOURCE_DIR}" ]]; then
cd "${SOURCE_DIR}"
(set -x; git fetch origin "$TAG:$TAG" --depth 1)
(set -x; git checkout "refs/tags/${TAG}")
cd "$BASE_DIR"
else
(set -x; git clone "${REPO_URL}" "${SOURCE_DIR}" --branch "${TAG}" --depth 1)
fi
cd "${SOURCE_DIR}"
rm -rf target/doc
(set -x; rustup run "$TOOLCHAIN" cargo update)
if [[ -n ${FEATURES:-} ]]; then
(set -x; rustup run "$TOOLCHAIN" cargo doc --features "${FEATURES}" --no-deps)
else
(set -x; rustup run "$TOOLCHAIN" cargo doc --no-deps)
fi
echo > target/doc/src/build-info.txt "timestamp: $(date --rfc-2822)"
echo >>target/doc/src/build-info.txt "toolchain: ${TOOLCHAIN}"
if [[ -n ${FEATURES:-} ]]; then
echo >>target/doc/src/build-info.txt "features: ${FEATURES}"
fi
echo >>target/doc/src/build-info.txt "rustc-version: $(rustup run $TOOLCHAIN rustc --version)"
echo >>target/doc/src/build-info.txt "cargo-version: $(rustup run $TOOLCHAIN cargo --version)"
echo > target/doc/index.html \
"<meta http-equiv=\"refresh\" content=\"0;URL=${PROJECT//-/_}/index.html\" />"
cp -f Cargo.lock target/doc/src/Cargo.lock
cd "$BASE_DIR"
echo "copying..."
mkdir -p "$TARGET_DIR"
(set -x; rsync -av --delete --exclude '.lock' "${SOURCE_DIR}/target/doc/" "${TARGET_DIR}")