Skip to content

Commit

Permalink
add unified, single-file distro package [ci skip]
Browse files Browse the repository at this point in the history
Single-file per target (win64, win32) curl-for-win binaries. The files
contain curl.exe, curl DLL + implib, docs and C headers + static libs
for curl and all of its dependencies, along with LICENSE/NEWS text files
for each dependency (also some extra docs for libssh2.)

These two files are included in the all-mingw*.zip package, and also
downloadable as an artifact from the CI page. The idea is that this
replaces the per-dependency packages in which curl components were
historically distributed in curl-for-win. This makes everything simpler,
especially for those who are looking for the static libs. Now they are
in one downloadable file instead of a bunch (8-10) of them. The new
files are named 'curl-uni-*', mainly to not collide with the single-file
curl package. Old-style packages will be discontinued, at which point
'curl-uni-*' will likely be renamed to simply 'curl-*'.

There is also some space/download-size savings with the unified packages.

This is in addition to size savings introduced recently by dropping
unused DLLs and EXEs, and enabling -O3 optimization for all dependencies.
This counteracts the slight size increase caused by HTTP/3 (aka QUIC)
support, introduced earlier today.

This will also need some updates on the server-side for publishing and
and a small update for the https://curl.se/windows/ page and scripts, by
deleting the individual dependency download links.
  • Loading branch information
vszakats committed May 21, 2022
1 parent af95d49 commit 3182733
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 18 deletions.
16 changes: 15 additions & 1 deletion _build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o p
# - Drop brotli support?
# - Use Universal CRT?
# - Switch to LibreSSL or rustls or Schannel?
# - Move all lib and header dependencies into the curl distro package?
# - delete gcc logic

# Tools:
Expand Down Expand Up @@ -87,6 +86,8 @@ elif [ "${_BRANCH#*micro*}" != "${_BRANCH}" ]; then
_FLAV='-micro'
elif [ "${_BRANCH#*mini*}" != "${_BRANCH}" ]; then
_FLAV='-mini'
elif [ "${_BRANCH#*quic*}" != "${_BRANCH}" ]; then
_FLAV='-quic'
fi

# For 'configure'-based builds.
Expand Down Expand Up @@ -257,6 +258,10 @@ build_single_target() {
echo ".gcc-mingw-w64-${_machine} $("${_CCPREFIX}gcc" -dumpversion)" >> "${_BLD}"
echo ".binutils-mingw-w64-${_machine} $("${_CCPREFIX}ar" V | grep -o -a -E '[0-9]+\.[0-9]+(\.[0-9]+)?')" >> "${_BLD}"

# Unified, per-target package: Initialize
export _UNIPKG="curl-uni-${CURL_VER_}${_REVSUFFIX}${_PKGSUFFIX}${_FLAV}"
rm -r -f "${_UNIPKG:?}"

time ./zlib.sh "${ZLIB_VER_}"
time ./brotli.sh "${BROTLI_VER_}"
time ./libgsasl.sh "${LIBGSASL_VER_}"
Expand All @@ -269,6 +274,15 @@ build_single_target() {
time ./ngtcp2.sh "${NGTCP2_VER_}"
time ./libssh2.sh "${LIBSSH2_VER_}"
time ./curl.sh "${CURL_VER_}"

# Unified, per-target package: Build
export _NAM="${_UNIPKG}"
export _VER="${CURL_VER_}"
export _OUT="${_UNIPKG}"
export _BAS="${_UNIPKG}"
export _DST="${_UNIPKG}"

./_pkg.sh "${_DST}/CHANGES.txt"
}

# Build binaries
Expand Down
67 changes: 50 additions & 17 deletions _pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,62 @@ fi

_cdo="$(pwd)"

_fn="${_DST}/BUILD-README.txt"
cat <<EOF > "${_fn}"
if [ "${_NAM}" != "${_UNIPKG}" ]; then
# First, merge this package into the unified package
unipkg="${_UNIPKG}"
{
[ -d "${_DST}/bin" ] && rsync --archive --update "${_DST}/bin" "${unipkg}"
[ -d "${_DST}/include" ] && rsync --archive --update "${_DST}/include" "${unipkg}"
[ "${_NAM}" = 'libssh2' ] && rsync --archive --update "${_DST}/docs" "${unipkg}/more/${_NAM}"
if [ -d "${_DST}/lib64" ]; then # openssl
rsync --archive --update "${_DST}/lib64/" "${unipkg}/lib/"
else
rsync --archive --update "${_DST}/lib" "${unipkg}"
fi
if [ "${_NAM}" = 'curl' ]; then
find "${_DST}" -maxdepth 1 -type f -name '*.*' -a -not -name 'COPYING-*.*' | while read -r f; do
cp -f -p "${f}" "${unipkg}"
done
rsync --archive --update "${_DST}/docs" "${unipkg}"
else
_NAM_MORE="${unipkg}/more/$(printf '%s' "${_NAM}" | tr '_' '-')"
mkdir -p "${_NAM_MORE}"
cp -f -p "${_DST}"/*.* "${_NAM_MORE}"
fi
}

_fn="${_DST}/BUILD-README.txt"
cat <<EOF > "${_fn}"
Visit the project page for details about these builds and the list of changes:
${_URL}
${_URL}
EOF
touch -c -r "$1" "${_fn}"
touch -c -r "$1" "${_fn}"
[ "${_NAM}" = 'curl' ] && cp -f -p "${_fn}" "${unipkg}"

_fn="${_DST}/BUILD-HOMEPAGE.url"
cat <<EOF > "${_fn}"
_fn="${_DST}/BUILD-HOMEPAGE.url"
cat <<EOF > "${_fn}"
[InternetShortcut]
URL=${_URL}
EOF
unix2dos --quiet --keepdate "${_fn}"
touch -c -r "$1" "${_fn}"

find "${_DST}" -depth -type d -exec touch -c -r "$1" '{}' +
# NOTE: Not effective on MSYS2:
find "${_DST}" -name '*.a' -exec chmod a-x '{}' +
find "${_DST}" \( -name '*.exe' -o -name '*.dll' \) -exec chmod a+x '{}' +
unix2dos --quiet --keepdate "${_fn}"
touch -c -r "$1" "${_fn}"
[ "${_NAM}" = 'curl' ] && cp -f -p "${_fn}" "${unipkg}"

find "${_DST}" -depth -type d -exec touch -c -r "$1" '{}' +
# NOTE: Not effective on MSYS2:
find "${_DST}" -name '*.a' -exec chmod a-x '{}' +
find "${_DST}" \( -name '*.exe' -o -name '*.dll' \) -exec chmod a+x '{}' +
fi

create_pkg() {
arch_ext="$2"

_suf="${_FLAV}"
if [ "${_NAM}" != "${_UNIPKG}" ]; then
_suf="${_FLAV}"
else
_suf='' # _FLAV already added, do not add it a second time
fi
# Alter filename for non-release packages
if [ "${_BRANCH#*main*}" != "${_BRANCH}" ]; then
if [ "${PUBLISH_PROD_FROM}" != "${_OS}" ]; then
Expand Down Expand Up @@ -131,9 +162,11 @@ EOF
create_pkg "$1" '.tar.xz'
create_pkg "$1" '.zip'

ver="${_NAM} ${_VER}"
if ! grep -q -a -F "${ver}" -- "${_BLD}"; then
echo "${ver}" >> "${_BLD}"
if [ "${_NAM}" != "${_UNIPKG}" ]; then
ver="${_NAM} ${_VER}"
if ! grep -q -a -F "${ver}" -- "${_BLD}"; then
echo "${ver}" >> "${_BLD}"
fi
fi

rm -r -f "${_DST:?}"

0 comments on commit 3182733

Please sign in to comment.