| 1 | % (c) 2009-2019 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 | ]). | |
| 10 | ||
| 11 | :- use_module(module_information,[module_info/2]). | |
| 12 | ||
| 13 | :- module_info(group,infrastructure). | |
| 14 | :- module_info(description,'This module contains the current version number of ProB together with automatically updated version control infos.'). | |
| 15 | ||
| 16 | ||
| 17 | version(1,9,0,'beta8'). | |
| 18 | ||
| 19 | % example call: compare_current_version([1,7],Res). | |
| 20 | compare_current_version(NrList,Result) :- version(A,B,C,_), | |
| 21 | compare_aux(NrList,[A,B,C],Result). | |
| 22 | ||
| 23 | compare_aux([],_,current_matches). | |
| 24 | compare_aux([Requested|RT],[Cur|CT],Res) :- Requested = Cur,!, compare_aux(RT,CT,Res). | |
| 25 | compare_aux([Requested|_],[Cur|_],Res) :- Requested > Cur,!, Res = current_older. | |
| 26 | compare_aux(_,_,current_newer). | |
| 27 | ||
| 28 | :- use_module(library(lists),[append/2]). | |
| 29 | version_str(Str) :- version(V1,V2,V3,Suffix), | |
| 30 | number_codes(V1,C1), | |
| 31 | number_codes(V2,C2), | |
| 32 | number_codes(V3,C3), | |
| 33 | atom_codes(Suffix,S), | |
| 34 | append([C1,".",C2,".",C3,"-",S],C), | |
| 35 | atom_codes(Str,C). | |
| 36 | ||
| 37 | % this file needs to be touched and committed for information below to be updated! | |
| 38 | ||
| 39 | get_revision(R) :- catch(read_revision(R),_,R='no revision found'). | |
| 40 | get_lastchanged(R) :- catch(read_lastchanged(R),_,R='no lastchanged found'). | |
| 41 | ||
| 42 | ||
| 43 | % Tries to read the revision file generated by make. | |
| 44 | % If it does not come from svn, the fallback revision number is used. | |
| 45 | read_revision(A) :- | |
| 46 | open('revision', read, ID), | |
| 47 | read_line(ID,R), close(ID), | |
| 48 | atom_codes(A,R). | |
| 49 | ||
| 50 | read_lastchanged(A) :- | |
| 51 | open('lastchanged', read, ID), | |
| 52 | read_line(ID,R), close(ID), | |
| 53 | atom_codes(A,R). | |
| 54 | ||
| 55 | :- dynamic revision/1, lastchangeddate/1. | |
| 56 | :- get_revision(X), assert(revision(X)). | |
| 57 | :- get_lastchanged(X), assert(lastchangeddate(X)). |