@@ -709,12 +709,60 @@ def _starlarkify_clang_attrs(repository_ctx, attrs):
709
709
710
710
# MARK: - System Library Targets
711
711
712
- # GH009(chuck): Remove unused-variable directives
713
-
714
- # buildifier: disable=unused-variable
715
712
def _system_library_build_file (target ):
716
- # GH009(chuck): Implement _system_library_build_file
717
- return None
713
+ # System libraries are typically C/Objc libraries that need to be exposed to Swift.
714
+ # We generate a cc_library with a swift_interop_hint for proper Swift interop.
715
+
716
+ bzl_target_name = target .label .name
717
+
718
+ # Build the cc_library attributes
719
+ attrs = {}
720
+
721
+ # For system libraries, sources is always empty. We need to use glob to find files.
722
+ # Look for all .h files in the target path
723
+ hdrs_glob = paths .join (target .path , "**/*.h" )
724
+
725
+ # System libraries typically have headers and a module.modulemap
726
+ # We'll use glob patterns to find them
727
+ attrs ["hdrs" ] = scg .new_fn_call ("glob" , [hdrs_glob ])
728
+
729
+ # Create swift_interop_hint for C/Swift interop
730
+ aspect_hint_target_name = pkginfo_targets .swift_hint_label_name (bzl_target_name )
731
+
732
+ load_stmts = [swift_interop_hint_load_stmt ]
733
+ decls = []
734
+
735
+ # Create the swift_interop_hint
736
+ decls .append (
737
+ build_decls .new (
738
+ kind = swift_kinds .interop_hint ,
739
+ name = aspect_hint_target_name ,
740
+ attrs = {
741
+ # For system libraries, we often don't have a module map file
742
+ # Set to None and let rules_swift generate one if needed
743
+ "module_map" : None ,
744
+ "module_name" : target .c99name ,
745
+ },
746
+ ),
747
+ )
748
+
749
+ # Add aspect_hints to cc_library
750
+ attrs ["aspect_hints" ] = [":{}" .format (aspect_hint_target_name )]
751
+ attrs ["visibility" ] = ["//visibility:public" ]
752
+
753
+ # Create the cc_library
754
+ decls .append (
755
+ build_decls .new (
756
+ kind = clang_kinds .library ,
757
+ name = bzl_target_name ,
758
+ attrs = attrs ,
759
+ ),
760
+ )
761
+
762
+ return build_files .new (
763
+ load_stmts = load_stmts ,
764
+ decls = decls ,
765
+ )
718
766
719
767
# MARK: - Apple xcframework Targets
720
768
0 commit comments