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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#!/bin/bash
# This script downloads and imports a revision of zstandard.
# It can be run on Linux, Mac OS X or Windows WSL.
# Actual integration into the build system is not done by this script.
#
# Turn on strict error checking, like perl use 'strict'
set -xeuo pipefail
IFS=$'\n\t'
if [ "$#" -ne 0 ]; then
echo "This script does not take any arguments"
exit 1
fi
GIT_EXE=git
if grep -q Microsoft /proc/version; then
GIT_EXE=git.exe
fi
NAME=zstandard
REVISION=1.5.2
if grep -q Microsoft /proc/version; then
SRC_ROOT=$(wslpath -u $(powershell.exe -Command "Get-ChildItem Env:TEMP | Get-Content | Write-Host"))
SRC_ROOT+="$(mktemp -u /zstandard.XXXXXX)"
mkdir -p $SRC_ROOT
else
SRC_ROOT=$(mktemp -d /tmp/zstandard.XXXXXX)
fi
SRC=${SRC_ROOT}/${NAME}
CLONE_DEST=$SRC
if grep -q Microsoft /proc/version; then
CLONE_DEST=$(wslpath -m $SRC)
fi
DEST_DIR=$($GIT_EXE rev-parse --show-toplevel)/src/third_party/$NAME
PATCH_DIR=$($GIT_EXE rev-parse --show-toplevel)/src/third_party/$NAME/patches
if grep -q Microsoft /proc/version; then
DEST_DIR=$(wslpath -u "$DEST_DIR")
PATCH_DIR=$(wslpath -w $(wslpath -u "$PATCH_DIR"))
fi
echo "dest: $DEST_DIR"
echo "patch: $PATCH_DIR"
if [ ! -d $SRC ]; then
$GIT_EXE clone https://github.com/facebook/zstd.git $CLONE_DEST
pushd $SRC
$GIT_EXE checkout v$REVISION
popd
fi
test -d $DEST_DIR/zstd && rm -r $DEST_DIR/zstd
mkdir -p $DEST_DIR/zstd
mv $SRC/* $DEST_DIR/zstd
# Generate the SConscript
( cat > ${DEST_DIR}/SConscript ) << ___EOF___
# -*- mode: python; -*-
# NOTE: This file is auto-generated by "$(basename $0)" - DO NOT EDIT
Import("env")
env = env.Clone()
env.Prepend(CPPPATH=[
'zstd/lib/common',
])
env.Library(
target="zstd",
source=[
'zstd/lib/common/entropy_common.c',
'zstd/lib/common/error_private.c',
'zstd/lib/common/fse_decompress.c',
'zstd/lib/common/pool.c',
'zstd/lib/common/threading.c',
'zstd/lib/common/xxhash.c',
'zstd/lib/common/zstd_common.c',
'zstd/lib/compress/fse_compress.c',
'zstd/lib/compress/hist.c',
'zstd/lib/compress/huf_compress.c',
'zstd/lib/compress/zstd_compress.c',
'zstd/lib/compress/zstd_compress_literals.c',
'zstd/lib/compress/zstd_compress_sequences.c',
'zstd/lib/compress/zstd_compress_superblock.c',
'zstd/lib/compress/zstd_double_fast.c',
'zstd/lib/compress/zstd_fast.c',
'zstd/lib/compress/zstd_lazy.c',
'zstd/lib/compress/zstd_ldm.c',
'zstd/lib/compress/zstd_opt.c',
'zstd/lib/compress/zstdmt_compress.c',
'zstd/lib/decompress/huf_decompress.c',
'zstd/lib/decompress/huf_decompress_amd64.S' if not env.TargetOSIs('windows') else [],
'zstd/lib/decompress/zstd_ddict.c',
'zstd/lib/decompress/zstd_decompress.c',
'zstd/lib/decompress/zstd_decompress_block.c',
'zstd/lib/deprecated/zbuff_common.c',
'zstd/lib/deprecated/zbuff_compress.c',
'zstd/lib/deprecated/zbuff_decompress.c',
'zstd/lib/dictBuilder/cover.c',
'zstd/lib/dictBuilder/divsufsort.c',
'zstd/lib/dictBuilder/fastcover.c',
'zstd/lib/dictBuilder/zdict.c',
],
LIBDEPS_TAGS=[
'init-no-global-side-effects',
],
)
___EOF___
echo "Done"
|