File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -201,13 +201,42 @@ No Starlark expression members were generated for {}\
201201
202202    return  scg .new_expr (* expr_members )
203203
204+ def  _unwrap_list (values , kind_handlers  =  {}):
205+     """Converts the provied values into unstructured types using the information in the \  
206+ 
207+ 
208+     Args: 
209+         values: A `list` of values that are processed and added to the output. 
210+         kind_handlers: A `dict` of king handler `struct` values 
211+             (`bzl_selects.new_kind_handler`). 
212+ 
213+     Returns: 
214+         A list where `struct` values are unwrapped 
215+     """ 
216+     result  =  []
217+     for  v  in  values :
218+         v_type  =  type (v )
219+         if  v_type  !=  "struct" :
220+             if  v_type  ==  "list" :
221+                 result .extend (v )
222+             else :
223+                 result .append (v )
224+             continue 
225+ 
226+         # We are assuming that the select will always result in a list. 
227+         # Hence, we wrap the transformed value in a list. 
228+         kind_handler  =  kind_handlers .get (v .kind , _noop_kind_handler )
229+         result .extend (lists .flatten (kind_handler .transform (v .value )))
230+     return  result 
231+ 
204232bzl_selects  =  struct (
205233    default_condition  =  _bazel_select_default_condition ,
206234    new  =  _new ,
207235    new_from_build_setting  =  _new_from_build_setting ,
208236    new_from_target_dependency_condition  =  _new_from_target_dependency_condition ,
209237    new_kind_handler  =  _new_kind_handler ,
210238    to_starlark  =  _to_starlark ,
239+     unwrap_list  =  _unwrap_list ,
211240)
212241
213242# NEED TO CONVERT: 
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ def _swift_target_build_file(pkg_ctx, target):
106106    if  len (defines ) >  0 :
107107        attrs ["defines" ] =  bzl_selects .to_starlark (defines )
108108    if  len (copts ) >  0 :
109-         attrs ["copts" ] =  bzl_selects .to_starlark (copts )
109+         attrs ["copts" ] =  bzl_selects .unwrap_list (copts )
110110
111111    res_build_file  =  _handle_target_resources (
112112        pkg_ctx ,
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments