|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +## $1 : version, clspv does not have any and only uses master branch. |
| 4 | +## $2 : destination: a directory or S3 path (eg. s3://...) |
| 5 | +## $3 : last revision successfully build |
| 6 | + |
| 7 | +set -ex |
| 8 | + |
| 9 | +ROOT=$PWD |
| 10 | +VERSION="${1}" |
| 11 | +LAST_REVISION="${3}" |
| 12 | + |
| 13 | +if [[ "${VERSION}" != "master" ]]; then |
| 14 | + echo "Only support building master" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +URL="https://github.com/google/clspv.git" |
| 19 | +BRANCH="master" |
| 20 | + |
| 21 | +REVISION=$(git ls-remote --heads "${URL}" "refs/heads/${BRANCH}" | cut -f 1) |
| 22 | +echo "ce-build-revision:${REVISION}" |
| 23 | + |
| 24 | +if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then |
| 25 | + echo "ce-build-status:SKIPPED" |
| 26 | + exit |
| 27 | +fi |
| 28 | + |
| 29 | +FULLNAME=clspv-${VERSION}-$(date +%Y%m%d) |
| 30 | + |
| 31 | +OUTPUT=${ROOT}/${FULLNAME}.tar.xz |
| 32 | +S3OUTPUT= |
| 33 | +if [[ $2 =~ ^s3:// ]]; then |
| 34 | + S3OUTPUT=$2 |
| 35 | +else |
| 36 | + if [[ -d "${2}" ]]; then |
| 37 | + OUTPUT=$2/${FULLNAME}.tar.xz |
| 38 | + else |
| 39 | + OUTPUT=${2-$OUTPUT} |
| 40 | + fi |
| 41 | +fi |
| 42 | + |
| 43 | +## From now, no unset variable |
| 44 | +set -u |
| 45 | + |
| 46 | +OUTPUT=$(realpath "${OUTPUT}") |
| 47 | + |
| 48 | +git clone --depth 1 "${URL}" --branch "${BRANCH}" |
| 49 | +pushd clspv |
| 50 | + |
| 51 | +python3 utils/fetch_sources.py |
| 52 | + |
| 53 | +mkdir build |
| 54 | +cmake -S . -B build -G "Unix Makefiles" |
| 55 | +cmake --build build |
| 56 | + |
| 57 | +export XZ_DEFAULTS="-T 0" |
| 58 | +tar Jcf "${OUTPUT}" --transform "s,^./,./${FULLNAME}/," ./ |
| 59 | + |
| 60 | +if [[ -n "${S3OUTPUT}" ]]; then |
| 61 | + s3cmd put --rr "${OUTPUT}" "${S3OUTPUT}" |
| 62 | +fi |
| 63 | +popd |
0 commit comments