Skip to content

Commit

Permalink
Build ngtcp2/nghttp3 into worker for WebTransport.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurik committed Nov 18, 2024
1 parent 30410bc commit eb3c261
Show file tree
Hide file tree
Showing 18 changed files with 210 additions and 7 deletions.
66 changes: 66 additions & 0 deletions env/cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
set -e
exec 1>&2

arch=${1}
output=${2}
curdir=${3}
meson=${4}
ar=${5}
strip=${6}
windres=${7}
cc=${8}
cxx=${9}
objc=${10}
qflags=${11}
wflags=${12}
xflags=${13}
mflags=${14}
shift 14

if [[ $# -ne 0 ]]; then
exit 1
fi

meson=(${meson})

cc=(${cc})
cxx=(${cxx})
objc=(${objc})

qflags=(${qflags})
wflags=(${wflags})
xflags=(${xflags})

mkdir -p "${output}/${arch}"

cflags=(-I"${curdir}/${output}/${arch}/usr/include")
lflags=(-L"${curdir}/${output}/${arch}/usr/lib")

cflags+=("${qflags[@]}")

cfg="${curdir}/${output}/${arch}/cmake.cfg"
echo "${wflags[@]}" >"${curdir}/${output}/${arch}/cmake.cfg"
cfg=(--config "${cfg}")


# XXX: I need to set CMAKE_SYSTEM_VERSION
cat >"${output}/${arch}"/cmake.new <<EOF
set(CMAKE_SYSTEM_NAME ${meson[0]})
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "${meson[1]}")
set(CMAKE_ASM_COMPILER ${cc[@]} ${cfg[@]})
set(CMAKE_C_COMPILER ${cc[@]} ${cfg[@]})
set(CMAKE_CXX_COMPILER ${cxx[@]} ${cfg[@]})
set(CMAKE_ASM_FLAGS "\${CMAKE_ASM_FLAGS} ${cflags[@]}" CACHE STRING "asm flags")
set(CMAKE_C_FLAGS "\${CMAKE_C_FLAGS} ${cflags[@]}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} ${cflags[@]} ${xflags[@]}" CACHE STRING "c++ flags")
EOF

if diff "${output}/${arch}"/cmake.{new,txt} &>/dev/null; then
rm -f "${output}/${arch}"/cmake.new
else
mv -f "${output}/${arch}"/cmake.{new,txt}
fi
1 change: 1 addition & 0 deletions env/meson.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ cfg="${curdir}/${output}/${arch}/meson.cfg"
echo "${wflags[@]}" >"${curdir}/${output}/${arch}/meson.cfg"
cfg=(--config "${cfg}")


function args() {
comma=false
for arg in "$@"; do
Expand Down
7 changes: 7 additions & 0 deletions env/output.mk
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export ENV_CURDIR := $(CURDIR)
export ENV_OUTPUT := $(output)

define _
$(shell env/cmake.sh $(1) $(output) '$(CURDIR)' '$(cmake) $(meson/$(1))' '$(ar/$(1))' '$(strip/$(1))' '$(windres/$(1))' '$(cc) $(more/$(1))' '$(cxx) $(more/$(1))' '$(objc) $(more/$(1))' '$(qflags)' '$(wflags)' '$(xflags)' '$(mflags)')
$(shell env/meson.sh $(1) $(output) '$(CURDIR)' '$(meson) $(meson/$(1))' '$(ar/$(1))' '$(strip/$(1))' '$(windres/$(1))' '$(cc) $(more/$(1))' '$(cxx) $(more/$(1))' '$(objc) $(more/$(1))' '$(qflags)' '$(wflags)' '$(xflags)' '$(mflags)')
endef
$(each)
Expand All @@ -134,6 +135,12 @@ $(output)/%/Makefile: $$(specific) $$(folder)/configure $(sysroot) $$(call head,
--enable-static --disable-shared $(subst =@/,=$(CURDIR)/$(output)/$(arch)/,$(w_$(subst -,_,$(notdir $(patsubst %/configure,%,$<)))))
cd $(dir $@); $(m_$(subst -,_,$(notdir $(patsubst %/configure,%,$<))))

$(output)/%/cmake/Makefile: $$(specific) $$(folder)/CMakeLists.txt $(output)/$$(arch)/cmake.txt $(sysroot) $$(call head,$$(folder))
$(specific)
@rm -rf $(dir $@)
@mkdir -p $(dir $@)
cmake -S$(dir $<) --toolchain $(CURDIR)/$(output)/$(arch)/cmake.txt -B$(dir $@) -DCMAKE_BUILD_TYPE=Release

$(output)/%/build.ninja: $$(specific) $$(folder)/meson.build $(output)/$$(arch)/meson.txt $(sysroot) $$(call head,$$(folder)) $(output)/$$(arch)/usr/bin/pkg-config
$(specific)
@rm -rf $(dir $@)
Expand Down
1 change: 1 addition & 0 deletions env/target-and.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lib := a
exe :=

meson := linux
cmake += Android

archs += armeabi-v7a
openssl/armeabi-v7a := android-arm
Expand Down
2 changes: 1 addition & 1 deletion env/target-any.mk
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ qflags += -ffile-prefix-map=$(CURDIR)=.

rflags += --remap-path-prefix=$(CURDIR)/$(output)/cargo/=~/.cargo/

qflags += -fno-ident
wflags += -fno-ident

$(output)/%/extra/revision.hpp: force
@mkdir -p $(dir $@)
Expand Down
2 changes: 2 additions & 0 deletions env/target-ios.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# }}}


cmake := iOS

archs += armv7
openssl/armv7 := ios-xcrun
host/armv7 := arm-apple-darwin
Expand Down
1 change: 1 addition & 0 deletions env/target-lnx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ libc := gnu
endif

meson := linux
cmake := Linux

archs += i386
openssl/i386 := linux-x86
Expand Down
2 changes: 2 additions & 0 deletions env/target-mac.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# }}}


cmake := Darwin

archs += i386
openssl/i386 := darwin-i386-cc
host/i386 := i386-apple-darwin
Expand Down
1 change: 1 addition & 0 deletions env/target-win.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lib := lib
exe := .exe

meson := windows
cmake := CYGWIN

archs += i686
openssl/i686 := mingw
Expand Down
15 changes: 15 additions & 0 deletions min-boringssl/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@
# }}}


pwd/boringssl := $(pwd)/boringssl

boringssl :=
boringssl += $(pwd/boringssl)/cmake/libssl.a
boringssl += $(pwd/boringssl)/cmake/libcrypto.a

$(subst @,%,$(patsubst %,$(output)/@/%,$(boringssl))): $(output)/%/$(pwd/boringssl)/cmake/Makefile
$(MAKE) -C $(dir $<) ssl

cflags += -I$(pwd)/boringssl/include

linked += $(boringssl)

export BORINGSSL_CFLAGS := -I$(CURDIR)/$(pwd/boringssl)/include
# XXX: this needs to be shoved down and then split for each architecture
export BORINGSSL_LIBS := -L$(CURDIR)/$(output)/$(machine)/$(pwd/boringssl)/cmake -lcrypto -lssl
6 changes: 3 additions & 3 deletions min-cairo/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ p_cairo += -Wno-unused-variable
p_cairo += -I$(CURDIR)/$(pwd)/zlb/libz
l_cairo += -L@/$(pwd)/zlb

p_cairo += -I$(CURDIR)/$(pwd)/libpng
p_cairo += -I@/$(pwd)/libpng
p_cairo += -I$(CURDIR)/$(pwd)/libpng
l_cairo += -L@/libpbg/.libs

p_cairo += -I$(CURDIR)/$(pwd)/pixman/pixman
p_cairo += -I@/$(pwd)/pixman/pixman
p_cairo += -I$(CURDIR)/$(pwd)/pixman/pixman
l_cairo += -L@/$(pwd)/pixman/.libs

libcairo := $(pwd)/cairo/src/.libs/libcairo.a
Expand All @@ -38,8 +38,8 @@ $(subst @,%,$(patsubst %,$(output)/@/%,$(libcairo))) \
: $(output)/%/$(pwd)/cairo/Makefile $(sysroot)
$(MAKE) -C $(dir $<)/src

cflags += -I$(pwd)/cairo/src
cflags += -I@/$(pwd)/cairo/src
cflags += -I$(pwd)/cairo/src

linked += $(libcairo)

Expand Down
34 changes: 34 additions & 0 deletions min-http3/nghttp3.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Orchid - WebRTC P2P VPN Market (on Ethereum)
# Copyright (C) 2017-2020 The Orchid Authors

# GNU Affero General Public License, Version 3 {{{ */
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# }}}


w_nghttp3 += --enable-lib-only

nghttp3 :=
nghttp3 += $(pwd)/nghttp3/lib/.libs/libnghttp3.a

$(output)/%/$(pwd)/nghttp3/lib/includes/nghttp3/version.h $(subst @,%,$(patsubst %,$(output)/@/%,$(nghttp3))): $(output)/%/$(pwd)/nghttp3/Makefile
$(MAKE) -C $(dir $<)

cflags += -I@/$(pwd)/nghttp3/lib/includes
cflags += -I$(pwd)/nghttp3/lib/includes

header += @/$(pwd)/nghttp3/lib/includes/nghttp3/version.h

linked += $(nghttp3)
2 changes: 1 addition & 1 deletion min-http3/ngtcp2
46 changes: 46 additions & 0 deletions min-http3/ngtcp2.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Orchid - WebRTC P2P VPN Market (on Ethereum)
# Copyright (C) 2017-2020 The Orchid Authors

# GNU Affero General Public License, Version 3 {{{ */
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# }}}


w_ngtcp2 += --enable-lib-only

w_ngtcp2 += --without-libev
w_ngtcp2 += --without-openssl
w_ngtcp2 += --with-boringssl

define _
$(output)/$(1)/$(pwd)/ngtcp2/Makefile: $(output)/$(1)/$(pwd/boringssl)/cmake/libssl.a
endef
$(each)

ngtcp2 :=
ngtcp2 += $(pwd)/ngtcp2/lib/.libs/libngtcp2.a
ngtcp2 += $(pwd)/ngtcp2/crypto/boringssl/libngtcp2_crypto_boringssl.a

$(output)/%/$(pwd)/ngtcp2/lib/includes/ngtcp2/version.h $(subst @,%,$(patsubst %,$(output)/@/%,$(ngtcp2))): $(output)/%/$(pwd)/ngtcp2/Makefile
$(MAKE) -C $(dir $<)

cflags += -I$(pwd)/ngtcp2/crypto/includes

cflags += -I@/$(pwd)/ngtcp2/lib/includes
cflags += -I$(pwd)/ngtcp2/lib/includes

header += @/$(pwd)/ngtcp2/lib/includes/ngtcp2/version.h

linked += $(ngtcp2)
22 changes: 22 additions & 0 deletions min-http3/target.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Orchid - WebRTC P2P VPN Market (on Ethereum)
# Copyright (C) 2017-2020 The Orchid Authors

# GNU Affero General Public License, Version 3 {{{ */
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# }}}


include $(pwd)/ngtcp2.mk
include $(pwd)/nghttp3.mk
7 changes: 5 additions & 2 deletions min-openssl/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ $(output)/%/openssl/Makefile $(subst @,%,$(patsubst %,$(output)/@/openssl/includ
$(output)/%/openssl/libssl.a $(output)/%/openssl/libcrypto.a: $(output)/%/openssl/Makefile $(sysroot)
$(if $(findstring /,$(word 1,$(cc))),PATH=$(dir $(word 1,$(cc))):$${PATH}) $(MAKE) -C $(output)/$*/openssl build_libs

cflags += -I@/openssl/include
cflags += -I$(pwd)/openssl/include

cflags += -I$(pwd)/openssl/test/ossl_shim/include
cflags += -I@/openssl/include

header += @/openssl/include/openssl/opensslconf.h

linked += openssl/libssl.a
linked += openssl/libcrypto.a
header += @/openssl/include/openssl/opensslconf.h

define _
export $(subst -,_,$(call uc,$(triple/$(1))))_OPENSSL_LIB_DIR := $(CURDIR)/$(output)/$(1)/openssl
Expand Down
1 change: 1 addition & 0 deletions srv-worker/http3
1 change: 1 addition & 0 deletions srv-worker/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cflags += -I$(pwd)/extra
$(call include,cv8/target.mk)

$(call include,lib/target.mk)
$(call include,http3/target.mk)

# XXX: I might not need this anymore
cflags += -D_LIBCPP_HAS_NO_STDIN=
Expand Down

0 comments on commit eb3c261

Please sign in to comment.