]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/build/version.jam
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / build / src / build / version.jam
1 # Copyright 2002, 2003, 2004, 2006 Vladimir Prus
2 # Copyright 2008, 2012 Jurko Gospodnetic
3 # Distributed under the Boost Software License, Version 1.0.
4 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
5
6 import numbers ;
7
8
9 .major = "2015" ;
10 .minor = "07" ;
11
12
13 rule boost-build ( )
14 {
15 return "$(.major).$(.minor)-git" ;
16 }
17
18
19 rule print ( )
20 {
21 if [ verify-engine-version ]
22 {
23 ECHO "Boost.Build" [ boost-build ] ;
24 }
25 }
26
27
28 rule verify-engine-version ( )
29 {
30 local v = [ modules.peek : JAM_VERSION ] ;
31
32 if $(v[1]) != $(.major) || $(v[2]) != $(.minor)
33 {
34 local argv = [ modules.peek : ARGV ] ;
35 local e = $(argv[1]) ;
36 local l = [ modules.binding version ] ;
37 l = $(l:D) ;
38 l = $(l:D) ;
39 ECHO "warning: mismatched versions of Boost.Build engine and core" ;
40 ECHO "warning: Boost.Build engine ($(e)) is $(v:J=.)" ;
41 ECHO "warning: Boost.Build core (at $(l)) is" [ boost-build ] ;
42 }
43 else
44 {
45 return true ;
46 }
47 }
48
49
50 # Utility rule for testing whether all elements in a sequence are equal to 0.
51 #
52 local rule is-all-zeroes ( sequence * )
53 {
54 local result = "true" ;
55 for local e in $(sequence)
56 {
57 if $(e) != "0"
58 {
59 result = "" ;
60 }
61 }
62 return $(result) ;
63 }
64
65
66 # Returns "true" if the first version is less than the second one.
67 #
68 rule version-less ( lhs + : rhs + )
69 {
70 numbers.check $(lhs) ;
71 numbers.check $(rhs) ;
72
73 local done ;
74 local result ;
75
76 while ! $(done) && $(lhs) && $(rhs)
77 {
78 if [ numbers.less $(lhs[1]) $(rhs[1]) ]
79 {
80 done = "true" ;
81 result = "true" ;
82 }
83 else if [ numbers.less $(rhs[1]) $(lhs[1]) ]
84 {
85 done = "true" ;
86 }
87 else
88 {
89 lhs = $(lhs[2-]) ;
90 rhs = $(rhs[2-]) ;
91 }
92 }
93 if ( ! $(done) && ! $(lhs) && ! [ is-all-zeroes $(rhs) ] )
94 {
95 result = "true" ;
96 }
97
98 return $(result) ;
99 }
100
101
102 # Returns "true" if the current JAM version version is at least the given
103 # version.
104 #
105 rule check-jam-version ( version + )
106 {
107 local version-tag = $(version:J=.) ;
108 if ! $(version-tag)
109 {
110 import errors ;
111 errors.error Invalid version specifier: : $(version:E="(undefined)") ;
112 }
113
114 if ! $(.jam-version-check.$(version-tag))-is-defined
115 {
116 local jam-version = [ modules.peek : JAM_VERSION ] ;
117 if ! $(jam-version)
118 {
119 import errors ;
120 errors.error "Unable to deduce Boost Jam version. Your Boost Jam"
121 "installation is most likely terribly outdated." ;
122 }
123 .jam-version-check.$(version-tag) = "true" ;
124 if [ version-less [ modules.peek : JAM_VERSION ] : $(version) ]
125 {
126 .jam-version-check.$(version-tag) = "" ;
127 }
128 }
129 return $(.jam-version-check.$(version-tag)) ;
130 }
131
132
133 rule __test__ ( )
134 {
135 import assert ;
136
137 local jam-version = [ modules.peek : JAM_VERSION ] ;
138 local future-version = $(jam-version) ;
139 future-version += "1" ;
140
141 assert.true check-jam-version $(jam-version) ;
142 assert.false check-jam-version $(future-version) ;
143
144 assert.true version-less 0 : 1 ;
145 assert.false version-less 0 : 0 ;
146 assert.true version-less 1 : 2 ;
147 assert.false version-less 1 : 1 ;
148 assert.false version-less 2 : 1 ;
149 assert.true version-less 3 1 20 : 3 4 10 ;
150 assert.false version-less 3 1 10 : 3 1 10 ;
151 assert.false version-less 3 4 10 : 3 1 20 ;
152 assert.true version-less 3 1 20 5 1 : 3 4 10 ;
153 assert.false version-less 3 1 10 5 1 : 3 1 10 ;
154 assert.false version-less 3 4 10 5 1 : 3 1 20 ;
155 assert.true version-less 3 1 20 : 3 4 10 5 1 ;
156 assert.true version-less 3 1 10 : 3 1 10 5 1 ;
157 assert.false version-less 3 4 10 : 3 1 20 5 1 ;
158 assert.false version-less 3 1 10 : 3 1 10 0 0 ;
159 assert.false version-less 3 1 10 0 0 : 3 1 10 ;
160 assert.false version-less 3 1 10 0 : 3 1 10 0 0 ;
161 assert.false version-less 3 1 10 0 : 03 1 10 0 0 ;
162 assert.false version-less 03 1 10 0 : 3 1 10 0 0 ;
163
164 # TODO: Add tests for invalid input data being sent to version-less.
165 }