Skip to content

Commit 0570431

Browse files
committed
start marking Windows-specific build settings [ci skip]
Also add future targets: linux and mac
1 parent 812f6e2 commit 0570431

23 files changed

+186
-97
lines changed

.github/workflows/daily.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ on:
1111
permissions: {}
1212

1313
jobs:
14-
build:
14+
win:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v3
1818
with:
1919
fetch-depth: 8
2020
- name: 'build'
2121
env:
22-
CW_CONFIG: 'dev'
22+
CW_CONFIG: 'dev-win'
2323
CW_LLVM_MINGW_DL: '1'
2424
CW_LLVM_MINGW_ONLY: '0'
2525
CW_MAP: '1'
@@ -43,7 +43,7 @@ jobs:
4343
# https://github.com/actions/upload-artifact
4444
- uses: actions/upload-artifact@v3
4545
with:
46-
name: 'binaries'
46+
name: 'Windows binaries'
4747
retention-days: 42
4848
path: |
4949
*-*-mingw*.*

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 K
7777
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
7878
Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL SSPI threadsafe UnixSockets zstd
7979
80-
"mini", Schannel, without brotli and zstd:
80+
"mini", without brotli and zstd, with OS TLS backend (Schannel, SecureTransport) if available:
8181
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
8282
Features: alt-svc AsynchDNS HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM SPNEGO SSL SSPI threadsafe UnixSockets
8383

_build.sh

+22-13
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o p
5151
# unicode build curl in UNICODE mode [EXPERIMENTAL]
5252
# werror turn compiler warnings into errors
5353
# debug debug build
54+
# mac build macOS target (requires macOS host)
55+
# linux build Linux target (requires Linux host)
5456
#
5557
# CW_JOBS
5658
# Number of parallel make jobs. Default: 2
@@ -70,6 +72,9 @@ set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o p
7072

7173
# TODO:
7274
# - Change default TLS to BoringSSL (with OPENSSL_SMALL?) or LibreSSL?
75+
# - Linux: use musl.
76+
# - Rename _BRANCH to CW_CONFIG internally.
77+
# - Replace .zip with .tar.gz for all-packages artifact (in _ul.sh)?
7378
# - Drop x86 builds.
7479
# https://data.firefox.com/dashboard/hardware
7580
# https://gs.statcounter.com/windows-version-market-share
@@ -186,6 +191,20 @@ else
186191
_TAR="${_URL_BASE}/archive/refs/heads/${_BRANCH}.tar.gz"
187192
fi
188193

194+
# Detect host OS
195+
export _HOSTOS
196+
case "$(uname)" in
197+
*_NT*) _HOSTOS='win';;
198+
Linux*) _HOSTOS='linux';;
199+
Darwin*) _HOSTOS='mac';;
200+
*BSD) _HOSTOS='bsd';;
201+
*) _HOSTOS='unrecognized';;
202+
esac
203+
204+
export _OS='win'
205+
[ ! "${_BRANCH#*mac*}" = "${_BRANCH}" ] && _OS='mac'
206+
[ ! "${_BRANCH#*linux*}" = "${_BRANCH}" ] && _OS='linux'
207+
189208
export _CACERT='cacert.pem'
190209

191210
[ -n "${CW_CCSUFFIX:-}" ] || CW_CCSUFFIX=''
@@ -207,16 +226,6 @@ export _JOBS=2
207226
my_time='time'
208227
[ -n "${CW_NOTIME:-}" ] && my_time=
209228

210-
# Detect host OS
211-
export _HOSTOS
212-
case "$(uname)" in
213-
*_NT*) _HOSTOS='win';;
214-
Linux*) _HOSTOS='linux';;
215-
Darwin*) _HOSTOS='mac';;
216-
*BSD) _HOSTOS='bsd';;
217-
*) _HOSTOS='unrecognized';;
218-
esac
219-
220229
# Form suffix for alternate builds
221230
export _FLAV=''
222231
if [ "${_BRANCH#*pico*}" != "${_BRANCH}" ]; then
@@ -271,7 +280,7 @@ export _REVSUFFIX="${_REV}"; [ -z "${_REVSUFFIX}" ] || _REVSUFFIX="_${_REVSUFFIX
271280
. ./_dl.sh
272281

273282
# Install required component
274-
if [ "${_HOSTOS}" = 'mac' ]; then
283+
if [ "${_OS}" = 'win' ] && [ "${_HOSTOS}" = 'mac' ]; then
275284
if [ ! -d .venv ]; then
276285
python3 -m venv .venv
277286
PIP_PROGRESS_BAR=off .venv/bin/python3 -m pip --disable-pip-version-check --no-cache-dir --require-virtualenv install pefile
@@ -585,7 +594,7 @@ build_single_target() {
585594
_CC_GLOBAL="${_CC_GLOBAL} --sysroot=${_SYSROOT}"
586595
_CONFIGURE_GLOBAL="${_CONFIGURE_GLOBAL} --with-sysroot=${_SYSROOT}"
587596
fi
588-
if [ "${_HOSTOS}" = 'linux' ]; then
597+
if [ "${_HOSTOS}" = 'linux' ] && [ "${_OS}" = 'win' ]; then
589598
# We used to pass this via CFLAGS for CMake to make it detect llvm/clang,
590599
# so we need to pass this via CMAKE_C_FLAGS, though meant for the linker.
591600
if [ "${_TOOLCHAIN}" = 'llvm-mingw' ]; then
@@ -640,7 +649,7 @@ build_single_target() {
640649
_BINUTILS_PREFIX='llvm-'
641650
_BINUTILS_SUFFIX="${_CCSUFFIX}"
642651
_LDFLAGS_GLOBAL="${_LDFLAGS_GLOBAL} -fuse-ld=lld${_CCSUFFIX}"
643-
if [ "${_HOSTOS}" = 'mac' ]; then
652+
if [ "${_HOSTOS}" = 'mac' ] && [ "${_OS}" = 'win' ]; then
644653
_RCFLAGS_GLOBAL="${_RCFLAGS_GLOBAL} -I${_SYSROOT}/${_TRIPLET}/include"
645654
fi
646655
fi

_ci-linux-debian.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ export CW_CCSUFFIX='-16'
1212

1313
extra=''
1414
[[ "${CW_CONFIG:-}" = *'boringssl'* ]] && extra="${extra} golang nasm"
15+
[[ "${CW_CONFIG:-}" = *'win'* ]] && extra="${extra} mingw-w64 osslsigncode wine64"
1516

1617
apt-get --quiet 2 --option Dpkg::Use-Pty=0 update
1718
# shellcheck disable=SC2086
1819
apt-get --quiet 2 --option Dpkg::Use-Pty=0 install \
1920
curl git gpg rsync python3-pefile make cmake \
20-
mingw-w64 \
2121
"llvm${CW_CCSUFFIX}" "clang${CW_CCSUFFIX}" "lld${CW_CCSUFFIX}" \
22-
autoconf automake autopoint libtool osslsigncode \
23-
zip time jq dos2unix secure-delete wine64 ${extra}
22+
autoconf automake autopoint libtool \
23+
zip time jq dos2unix secure-delete ${extra}
2424

2525
./_build.sh

_ci-mac-homebrew.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o p
88

99
extra=''
1010
[[ "${CW_CONFIG:-}" = *'boringssl'* ]] && extra="${extra} go nasm"
11+
[[ "${CW_CONFIG:-}" = *'win'* ]] && extra="${extra} mingw-w64 osslsigncode wine-stable openssh"
1112

1213
export HOMEBREW_NO_AUTO_UPDATE=1
1314
export HOMEBREW_NO_ANALYTICS=1
1415
brew update >/dev/null
1516
# shellcheck disable=SC2086
16-
brew install coreutils mingw-w64 llvm \
17-
dos2unix osslsigncode openssh wine-stable ${extra}
18-
wineboot --init
17+
brew install coreutils llvm dos2unix ${extra}
18+
19+
[[ "${CW_CONFIG:-}" = *'win'* ]] && wineboot --init
1920

2021
./_build.sh

_clean-bin.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
# Copyright (C) Viktor Szakats. See LICENSE.md
4+
# SPDX-License-Identifier: MIT
5+
6+
# shellcheck disable=SC3040,SC2039
7+
set -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o pipefail
8+
9+
if [ "${_OS:-}" = 'win' ]; then
10+
"$(dirname "$0")"/_peclean.py "$@"
11+
fi

_dl.sh

+14-7
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,8 @@ EOF
638638
}
639639

640640
# Download llvm-mingw
641-
if [ "${CW_LLVM_MINGW_DL:-}" = '1' ] && \
641+
if [ "${_OS}" = 'win' ] && \
642+
[ "${CW_LLVM_MINGW_DL:-}" = '1' ] && \
642643
[ ! -d 'llvm-mingw' ]; then
643644
name=''; vers=''; hash=''; arch="$(uname -m)"
644645
if [ "${_HOSTOS}-${arch}" = 'linux-x86_64' ]; then
@@ -725,13 +726,19 @@ if [ "${_BRANCH#*mbedtls*}" != "${_BRANCH}" ]; then
725726
live_xt mbedtls "${MBEDTLS_HASH}"
726727
fi
727728

728-
need_cacert=0
729+
need_openssl=0
730+
if [ "${_OS}" != 'win' ]; then
731+
need_openssl=1
732+
elif [ "${_BRANCH#*pico*}" = "${_BRANCH}" ] && \
733+
[ "${_BRANCH#*nano*}" = "${_BRANCH}" ] && \
734+
[ "${_BRANCH#*micro*}" = "${_BRANCH}" ] && \
735+
[ "${_BRANCH#*mini*}" = "${_BRANCH}" ] && \
736+
[ "${_BRANCH#*schannel*}" = "${_BRANCH}" ]; then
737+
need_openssl=1
738+
fi
729739

730-
if [ "${_BRANCH#*pico*}" = "${_BRANCH}" ] && \
731-
[ "${_BRANCH#*nano*}" = "${_BRANCH}" ] && \
732-
[ "${_BRANCH#*micro*}" = "${_BRANCH}" ] && \
733-
[ "${_BRANCH#*mini*}" = "${_BRANCH}" ] && \
734-
[ "${_BRANCH#*schannel*}" = "${_BRANCH}" ]; then
740+
need_cacert=0
741+
if [ "${need_openssl}" = '1' ]; then
735742
if [ "${_BRANCH#*libressl*}" != "${_BRANCH}" ]; then
736743
live_dl libressl "${LIBRESSL_VER_}"
737744
live_xt libressl "${LIBRESSL_HASH}"

_pkg.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ if [ "${_NAM}" != "${_UNIPKG}" ]; then
2020
chmod -R a+rw-s,go-w "${_DST}"
2121
# NOTE: Not effective on MSYS2:
2222
find "${_DST}" -name '*.a' -exec chmod a-x '{}' +
23-
find "${_DST}" \( -name '*.exe' -o -name '*.dll' \) -exec chmod a+x '{}' +
23+
if [ "${_OS}" = 'win' ]; then
24+
find "${_DST}" \( -name '*.exe' -o -name '*.dll' \) -exec chmod a+x '{}' +
25+
fi
2426

2527
# First, merge this package into the unified package
2628
unipkg="${_UNIPKG}"

_sign-code.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
# shellcheck disable=SC3040,SC2039
77
set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o pipefail
88

9-
if [ -s "${SIGN_CODE_KEY}" ] && \
9+
# TODO: add support for code signing Unixy binaries
10+
# E.g. 'codesign' for mac.
11+
# Linux: https://stackoverflow.com/questions/1732927/signed-executables-under-linux
12+
if [ "${_OS}" = 'win' ] && \
13+
[ -s "${SIGN_CODE_KEY}" ] && \
1014
[ -n "${SIGN_CODE_KEY_PASS:+1}" ]; then
1115

1216
_ref="$1"

_ul.sh

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ sed 's/-built-on-[^.]*//g' hashes.txt | sort > hashes.txt.all
3636
touch -r hashes.txt hashes.txt.all
3737
mv -f hashes.txt.all hashes.txt
3838

39+
if [ "${_OS}" != 'win' ]; then
40+
exit 0
41+
fi
42+
3943
# Create an artifact that includes all packages
4044
_ALL="all-mingw-${CURL_VER_}${_REVSUFFIX}${_FLAV}.zip"
4145
{

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ environment:
4646
DOCKER_CONTENT_TRUST: '1'
4747
build_script:
4848
- sh: |
49-
export CW_CONFIG="${APPVEYOR_REPO_BRANCH}"
49+
export CW_CONFIG="${APPVEYOR_REPO_BRANCH}-win"
5050
. ./_versions.sh
5151
docker trust inspect --pretty "${DOCKER_IMAGE}"
5252
time docker pull "${DOCKER_IMAGE}"

curl-autotools.sh

+22-11
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ _VER="$1"
5151

5252
if [ "${CW_DEV_LLD_REPRODUCE:-}" = '1' ] && [ "${_LD}" = 'lld' ]; then
5353
if [ "${pass}" = 'shared' ]; then
54-
LDFLAGS="${LDFLAGS} -Wl,--reproduce=$(pwd)/$(basename "$0" .sh)-dll.tar"
54+
LDFLAGS="${LDFLAGS} -Wl,--reproduce=$(pwd)/$(basename "$0" .sh)-dyn.tar"
5555
else
56-
LDFLAGS="${LDFLAGS} -Wl,--reproduce=$(pwd)/$(basename "$0" .sh)-exe.tar"
56+
LDFLAGS="${LDFLAGS} -Wl,--reproduce=$(pwd)/$(basename "$0" .sh)-bin.tar"
5757
fi
5858
fi
5959

6060
if [ "${pass}" = 'static' ]; then
6161
LDFLAGS="${LDFLAGS} ${_LDFLAGS_BIN_GLOBAL}"
6262
fi
6363

64-
if [ ! "${_BRANCH#*unicode*}" = "${_BRANCH}" ]; then
64+
if [ "${_OS}" = 'win' ] && [ "${_BRANCH#*unicode*}" != "${_BRANCH}" ]; then
6565
CPPFLAGS="${CPPFLAGS} -Dmain=wmain" # FIXME: upstream. https://github.com/curl/curl/issues/7229
6666
CPPFLAGS="${CPPFLAGS} -DUNICODE -D_UNICODE"
6767
LDFLAGS="${LDFLAGS} -municode"
@@ -125,7 +125,9 @@ _VER="$1"
125125
options="${options} --without-zstd"
126126
fi
127127

128-
options="${options} --with-schannel"
128+
if [ "${_OS}" = 'win' ]; then
129+
options="${options} --with-schannel"
130+
fi
129131
CPPFLAGS="${CPPFLAGS} -DHAS_ALPN"
130132

131133
h3=0
@@ -142,7 +144,9 @@ _VER="$1"
142144
fi
143145
h3=1
144146
elif [ "${_OPENSSL}" = 'quictls' ] || [ "${_OPENSSL}" = 'libressl' ] || [ "${_OPENSSL}" = 'openssl' ]; then
145-
LIBS="${LIBS} -lbcrypt" # for auto-detection
147+
if [ "${_OS}" = 'win' ]; then
148+
LIBS="${LIBS} -lbcrypt" # for auto-detection
149+
fi
146150
[ "${_OPENSSL}" = 'openssl' ] || h3=1
147151
fi
148152
fi
@@ -180,11 +184,13 @@ _VER="$1"
180184
options="${options} --with-libssh2=${_TOP}/libssh2/${_PP}"
181185
options="${options} --without-wolfssh"
182186
options="${options} --without-libssh"
183-
LIBS="${LIBS} -lbcrypt" # for auto-detection
187+
if [ "${_OS}" = 'win' ]; then
188+
LIBS="${LIBS} -lbcrypt" # for auto-detection
184189

185-
# Workaround for libssh2 1.11.0 regression:
186-
# Omit __declspec(dllimport) with libssh2 1.11.0 to link statically
187-
[ "${LIBSSH2_VER_}" = '1.11.0' ] && CPPFLAGS="${CPPFLAGS} -DLIBSSH2_API="
190+
# Workaround for libssh2 1.11.0 regression:
191+
# Omit __declspec(dllimport) with libssh2 1.11.0 to link statically
192+
[ "${LIBSSH2_VER_}" = '1.11.0' ] && CPPFLAGS="${CPPFLAGS} -DLIBSSH2_API="
193+
fi
188194
else
189195
options="${options} --without-wolfssh"
190196
options="${options} --without-libssh"
@@ -217,7 +223,9 @@ _VER="$1"
217223
fi
218224
elif [ "${_BRANCH#*pico*}" = "${_BRANCH}" ]; then
219225
options="${options} --without-libidn2"
220-
options="${options} --with-winidn"
226+
if [ "${_OS}" = 'win' ]; then
227+
options="${options} --with-winidn"
228+
fi
221229
fi
222230

223231
if [ -d ../cares ]; then
@@ -273,6 +281,10 @@ _VER="$1"
273281
options="${options} --without-ngtcp2"
274282
fi
275283

284+
if [ "${_OS}" = 'win' ]; then
285+
options="${options} --enable-sspi"
286+
fi
287+
276288
options="${options} --without-quiche --without-msh3"
277289

278290
options="${options} --enable-websockets"
@@ -310,7 +322,6 @@ _VER="$1"
310322
--enable-libcurl-option \
311323
--enable-ipv6 \
312324
--enable-verbose \
313-
--enable-sspi \
314325
--enable-ntlm \
315326
--enable-cookies \
316327
--enable-http-auth \

curl-cmake.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _VER="$1"
3131
LDFLAGS_BIN="${_LDFLAGS_BIN_GLOBAL}"
3232
LDFLAGS_LIB=''
3333

34-
if [ ! "${_BRANCH#*unicode*}" = "${_BRANCH}" ]; then
34+
if [ "${_OS}" = 'win' ] && [ "${_BRANCH#*unicode*}" != "${_BRANCH}" ]; then
3535
options="${options} -DENABLE_UNICODE=ON"
3636
fi
3737

@@ -258,7 +258,9 @@ _VER="$1"
258258
fi
259259
elif [ "${_BRANCH#*pico*}" = "${_BRANCH}" ]; then
260260
options="${options} -DUSE_LIBIDN2=OFF"
261-
options="${options} -DUSE_WIN32_IDN=ON"
261+
if [ "${_OS}" = 'win' ]; then
262+
options="${options} -DUSE_WIN32_IDN=ON"
263+
fi
262264
fi
263265

264266
# Official method correctly enables the manual, but with the side-effect
@@ -268,8 +270,8 @@ _VER="$1"
268270
CPPFLAGS="${CPPFLAGS} -DUSE_MANUAL=1"
269271

270272
if [ "${CW_DEV_LLD_REPRODUCE:-}" = '1' ] && [ "${_LD}" = 'lld' ]; then
271-
LDFLAGS_BIN="${LDFLAGS_BIN} -Wl,--reproduce=$(pwd)/$(basename "$0" .sh)-exe.tar"
272-
LDFLAGS_LIB="${LDFLAGS_LIB} -Wl,--reproduce=$(pwd)/$(basename "$0" .sh)-dll.tar"
273+
LDFLAGS_BIN="${LDFLAGS_BIN} -Wl,--reproduce=$(pwd)/$(basename "$0" .sh)-bin.tar"
274+
LDFLAGS_LIB="${LDFLAGS_LIB} -Wl,--reproduce=$(pwd)/$(basename "$0" .sh)-dyn.tar"
273275
fi
274276

275277
# shellcheck disable=SC2086

0 commit comments

Comments
 (0)