chore(build): Get rel vsn fallback (#4339)

This commit is contained in:
William Yang 2021-03-16 09:49:11 +01:00 committed by GitHub
parent ef1be26bc8
commit d5886c0c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 11 deletions

View File

@ -70,18 +70,15 @@ get_description() ->
Str -> string:strip(Str, both, $\n) Str -> string:strip(Str, both, $\n)
end. end.
-ifdef(TEST).
%% When testing, the 'cover' compiler stripps aways compile info
get_release() -> release_in_macro().
-else.
%% Otherwise print the build number,
%% which may have a git commit in its suffix.
get_release() -> get_release() ->
{_, Vsn} = lists:keyfind(emqx_vsn, 1, ?MODULE:module_info(compile)), case lists:keyfind(emqx_vsn, 1, ?MODULE:module_info(compile)) of
false -> %% For TEST build or depedency build.
release_in_macro();
{_, Vsn} -> %% For emqx release build
VsnStr = release_in_macro(), VsnStr = release_in_macro(),
1 = string:str(Vsn, VsnStr), %% assert 1 = string:str(Vsn, VsnStr), %% assert
Vsn. Vsn
-endif. end.
release_in_macro() -> release_in_macro() ->
element(2, ?EMQX_RELEASE). element(2, ?EMQX_RELEASE).