@@ -66,7 +66,7 @@ def _include_path(hdr):
6666
6767def new_cc_import (
6868 go ,
69- hdrs = _EMPTY_DEPSET ,
69+ hdr = None ,
7070 defines = _EMPTY_DEPSET ,
7171 local_defines = _EMPTY_DEPSET ,
7272 dynamic_library = None ,
@@ -77,8 +77,8 @@ def new_cc_import(
7777 compilation_context = cc_common .create_compilation_context (
7878 defines = defines ,
7979 local_defines = local_defines ,
80- headers = hdrs ,
81- includes = depset ([_include_path (hdr ) for hdr in hdrs . to_list () ]),
80+ headers = depset ([ hdr ]) ,
81+ includes = depset ([_include_path (hdr )]),
8282 ),
8383 linking_context = cc_common .create_linking_context (
8484 linker_inputs = depset ([
@@ -137,9 +137,7 @@ def _go_binary_impl(ctx):
137137 importable = False ,
138138 is_main = is_main ,
139139 )
140- name = ctx .attr .basename
141- if not name :
142- name = ctx .label .name
140+ name = ctx .attr .basename or ctx .label .name
143141 executable = None
144142 if ctx .attr .out :
145143 # Use declare_file instead of attr.output(). When users set output files
@@ -161,7 +159,7 @@ def _go_binary_impl(ctx):
161159 providers = [
162160 archive ,
163161 OutputGroupInfo (
164- cgo_exports = archive .cgo_exports ,
162+ cgo_exports = [ archive .cgo_export ] if archive . cgo_export else [] ,
165163 compilation_outputs = [archive .data .file ],
166164 nogo_fix = [nogo_diagnostics ] if nogo_diagnostics else [],
167165 _validation = [validation_output ] if validation_output else [],
@@ -202,14 +200,13 @@ def _go_binary_impl(ctx):
202200 "windows" : ["-mthreads" ],
203201 }.get (go .mode .goos , ["-pthread" ]),
204202 }
205- cgo_exports = archive .cgo_exports .to_list ()
206- if cgo_exports :
203+ if archive .cgo_export :
207204 header = ctx .actions .declare_file ("{}.h" .format (name ))
208205 ctx .actions .symlink (
209206 output = header ,
210- target_file = cgo_exports [ 0 ] ,
207+ target_file = archive . cgo_export ,
211208 )
212- cc_import_kwargs ["hdrs " ] = depset ([ header ])
209+ cc_import_kwargs ["hdr " ] = header
213210 if go .mode .linkmode == LINKMODE_C_SHARED :
214211 cc_import_kwargs ["dynamic_library" ] = executable
215212 elif go .mode .linkmode == LINKMODE_C_ARCHIVE :
0 commit comments