|
@ -28,10 +28,20 @@ main(Args) -> |
|
|
%% Extract the system info of the version of OTP we use to compile rebar |
|
|
%% Extract the system info of the version of OTP we use to compile rebar |
|
|
OtpInfo = string:strip(erlang:system_info(otp_release), both, $\n), |
|
|
OtpInfo = string:strip(erlang:system_info(otp_release), both, $\n), |
|
|
|
|
|
|
|
|
|
|
|
%% Types dict:dict() and digraph:digraph() have been introduced in Erlang 17. |
|
|
|
|
|
%% At the same time, their counterparts dict() and digraph() are to be deprecated |
|
|
|
|
|
%% in Erlang 18. namespaced_types option is used to select proper type name |
|
|
|
|
|
%% depending of the OTP version used. |
|
|
|
|
|
NamespacedTypes = case is_otp(OtpInfo, "^[0-9]+") of |
|
|
|
|
|
true -> {d, namespaced_types}; |
|
|
|
|
|
false -> undefined |
|
|
|
|
|
end, |
|
|
|
|
|
|
|
|
%% Compile all src/*.erl to ebin |
|
|
%% Compile all src/*.erl to ebin |
|
|
case make:files(filelib:wildcard("src/*.erl"), |
|
|
case make:files(filelib:wildcard("src/*.erl"), |
|
|
[{outdir, "ebin"}, {i, "include"}, |
|
|
[{outdir, "ebin"}, {i, "include"}, |
|
|
DebugFlag, |
|
|
DebugFlag, |
|
|
|
|
|
NamespacedTypes, |
|
|
{d, 'BUILD_TIME', Built}, |
|
|
{d, 'BUILD_TIME', Built}, |
|
|
{d, 'VCS_INFO', VcsInfo}, |
|
|
{d, 'VCS_INFO', VcsInfo}, |
|
|
{d, 'OTP_INFO', OtpInfo}]) of |
|
|
{d, 'OTP_INFO', OtpInfo}]) of |
|
@ -79,6 +89,12 @@ main(Args) -> |
|
|
"Place this script anywhere in your path\n" |
|
|
"Place this script anywhere in your path\n" |
|
|
"and you can use rebar to build OTP-compliant apps.\n"). |
|
|
"and you can use rebar to build OTP-compliant apps.\n"). |
|
|
|
|
|
|
|
|
|
|
|
is_otp(OtpInfo, Regex) -> |
|
|
|
|
|
case re:run(OtpInfo, Regex, [{capture, none}]) of |
|
|
|
|
|
match -> true; |
|
|
|
|
|
nomatch -> false |
|
|
|
|
|
end. |
|
|
|
|
|
|
|
|
rm(Path) -> |
|
|
rm(Path) -> |
|
|
NativePath = filename:nativename(Path), |
|
|
NativePath = filename:nativename(Path), |
|
|
Cmd = case os:type() of |
|
|
Cmd = case os:type() of |
|
|