forked from nelhage/rules_boost
-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_lzma_config_header.sh
executable file
·74 lines (60 loc) · 2.41 KB
/
update_lzma_config_header.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
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
# This is a helper script to update the config header for LZMA, i.e.
# - config.lzma-android.h,
# - config.lzma-ios-arm64.h
# - config.lzma-ios-armv7.h
# - config.lzma-ios-i386.h
# - config.lzma-linux.h
# - config.lzma-osx-arm64.h
# - config.lzma-osx-x86_64.h
# - config.lzma-windows.h
#
# Those files are dependent on the target OS and architecture.
# Every time the version number of xz is bumped the corresponding config headers should be updated.
# Note: This script has to be executed on macOS, Linux, and Windows since the configuration of the headers is specific to the underlying OS environment
# Fail on error, etc.
set -euxo pipefail
# Get script location
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Path where the WORKSPACE file is located
rules_boost_dir=$script_dir
# Create a temporary directory
tmpdir=$(mktemp -d)
# Get rid of temporary files when script exits
trap "rm -rf $tmpdir" EXIT
# Version number of xz
xz_version_number="5.4.2"
# Download, and untar xz
cd "$tmpdir"
curl -sL 'https://github.com/tukaani-project/xz/releases/download/v'$xz_version_number'/xz-'$xz_version_number'.tar.gz' --output 'xz-'$xz_version_number'.tar.gz'
tar -xf 'xz-'$xz_version_number'.tar.gz'
# Switch to xz directory
cd 'xz-'$xz_version_number
# config header files depend on the specific OS
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
./configure
cp config.h "${rules_boost_dir}/config.lzma-linux.h"
elif [[ "$OSTYPE" == "darwin"* ]]; then
CC="clang -arch x86_64" ./configure --host=$MACHTYPE
cp config.h "${rules_boost_dir}/config.lzma-osx-x86_64.h"
CC="clang -arch arm64" ./configure --host=$MACHTYPE
cp config.h "${rules_boost_dir}/config.lzma-osx-arm64.h"
CC="clang -arch arm64 \
-isysroot $(xcrun --sdk iphoneos --show-sdk-path)" \
./configure --host=$MACHTYPE
cp config.h "${rules_boost_dir}/config.lzma-ios-arm64.h"
CC="clang -arch armv7 \
-isysroot $(xcrun --sdk iphoneos --show-sdk-path)" \
./configure --host=$MACHTYPE
cp config.h "${rules_boost_dir}/config.lzma-ios-armv7.h"
CC="clang -arch i386 \
-isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" \
./configure --host=$MACHTYPE
cp config.h "${rules_boost_dir}/config.lzma-ios-i386.h"
elif [[ "$OSTYPE" == "msys"* ]]; then
./configure
cp config.h "${rules_boost_dir}/config.lzma-windows.h"
else
echo "Unsupported OS"
echo "$OSTYPE"
fi