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: diff --git a/CMakeLists.txt b/CMakeLists.txt index 73b8204d..706f2d62 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}/include/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 ) @@ -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 8ab89935..ba55f40e 100755 --- a/build.sh +++ b/build.sh @@ -46,8 +46,9 @@ 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 + tar zxvf "_packages/${PKGNAME}" -C $(dirname "$TARGET_SO") + + erlc -I include -I priv src/quicer_nif.erl if erl -noshell -eval '[_|_]=quicer_nif:module_info(), halt(0).'; then res=0 else @@ -66,7 +67,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" @@ -90,3 +91,10 @@ 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/" + 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 a7104ab6..e817c7e2 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,5 @@ -{erl_opts, [debug_info]}. +{erl_opts, [ debug_info + ]}. {pre_hooks, [{"(linux|darwin|solaris)", compile, "make build-nif"} @@ -29,6 +30,10 @@ ] }. +{artifacts, [ "include/quicer_vsn.hrl" + , "priv/libquicer_nif.so" + ]}. + {relx, [{release, {quicer, git}, [quicer]}, {dev_mode, true}, 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() -> 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