@@ -132,31 +132,40 @@ for a particular version.
132132 },
133133)
134134
135- def _configure (config , * , platform , compatible_with , target_settings , urls = [], sha256 = "" , ** values ):
135+ def _configure (config , * , platform , compatible_with , target_settings , urls = [], sha256 = "" , override = False , ** values ):
136136 """Set the value in the config if the value is provided"""
137137 for key , value in values .items ():
138138 if not value :
139139 continue
140140
141+ if not override and config .get (key ):
142+ continue
143+
141144 config [key ] = value
142145
143146 config .setdefault ("platforms" , {})
144- if platform and not (compatible_with or target_settings or urls ):
145- config ["platforms" ].pop (platform )
146- elif platform :
147- if compatible_with or target_settings :
148- config ["platforms" ][platform ] = struct (
149- name = platform .replace ("-" , "_" ).lower (),
150- compatible_with = compatible_with ,
151- target_settings = target_settings ,
152- )
153- if urls :
154- config .setdefault ("urls" , {})[platform ] = struct (
155- sha256 = sha256 ,
156- urls = urls ,
157- )
147+ if not platform :
148+ if compatible_with or target_settings or urls :
149+ fail ("`platform` name must be specified when specifying `compatible_with`, `target_settings` or `urls`" )
158150 elif compatible_with or target_settings :
159- fail ("`platform` name must be specified when specifying `compatible_with` or `target_settings`" )
151+ if not override and config .get ("platforms" , {}).get (platform ):
152+ return
153+
154+ config ["platforms" ][platform ] = struct (
155+ name = platform .replace ("-" , "_" ).lower (),
156+ compatible_with = compatible_with ,
157+ target_settings = target_settings ,
158+ )
159+ elif urls :
160+ if not override and config .get ("urls" , {}).get (platform ):
161+ return
162+
163+ config .setdefault ("urls" , {})[platform ] = struct (
164+ sha256 = sha256 ,
165+ urls = urls ,
166+ )
167+ else :
168+ config ["platforms" ].pop (platform )
160169
161170def process_modules (
162171 module_ctx ,
@@ -205,6 +214,7 @@ def process_modules(
205214 platform = tag .platform ,
206215 compatible_with = tag .compatible_with ,
207216 target_settings = tag .target_settings ,
217+ override = mod .is_root ,
208218 )
209219
210220 for key in [
@@ -259,6 +269,7 @@ def process_modules(
259269 target_settings = tag .target_settings ,
260270 sha256 = tag .sha256 ,
261271 urls = tag .urls ,
272+ override = mod .is_root ,
262273 )
263274
264275 if not versions :
0 commit comments