forked from lifting-bits/cxx-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emit_artifacts.sh
executable file
·66 lines (56 loc) · 1.73 KB
/
emit_artifacts.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -euo pipefail
# Compression tool to use
compressor="pixz"
# Extension for compressed file generated by this script
output_extension=".tar.xz"
# NOTE: vcpkg saves the raw directory layout into a directory of the same name
# as passed as argument without the output extension
if [[ $1 != *"${output_extension}" ]]; then
echo "Must provide output filename ending with '${output_extension}'"
exit 1
fi
export_dir="${1%%${output_extension}*}"
echo "Exporting to directory: ${export_dir}"
# check for pixz for parallel xz
if ! command -v "${compressor}" &>/dev/null; then
echo "Could not find recommended compression tool '${compressor}'"
echo "Please install and place on PATH."
exit
fi
echo "Using compression tool '${compressor}'"
echo ""
# Check for vcpkg directory
vcpkg_root="${PWD}/vcpkg"
if [ ! -d "${vcpkg_root}" ]; then
echo "Could not find 'vcpkg' directory at '${PWD}'"
exit
fi
vcpkg_exe="${vcpkg_root}/vcpkg"
if [ ! -f "${vcpkg_exe}" ]; then
echo "Could not find 'vcpkg' executable at '${vcpkg_root}'"
exit
fi
echo "Exporting all vcpkg packages"
# TODO: Say something about the overlay directories
# NOTE: Always saves the export output in vcpkg root
start_time="$(date +%s)"
(
set -x
"${vcpkg_exe}" export --x-all-installed --overlay-ports=./ports --overlay-triplets=./triplets --raw "--output=${export_dir}"
)
echo Duration: "$(($(date +%s) - start_time))s"
echo ""
echo "Compressing vcpkg packages with '${compressor}' to: ${1}"
start_time="$(date +%s)"
(
set -x
tar --use-compress-program "${compressor}" -cf "${1}" -C "${vcpkg_root}" "${export_dir}"
)
echo Duration: "$(($(date +%s) - start_time))s"
echo ""
echo "Cleaning up export directory"
(
set -x
rm -r "${vcpkg_root:?}/${export_dir}"
)