Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 56 lines (51 sloc) 2.1 KB
#!/usr/bin/env escript
%%% Copyright 2010-2017 Manolis Papadakis <manopapad@gmail.com>,
%%% Eirini Arvaniti <eirinibob@gmail.com>
%%% and Kostis Sagonas <kostis@cs.ntua.gr>
%%%
%%% This file is part of PropEr.
%%%
%%% PropEr is free software: you can redistribute it and/or modify
%%% it under the terms of the GNU General Public License as published by
%%% the Free Software Foundation, either version 3 of the License, or
%%% (at your option) any later version.
%%%
%%% PropEr is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%%% GNU General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with PropEr. If not, see <http://www.gnu.org/licenses/>.
%%% Author(s): Manolis Papadakis and Kostis Sagonas
%%% Description: Compilation environment setup script: This script computes and
%%% prints out the correct set of compilation flags for the
%%% currently running version of the OTP.
-spec main([file:filename(),...]) -> 'ok'.
main([OutFile]) ->
CurrVer = parse_version_string(erlang:system_info(version)),
case CurrVer < [6,0] of
false ->
{ok, Handle} = file:open(OutFile, [write]),
ToDefine =
case CurrVer < [8,0] of
true -> [];
false -> ["AT_LEAST_19"]
end ++
%% older than 18.0 => erl_scan:line() type not marked deprecated
case CurrVer < [7,0] of
true -> ["USE_ERL_SCAN_LINE"];
false -> []
end,
Fun = fun(X) -> io:format(Handle, "-define(~s, 1).~n", [X]) end,
lists:foreach(Fun, ToDefine),
ok = file:close(Handle);
true ->
halt(1) %% we do not support releases prior to 17
end.
%% the stupid try-catch construct below is due to e.g. the R15A
%% release being denoted as having "5.9.pre" as version info :-(
-spec parse_version_string(string()) -> [non_neg_integer()].
parse_version_string(VerStr) ->
[try list_to_integer(S)
catch _:_ -> 0 end || S <- string:tokens(VerStr, ".")].