1 % (c) 2009-2024 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
2 % Heinrich Heine Universitaet Duesseldorf
3 % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
4
5 :- module(version, [ version/4, version_str/1,
6 revision/1,
7 lastchangeddate/1,
8 compare_current_version/2,
9 format_prob_version/1
10 ]).
11
12 :- use_module(module_information,[module_info/2]).
13
14 :- module_info(group,infrastructure).
15 :- module_info(description,'This module contains the current version number of ProB together with automatically updated version control infos.').
16
17
18 version(1,13,1,'nightly'). % next beta will be beta1
19
20 % example call: compare_current_version([1,7],Res).
21 compare_current_version(NrList,Result) :- version(A,B,C,_),
22 compare_aux(NrList,[A,B,C],Result).
23
24 compare_aux([],_,current_matches).
25 compare_aux([Requested|RT],[Cur|CT],Res) :- Requested = Cur,!, compare_aux(RT,CT,Res).
26 compare_aux([Requested|_],[Cur|_],Res) :- Requested > Cur,!, Res = current_older.
27 compare_aux(_,_,current_newer).
28
29 :- use_module(library(lists),[append/2]).
30 version_str(Str) :- version(V1,V2,V3,Suffix),
31 number_codes(V1,C1),
32 number_codes(V2,C2),
33 number_codes(V3,C3),
34 atom_codes(Suffix,S),
35 append([C1,[0'.],C2,[0'.],C3,[0'-],S],C),
36 atom_codes(Str,C).
37
38
39 format_prob_version(Stream) :-
40 version_str(VS), revision(Rev), lastchangeddate(DD),
41 format(Stream,'ProB ~w~n Revision: ~w~n Date: ~w',[VS,Rev,DD]).
42
43
44 % this file needs to be touched and committed for information below to be updated!
45
46 get_revision(R) :- catch(read_revision(R),_,R='no revision found').
47 get_lastchanged(R) :- catch(read_lastchanged(R),_,R='no lastchanged found').
48
49
50 % Tries to read the revision file generated by make.
51 % If it does not come from svn, the fallback revision number is used.
52 read_revision(A) :-
53 open('revision', read, ID),
54 read_line(ID,R), close(ID),
55 atom_codes(A,R).
56
57 read_lastchanged(A) :-
58 open('lastchanged', read, ID),
59 read_line(ID,R), close(ID),
60 atom_codes(A,R).
61
62 :- dynamic revision/1, lastchangeddate/1.
63 :- get_revision(X), assertz(revision(X)).
64 :- get_lastchanged(X), assertz(lastchangeddate(X)).