9
9
import logging
10
10
import os
11
11
12
+ import glad .files
12
13
from glad .config import Config , ConfigOption
13
14
from glad .sink import LoggingSink
14
15
from glad .opener import URLOpener
@@ -48,7 +49,7 @@ class GlobalConfig(Config):
48
49
default = None ,
49
50
description = 'Path to a file containing a list of extensions or '
50
51
'a comma separated list of extensions, if missing '
51
- 'all possible extensions are included'
52
+ 'all possible extensions are included. '
52
53
)
53
54
MERGE = ConfigOption (
54
55
converter = bool ,
@@ -57,11 +58,17 @@ class GlobalConfig(Config):
57
58
)
58
59
QUIET = ConfigOption (
59
60
converter = bool ,
60
- description = 'Disable logging'
61
+ description = 'Disable logging.'
62
+ )
63
+ REPRODUCIBLE = ConfigOption (
64
+ converter = bool ,
65
+ default = False ,
66
+ description = 'Makes the build reproducible by not fetching the latest '
67
+ 'specification from Khronos.'
61
68
)
62
69
63
70
64
- def load_specifications (specification_names , opener , specification_classes = None ):
71
+ def load_specifications (specification_names , opener , specification_classes = None , reproducible = False ):
65
72
specifications = dict ()
66
73
67
74
if specification_classes is None :
@@ -71,7 +78,10 @@ def load_specifications(specification_names, opener, specification_classes=None)
71
78
Specification = specification_classes [name ]
72
79
xml_name = name + '.xml'
73
80
74
- if os .path .isfile (xml_name ):
81
+ if reproducible and False :
82
+ logger .info ('reproducible build, using packaged specification: %s' , xml_name )
83
+ specification = Specification .from_file (glad .files .open_local (xml_name ))
84
+ elif os .path .isfile (xml_name ):
75
85
logger .info ('using local specification: %s' , xml_name )
76
86
specification = Specification .from_file (xml_name , opener = opener )
77
87
else :
@@ -132,11 +142,15 @@ def main(args=None):
132
142
global_config .validate () # Done before, but doesn't hurt
133
143
config .validate ()
134
144
135
- opener = URLOpener ()
145
+ if global_config ['REPRODUCIBLE' ]:
146
+ opener = glad .files .StaticFileOpener ()
147
+ else :
148
+ opener = URLOpener ()
136
149
137
150
specifications = load_specifications (
138
151
[value [0 ] for value in global_config ['API' ].values ()],
139
- opener = opener
152
+ opener = opener ,
153
+ reproducible = global_config ['REPRODUCIBLE' ]
140
154
)
141
155
142
156
generator = generators [ns .subparser_name ](global_config ['OUT_PATH' ], opener = opener )
0 commit comments