forked from lwthiker/curl-impersonate
-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.sh
102 lines (79 loc) · 2.68 KB
/
build.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
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
#!/bin/bash
set -ex
mkdir -p build/
cd build/
# Download and patch boringssl
BORING_SSL_COMMIT=cd95210465496ac2337b313cf49f607762abe286
curl -L https://github.com/google/boringssl/archive/${BORING_SSL_COMMIT}.zip -o boringssl.zip
unzip -q -o boringssl.zip
mv boringssl-${BORING_SSL_COMMIT} boringssl
cd boringssl
patchfile=../../chrome/patches/boringssl.patch
patch -p1 < $patchfile
sed -i 's/-ggdb//g' CMakeLists.txt
sed -i 's/-Werror//g' CMakeLists.txt
cmake -G "Ninja" -S . -B lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc.exe -DOPENSSL_NO_ASM=1
ninja -C lib crypto ssl
mv lib/crypto/libcrypto.a lib/libcrypto.a
mv lib/ssl/libssl.a lib/libssl.a
cd ..
export BROTLI_LIBS='-lbrotlidec -lbrotlicommon'
export OPENSSL_PATH=$PWD/boringssl
export OPENSSL_LIBPATH=$PWD/boringssl/lib
CURL_VERSION=curl-8_7_1
curl -L https://github.com/curl/curl/archive/${CURL_VERSION}.zip -o curl.zip
unzip -q -o curl.zip
mv curl-${CURL_VERSION} curl
# Apparently, building curl on windows has changes since this commit:
# https://github.com/curl/curl/commit/a8861b6ccdd7ca35b6115588a578e36d765c9e38
cd curl
patchfile=../../chrome/patches/curl-impersonate.patch
patch -p1 < $patchfile
export CMAKE_PREFIX_PATH=../boringssl
export CFLAGS='-Wno-unused-variable -static -static-libgcc -static-libstdc++'
export CXXFLAGS='-static -static-libgcc -static-libstdc++'
export LDFLAGS='-static -static-libgcc -static-libstdc++ -lz -lidn2 -lnghttp2 -lbrotlidec -lpsl'
cmake -B build -G "MinGW Makefiles" \
-DENABLE_IPV6=ON \
-DENABLE_UNICODE=ON \
-DUSE_NGHTTP2=ON \
-DUSE_LIBIDN2=ON \
-DENABLE_WEBSOCKETS=ON \
-DCURL_BROTLI=ON \
-DCURL_ZLIB=ON \
-DCURL_ZSTD=ON \
-DENABLE_IPV6=ON \
-DCURL_ENABLE_SSL=ON \
-DCURL_USE_OPENSSL=ON \
-DCURL_USE_LIBSSH2=OFF \
-DCURL_USE_LIBSSH=OFF \
-DUSE_ECH=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_STATIC_CURL=ON \
cd build
mingw32-make clean
mingw32-make -j CFG=-ssl-zlib-nghttp2-idn2-brotli-zstd-ipv6
cd ..
SYS=$1
mkdir -p ../dist
ls build
mv build/lib/libcurl* ../dist/
cp /$SYS/bin/libidn2-0.dll ../dist/
cp /$SYS/bin/libnghttp2-14.dll ../dist/
cp /$SYS/bin/libbrotlidec.dll ../dist/
cp /$SYS/bin/libbrotlicommon.dll ../dist/
cp /$SYS/bin/libpsl-5.dll ../dist/
cp /$SYS/bin/libssh2-1.dll ../dist/
cp /$SYS/bin/libzstd.dll ../dist/
cp /$SYS/bin/zlib1.dll ../dist/
cp /$SYS/bin/libiconv-2.dll ../dist/
cp /$SYS/bin/libintl-8.dll ../dist/
cp /$SYS/bin/libunistring-5.dll ../dist
cp /$SYS/bin/libgcc_s_dw2-1.dll ../dist | true # 32bit
cp /$SYS/bin/libgcc_s_seh-1.dll ../dist | true # 64bit
cp /$SYS/bin/libwinpthread-1.dll ../dist
cp /$SYS/bin//libstdc++-6.dll ../dist
mv build/src/*.exe ../dist/
cd ..
dist/curl.exe -V