From 2f835bc9a5c317219f0448188bf23e31544bb28a Mon Sep 17 00:00:00 2001 From: William Yang Date: Sat, 4 Nov 2023 20:57:42 +0100 Subject: [PATCH 1/5] build: update package script --- build.sh | 17 +++++------------ src/quicer_nif.erl | 4 ---- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/build.sh b/build.sh index 8ab89935..af1b415b 100755 --- a/build.sh +++ b/build.sh @@ -46,17 +46,10 @@ download() { echo "$(cat "_packages/${PKGNAME}.sha256") _packages/${PKGNAME}" | sha256sum -c || return 1 - gzip -c -d "_packages/${PKGNAME}" > "$TARGET_SO" - erlc -I include src/quicer_nif.erl - if erl -noshell -eval '[_|_]=quicer_nif:module_info(), halt(0).'; then - res=0 - else - # failed to load, build from source - rm -f $TARGET_SO - res=1 - fi - rm -f quicer_nif.beam - return $res + tar zxvf "_packages/${PKGNAME}" -C $(dirname "$TARGET_SO") + VSN=$(echo "${PKGNAME}" | cut -d '-' -f 2) + [[ -f "priv/libquicer_nif.so.*-${VSN}" ]] + return $? } release() { @@ -66,7 +59,7 @@ release() { fi mkdir -p _packages TARGET_PKG="_packages/${PKGNAME}" - gzip -c "$TARGET_SO" > "$TARGET_PKG" + tar czvf "$TARGET_PKG" -C $(dirname "$TARGET_SO") --exclude include --exclude share --exclude .gitignore . # use openssl but not sha256sum command because in some macos env it does not exist if command -v openssl; then openssl dgst -sha256 "${TARGET_PKG}" | cut -d ' ' -f 2 > "${TARGET_PKG}.sha256" diff --git a/src/quicer_nif.erl b/src/quicer_nif.erl index a10aa547..e79f362c 100644 --- a/src/quicer_nif.erl +++ b/src/quicer_nif.erl @@ -69,7 +69,6 @@ -include("quicer.hrl"). -include("quicer_types.hrl"). -include("quicer_vsn.hrl"). --include_lib("snabbkaffe/include/snabbkaffe.hrl"). -spec abi_version() -> integer(). abi_version() -> @@ -103,9 +102,6 @@ init(ABIVsn) -> ok end; {error, _Reason} = Res-> - %% load fail, but beam will keep using current vsn if presents. - ?tp_ignore_side_effects_in_prod(debug, - #{module => ?MODULE, event => init, result => Res}), Res end. -spec open_lib() -> From f133a7939f94b829e1ae8ffebcd7fdc8bbb03e07 Mon Sep 17 00:00:00 2001 From: William Yang Date: Mon, 6 Nov 2023 14:27:08 +0100 Subject: [PATCH 2/5] build: comfort emqx forked rebar3 --- CMakeLists.txt | 5 +++-- Makefile | 1 + build.sh | 20 +++++++++++++++++--- rebar.config | 8 +++++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73b8204d..4f5190f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ set(QUIC_TLS_SECRETS_SUPPORT "ON") configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/include/quicer_vsn.hrl.in - ${CMAKE_CURRENT_SOURCE_DIR}/include/quicer_vsn.hrl + ${CMAKE_CURRENT_SOURCE_DIR}/priv/quicer_vsn.hrl ) configure_file( @@ -167,7 +167,8 @@ add_dependencies(quicer_static msquic) set_target_properties(quicer_nif PROPERTIES LIBRARY_OUTPUT_NAME quicer_nif - VERSION ${QUICER_ABI_VERSION}-${QUICER_VERSION} + VERSION ${QUICER_VERSION} + SOVERSION ${QUICER_ABI_VERSION} ) include(GNUInstallDirs) install(TARGETS quicer_nif LIBRARY DESTINATION ${PROJECT_SOURCE_DIR}/priv/) diff --git a/Makefile b/Makefile index 576eeb4e..fdaacd05 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ distclean: $(REBAR) unlock --all rm -rf _build erl_crash.dump rebar3.crashdump rm -rf c_build/* + rm -rf priv/* .PHONY: xref xref: diff --git a/build.sh b/build.sh index af1b415b..4115cdea 100755 --- a/build.sh +++ b/build.sh @@ -47,9 +47,17 @@ download() { echo "$(cat "_packages/${PKGNAME}.sha256") _packages/${PKGNAME}" | sha256sum -c || return 1 tar zxvf "_packages/${PKGNAME}" -C $(dirname "$TARGET_SO") - VSN=$(echo "${PKGNAME}" | cut -d '-' -f 2) - [[ -f "priv/libquicer_nif.so.*-${VSN}" ]] - return $? + + erlc -I include -I priv src/quicer_nif.erl + if erl -noshell -eval '[_|_]=quicer_nif:module_info(), halt(0).'; then + res=0 + else + # failed to load, build from source + rm -f $TARGET_SO + res=1 + fi + rm -f quicer_nif.beam + return $res } release() { @@ -83,3 +91,9 @@ else build fi fi + +## workaround for emqx forked rebar3 +if ([ -n $REBAR_DEPS_DIR ] && [ $(realpath -P "${REBAR_DEPS_DIR}/quicer/priv") != "${PWD}/priv" ]); +then + cp -r priv/* "${REBAR_DEPS_DIR}/quicer/priv/" +fi diff --git a/rebar.config b/rebar.config index a7104ab6..83d4f6cc 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,6 @@ -{erl_opts, [debug_info]}. +{erl_opts, [ debug_info + , {i, "priv/"} %% for generated quicer_vsn.hrl + ]}. {pre_hooks, [{"(linux|darwin|solaris)", compile, "make build-nif"} @@ -29,6 +31,10 @@ ] }. +{artifacts, [ "priv/quicer_vsn.hrl" + , "priv/libquicer_nif.so" + ]}. + {relx, [{release, {quicer, git}, [quicer]}, {dev_mode, true}, From 8d32f93f29e4b7bc8f57f3033be4eacb9ecb1ac5 Mon Sep 17 00:00:00 2001 From: William Yang Date: Tue, 7 Nov 2023 11:39:15 +0100 Subject: [PATCH 3/5] chore: templates in templates dir --- CMakeLists.txt | 4 ++-- {c_src => templates}/quicer_vsn.h.in | 0 {include => templates}/quicer_vsn.hrl.in | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {c_src => templates}/quicer_vsn.h.in (100%) rename {include => templates}/quicer_vsn.hrl.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f5190f6..0105df31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,12 +82,12 @@ set(QUIC_BUILD_PERF "OFF") set(QUIC_TLS_SECRETS_SUPPORT "ON") configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/include/quicer_vsn.hrl.in + ${CMAKE_CURRENT_SOURCE_DIR}/templates/quicer_vsn.hrl.in ${CMAKE_CURRENT_SOURCE_DIR}/priv/quicer_vsn.hrl ) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/c_src/quicer_vsn.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/templates/quicer_vsn.h.in ${CMAKE_CURRENT_BINARY_DIR}/c_src/quicer_vsn.h ) diff --git a/c_src/quicer_vsn.h.in b/templates/quicer_vsn.h.in similarity index 100% rename from c_src/quicer_vsn.h.in rename to templates/quicer_vsn.h.in diff --git a/include/quicer_vsn.hrl.in b/templates/quicer_vsn.hrl.in similarity index 100% rename from include/quicer_vsn.hrl.in rename to templates/quicer_vsn.hrl.in From f7b66dcc83ecfa08c66e49de889a0efff51a3e7b Mon Sep 17 00:00:00 2001 From: William Yang Date: Tue, 7 Nov 2023 16:17:42 +0100 Subject: [PATCH 4/5] build: commit generated quicer_vsn.hrl --- CMakeLists.txt | 2 +- build.sh | 1 + include/quicer_vsn.hrl | 19 +++++++++++++++++++ rebar.config | 3 +-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 include/quicer_vsn.hrl diff --git a/CMakeLists.txt b/CMakeLists.txt index 0105df31..706f2d62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ set(QUIC_TLS_SECRETS_SUPPORT "ON") configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/templates/quicer_vsn.hrl.in - ${CMAKE_CURRENT_SOURCE_DIR}/priv/quicer_vsn.hrl + ${CMAKE_CURRENT_SOURCE_DIR}/include/quicer_vsn.hrl ) configure_file( diff --git a/build.sh b/build.sh index 4115cdea..ba55f40e 100755 --- a/build.sh +++ b/build.sh @@ -96,4 +96,5 @@ fi if ([ -n $REBAR_DEPS_DIR ] && [ $(realpath -P "${REBAR_DEPS_DIR}/quicer/priv") != "${PWD}/priv" ]); then cp -r priv/* "${REBAR_DEPS_DIR}/quicer/priv/" + cp include/quicer_vsn.hrl "${REBAR_DEPS_DIR}/quicer/include/" fi diff --git a/include/quicer_vsn.hrl b/include/quicer_vsn.hrl new file mode 100644 index 00000000..d5eaca10 --- /dev/null +++ b/include/quicer_vsn.hrl @@ -0,0 +1,19 @@ +%%-------------------------------------------------------------------- +%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%%-------------------------------------------------------------------- +-ifndef(QUICER_VSN_HRL). +-define(QUICER_VSN_HRL, true). +-define(QUICER_ABI_VERSION, 1). +-endif. diff --git a/rebar.config b/rebar.config index 83d4f6cc..e817c7e2 100644 --- a/rebar.config +++ b/rebar.config @@ -1,5 +1,4 @@ {erl_opts, [ debug_info - , {i, "priv/"} %% for generated quicer_vsn.hrl ]}. {pre_hooks, @@ -31,7 +30,7 @@ ] }. -{artifacts, [ "priv/quicer_vsn.hrl" +{artifacts, [ "include/quicer_vsn.hrl" , "priv/libquicer_nif.so" ]}. From ae1fad8df692a2df7c02a15cccfdefdd715dec0c Mon Sep 17 00:00:00 2001 From: William Yang Date: Tue, 7 Nov 2023 16:18:49 +0100 Subject: [PATCH 5/5] ci: bump macos build timeout in case of cache miss --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 028c90df..faa6ddcd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ on: [push, pull_request] jobs: mac: - timeout-minutes: 45 + timeout-minutes: 60 strategy: fail-fast: false matrix: