Skip to content

Instantly share code, notes, and snippets.

@roblav96
Last active September 4, 2022 12:12
Show Gist options
  • Save roblav96/81341724b49fd05991aa84e4e58f0a28 to your computer and use it in GitHub Desktop.
Save roblav96/81341724b49fd05991aa84e4e58f0a28 to your computer and use it in GitHub Desktop.
#!/usr/bin/env just --justfile
# https://github.com/casey/just
set shell := ["bash", "-uc"]
_default :
@just --dump
# export PKG_CONFIG_PATH := if os() == "macos" {
# nghttp2_libexec + "/lib/pkgconfig:\
# " + `brew --prefix libressl` + "/lib/pkgconfig:\
# " + `brew --prefix libxml2` + "/lib/pkgconfig:\
# " + `brew --prefix libxslt` + "/lib/pkgconfig:\
# " + `brew --prefix zlib` + "/lib/pkgconfig"
# } else {
# nghttp2_libexec + "/lib/pkgconfig"
# }
# cwd := justfile_directory()
export HOMEBREW_COLOR := "1"
# export HOMEBREW_VERBOSE := "1"
export LDFLAGS := "-Wl,-rpath," + openssl_prefix + "/lib"
export OPENSSL_ROOT_DIR := openssl_prefix
# export MAKEFLAGS := "-j" + `nproc`
# export PKG_CONFIG_PATH := openssl_prefix + "/lib/pkgconfig:" + libnghttp2_prefix + "/lib/pkgconfig"
export PKG_CONFIG_PATH := "\
" + openssl_prefix + "/lib/pkgconfig:\
" + libnghttp2_prefix + "/lib/pkgconfig:\
" + wslay_prefix + "/lib/pkgconfig"
# export PKG_CONFIG_PATH := nghttp2_libexec + "/lib/pkgconfig:\
# " + `brew --prefix jemalloc` + "/lib/pkgconfig:\
# " + `brew --prefix libxml2` + "/lib/pkgconfig:\
# " + `brew --prefix libxslt` + "/lib/pkgconfig:\
# " + `brew --prefix zlib` + "/lib/pkgconfig"
# /usr/local/opt/libressl/lib/pkgconfig:\
# /usr/local/opt/libxslt/lib/pkgconfig"
# export PKG_CONFIG_LIBDIR := "\
# /usr/lib/pkgconfig:\
# /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.15"
# /usr/local/opt/ruby/bin:\
# /usr/local/lib/ruby/gems/3.0.0/bin:\
# /Library/Developer/CommandLineTools/usr/bin:\
# "+brew_prefix+"/opt/ccache/libexec:\
# export PATH := "\
# "+`echo ${PATH%':.'}`
# export SDKROOT := if os() == "macos" { `xcrun --sdk macosx --show-sdk-path` } else { "" }
# export ACLOCAL_PATH := "/usr/local/share/aclocal"
# export OPENSSL_ROOT_DIR := cwd+"/openssl/build"
# export OPENSSL_LOCAL_CONFIG_DIR := "/usr/local/etc/[email protected]"
# export PATH := "/usr/local/opt/ccache/libexec:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
# export PATH := "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
# export PATH := "/usr/local/opt/ccache/libexec:"+`echo $PATH`
# export PATH := "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:."
make := if os() == "macos" { "bear -- make" } else { "make" }
cmake := if os() == "macos" { "cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=on" } else { "cmake" }
export CC := if os() == "macos" { "clang" } else { "gcc" }
export CXX := if os() == "macos" { "clang++" } else { "g++" }
# export LD_LIBRARY_PATH := if os() == "macos" { "" } else { openssl_prefix + "/lib" }
# export JEMALLOC_CFLAGS := "-I" + `realpath "$(brew --prefix jemalloc)"` + "/include"
# export JEMALLOC_LIBS := "-L" + `realpath "$(brew --prefix jemalloc)"` + "/lib -ljemalloc"
# export OPENSSL_ROOT_DIR := brp_openssl
# export OPENSSL_ROOT_DIR := "/usr/local"
# export CPPFLAGS := "-fsanitize=address,undefined -fno-sanitize-recover=undefined -g"
# export LDFLAGS := "-fsanitize=address,undefined -fno-sanitize-recover=undefined -Wl,-rpath,"+cwd+"/openssl/build/lib"
# export LD := "/usr/local/opt/llvm/bin/ld64.lld"
# export M4 := "/Library/Developer/CommandLineTools/usr/bin/m4"
# export CC := "cc"
# export CFLAGS := "-g -arch x86_64"
# export LDFLAGS := "-arch x86_64 -Wl,-rpath,"+cwd+"/openssl/build/lib"
# export CXX := "c++"
# export CPPFLAGS := "-g -arch x86_64"
# export CXXFLAGS := "-g -arch x86_64"
# export OBJC := "cc"
# export OBJCFLAGS := "-g -arch x86_64"
_debug :
@echo
declare | bat -pp -lini
@echo
echo $0
@echo
echo ${PATH} | sed "s#:#\n#g"
@echo
echo ${PKG_CONFIG_PATH} | sed "s#:#\n#g"
@echo
-echo ${CC} && ${CC} --version
@echo
-echo ${CXX} && ${CXX} --version
@echo
# make_install := if os() == "macos" { "make" } else { "sudo make" }
# openssl_prefix := if os() == "macos" { `realpath $(brew --prefix [email protected])` } else { "/usr/local" }
# export LDFLAGS := "-Wl,-rpath,"+openssl_prefix+"/lib"
# build :
# just reset openssl nghttp3 ngtcp2 nghttp2 h2o curl
reset :
rm -rf openssl nghttp3 ngtcp2 libnghttp2 nghttp2 h2o curl
openssl_dir := if os() == "macos" { `brew --prefix` + "/etc/[email protected]" } else { "/etc/ssl" }
openssl_prefix := `realpath $(brew --prefix [email protected])`
openssl :
brew reinstall --force-bottle --formula [email protected]
-find {{openssl_prefix}}/bin -type f -exec chmod -c u+w '{}' \;
-find {{openssl_prefix}}/lib -type f -exec chmod -c u+w '{}' \;
rm -rf openssl
git clone --depth 1 -b OpenSSL_1_1_1l+quic https://github.com/quictls/openssl && cd openssl \
&& unset LDFLAGS \
&& ./config --prefix={{openssl_prefix}} --openssldir={{openssl_dir}} \
&& {{make}} -j$(nproc) \
&& make install_sw
-find {{openssl_prefix}}/bin -type f -exec chmod -c 555 '{}' \;
-find {{openssl_prefix}}/lib -type f -exec chmod -c 444 '{}' \;
-test "{{os()}}" != "macos" && brew unlink [email protected] && brew link [email protected]
brew postinstall [email protected]
env {{openssl_prefix}}/bin/openssl version -a
# && perl configdata.pm --dump
nghttp2_extra_autotools_opts := if os() == "macos" { "--with-systemd=no" } else { "--with-libbpf=no" }
libnghttp2_prefix := `realpath $(brew --prefix libnghttp2)`
libnghttp2 :
brew reinstall --force-bottle --formula libnghttp2
-find {{libnghttp2_prefix}}/bin -type f -exec chmod -c u+w '{}' \;
-find {{libnghttp2_prefix}}/lib -type f -exec chmod -c u+w '{}' \;
rm -rf nghttp3
git clone https://github.com/ngtcp2/nghttp3 && cd nghttp3 \
&& autoreconf -i \
&& ./configure --prefix={{libnghttp2_prefix}} --enable-lib-only \
&& {{make}} -j$(nproc) \
&& make install
rm -rf ngtcp2
git clone https://github.com/ngtcp2/ngtcp2 && cd ngtcp2 \
&& autoreconf -i \
&& ./configure --prefix={{libnghttp2_prefix}} --enable-lib-only --with-openssl \
&& {{make}} -j$(nproc) \
&& make install
rm -rf libnghttp2
git clone --recurse-submodules https://github.com/nghttp2/nghttp2 libnghttp2 && cd libnghttp2 \
&& autoreconf -i \
&& ./configure --prefix={{libnghttp2_prefix}} \
--disable-examples --disable-hpack-tools --disable-python-bindings \
--with-mruby --with-neverbleed --enable-http3 --enable-lib-only {{nghttp2_extra_autotools_opts}} \
&& make -C lib \
&& make -C lib install
-find {{libnghttp2_prefix}}/bin -type f -exec chmod -c 555 '{}' \;
-find {{libnghttp2_prefix}}/lib -type f -exec chmod -c 444 '{}' \;
brew unlink libnghttp2 && brew link libnghttp2
brew postinstall libnghttp2
# && ln -v -sf -t {{libnghttp2_prefix}} {{libnghttp2_prefix}}/share/doc/nghttp2/README.rst \
# cmake -DCMAKE_INSTALL_PREFIX=$PWD/build -DENABLE_EXAMPLES=0 -DENABLE_HPACK_TOOLS=0 -DENABLE_PYTHON_BINDINGS=0 -DWITH_MRUBY=0 -DWITH_NEVERBLEED=1 -DENABLE_HTTP3=1 -DENABLE_APP=1 . && \
nghttp2_prefix := `realpath $(brew --prefix nghttp2)`
nghttp2 :
brew reinstall --force-bottle --formula nghttp2
-find {{nghttp2_prefix}}/bin -type f -exec chmod -c u+w '{}' \;
-find {{nghttp2_prefix}}/lib -type f -exec chmod -c u+w '{}' \;
rm -rf nghttp2
git clone --recurse-submodules https://github.com/nghttp2/nghttp2 && cd nghttp2 \
&& autoreconf -i \
&& ./configure --prefix={{nghttp2_prefix}} \
--disable-examples --disable-hpack-tools --disable-python-bindings \
--with-mruby --with-neverbleed --enable-http3 --enable-app {{nghttp2_extra_autotools_opts}} \
&& {{make}} \
&& make html \
&& make install \
&& ln -srf -t {{nghttp2_prefix}} {{nghttp2_prefix}}/share/doc/nghttp2/README.rst \
&& cp -rf -t {{nghttp2_prefix}}/share/doc/nghttp2 doc
rm -rf {{nghttp2_prefix}}/{include,lib}
-find {{nghttp2_prefix}}/bin -type f -exec chmod -c 555 '{}' \;
-find {{nghttp2_prefix}}/lib -type f -exec chmod -c 444 '{}' \;
brew unlink nghttp2 && brew link nghttp2
brew postinstall nghttp2
env {{nghttp2_prefix}}/bin/nghttpx --version
rm -rf libnghttp2
wslay_prefix := `realpath $(brew --prefix wslay)`
h2o_prefix := `realpath $(brew --prefix h2o)`
h2o :
brew reinstall --force-bottle --formula h2o
-find {{h2o_prefix}}/bin -type f -exec chmod -c u+w '{}' \;
-find {{h2o_prefix}}/lib -type f -exec chmod -c u+w '{}' \;
rm -rf h2o
git clone --recurse-submodules https://github.com/h2o/h2o && cd h2o \
&& {{cmake}} -DCMAKE_INSTALL_PREFIX={{h2o_prefix}} \
-DWITH_MRUBY=off -DWITH_DTRACE=off -DWITH_H2OLOG=off . \
&& make \
&& make doc \
&& make install
-find {{h2o_prefix}}/bin -type f -exec chmod -c 555 '{}' \;
-find {{h2o_prefix}}/lib -type f -exec chmod -c 444 '{}' \;
brew unlink h2o && brew link h2o
brew postinstall h2o
env {{h2o_prefix}}/bin/h2o --version
curl_prefix := `realpath $(brew --prefix curl)`
curl :
brew reinstall --force-bottle --formula curl
-find {{curl_prefix}}/bin -type f -exec chmod -c u+w '{}' \;
-find {{curl_prefix}}/lib -type f -exec chmod -c u+w '{}' \;
rm -rf curl
git clone https://github.com/curl/curl && cd curl \
&& autoreconf -i \
&& ./configure --prefix={{curl_prefix}} \
--with-openssl={{openssl_prefix}} --with-nghttp3={{libnghttp2_prefix}} --with-ngtcp2={{libnghttp2_prefix}} \
&& {{make}} \
&& make install
-find {{curl_prefix}}/bin -type f -exec chmod -c 555 '{}' \;
-find {{curl_prefix}}/lib -type f -exec chmod -c 444 '{}' \;
-test "{{os()}}" != "macos" && brew unlink curl && brew link curl
brew postinstall curl
env {{curl_prefix}}/bin/curl --version
.*env*
/boringssl/
/curl/
/h2o/
/haproxy/
/libnghttp2/
/nghttp2/
/nghttp3/
/nginx/
/ngtcp2/
/openssl/
/quictls/
/wslay/
#!/usr/bin/env just --justfile
# https://github.com/casey/just
set dotenv-load
set shell := ["bash", "-uc"]
_default:
@just --dump
epoch := `date '+%s'`
prefix := `brew --prefix`
cellar := `brew --cellar`
make := if os() == "macos" { "bear -- make" } else { "make" }
cmake := if os() == "macos" { "cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" } else { "cmake" }
export CC := if os() == "macos" { "clang" } else { "gcc" }
export CXX := if os() == "macos" { "clang++" } else { "g++" }
export ACLOCAL_PATH := if os() == "macos" { "/usr/local/share/aclocal" } else { "/usr/share/aclocal" }
# export LIBEV_CFLAGS := "-I" + `realpath "$(brew --prefix libev)"` + "/include"
# export LIBEV_LIBS := "-L" + `realpath "$(brew --prefix libev)"` + "/lib -lev"
# export JEMALLOC_CFLAGS := "-I" + `realpath "$(brew --prefix jemalloc)"` + "/include"
# export JEMALLOC_LIBS := "-L" + `realpath "$(brew --prefix jemalloc)"` + "/lib -ljemalloc"
# export SDKROOT := if os() == "macos" { `xcrun --sdk macosx --show-sdk-path` } else { "" }
export HOMEBREW_VERBOSE := "1"
export OPENSSL_ROOT_DIR := quictls_prefix
export RUBY_CONFIGURE_OPTS := "--with-openssl-dir=" + quictls_opt_prefix
export LDFLAGS := "-Wl,-rpath," + quictls_prefix + "/lib"
export PKG_CONFIG_PATH := "\
" + quictls_prefix + "/lib/pkgconfig:\
" + nghttp2_prefix + "/lib/pkgconfig:\
" + h2o_prefix + "/lib/pkgconfig"
_debug:
@echo
declare | bat -pp -lini
@echo
echo $0
@echo
echo ${PATH} | sed "s#:#\n#g"
@echo
echo ${PKG_CONFIG_PATH} | sed "s#:#\n#g"
@echo
-echo ${CC} && ${CC} --version
@echo
-echo ${CXX} && ${CXX} --version
@echo
reset:
find . -mindepth 1 -maxdepth 1 -type d -not -path ./.git -print -exec rm -rf '{}' \;
quictls_prefix := cellar + "/[email protected]/HEAD-" + `curl -s -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/quictls/openssl/branches/OpenSSL_1_1_1q+quic | jq -r '.commit.sha' | head -c8`
quictls_opt_prefix := prefix + "/opt/[email protected]"
quictls:
-brew uninstall --force --ignore-dependencies --formula [email protected]
rm -rf quictls
git clone --depth 1 --branch OpenSSL_1_1_1q+quic https://github.com/quictls/openssl quictls && cd quictls \
&& ./config --prefix="{{quictls_prefix}}" \
--openssldir="{{prefix + "/etc/[email protected]"}}" \
&& {{make}} -j$(nproc) \
&& make install_sw
ln -srf {{quictls_prefix}} {{quictls_opt_prefix}}
env {{quictls_prefix}}/bin/openssl version -a | bat -lyml
boringssl_prefix := cellar + "/boringssl/HEAD-" + epoch
boringssl_opt_prefix := prefix + "/opt/boringssl"
boringssl:
-brew uninstall --force --ignore-dependencies --formula boringssl
rm -rf boringssl
git clone https://boringssl.googlesource.com/boringssl boringssl && cd boringssl \
&& {{cmake}} -DCMAKE_INSTALL_PREFIX={{boringssl_prefix}} \
-DCMAKE_BUILD_TYPE=Release -GNinja . \
&& ninja \
&& ninja install
ln -srf {{boringssl_prefix}} {{boringssl_opt_prefix}}
env {{boringssl_prefix}}/bin/bssl | bat -lyml
nghttp2_prefix := cellar + "/nghttp2/HEAD-" + `curl -s -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/nghttp2/nghttp2/branches/$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/nghttp2/nghttp2 | jq -r '.default_branch') | jq -r '.commit.sha' | head -c8`
nghttp2_options := if os() == "macos" { "--with-systemd=no" } else { "--with-libbpf=no --with-neverbleed" }
nghttp2:
-brew uninstall --force --ignore-dependencies --formula nghttp2
rm -rf nghttp3
git clone https://github.com/ngtcp2/nghttp3 && cd nghttp3 \
&& autoreconf -i \
&& ./configure --prefix={{nghttp2_prefix}} --enable-lib-only \
&& {{make}} -j$(nproc) \
&& make install
rm -rf ngtcp2
git clone https://github.com/ngtcp2/ngtcp2 && cd ngtcp2 \
&& autoreconf -i \
&& ./configure --prefix={{nghttp2_prefix}} --enable-lib-only --with-openssl \
&& {{make}} -j$(nproc) \
&& make install
rm -rf nghttp2
git clone --recurse-submodules https://github.com/nghttp2/nghttp2 && cd nghttp2 \
&& autoreconf -i \
&& ./configure --prefix={{nghttp2_prefix}} \
--disable-examples --disable-hpack-tools --disable-python-bindings \
--with-mruby=no --enable-http3 --enable-app --with-libev \
--with-libevent-openssl=no {{nghttp2_options}} \
&& make \
&& make html \
&& make install \
&& ln -srf -t {{nghttp2_prefix}} {{nghttp2_prefix}}/share/doc/nghttp2/README.rst \
&& cp -rf -t {{nghttp2_prefix}}/share/doc/nghttp2 doc
-find {{nghttp2_prefix}}/lib -type f -name '*.la' -exec rm -rfv '{}' \;
brew unlink libnghttp2
brew link --force --HEAD nghttp2
brew link --force --overwrite libnghttp2
env {{nghttp2_prefix}}/bin/nghttpx --version | bat -lsh
h2o_prefix := cellar + "/h2o/HEAD-" + `curl -s -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/h2o/h2o/branches/$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/h2o/h2o | jq -r '.default_branch') | jq -r '.commit.sha' | head -c8`
h2o:
-brew uninstall --force --ignore-dependencies --formula h2o
rm -rf wslay
git clone https://github.com/tatsuhiro-t/wslay && cd wslay \
&& autoreconf -i \
&& ./configure --prefix={{h2o_prefix}} \
&& {{make}} -j$(nproc) \
&& make install
rm -rf h2o
git clone --recurse-submodules https://github.com/h2o/h2o && cd h2o \
&& {{cmake}} -DCMAKE_INSTALL_PREFIX={{h2o_prefix}} \
-DWITH_MRUBY=off -DWITH_DTRACE=off -DWITH_H2OLOG=off . \
&& make \
&& make doc \
&& make install
-find {{h2o_prefix}}/lib -type f -name '*.la' -exec rm -rfv '{}' \;
brew link --force --HEAD h2o
env {{h2o_prefix}}/bin/h2o --version | bat -lsh
haproxy_prefix := cellar + "/haproxy/HEAD-" + `curl -s -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/haproxy/haproxy/branches/$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/haproxy/haproxy | jq -r '.default_branch') | jq -r '.commit.sha' | head -c8`
haproxy_target := if os() == "macos" { "osx" } else { "linux-glibc" }
haproxy_options := if os() == "macos" { "USE_TFO=1" } else { "USE_QUIC=1 USE_SYSTEMD=1" }
haproxy:
-brew uninstall --force --ignore-dependencies --formula haproxy
rm -rf haproxy
git clone --recurse-submodules https://github.com/haproxy/haproxy && cd haproxy \
&& {{make}} V=1 TARGET={{haproxy_target}} CC={{CC}} LDFLAGS={{LDFLAGS}} \
USE_PCRE2=1 USE_PCRE2_JIT=1 USE_ZLIB=1 USE_OPENSSL=1 {{haproxy_options}} \
SSL_INC={{quictls_prefix}}/include SSL_LIB={{quictls_prefix}}/lib \
&& make install PREFIX={{haproxy_prefix}} DOCDIR={{haproxy_prefix}}/share/doc/haproxy
brew link --force --HEAD haproxy
env {{haproxy_prefix}}/sbin/haproxy -vv | bat -lyml
nginx_prefix := cellar + "/nginx/HEAD-" + epoch
nginx:
-brew uninstall --force --ignore-dependencies --formula nginx
rm -rf nginx
hg clone --branch quic https://hg.nginx.org/nginx-quic nginx && cd nginx \
&& hg clone https://hg.nginx.org/njs \
&& git clone https://github.com/arut/nginx-dav-ext-module \
&& ./auto/configure --prefix={{nginx_prefix}} \
--sbin-path={{nginx_prefix}}/bin/nginx \
--modules-path={{nginx_prefix}}/lib/nginx/modules \
--with-cc={{CC}} --with-cpp={{CXX}} \
--with-cc-opt="-I{{quictls_prefix}}/include" \
--with-ld-opt="-L{{quictls_prefix}}/lib -Wl,-rpath,{{quictls_prefix}}/lib" \
--conf-path={{prefix}}/etc/nginx/nginx.conf \
--pid-path={{prefix}}/var/run/nginx.pid \
--lock-path={{prefix}}/var/run/nginx.lock \
--http-client-body-temp-path={{prefix}}/var/run/nginx/client_body_temp \
--http-proxy-temp-path={{prefix}}/var/run/nginx/proxy_temp \
--http-fastcgi-temp-path={{prefix}}/var/run/nginx/fastcgi_temp \
--http-uwsgi-temp-path={{prefix}}/var/run/nginx/uwsgi_temp \
--http-scgi-temp-path={{prefix}}/var/run/nginx/scgi_temp \
--http-log-path={{prefix}}/var/log/nginx/access.log \
--error-log-path={{prefix}}/var/log/nginx/error.log \
--with-compat --with-threads \
--with-http_addition_module --with-http_auth_request_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_realip_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module \
--with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module \
--with-http_v3_module --with-stream_quic_module \
--with-pcre --with-pcre-jit \
--with-http_dav_module --add-module=./nginx-dav-ext-module \
--add-module=./njs/nginx \
&& {{make}} \
&& make install \
&& mkdir -p {{nginx_prefix}}/share/man/man8 \
&& cp -f -t {{nginx_prefix}}/share/man/man8 docs/man/*
cp -f -t {{prefix}}/var/www {{nginx_prefix}}/html/*
rm -rf {{nginx_prefix}}/html
ln -srf {{prefix}}/var/www {{nginx_prefix}}/html
brew link --force --HEAD nginx
env {{nginx_prefix}}/bin/nginx -V 2>&1 | sed 's/ --/\n--/g' | bat -lnix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment