Skip to content

Commit

Permalink
Merge pull request #70 from stunnel/feature/trurl
Browse files Browse the repository at this point in the history
compile trurl
  • Loading branch information
travislee89 authored Mar 1, 2024
2 parents f4f7d3b + 753cd3f commit 34cdb18
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 23 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
ZSTD_VERSION: ${{ vars.ZSTD_VERSION }}
LIBSSH2_VERSION: ${{ vars.LIBSSH2_VERSION }}
ARES_VERSION: ${{ vars.ARES_VERSION }}
ENABLE_TRURL: ${{ vars.ENABLE_TRURL }}
TRURL_VERSION: ${{ vars.TRURL_VERSION }}
LIBC: glibc
STATIC_LIBRARY: 1
CONTAINER_IMAGE: debian:latest
Expand All @@ -52,6 +54,8 @@ jobs:
ZSTD_VERSION=${ZSTD_VERSION}
LIBSSH2_VERSION=${LIBSSH2_VERSION}
ARES_VERSION=${ARES_VERSION}
ENABLE_TRURL=${ENABLE_TRURL}
TRURL_VERSION=${TRURL_VERSION}
LIBC=${LIBC}
STATIC_LIBRARY=${STATIC_LIBRARY}
CONTAINER_IMAGE=${CONTAINER_IMAGE}
Expand Down Expand Up @@ -107,6 +111,8 @@ jobs:
ZSTD_VERSION: ${{ vars.ZSTD_VERSION }}
LIBSSH2_VERSION: ${{ vars.LIBSSH2_VERSION }}
ARES_VERSION: ${{ vars.ARES_VERSION }}
ENABLE_TRURL: ${{ vars.ENABLE_TRURL }}
TRURL_VERSION: ${{ vars.TRURL_VERSION }}
LIBC: musl
CONTAINER_IMAGE: debian:latest
TOKEN_READ: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -127,6 +133,8 @@ jobs:
ZSTD_VERSION=${ZSTD_VERSION}
LIBSSH2_VERSION=${LIBSSH2_VERSION}
ARES_VERSION=${ARES_VERSION}
ENABLE_TRURL=${ENABLE_TRURL}
TRURL_VERSION=${TRURL_VERSION}
LIBC=${LIBC}
CONTAINER_IMAGE=${CONTAINER_IMAGE}
TOKEN_READ=${TOKEN_READ}
Expand Down Expand Up @@ -181,6 +189,8 @@ jobs:
ZSTD_VERSION: ${{ vars.ZSTD_VERSION }}
LIBSSH2_VERSION: ${{ vars.LIBSSH2_VERSION }}
ARES_VERSION: ${{ vars.ARES_VERSION }}
ENABLE_TRURL: ${{ vars.ENABLE_TRURL }}
TRURL_VERSION: ${{ vars.TRURL_VERSION }}
CONTAINER_IMAGE: mstorsjo/llvm-mingw:latest
TOKEN_READ: ${{ secrets.GITHUB_TOKEN }}
ARCHES: "x86_64 aarch64 armv7 i686"
Expand All @@ -200,6 +210,8 @@ jobs:
ZSTD_VERSION=${ZSTD_VERSION}
LIBSSH2_VERSION=${LIBSSH2_VERSION}
ARES_VERSION=${ARES_VERSION}
ENABLE_TRURL=${ENABLE_TRURL}
TRURL_VERSION=${TRURL_VERSION}
CONTAINER_IMAGE=${CONTAINER_IMAGE}
TOKEN_READ=${TOKEN_READ}
sh curl-static-win.sh
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Simply execute it to compile the most recent version.
- [libidn2](https://github.com/libidn/libidn2)
- [c-ares](https://c-ares.haxx.se)
- [libpsl](https://rockdaboot.github.io/libpsl/)
- [trurl](https://curl.se/trurl/)

`curl -V`
- Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Expand All @@ -36,6 +37,7 @@ The binary is built with GitHub Actions.
- `curl-linux-ARCH-dev-VERSION`: binaries, headers and static library archives for Linux, for development
- `curl-linux-ARCH-musl-VERSION`: binaries for Linux, linked with `musl`
- `curl-macOS-ARCH-VERSION`: binaries for macOS
- `curl-macOS-ARCH-dev-VERSION`: binaries, headers and static library archives for macOS, for development
- `curl-windows-ARCH-VERSION`: binaries for Windows
- `curl-windows-ARCH-dev-VERSION`: binaries, headers and library archives for Windows, for development

Expand Down Expand Up @@ -90,6 +92,8 @@ script will create a container and compile the host architecture cURL only.
-e LIBIDN2_VERSION="" \
-e LIBPSL_VERSION="" \
-e ARES_VERSION="" \
-e ENABLE_TRURL="true" \
-e TRURL_VERSION="" \
debian:latest sh curl-static-cross.sh
```

Expand Down Expand Up @@ -140,6 +144,8 @@ ARCHES="x86_64 arm64" \
-e LIBIDN2_VERSION="" \
-e LIBPSL_VERSION="" \
-e ARES_VERSION="" \
-e ENABLE_TRURL="true" \
-e TRURL_VERSION="" \
mstorsjo/llvm-mingw:latest sh curl-static-win.sh
```

Expand All @@ -164,10 +170,8 @@ For all `VERSION` variables, leaving them blank will automatically fetch the lat
- `BROTLI_VERSION`: The version of brotli.
- `ZSTD_VERSION`: The version of zstd.
- `ARES_VERSION`: The version of c-ares.
- `TRURL_VERSION`: The version of trurl.
- `ENABLE_TRURL`: Compile trurl. Default is `false`, set to `true` or `yes` to enable it. NOT available for macOS.
- `ENABLE_DEBUG`: Enable curl debug. Default is `false`, set to `true` or `yes` to enable it.

The compiled files will be saved in the current `release` directory.

## Why build cURL on my own?

Because I need to test HTTP3, but currently there is no Linux distribution's cURL that supports HTTP3.
44 changes: 39 additions & 5 deletions curl-static-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# -e BROTLI_VERSION="" \
# -e ZSTD_VERSION="" \
# -e LIBSSH2_VERSION="" \
# -e ENABLE_TRURL="" \
# -e TRURL_VERSION="" \
# -e LIBC="" \
# -e STATIC_LIBRARY=1 \
# -e CONTAINER_IMAGE=debian:latest \
Expand Down Expand Up @@ -66,6 +68,7 @@ init_env() {
echo "zstd version: ${ZSTD_VERSION}"
echo "libssh2 version: ${LIBSSH2_VERSION}"
echo "c-ares version: ${ARES_VERSION}"
echo "trurl version: ${TRURL_VERSION}"

export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PREFIX}/lib64/pkgconfig";

Expand Down Expand Up @@ -669,8 +672,32 @@ compile_zstd() {
-DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_SHARED=OFF ..;
cmake --build . --config Release --target install;

if [ ! -f "${PREFIX}/lib/libzstd.a" ]; then cp -f lib/libzstd.a "${PREFIX}/lib/libzstd.a"; fi
_copy_license ../../../LICENSE zstd
if [ ! -f "${PREFIX}/lib/libzstd.a" ]; then cp -f lib/libzstd.a "${PREFIX}/lib/libzstd.a"; fi
}

compile_trurl() {
case "${ENABLE_TRURL}" in
true|1|yes|on|y|Y)
echo ;;
*)
return ;;
esac

echo "Compiling trurl, Arch: ${ARCH}" | tee "${RELEASE_DIR}/running"
local url
change_dir;

url_from_github curl/trurl "${TRURL_VERSION}"
url="${URL}"
download_and_extract "${url}"

export PATH=${PREFIX}/bin:$PATH

LDFLAGS="-static -Wl,-s ${LDFLAGS}" make PREFIX="${PREFIX}";
make install;

_copy_license LICENSES/curl.txt trurl;
}

curl_config() {
Expand Down Expand Up @@ -753,17 +780,21 @@ compile_curl() {
install_curl() {
mkdir -p "${RELEASE_DIR}/release/bin/"

ls -l src/curl
cp -pf src/curl "${RELEASE_DIR}/release/bin/curl-linux-${ARCH}${libc_flag}"
ls -l "${PREFIX}/bin/curl";
cp -pf "${PREFIX}/bin/curl" "${RELEASE_DIR}/release/bin/curl-linux-${ARCH}${libc_flag}";
if [ -f "${PREFIX}/bin/trurl" ]; then
ls -l "${PREFIX}/bin/trurl";
cp -pf "${PREFIX}/bin/trurl" "${RELEASE_DIR}/release/bin/trurl-linux-${ARCH}${libc_flag}";
fi

if [ ! -f "${RELEASE_DIR}/release/version.txt" ]; then
echo "${CURL_VERSION}" > "${RELEASE_DIR}/release/version.txt"
fi
if [ ! -f "${RELEASE_DIR}/release/version-info.txt" ]; then
src/curl -V >> "${RELEASE_DIR}/release/version-info.txt"
"${PREFIX}"/bin/curl -V >> "${RELEASE_DIR}/release/version-info.txt"
fi

if [ -z "${STATIC_LIBRARY}" ]; then
if [ -n "${STATIC_LIBRARY}" ]; then
XZ_OPT=-9 tar -Jcf "${RELEASE_DIR}/release/curl-linux-${ARCH}-dev-${CURL_VERSION}.tar.xz" -C "${DIR}" "curl-${ARCH}"
fi
}
Expand Down Expand Up @@ -833,6 +864,8 @@ _build_in_docker() {
-e LIBSSH2_VERSION="${LIBSSH2_VERSION}" \
-e LIBUNISTRING_VERSION="${LIBUNISTRING_VERSION}" \
-e LIBIDN2_VERSION="${LIBIDN2_VERSION}" \
-e ENABLE_TRURL="${ENABLE_TRURL}" \
-e TRURL_VERSION="${TRURL_VERSION}" \
-e LIBC="${LIBC}" \
-e STATIC_LIBRARY="${STATIC_LIBRARY}" \
"${container_image}" sh "${RELEASE_DIR}/${base_name}" 2>&1 | tee -a "${container_name}.log"
Expand All @@ -858,6 +891,7 @@ compile() {
compile_nghttp2;
compile_brotli;
compile_curl;
compile_trurl;

install_curl;
}
Expand Down
43 changes: 37 additions & 6 deletions curl-static-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ change_dir() {
cd "${DIR}";
}

_copy_license() {
# $1: original file name; $2: target file name
mkdir -p "${PREFIX}/licenses/";
cp -p "${1}" "${PREFIX}/licenses/${2}";
}

compile_zlib() {
echo "Compiling zlib, Arch: ${ARCH}" | tee "${RELEASE_DIR}/running"
local url
Expand All @@ -255,6 +261,8 @@ compile_zlib() {
./configure --prefix="${PREFIX}" --static;
make -j "${CPU_CORES}";
make install;

_copy_license LICENSE zlib;
}

compile_libunistring() {
Expand All @@ -269,6 +277,8 @@ compile_libunistring() {
./configure --host="${TARGET}" --prefix="${PREFIX}" --disable-rpath --disable-shared;
make -j "${CPU_CORES}";
make install;

_copy_license COPYING libunistring;
}

compile_libidn2() {
Expand All @@ -288,6 +298,8 @@ compile_libidn2() {
--disable-shared;
make -j "${CPU_CORES}";
make install;

_copy_license COPYING libidn2;
}

compile_libpsl() {
Expand All @@ -305,6 +317,8 @@ compile_libpsl() {
--enable-static --enable-shared=no --enable-builtin --disable-runtime;
make -j "${CPU_CORES}";
make install;

_copy_license LICENSE libpsl;
}

compile_ares() {
Expand All @@ -319,6 +333,8 @@ compile_ares() {
./configure --host="${TARGET}" --prefix="${PREFIX}" --enable-static --disable-shared;
make -j "$(nproc)";
make install;

_copy_license LICENSE.md c-ares;
}

compile_tls() {
Expand Down Expand Up @@ -349,6 +365,8 @@ compile_tls() {

make -j "${CPU_CORES}";
make install_sw;

_copy_license LICENSE.txt openssl;
}

compile_libssh2() {
Expand All @@ -368,6 +386,8 @@ compile_libssh2() {
--with-crypto=openssl --with-libssl-prefix="${PREFIX}";
make -j "${CPU_CORES}";
make install;

_copy_license COPYING libssh2;
}

compile_nghttp2() {
Expand All @@ -385,6 +405,8 @@ compile_nghttp2() {
--enable-lib-only --enable-shared=no;
make -j "${CPU_CORES}";
make install;

_copy_license COPYING nghttp2;
}

compile_ngtcp2() {
Expand All @@ -408,6 +430,8 @@ compile_ngtcp2() {
make install;
cp -a crypto/includes/ngtcp2/ngtcp2_crypto_quictls.h crypto/includes/ngtcp2/ngtcp2_crypto.h \
"${PREFIX}/include/ngtcp2/"

_copy_license COPYING ngtcp2;
}

compile_nghttp3() {
Expand All @@ -425,6 +449,8 @@ compile_nghttp3() {
--enable-lib-only --disable-dependency-tracking;
make -j "${CPU_CORES}";
make install;

_copy_license COPYING nghttp3;
}

compile_brotli() {
Expand All @@ -445,6 +471,7 @@ compile_brotli() {
PKG_CONFIG="pkg-config --static" \
cmake --build . --config Release --target install;

_copy_license ../LICENSE brotli;
cd "${PREFIX}/lib/"
if [ -f libbrotlidec-static.a ] && [ ! -f libbrotlidec.a ]; then ln -f libbrotlidec-static.a libbrotlidec.a; fi
if [ -f libbrotlienc-static.a ] && [ ! -f libbrotlienc.a ]; then ln -f libbrotlienc-static.a libbrotlienc.a; fi
Expand All @@ -463,6 +490,8 @@ compile_zstd() {
PKG_CONFIG="pkg-config --static" \
make -j "${CPU_CORES}" PREFIX="${PREFIX}";
make install;

_copy_license LICENSE zstd
}

curl_config() {
Expand Down Expand Up @@ -541,22 +570,24 @@ compile_curl() {
CFLAGS="-I${PREFIX}/include -I${PREFIX}/include/brotli" \
CPPFLAGS="-I${PREFIX}/include -I${PREFIX}/include/brotli" \
make -j "${CPU_CORES}";

_copy_license COPYING curl;
make install;
}

install_curl() {
mkdir -p "${RELEASE_DIR}/release/bin/"

ls -l src/curl
file src/curl
otool -L src/curl
sha256sum src/curl
src/curl -V || true
ls -l "${PREFIX}"/bin/curl;
cp -pf "${PREFIX}/bin/curl" "${RELEASE_DIR}/release/bin/curl-macos-${ARCH}";

cp -f src/curl "${RELEASE_DIR}/release/bin/curl-macos-${ARCH}"
${PREFIX}/bin/curl -V || true

if [ ! -f "${RELEASE_DIR}/version.txt" ]; then
echo "${CURL_VERSION}" > "${RELEASE_DIR}/version.txt"
fi

XZ_OPT=-9 tar -Jcf "${RELEASE_DIR}/release/curl-macos-${ARCH}-dev-${CURL_VERSION}.tar.xz" -C "${DIR}" "curl-${ARCH}"
}

_arch_match() {
Expand Down
Loading

0 comments on commit 34cdb18

Please sign in to comment.