Skip to content

Commit

Permalink
Merge pull request #227 from qzhuyan/dev/william/update-packaging
Browse files Browse the repository at this point in the history
fixing release script
  • Loading branch information
qzhuyan authored Nov 8, 2023
2 parents 9cfccfa + ae1fad8 commit c63fd66
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push, pull_request]

jobs:
mac:
timeout-minutes: 45
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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/)
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
19 changes: 19 additions & 0 deletions include/quicer_vsn.hrl
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 6 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{erl_opts, [debug_info]}.
{erl_opts, [ debug_info
]}.

{pre_hooks,
[{"(linux|darwin|solaris)", compile, "make build-nif"}
Expand Down Expand Up @@ -29,6 +30,10 @@
]
}.

{artifacts, [ "include/quicer_vsn.hrl"
, "priv/libquicer_nif.so"
]}.

{relx, [{release, {quicer, git},
[quicer]},
{dev_mode, true},
Expand Down
4 changes: 0 additions & 4 deletions src/quicer_nif.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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() ->
Expand Down Expand Up @@ -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() ->
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit c63fd66

Please sign in to comment.