3
3
\ This file is part of Solo Forth
4
4
\ http://programandala.net/en.program.solo_forth.html
5
5
6
- \ Last modified 202010012056
6
+ \ Last modified 202010021653
7
7
\ See change log at the end of the file
8
8
9
9
\ ==============================================================
10
10
\ Description
11
11
12
12
\ This program extracts the version number of Solo Forth from the
13
13
\ labels defined in the Z80 source and prints it in certain format.
14
- \
15
14
16
15
\ This program is written in Forth (http://forth-standard.org)
17
16
\ with Gforth (http://gnu.org/software/gforth/).
21
20
22
21
\ Invocation:
23
22
24
- \ gforth -e 's" PATH-TO/version.z80s" flag ' version_number.fs
23
+ \ gforth -e 's" PATH-TO/version.z80s" FORMAT ' version_number.fs
25
24
26
- \ Where "flag" is either `true` (complete version number) or `false`
27
- \ (simplified format used as a file name for the background images).
25
+ \ Where FORMAT is 0..3 with the following meaning:
26
+ \
27
+ \ 0 = XX.YY.ZZ (two digits per element, with padding zeros)
28
+ \ 1 = X.Y.Z
29
+ \ 2 = X.Y.Z-prerelease
30
+ \ 3 = X.Y.Z-prerelease+build
28
31
29
32
\ ==============================================================
30
33
\ Author
31
34
32
- \ Marcos Cruz (programandala.net), 2016, 2017.
35
+ \ Marcos Cruz (programandala.net), 2016, 2017, 2020 .
33
36
34
37
\ ==============================================================
35
38
\ License
@@ -44,7 +47,7 @@ only forth definitions decimal
44
47
45
48
\ ==============================================================
46
49
47
- variable real- format \ flag
50
+ variable format \ version output format ID (0..2)
48
51
49
52
variable version-major
50
53
variable version-minor
@@ -54,36 +57,52 @@ variable version-prerelease
54
57
variable version-build-high
55
58
variable version-build-low
56
59
57
- : .version-part ( n -- ) s>d <# #S #> type ;
60
+ defer .version-part
61
+
62
+ : .full-version-part ( n -- ) s>d <# #S #> type ;
58
63
\ Print one part of the version number.
64
+ \ Default action of `.version-part`.
65
+
66
+ : .version-part-00 ( n -- ) s>d <# # # #> type ;
67
+ \ Print one part of the version number, with two digits,
68
+ \ padded with zeros.
69
+ \ Alternative action of `.version-part`.
70
+
71
+ ' .full-version-part is .version-part
59
72
60
73
: build-date ( -- u )
61
74
version-build-low @ version-build-high @ $10000 * + ;
62
75
63
- : .real- version ( -- )
76
+ : .version-x.y.z ( -- )
64
77
version-major @ .version-part '.' emit
65
78
version-minor @ .version-part '.' emit
66
- version-patch @ .version-part
79
+ version-patch @ .version-part ;
80
+ \ Print the version number using format "X.Y.Z".
81
+
82
+ : .version-0x.0y.0z ( -- )
83
+ ['] .version-part-00 is .version-part
84
+ .version-x.y.z ;
85
+
86
+ : .version-x.y.z-prerelease ( -- )
87
+ .version-x.y.z
67
88
version-prerelease @ ?dup if
68
89
version-prerelease-id @ case
69
- 'd' of ." -dev." .version-part endof
70
- 'p' of ." -pre." .version-part endof
90
+ 'd' of ." -dev." endof
91
+ 'p' of ." -pre." endof
71
92
'r' of ." -rc." endof
72
93
endcase .version-part
73
- then '+' emit build-date 0 .r ;
94
+ then ;
74
95
75
- : .version-part-00 ( n -- ) s>d <# # # #> type ;
76
- \ Print one part of the version number, with two digits,
77
- \ padded with zeros.
78
-
79
- : .simple-version ( -- )
80
- version-major @ .version-part-00 '.' emit
81
- version-minor @ .version-part-00 '.' emit
82
- version-patch @ .version-part-00 ;
83
- \ Print the version number using format "MM.mm.pp".
96
+ : .version-x.y.z-prerelease+build ( -- )
97
+ .version-x.y.z-prerelease '+' emit build-date 0 .r ;
84
98
85
99
: .version ( -- )
86
- real-format @ if .real-version else .simple-version then ;
100
+ format @ case
101
+ 0 of .version-0x.0y.0z endof
102
+ 1 of .version-x.y.z endof
103
+ 2 of .version-x.y.z-prerelease endof
104
+ 3 of .version-x.y.z-prerelease+build endof
105
+ endcase ;
87
106
88
107
\ ==============================================================
89
108
\ Parser
@@ -115,7 +134,7 @@ forth-wordlist set-current
115
134
\ ==============================================================
116
135
\ Main
117
136
118
- real- format ! parser-wordlist >order included .version bye
137
+ format ! parser-wordlist >order included .version bye
119
138
120
139
\ ==============================================================
121
140
\ Change log
@@ -132,4 +151,7 @@ real-format ! parser-wordlist >order included .version bye
132
151
\ 2017-07-26: Update to the new internal format of the version number.
133
152
\
134
153
\ 2020-10-01: Update to support dev/pre/rc prereleases.
154
+ \
155
+ \ 2020-10-02: Improve format selection from true/false to 0..3.
135
156
157
+ \ vim: filetype=gforth
0 commit comments