From 3511b7b36c436170d46b48552c4e928488a4b42a Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 14 Jul 2024 15:18:53 -0600 Subject: [PATCH 01/21] Add c_language_standard and cxx_language_standard to pkginfo. --- swiftpkg/internal/pkginfos.bzl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/swiftpkg/internal/pkginfos.bzl b/swiftpkg/internal/pkginfos.bzl index 6fa956e00..81ef300be 100644 --- a/swiftpkg/internal/pkginfos.bzl +++ b/swiftpkg/internal/pkginfos.bzl @@ -624,6 +624,8 @@ def _new_from_parsed_json( targets = targets, url = url, version = version, + c_language_standard = dump_manifest.get("cLanguageStandard"), + cxx_language_standard = dump_manifest.get("cxxLanguageStandard"), ) # MARK: - Swift Package @@ -638,7 +640,9 @@ def _new( products = [], targets = [], url = None, - version = None): + version = None, + c_language_standard = None, + cxx_language_standard = None): """Returns a `struct` representing information about a Swift package. Args: @@ -657,6 +661,10 @@ def _new( `pkginfos.new_target()`. url: Optional. The url of the package (`string`). version: Optional. The semantic version of the package (`string`). + c_language_standard: Optional. The c language standard (e.g. `c99`, + `gnu99`, `c11`). + cxx_language_standard: Optional. The c++ language standard (e.g. + `c++11`, `c++20`). Returns: A `struct` representing information about a Swift package. @@ -672,6 +680,8 @@ def _new( targets = targets, url = url, version = version, + c_language_standard = c_language_standard, + cxx_language_standard = cxx_language_standard, ) # MARK: - Platform From f1c90ba7a68e162749ebfb07bb30391fea74369f Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 28 Jul 2024 11:12:21 -0700 Subject: [PATCH 02/21] Add utility functions to detect c++ code. --- swiftpkg/internal/clang_files.bzl | 10 +++++++++- swiftpkg/tests/clang_files_tests.bzl | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/swiftpkg/internal/clang_files.bzl b/swiftpkg/internal/clang_files.bzl index eb3de1283..6912e6e64 100644 --- a/swiftpkg/internal/clang_files.bzl +++ b/swiftpkg/internal/clang_files.bzl @@ -13,12 +13,15 @@ _PUBLIC_HDR_DIRNAMES = ["include", "public"] # https://bazel.build/reference/be/c-cpp#cc_library.srcs _HEADER_EXTS = [".h", ".hh", ".hpp", ".hxx", ".inl", ".H"] +# C++ source extensions +_CXX_SRCS_EXTS = [".cc", ".cpp"] + # Acceptable sources clang and objc: # https://bazel.build/reference/be/c-cpp#cc_library.srcs # https://bazel.build/reference/be/objective-c#objc_library.srcs # NOTE: From examples found so far, .inc files tend to include source, not # header declarations. -_SRC_EXTS = [".c", ".cc", ".cpp", ".S", ".so", ".o", ".m", ".mm", ".inc"] +_SRC_EXTS = [".c", ".S", ".so", ".o", ".m", ".mm", ".inc"] + _CXX_SRCS_EXTS def _is_hdr(path): _root, ext = paths.split_extension(path) @@ -323,10 +326,15 @@ def _collect_files( textual_hdrs = sorted(textual_hdrs), ) +def _is_cxx_src(path): + _root, ext = paths.split_extension(path) + return ext in _CXX_SRCS_EXTS + clang_files = struct( collect_files = _collect_files, find_magical_public_hdr_dir = _find_magical_public_hdr_dir, get_hdr_paths_from_modulemap = _get_hdr_paths_from_modulemap, + is_cxx_src = _is_cxx_src, is_hdr = _is_hdr, is_include_hdr = _is_include_hdr, is_public_modulemap = _is_public_modulemap, diff --git a/swiftpkg/tests/clang_files_tests.bzl b/swiftpkg/tests/clang_files_tests.bzl index 994145a2d..2b2f85c22 100644 --- a/swiftpkg/tests/clang_files_tests.bzl +++ b/swiftpkg/tests/clang_files_tests.bzl @@ -232,9 +232,27 @@ def _reduce_paths_test(ctx): reduce_paths_test = unittest.make(_reduce_paths_test) +def _is_cxx_src_test(ctx): + env = unittest.begin(ctx) + + tests = [ + struct(path = "foo.cc", exp = True, msg = ".cc"), + struct(path = "foo.cpp", exp = True, msg = ".cpp"), + struct(path = "foo", exp = False, msg = "no extension"), + struct(path = "foo.c", exp = False, msg = "wrong extension"), + ] + for t in tests: + actual = clang_files.is_cxx_src(t.path) + asserts.equals(env, t.exp, actual, t.msg) + + return unittest.end(env) + +is_cxx_src_test = unittest.make(_is_cxx_src_test) + def clang_files_test_suite(): return unittest.suite( "clang_files_tests", + is_cxx_src_test, is_hdr_test, is_include_hdr_test, is_public_modulemap_test, From 1bbcdedfc77a6c120cac264e52662b1699819561 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 4 Aug 2024 12:38:31 -0600 Subject: [PATCH 03/21] The interesting_deps example passes. --- examples/interesting_deps/.bazelrc | 4 +- swiftpkg/internal/clang_files.bzl | 46 +- swiftpkg/internal/pkginfos.bzl | 4 +- swiftpkg/internal/starlark_codegen.bzl | 6 + swiftpkg/internal/swiftpkg_build_files.bzl | 548 ++++++++++++++---- swiftpkg/tests/clang_files_tests.bzl | 32 +- swiftpkg/tests/swiftpkg_build_files_tests.bzl | 6 + 7 files changed, 529 insertions(+), 117 deletions(-) diff --git a/examples/interesting_deps/.bazelrc b/examples/interesting_deps/.bazelrc index 4f939dc08..a4f1d5fdd 100644 --- a/examples/interesting_deps/.bazelrc +++ b/examples/interesting_deps/.bazelrc @@ -7,5 +7,5 @@ import %workspace%/../../ci.bazelrc # Try to import a local.rc file; typically, written by CI try-import %workspace%/../../local.bazelrc -# Required by geos -build --cxxopt='-std=c++11' +# # Required by geos +# build --cxxopt='-std=c++11' diff --git a/swiftpkg/internal/clang_files.bzl b/swiftpkg/internal/clang_files.bzl index 6912e6e64..089335e1d 100644 --- a/swiftpkg/internal/clang_files.bzl +++ b/swiftpkg/internal/clang_files.bzl @@ -13,15 +13,27 @@ _PUBLIC_HDR_DIRNAMES = ["include", "public"] # https://bazel.build/reference/be/c-cpp#cc_library.srcs _HEADER_EXTS = [".h", ".hh", ".hpp", ".hxx", ".inl", ".H"] +# C source extensions +_C_SRC_EXTS = [".c"] + # C++ source extensions -_CXX_SRCS_EXTS = [".cc", ".cpp"] +_CXX_SRC_EXTS = [".cc", ".cpp"] + +# Objective-C source extensions +_OBJC_SRC_EXTS = [".m", ".mm"] + +# Assembly source extensions +_ASSEMBLY_SRC_EXTS = [".S"] + +# Sources that should be included when constructing other cc_xxx targets +_OTHER_SRC_EXTS = [".so", ".o", ".inc"] # Acceptable sources clang and objc: # https://bazel.build/reference/be/c-cpp#cc_library.srcs # https://bazel.build/reference/be/objective-c#objc_library.srcs # NOTE: From examples found so far, .inc files tend to include source, not # header declarations. -_SRC_EXTS = [".c", ".S", ".so", ".o", ".m", ".mm", ".inc"] + _CXX_SRCS_EXTS +_SRC_EXTS = _C_SRC_EXTS + _CXX_SRC_EXTS + _OBJC_SRC_EXTS + _ASSEMBLY_SRC_EXTS + _OTHER_SRC_EXTS def _is_hdr(path): _root, ext = paths.split_extension(path) @@ -326,19 +338,41 @@ def _collect_files( textual_hdrs = sorted(textual_hdrs), ) -def _is_cxx_src(path): - _root, ext = paths.split_extension(path) - return ext in _CXX_SRCS_EXTS +def _organize_srcs(srcs): + c_srcs = [] + cxx_srcs = [] + objc_srcs = [] + assembly_srcs = [] + other_srcs = [] + for src in srcs: + _root, ext = paths.split_extension(src) + if ext in _C_SRC_EXTS: + c_srcs.append(src) + elif ext in _CXX_SRC_EXTS: + cxx_srcs.append(src) + elif ext in _OBJC_SRC_EXTS: + objc_srcs.append(src) + elif ext in _ASSEMBLY_SRC_EXTS: + assembly_srcs.append(src) + else: + other_srcs.append(src) + return struct( + c_srcs = c_srcs, + cxx_srcs = cxx_srcs, + objc_srcs = objc_srcs, + assembly_srcs = assembly_srcs, + other_srcs = other_srcs, + ) clang_files = struct( collect_files = _collect_files, find_magical_public_hdr_dir = _find_magical_public_hdr_dir, get_hdr_paths_from_modulemap = _get_hdr_paths_from_modulemap, - is_cxx_src = _is_cxx_src, is_hdr = _is_hdr, is_include_hdr = _is_include_hdr, is_public_modulemap = _is_public_modulemap, is_under_path = _is_under_path, + organize_srcs = _organize_srcs, reduce_paths = _reduce_paths, relativize = _relativize, ) diff --git a/swiftpkg/internal/pkginfos.bzl b/swiftpkg/internal/pkginfos.bzl index 81ef300be..e5f2933f6 100644 --- a/swiftpkg/internal/pkginfos.bzl +++ b/swiftpkg/internal/pkginfos.bzl @@ -1175,6 +1175,8 @@ def _new_clang_src_info_from_sources( srcs = sets.to_list(srcs_set) explicit_srcs = sets.to_list(explicit_srcs_set) + # TODO(chuck): Can I remove explicit_srcs? I believe that it is obsolete. + return _new_clang_src_info( srcs = srcs, explicit_srcs = explicit_srcs, @@ -1194,7 +1196,7 @@ def _new_clang_src_info( private_includes = [], modulemap_path = None): return struct( - srcs = srcs, + organized_srcs = clang_files.organize_srcs(srcs), explicit_srcs = explicit_srcs, hdrs = hdrs, textual_hdrs = textual_hdrs, diff --git a/swiftpkg/internal/starlark_codegen.bzl b/swiftpkg/internal/starlark_codegen.bzl index d11d37f0a..b7e324ef0 100644 --- a/swiftpkg/internal/starlark_codegen.bzl +++ b/swiftpkg/internal/starlark_codegen.bzl @@ -102,6 +102,12 @@ def _process_complex_types(out): for v in out: v_type = type(v) + # # DEBUG BEGIN + # print("*** CHUCK ----") + # print("*** CHUCK v: ", v) + # print("*** CHUCK v_type: ", v_type) + # # DEBUG END + # Check for a with_indent struct and get its indent value and process # its wrapped value current_indent = 0 diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index f87f3d31f..40180897b 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -1,5 +1,6 @@ """Module for creating Bazel declarations to build a Swift package.""" +load("@bazel_skylib//lib:dicts.bzl", "dicts") load("@bazel_skylib//lib:paths.bzl", "paths") load("@cgrindel_bazel_starlib//bzllib:defs.bzl", "bazel_labels", "lists") load(":artifact_infos.bzl", "artifact_types", "link_types") @@ -220,47 +221,36 @@ def _swift_compiler_plugin_from_target(target, attrs): # MARK: - Clang Targets def _clang_target_build_file(repository_ctx, pkg_ctx, target): - all_build_files = [] clang_src_info = target.clang_src_info if clang_src_info == None: fail("Expected `clang_src_info` to not be None.") + all_build_files = [] - deps = lists.flatten([ - pkginfo_target_deps.bzl_select_list(pkg_ctx, td) - for td in target.dependencies - ]) + # These flags are used by SPM when compiling clang modules. + copts = [ + # Enable 'blocks' language feature + "-fblocks", + # Synthesize retain and release calls for Objective-C pointers + "-fobjc-arc", + # Enable support for PIC macros + "-fPIC", + # # Module name + # "-fmodule-name={}".format(target.c99name), + # The SWIFT_PACKAGE define is a magical value that SPM uses when it + # builds clang libraries that will be used as Swift modules. + "-DSWIFT_PACKAGE=1", + ] - attrs = { - # These flags are used by SPM when compiling clang modules. - "copts": [ - # Enable 'blocks' language feature - "-fblocks", - # Synthesize retain and release calls for Objective-C pointers - "-fobjc-arc", - # Enable support for PIC macros - "-fPIC", - # Module name - "-fmodule-name={}".format(target.c99name), - ], - "visibility": ["//:__subpackages__"], - } + def _if_not_empty(list_value, transform_fn = None): + if not list_value: + return None + return transform_fn(list_value) if transform_fn else list_value - def _set_if_not_empty(attr, list, transform_fn = None): - if len(list) > 0: - attrs[attr] = transform_fn(list) if transform_fn else list - - def _update_attr_list(name, value): - # We need to create a new list, because the retrieved list could be - # frozen. - attr_list = list(attrs.get(name, [])) - attr_list.append(value) - attrs[name] = attr_list - - _set_if_not_empty("deps", deps, bzl_selects.to_starlark) - _set_if_not_empty("hdrs", clang_src_info.hdrs) - _set_if_not_empty("srcs", clang_src_info.srcs) - _set_if_not_empty("includes", clang_src_info.public_includes) - _set_if_not_empty("textual_hdrs", clang_src_info.textual_hdrs) + # Do not add the srcs from the clang_src_info, yet. We will do that at the + # end of this function where we will create separate targets based upon the + # type of source file. + srcs = [] + data = [] if target.resources: clang_apple_res_bundle_info = _apple_resource_bundle_for_clang( @@ -268,7 +258,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): target, ) all_build_files.append(clang_apple_res_bundle_info.build_file) - _update_attr_list("data", ":{}".format( + data.append(":{}".format( clang_apple_res_bundle_info.bundle_label_name, )) if clang_apple_res_bundle_info.objc_accessor_hdr_label_name: @@ -277,23 +267,17 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): # to be available in every Objc source file. So, we specify the # -include flag specifying the header path. # https://github.com/apple/swift-package-manager/blob/8387798811c6cc43761c5e1b48df2d3412dc5de4/Sources/Build/BuildDescription/ClangTargetBuildDescription.swift#L390 - _update_attr_list("srcs", ":{}".format( - clang_apple_res_bundle_info.objc_accessor_hdr_label_name, - )) - _update_attr_list("copts", "-include$(location :{})".format( + srcs.extend([ + ":{}".format( + clang_apple_res_bundle_info.objc_accessor_hdr_label_name, + ), + ":{}".format( + clang_apple_res_bundle_info.objc_accessor_impl_label_name, + ), + ]) + copts.append("-include$(location :{})".format( clang_apple_res_bundle_info.objc_accessor_hdr_label_name, )) - _update_attr_list("srcs", ":{}".format( - clang_apple_res_bundle_info.objc_accessor_impl_label_name, - )) - - # The copts may be updated by functions that were executed before this - # point. Use whatever has been set. - copts = attrs.get("copts", []) - - # The SWIFT_PACKAGE define is a magical value that SPM uses when it - # builds clang libraries that will be used as Swift modules. - copts.append("-DSWIFT_PACKAGE=1") local_includes = [ bzl_selects.new(value = p, kind = _condition_kinds.private_includes) @@ -340,6 +324,8 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): for bs in settings.unsafe_flags ])) + copts.extend(local_includes) + linkopts = [] if target.linker_settings != None: linkopts.extend(lists.flatten([ @@ -351,46 +337,24 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): for bs in target.linker_settings.linked_frameworks ])) - if len(linkopts) > 0: - attrs["linkopts"] = bzl_selects.to_starlark( - linkopts, - kind_handlers = { - _condition_kinds.linked_library: bzl_selects.new_kind_handler( - transform = lambda ll: "-l{}".format(ll), - ), - _condition_kinds.linked_framework: bzl_selects.new_kind_handler( - transform = lambda f: "-framework {}".format(f), - ), - }, - ) - - # Short path relative to Bazel output base. This is typically used when - # adding a path to a copt or linkeropt. - ext_repo_path = paths.join("external", repository_ctx.name) - - copts.extend(local_includes) + # Assemble attributes - # The `includes` attribute adds includes as -isystem which propagates - # to cc_XXX that depend upon the library. Providing includes as -I - # only provides the includes for this target. - # https://bazel.build/reference/be/c-cpp#cc_library.includes - def _local_includes_transform(p): - # Normalize the path and replace spaces with an escape sequence. - normalized = paths.normalize(paths.join(ext_repo_path, p)) - normalized = normalized.replace(" ", "\\ ") - return "-I{}".format(normalized) + attrs = { + "copts": copts, + "hdrs": _if_not_empty(clang_src_info.hdrs), + "includes": _if_not_empty(clang_src_info.public_includes), + "srcs": srcs, + "textual_hdrs": _if_not_empty(clang_src_info.textual_hdrs), + "visibility": ["//:__subpackages__"], + } + deps = lists.flatten([ + pkginfo_target_deps.bzl_select_list(pkg_ctx, td) + for td in target.dependencies + ]) + if deps: + attrs["deps"] = deps - attrs["copts"] = bzl_selects.to_starlark( - copts, - kind_handlers = { - _condition_kinds.header_search_path: bzl_selects.new_kind_handler( - transform = _local_includes_transform, - ), - _condition_kinds.private_includes: bzl_selects.new_kind_handler( - transform = _local_includes_transform, - ), - }, - ) + # Generate cc_xxx and objc_xxx targets. bzl_target_name = target.label.name @@ -400,6 +364,12 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): attrs["enable_modules"] = True attrs["module_name"] = target.c99name + attrs["srcs"] = lists.flatten([ + clang_src_info.organized_srcs.objc_srcs, + clang_src_info.organized_srcs.other_srcs, + attrs.get("srcs", []), + ]) + sdk_framework_bzl_selects = [] for sf in target.objc_src_info.builtin_frameworks: platform_conditions = bazel_apple_platforms.for_framework(sf) @@ -411,9 +381,12 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): condition = pc, ), ) - attrs["sdk_frameworks"] = bzl_selects.to_starlark( - sdk_framework_bzl_selects, - ) + attrs["sdk_frameworks"] = sdk_framework_bzl_selects + # attrs["sdk_frameworks"] = bzl_selects.to_starlark( + # sdk_framework_bzl_selects, + # ) + + attrs["copts"].append("-fmodule-name={}".format(target.c99name)) # There is a known issue with Objective-C library targets not # supporting the `@import` of modules defined in other Objective-C @@ -434,7 +407,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): # See `generate_modulemap.bzl` for details on the modulemap generation. # See `//swiftpkg/tests/generate_modulemap_tests` package for a usage # example. - modulemap_deps = _collect_modulemap_deps(deps) + modulemap_deps = _collect_modulemap_deps(attrs.get("deps", [])) load_stmts = [swiftpkg_generate_modulemap_load_stmt] modulemap_target_name = pkginfo_targets.modulemap_label_name(bzl_target_name) noop_modulemap = clang_src_info.modulemap_path != None @@ -446,7 +419,11 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): "visibility": ["//:__subpackages__"], } decls = [ - build_decls.new(objc_kinds.library, bzl_target_name, attrs = attrs), + build_decls.new( + objc_kinds.library, + bzl_target_name, + attrs = _starlarkify_clang_attrs(repository_ctx, attrs), + ), build_decls.new( kind = swiftpkg_kinds.generate_modulemap, name = modulemap_target_name, @@ -454,20 +431,91 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): ), ] else: - load_stmts = [swift_interop_hint_load_stmt] aspect_hint_target_name = pkginfo_targets.swift_hint_label_name( bzl_target_name, ) - attrs["aspect_hints"] = [":{}".format(aspect_hint_target_name)] aspect_hint_attrs = {"module_name": target.c99name} + + load_stmts = [swift_interop_hint_load_stmt] decls = [ - build_decls.new(clang_kinds.library, bzl_target_name, attrs = attrs), build_decls.new( kind = swift_kinds.interop_hint, name = aspect_hint_target_name, attrs = aspect_hint_attrs, ), ] + + child_dep_names = [] + if clang_src_info.organized_srcs.c_srcs: + c_name = "{}_c".format(bzl_target_name) + child_dep_names.append(c_name) + c_attrs = dict(**attrs) + c_attrs["srcs"] = lists.flatten([ + clang_src_info.organized_srcs.c_srcs, + clang_src_info.organized_srcs.other_srcs, + attrs.get("srcs", []), + ]) + decls.append( + build_decls.new( + clang_kinds.library, + c_name, + attrs = _starlarkify_clang_attrs(repository_ctx, c_attrs), + ), + ) + + if clang_src_info.organized_srcs.cxx_srcs: + cxx_name = "{}_cxx".format(bzl_target_name) + child_dep_names.append(cxx_name) + cxx_attrs = dict(**attrs) + cxx_attrs["srcs"] = lists.flatten([ + clang_src_info.organized_srcs.cxx_srcs, + clang_src_info.organized_srcs.other_srcs, + attrs.get("srcs", []), + ]) + decls.append( + build_decls.new( + clang_kinds.library, + cxx_name, + attrs = _starlarkify_clang_attrs(repository_ctx, cxx_attrs), + ), + ) + + if clang_src_info.organized_srcs.assembly_srcs: + assembly_name = "{}_assembly".format(bzl_target_name) + child_dep_names.append(assembly_name) + assembly_attrs = dict(**attrs) + assembly_attrs["srcs"] = lists.flatten([ + clang_src_info.organized_srcs.assembly_srcs, + clang_src_info.organized_srcs.other_srcs, + attrs.get("srcs", []), + ]) + decls.append( + build_decls.new( + clang_kinds.library, + assembly_name, + attrs = _starlarkify_clang_attrs(repository_ctx, assembly_attrs), + ), + ) + + # Add the cc_library that brings all of the child targets together. + uber_attrs = dicts.omit(attrs, ["srcs"]) | { + "aspect_hints": [":{}".format(aspect_hint_target_name)], + "deps": [ + ":{}".format(dname) + for dname in child_dep_names + ], + } + copts = uber_attrs.get("copts", []) + copts.append("-fmodule-name={}".format(target.c99name)) + uber_attrs["copts"] = copts + decls.append( + build_decls.new( + clang_kinds.library, + bzl_target_name, + attrs = _starlarkify_clang_attrs(repository_ctx, uber_attrs), + ), + ) + all_build_files.append(build_files.new( load_stmts = load_stmts, decls = decls, @@ -475,6 +523,312 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): return build_files.merge(*all_build_files) +def _starlarkify_clang_attrs(repository_ctx, attrs): + attrs = dict(**attrs) + + deps = attrs.get("deps") + if deps: + attrs["deps"] = bzl_selects.to_starlark(deps) + + # Short path relative to Bazel output base. This is typically used when + # adding a path to a copt or linkeropt. + ext_repo_path = paths.join("external", repository_ctx.name) + + # The `includes` attribute adds includes as -isystem which propagates + # to cc_XXX that depend upon the library. Providing includes as -I + # only provides the includes for this target. + # https://bazel.build/reference/be/c-cpp#cc_library.includes + def _local_includes_transform(p): + # Normalize the path and replace spaces with an escape sequence. + normalized = paths.normalize(paths.join(ext_repo_path, p)) + normalized = normalized.replace(" ", "\\ ") + return "-I{}".format(normalized) + + copts = attrs.get("copts") + if copts: + attrs["copts"] = bzl_selects.to_starlark( + copts, + kind_handlers = { + _condition_kinds.header_search_path: bzl_selects.new_kind_handler( + transform = _local_includes_transform, + ), + _condition_kinds.private_includes: bzl_selects.new_kind_handler( + transform = _local_includes_transform, + ), + }, + ) + + linkopts = attrs.get("linkopts") + if linkopts: + attrs["linkopts"] = bzl_selects.to_starlark( + linkopts, + kind_handlers = { + _condition_kinds.linked_library: bzl_selects.new_kind_handler( + transform = lambda ll: "-l{}".format(ll), + ), + _condition_kinds.linked_framework: bzl_selects.new_kind_handler( + transform = lambda f: "-framework {}".format(f), + ), + }, + ) + + sdk_frameworks = attrs.get("sdk_frameworks") + if sdk_frameworks: + attrs["sdk_frameworks"] = bzl_selects.to_starlark( + sdk_frameworks, + ) + + return attrs + +#def _clang_target_build_file(repository_ctx, pkg_ctx, target): +# all_build_files = [] +# clang_src_info = target.clang_src_info +# if clang_src_info == None: +# fail("Expected `clang_src_info` to not be None.") + +# deps = lists.flatten([ +# pkginfo_target_deps.bzl_select_list(pkg_ctx, td) +# for td in target.dependencies +# ]) + +# attrs = { +# # These flags are used by SPM when compiling clang modules. +# "copts": [ +# # Enable 'blocks' language feature +# "-fblocks", +# # Synthesize retain and release calls for Objective-C pointers +# "-fobjc-arc", +# # Enable support for PIC macros +# "-fPIC", +# # Module name +# "-fmodule-name={}".format(target.c99name), +# ], +# "visibility": ["//:__subpackages__"], +# } + +# def _set_if_not_empty(attr, list, transform_fn = None): +# if len(list) > 0: +# attrs[attr] = transform_fn(list) if transform_fn else list + +# _set_if_not_empty("deps", deps, bzl_selects.to_starlark) +# _set_if_not_empty("hdrs", clang_src_info.hdrs) +# _set_if_not_empty("srcs", clang_src_info.srcs) +# _set_if_not_empty("includes", clang_src_info.public_includes) +# _set_if_not_empty("textual_hdrs", clang_src_info.textual_hdrs) + +# res_build_file = _handle_target_resources( +# pkg_ctx, +# target, +# attrs, +# include_swift_accessor = False, +# include_objc_accessor = (target.objc_src_info != None), +# ) + +# if res_build_file: +# all_build_files.append(res_build_file) + +# # The copts may be updated by functions that were executed before this +# # point. Use whatever has been set. +# copts = attrs.get("copts", []) + +# # The SWIFT_PACKAGE define is a magical value that SPM uses when it +# # builds clang libraries that will be used as Swift modules. +# copts.append("-DSWIFT_PACKAGE=1") + +# # DEBUG BEGIN +# print("*** CHUCK ===================") +# print("*** CHUCK target.name: ", target.name) +# print("*** CHUCK pkg_ctx.pkg_info.c_language_standard: ", pkg_ctx.pkg_info.c_language_standard) +# print("*** CHUCK pkg_ctx.pkg_info.cxx_language_standard: ", pkg_ctx.pkg_info.cxx_language_standard) +# # print("*** CHUCK clang_src_info.is_cxx: ", clang_src_info.is_cxx) +# # DEBUG END + +# # pkg_info = pkg_ctx.pkg_info +# # if pkg_info.cxx_language_standard and clang_src_info.is_cxx: +# # copts.append("-std={}".format(pkg_info.cxx_language_standard)) +# # elif pkg_info.c_language_standard and not clang_src_info.is_cxx: +# # copts.append("-std={}".format(pkg_info.c_language_standard)) + +# local_includes = [ +# bzl_selects.new(value = p, kind = _condition_kinds.private_includes) +# for p in clang_src_info.private_includes +# ] + +# def _normalize_and_create_copt_define(value): +# normalized = scg.normalize_define_value(value) +# return "-D" + normalized + +# all_settings = lists.compact([target.clang_settings, target.cxx_settings]) +# for settings in all_settings: +# copts.extend(lists.flatten([ +# bzl_selects.new_from_build_setting( +# bs, +# # Define values can contain spaces. Bazel requires that they +# # are already escaped. +# values_map_fn = _normalize_and_create_copt_define, +# ) +# for bs in settings.defines +# ])) + +# # Need to convert the headerSearchPaths to be relative to the +# # target path. We also do not want to lose any conditions that may +# # be attached. +# hsp_bss = [ +# pkginfos.new_build_setting( +# kind = bs.kind, +# values = [ +# paths.join(target.path, p) +# for p in bs.values +# ], +# condition = bs.condition, +# ) +# for bs in settings.hdr_srch_paths +# ] +# local_includes.extend(lists.flatten([ +# bzl_selects.new_from_build_setting(bs) +# for bs in hsp_bss +# ])) + +# copts.extend(lists.flatten([ +# bzl_selects.new_from_build_setting(bs) +# for bs in settings.unsafe_flags +# ])) + +# linkopts = [] +# if target.linker_settings != None: +# linkopts.extend(lists.flatten([ +# bzl_selects.new_from_build_setting(bs) +# for bs in target.linker_settings.linked_libraries +# ])) +# linkopts.extend(lists.flatten([ +# bzl_selects.new_from_build_setting(bs) +# for bs in target.linker_settings.linked_frameworks +# ])) + +# if len(linkopts) > 0: +# attrs["linkopts"] = bzl_selects.to_starlark( +# linkopts, +# kind_handlers = { +# _condition_kinds.linked_library: bzl_selects.new_kind_handler( +# transform = lambda ll: "-l{}".format(ll), +# ), +# _condition_kinds.linked_framework: bzl_selects.new_kind_handler( +# transform = lambda f: "-framework {}".format(f), +# ), +# }, +# ) + +# # Short path relative to Bazel output base. This is typically used when +# # adding a path to a copt or linkeropt. +# ext_repo_path = paths.join("external", repository_ctx.name) + +# copts.extend(local_includes) + +# # The `includes` attribute adds includes as -isystem which propagates +# # to cc_XXX that depend upon the library. Providing includes as -I +# # only provides the includes for this target. +# # https://bazel.build/reference/be/c-cpp#cc_library.includes +# def _local_includes_transform(p): +# # Normalize the path and replace spaces with an escape sequence. +# normalized = paths.normalize(paths.join(ext_repo_path, p)) +# normalized = normalized.replace(" ", "\\ ") +# return "-I{}".format(normalized) + +# attrs["copts"] = bzl_selects.to_starlark( +# copts, +# kind_handlers = { +# _condition_kinds.header_search_path: bzl_selects.new_kind_handler( +# transform = _local_includes_transform, +# ), +# _condition_kinds.private_includes: bzl_selects.new_kind_handler( +# transform = _local_includes_transform, +# ), +# }, +# ) + +# bzl_target_name = target.label.name + +# if target.objc_src_info != None: +# # Enable clang module support. +# # https://bazel.build/reference/be/objective-c#objc_library.enable_modules +# attrs["enable_modules"] = True +# attrs["module_name"] = target.c99name + +# sdk_framework_bzl_selects = [] +# for sf in target.objc_src_info.builtin_frameworks: +# platform_conditions = bazel_apple_platforms.for_framework(sf) +# for pc in platform_conditions: +# sdk_framework_bzl_selects.append( +# bzl_selects.new( +# value = sf, +# kind = _condition_kinds.sdk_frameworks, +# condition = pc, +# ), +# ) +# attrs["sdk_frameworks"] = bzl_selects.to_starlark( +# sdk_framework_bzl_selects, +# ) + +# # There is a known issue with Objective-C library targets not +# # supporting the `@import` of modules defined in other Objective-C +# # targets. As a workaround, we will define two targets. One is the +# # `objc_library` target. The other is a `generate_modulemap` +# # target. This second target generates a `module.modulemap` file and +# # provides information about that generated file to `objc_library` +# # targets, if `noop` is `False`. If `noop` is `True`, the target +# # generates nothing and returns "empty" providers. +# # +# # Why not skip adding the `generate_modulemap` if `noop` is `True`? +# # The logic that assigns dependencies for other targets has no way to +# # know whether the modulemap target exists. Hence, we ensure that it +# # always exists but does nothing. +# # +# # See `pkginfo_target_deps.bzl` for the logic that resolves the +# # dependency labels. +# # See `generate_modulemap.bzl` for details on the modulemap generation. +# # See `//swiftpkg/tests/generate_modulemap_tests` package for a usage +# # example. +# modulemap_deps = _collect_modulemap_deps(deps) +# load_stmts = [swiftpkg_generate_modulemap_load_stmt] +# modulemap_target_name = pkginfo_targets.modulemap_label_name(bzl_target_name) +# noop_modulemap = clang_src_info.modulemap_path != None +# modulemap_attrs = { +# "deps": bzl_selects.to_starlark(modulemap_deps), +# "hdrs": clang_src_info.hdrs, +# "module_name": target.c99name, +# "noop": noop_modulemap, +# "visibility": ["//:__subpackages__"], +# } +# decls = [ +# build_decls.new(objc_kinds.library, bzl_target_name, attrs = attrs), +# build_decls.new( +# kind = swiftpkg_kinds.generate_modulemap, +# name = modulemap_target_name, +# attrs = modulemap_attrs, +# ), +# ] +# else: +# load_stmts = [swift_interop_hint_load_stmt] +# aspect_hint_target_name = pkginfo_targets.swift_hint_label_name( +# bzl_target_name, +# ) +# attrs["aspect_hints"] = [":{}".format(aspect_hint_target_name)] +# aspect_hint_attrs = {"module_name": target.c99name} +# decls = [ +# build_decls.new(clang_kinds.library, bzl_target_name, attrs = attrs), +# build_decls.new( +# kind = swift_kinds.interop_hint, +# name = aspect_hint_target_name, +# attrs = aspect_hint_attrs, +# ), +# ] +# all_build_files.append(build_files.new( +# load_stmts = load_stmts, +# decls = decls, +# )) + +# return build_files.merge(*all_build_files) + # MARK: - System Library Targets # GH009(chuck): Remove unused-variable directives diff --git a/swiftpkg/tests/clang_files_tests.bzl b/swiftpkg/tests/clang_files_tests.bzl index 2b2f85c22..26145e363 100644 --- a/swiftpkg/tests/clang_files_tests.bzl +++ b/swiftpkg/tests/clang_files_tests.bzl @@ -232,27 +232,37 @@ def _reduce_paths_test(ctx): reduce_paths_test = unittest.make(_reduce_paths_test) -def _is_cxx_src_test(ctx): +def _organize_srcs_test(ctx): env = unittest.begin(ctx) - tests = [ - struct(path = "foo.cc", exp = True, msg = ".cc"), - struct(path = "foo.cpp", exp = True, msg = ".cpp"), - struct(path = "foo", exp = False, msg = "no extension"), - struct(path = "foo.c", exp = False, msg = "wrong extension"), + srcs = [ + "foo.cc", + "foo.c", + "foo.inc", + "foo.cpp", + "foo.m", + "foo.so", + "foo.mm", + "foo.o", + "foo.S", ] - for t in tests: - actual = clang_files.is_cxx_src(t.path) - asserts.equals(env, t.exp, actual, t.msg) + actual = clang_files.organize_srcs(srcs) + expected = struct( + c_srcs = ["foo.c"], + cxx_srcs = ["foo.cc", "foo.cpp"], + objc_srcs = ["foo.m", "foo.mm"], + other_srcs = ["foo.inc", "foo.so", "foo.o", "foo.S"], + ) + asserts.equals(env, expected, actual) return unittest.end(env) -is_cxx_src_test = unittest.make(_is_cxx_src_test) +organize_srcs_test = unittest.make(_organize_srcs_test) def clang_files_test_suite(): return unittest.suite( "clang_files_tests", - is_cxx_src_test, + organize_srcs_test, is_hdr_test, is_include_hdr_test, is_public_modulemap_test, diff --git a/swiftpkg/tests/swiftpkg_build_files_tests.bzl b/swiftpkg/tests/swiftpkg_build_files_tests.bzl index cd4b23b4f..e4cb03c13 100644 --- a/swiftpkg/tests/swiftpkg_build_files_tests.bzl +++ b/swiftpkg/tests/swiftpkg_build_files_tests.bzl @@ -964,6 +964,12 @@ resource_bundle_infoplist( for path, result in getattr(t, "is_directory", {}).items() }, ) + + # DEBUG BEGIN + print("*** CHUCK =======================") + print("*** CHUCK t.name: ", t.name) + + # DEBUG END actual = scg.to_starlark( swiftpkg_build_files.new_for_target(repository_ctx, _pkg_ctx, target), ) From 16bec219cab2f38b354c35df02c8b4416ece289b Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 4 Aug 2024 14:21:51 -0600 Subject: [PATCH 04/21] The resources_example works. --- .../Tests/MyAppTests/MyAppTests.swift | 23 +++++----- swiftpkg/internal/starlark_codegen.bzl | 44 +++++++++++++++---- swiftpkg/internal/swiftpkg_build_files.bzl | 19 +++++--- 3 files changed, 59 insertions(+), 27 deletions(-) diff --git a/examples/resources_example/Tests/MyAppTests/MyAppTests.swift b/examples/resources_example/Tests/MyAppTests/MyAppTests.swift index e5b8af9ee..dbac171db 100644 --- a/examples/resources_example/Tests/MyAppTests/MyAppTests.swift +++ b/examples/resources_example/Tests/MyAppTests/MyAppTests.swift @@ -11,27 +11,26 @@ class MyAppTests: XCTestCase { XCTAssertNotNil(actual) } - func test_CoolStuff_bundleName() { let bundle = Bundle.bundle(named: "package-with-resources_CoolUI") XCTAssertNotNil(bundle) } - + func test_AppLovinSDKResources() throws { let url = ALResourceManager.resourceBundleURL XCTAssertNotNil(url) } - + func test_IterableDataModel() throws { // Log Iterable messages to an array class LogDelegate: IterableLogDelegate { var messages: [String] = [] - - func log(level: LogLevel, message: String) { + + func log(level _: LogLevel, message: String) { messages.append(message) } } - + let logDelegate = LogDelegate() IterableLogUtil.sharedInstance = IterableLogUtil( dateProvider: SystemDateProvider(), @@ -41,14 +40,14 @@ class MyAppTests: XCTestCase { // Create the persistence container from the bundled CoreData model let container: PersistentContainer? = PersistentContainer.initialize() XCTAssertNotNil(container) - + // Assert that the persistence container was successfully created let lastMessage = try XCTUnwrap(logDelegate.messages.last) XCTAssert( lastMessage.contains("Successfully loaded persistent store at:"), "Expected success log message. Found: \(logDelegate.messages.last ?? "nil")" ) - + IterableLogUtil.sharedInstance = nil } } @@ -60,18 +59,18 @@ extension Foundation.Bundle { let candidates = [ // Bundle should be present here when the package is linked into an App. Bundle.main.resourceURL, - + // Bundle should be present here when the package is linked into a framework. Bundle(for: BundleFinder.self).resourceURL, - + // For command-line tools. Bundle.main.bundleURL, - + // Bundle should be present here when running previews from a different package (this is the path to "…/Debug-iphonesimulator/"). Bundle(for: BundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent(), Bundle(for: BundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent(), ] - + for candidate in candidates { let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle") if let bundle = bundlePath.flatMap(Bundle.init(url:)) { diff --git a/swiftpkg/internal/starlark_codegen.bzl b/swiftpkg/internal/starlark_codegen.bzl index b7e324ef0..0364ded60 100644 --- a/swiftpkg/internal/starlark_codegen.bzl +++ b/swiftpkg/internal/starlark_codegen.bzl @@ -97,16 +97,28 @@ def _to_starlark(val): fail("Failed to finish processing starlark for value: {}".format(val)) def _process_complex_types(out): + def _fail_with_orig_out(msg): + def _pad_str(width, value): + value = str(value) + val_len = len(value) + if val_len >= width: + return value + padding = width - val_len + return " " * padding + value + + # buildifier: disable=print + print("*** DEBUG _process_complet_types out: ") + for idx, item in enumerate(out): + # buildifier: disable=print + print("*** DEBUG", _pad_str(3, idx), ":", _pad_str(7, type(item)), ":", item) + fail(msg) + finished = True new_out = [] - for v in out: - v_type = type(v) - # # DEBUG BEGIN - # print("*** CHUCK ----") - # print("*** CHUCK v: ", v) - # print("*** CHUCK v_type: ", v_type) - # # DEBUG END + # for v in out: + for idx, v in enumerate(out): + v_type = type(v) # Check for a with_indent struct and get its indent value and process # its wrapped value @@ -133,10 +145,24 @@ def _process_complex_types(out): elif v_type == "struct": to_starlark_fn = getattr(v, "to_starlark_parts", None) if to_starlark_fn == None: - fail("Starlark code gen received a struct without a to_starlark_parts function.", v) + _fail_with_orig_out( + """\ +Starlark code gen received a struct without a to_starlark_parts function. \ +idx: {idx}, v: {v}\ +""".format( + idx = idx, + v = v, + ), + ) new_out.extend(to_starlark_fn(v, current_indent)) else: - fail("Starlark code gen received an unsupported type.", v_type, v) + _fail_with_orig_out("""\ +Starlark code gen received an unsupported type. idx: {idx}, v_type: {v_type}, v: {v}\ +""".format( + idx = idx, + v_type = v_type, + v = v, + )) return new_out, finished diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index 40180897b..4dc6c21e4 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -226,6 +226,11 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): fail("Expected `clang_src_info` to not be None.") all_build_files = [] + # # DEBUG BEGIN + # print("*** CHUCK ===================") + # print("*** CHUCK target.name: ", target.name) + # # DEBUG END + # These flags are used by SPM when compiling clang modules. copts = [ # Enable 'blocks' language feature @@ -341,18 +346,23 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): attrs = { "copts": copts, - "hdrs": _if_not_empty(clang_src_info.hdrs), - "includes": _if_not_empty(clang_src_info.public_includes), "srcs": srcs, - "textual_hdrs": _if_not_empty(clang_src_info.textual_hdrs), "visibility": ["//:__subpackages__"], } + if clang_src_info.hdrs: + attrs["hdrs"] = clang_src_info.hdrs + if clang_src_info.public_includes: + attrs["includes"] = clang_src_info.public_includes + if clang_src_info.textual_hdrs: + attrs["textual_hdrs"] = clang_src_info.textual_hdrs deps = lists.flatten([ pkginfo_target_deps.bzl_select_list(pkg_ctx, td) for td in target.dependencies ]) if deps: attrs["deps"] = deps + if data: + attrs["data"] = data # Generate cc_xxx and objc_xxx targets. @@ -382,9 +392,6 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): ), ) attrs["sdk_frameworks"] = sdk_framework_bzl_selects - # attrs["sdk_frameworks"] = bzl_selects.to_starlark( - # sdk_framework_bzl_selects, - # ) attrs["copts"].append("-fmodule-name={}".format(target.c99name)) From 74cc5e11b9ddec1cc3811740aa90365c63e1fc02 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 4 Aug 2024 14:26:29 -0600 Subject: [PATCH 05/21] Remove debug comments --- swiftpkg/internal/swiftpkg_build_files.bzl | 254 ------------------ swiftpkg/tests/swiftpkg_build_files_tests.bzl | 6 - 2 files changed, 260 deletions(-) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index 4dc6c21e4..b8c1c20fb 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -226,11 +226,6 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): fail("Expected `clang_src_info` to not be None.") all_build_files = [] - # # DEBUG BEGIN - # print("*** CHUCK ===================") - # print("*** CHUCK target.name: ", target.name) - # # DEBUG END - # These flags are used by SPM when compiling clang modules. copts = [ # Enable 'blocks' language feature @@ -587,255 +582,6 @@ def _starlarkify_clang_attrs(repository_ctx, attrs): return attrs -#def _clang_target_build_file(repository_ctx, pkg_ctx, target): -# all_build_files = [] -# clang_src_info = target.clang_src_info -# if clang_src_info == None: -# fail("Expected `clang_src_info` to not be None.") - -# deps = lists.flatten([ -# pkginfo_target_deps.bzl_select_list(pkg_ctx, td) -# for td in target.dependencies -# ]) - -# attrs = { -# # These flags are used by SPM when compiling clang modules. -# "copts": [ -# # Enable 'blocks' language feature -# "-fblocks", -# # Synthesize retain and release calls for Objective-C pointers -# "-fobjc-arc", -# # Enable support for PIC macros -# "-fPIC", -# # Module name -# "-fmodule-name={}".format(target.c99name), -# ], -# "visibility": ["//:__subpackages__"], -# } - -# def _set_if_not_empty(attr, list, transform_fn = None): -# if len(list) > 0: -# attrs[attr] = transform_fn(list) if transform_fn else list - -# _set_if_not_empty("deps", deps, bzl_selects.to_starlark) -# _set_if_not_empty("hdrs", clang_src_info.hdrs) -# _set_if_not_empty("srcs", clang_src_info.srcs) -# _set_if_not_empty("includes", clang_src_info.public_includes) -# _set_if_not_empty("textual_hdrs", clang_src_info.textual_hdrs) - -# res_build_file = _handle_target_resources( -# pkg_ctx, -# target, -# attrs, -# include_swift_accessor = False, -# include_objc_accessor = (target.objc_src_info != None), -# ) - -# if res_build_file: -# all_build_files.append(res_build_file) - -# # The copts may be updated by functions that were executed before this -# # point. Use whatever has been set. -# copts = attrs.get("copts", []) - -# # The SWIFT_PACKAGE define is a magical value that SPM uses when it -# # builds clang libraries that will be used as Swift modules. -# copts.append("-DSWIFT_PACKAGE=1") - -# # DEBUG BEGIN -# print("*** CHUCK ===================") -# print("*** CHUCK target.name: ", target.name) -# print("*** CHUCK pkg_ctx.pkg_info.c_language_standard: ", pkg_ctx.pkg_info.c_language_standard) -# print("*** CHUCK pkg_ctx.pkg_info.cxx_language_standard: ", pkg_ctx.pkg_info.cxx_language_standard) -# # print("*** CHUCK clang_src_info.is_cxx: ", clang_src_info.is_cxx) -# # DEBUG END - -# # pkg_info = pkg_ctx.pkg_info -# # if pkg_info.cxx_language_standard and clang_src_info.is_cxx: -# # copts.append("-std={}".format(pkg_info.cxx_language_standard)) -# # elif pkg_info.c_language_standard and not clang_src_info.is_cxx: -# # copts.append("-std={}".format(pkg_info.c_language_standard)) - -# local_includes = [ -# bzl_selects.new(value = p, kind = _condition_kinds.private_includes) -# for p in clang_src_info.private_includes -# ] - -# def _normalize_and_create_copt_define(value): -# normalized = scg.normalize_define_value(value) -# return "-D" + normalized - -# all_settings = lists.compact([target.clang_settings, target.cxx_settings]) -# for settings in all_settings: -# copts.extend(lists.flatten([ -# bzl_selects.new_from_build_setting( -# bs, -# # Define values can contain spaces. Bazel requires that they -# # are already escaped. -# values_map_fn = _normalize_and_create_copt_define, -# ) -# for bs in settings.defines -# ])) - -# # Need to convert the headerSearchPaths to be relative to the -# # target path. We also do not want to lose any conditions that may -# # be attached. -# hsp_bss = [ -# pkginfos.new_build_setting( -# kind = bs.kind, -# values = [ -# paths.join(target.path, p) -# for p in bs.values -# ], -# condition = bs.condition, -# ) -# for bs in settings.hdr_srch_paths -# ] -# local_includes.extend(lists.flatten([ -# bzl_selects.new_from_build_setting(bs) -# for bs in hsp_bss -# ])) - -# copts.extend(lists.flatten([ -# bzl_selects.new_from_build_setting(bs) -# for bs in settings.unsafe_flags -# ])) - -# linkopts = [] -# if target.linker_settings != None: -# linkopts.extend(lists.flatten([ -# bzl_selects.new_from_build_setting(bs) -# for bs in target.linker_settings.linked_libraries -# ])) -# linkopts.extend(lists.flatten([ -# bzl_selects.new_from_build_setting(bs) -# for bs in target.linker_settings.linked_frameworks -# ])) - -# if len(linkopts) > 0: -# attrs["linkopts"] = bzl_selects.to_starlark( -# linkopts, -# kind_handlers = { -# _condition_kinds.linked_library: bzl_selects.new_kind_handler( -# transform = lambda ll: "-l{}".format(ll), -# ), -# _condition_kinds.linked_framework: bzl_selects.new_kind_handler( -# transform = lambda f: "-framework {}".format(f), -# ), -# }, -# ) - -# # Short path relative to Bazel output base. This is typically used when -# # adding a path to a copt or linkeropt. -# ext_repo_path = paths.join("external", repository_ctx.name) - -# copts.extend(local_includes) - -# # The `includes` attribute adds includes as -isystem which propagates -# # to cc_XXX that depend upon the library. Providing includes as -I -# # only provides the includes for this target. -# # https://bazel.build/reference/be/c-cpp#cc_library.includes -# def _local_includes_transform(p): -# # Normalize the path and replace spaces with an escape sequence. -# normalized = paths.normalize(paths.join(ext_repo_path, p)) -# normalized = normalized.replace(" ", "\\ ") -# return "-I{}".format(normalized) - -# attrs["copts"] = bzl_selects.to_starlark( -# copts, -# kind_handlers = { -# _condition_kinds.header_search_path: bzl_selects.new_kind_handler( -# transform = _local_includes_transform, -# ), -# _condition_kinds.private_includes: bzl_selects.new_kind_handler( -# transform = _local_includes_transform, -# ), -# }, -# ) - -# bzl_target_name = target.label.name - -# if target.objc_src_info != None: -# # Enable clang module support. -# # https://bazel.build/reference/be/objective-c#objc_library.enable_modules -# attrs["enable_modules"] = True -# attrs["module_name"] = target.c99name - -# sdk_framework_bzl_selects = [] -# for sf in target.objc_src_info.builtin_frameworks: -# platform_conditions = bazel_apple_platforms.for_framework(sf) -# for pc in platform_conditions: -# sdk_framework_bzl_selects.append( -# bzl_selects.new( -# value = sf, -# kind = _condition_kinds.sdk_frameworks, -# condition = pc, -# ), -# ) -# attrs["sdk_frameworks"] = bzl_selects.to_starlark( -# sdk_framework_bzl_selects, -# ) - -# # There is a known issue with Objective-C library targets not -# # supporting the `@import` of modules defined in other Objective-C -# # targets. As a workaround, we will define two targets. One is the -# # `objc_library` target. The other is a `generate_modulemap` -# # target. This second target generates a `module.modulemap` file and -# # provides information about that generated file to `objc_library` -# # targets, if `noop` is `False`. If `noop` is `True`, the target -# # generates nothing and returns "empty" providers. -# # -# # Why not skip adding the `generate_modulemap` if `noop` is `True`? -# # The logic that assigns dependencies for other targets has no way to -# # know whether the modulemap target exists. Hence, we ensure that it -# # always exists but does nothing. -# # -# # See `pkginfo_target_deps.bzl` for the logic that resolves the -# # dependency labels. -# # See `generate_modulemap.bzl` for details on the modulemap generation. -# # See `//swiftpkg/tests/generate_modulemap_tests` package for a usage -# # example. -# modulemap_deps = _collect_modulemap_deps(deps) -# load_stmts = [swiftpkg_generate_modulemap_load_stmt] -# modulemap_target_name = pkginfo_targets.modulemap_label_name(bzl_target_name) -# noop_modulemap = clang_src_info.modulemap_path != None -# modulemap_attrs = { -# "deps": bzl_selects.to_starlark(modulemap_deps), -# "hdrs": clang_src_info.hdrs, -# "module_name": target.c99name, -# "noop": noop_modulemap, -# "visibility": ["//:__subpackages__"], -# } -# decls = [ -# build_decls.new(objc_kinds.library, bzl_target_name, attrs = attrs), -# build_decls.new( -# kind = swiftpkg_kinds.generate_modulemap, -# name = modulemap_target_name, -# attrs = modulemap_attrs, -# ), -# ] -# else: -# load_stmts = [swift_interop_hint_load_stmt] -# aspect_hint_target_name = pkginfo_targets.swift_hint_label_name( -# bzl_target_name, -# ) -# attrs["aspect_hints"] = [":{}".format(aspect_hint_target_name)] -# aspect_hint_attrs = {"module_name": target.c99name} -# decls = [ -# build_decls.new(clang_kinds.library, bzl_target_name, attrs = attrs), -# build_decls.new( -# kind = swift_kinds.interop_hint, -# name = aspect_hint_target_name, -# attrs = aspect_hint_attrs, -# ), -# ] -# all_build_files.append(build_files.new( -# load_stmts = load_stmts, -# decls = decls, -# )) - -# return build_files.merge(*all_build_files) - # MARK: - System Library Targets # GH009(chuck): Remove unused-variable directives diff --git a/swiftpkg/tests/swiftpkg_build_files_tests.bzl b/swiftpkg/tests/swiftpkg_build_files_tests.bzl index e4cb03c13..cd4b23b4f 100644 --- a/swiftpkg/tests/swiftpkg_build_files_tests.bzl +++ b/swiftpkg/tests/swiftpkg_build_files_tests.bzl @@ -964,12 +964,6 @@ resource_bundle_infoplist( for path, result in getattr(t, "is_directory", {}).items() }, ) - - # DEBUG BEGIN - print("*** CHUCK =======================") - print("*** CHUCK t.name: ", t.name) - - # DEBUG END actual = scg.to_starlark( swiftpkg_build_files.new_for_target(repository_ctx, _pkg_ctx, target), ) From b4a2b8d207126b7892cbdf6c9727ffdebf745ec7 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 8 Sep 2024 11:54:49 -0600 Subject: [PATCH 06/21] Fix typo. --- swiftpkg/internal/starlark_codegen.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swiftpkg/internal/starlark_codegen.bzl b/swiftpkg/internal/starlark_codegen.bzl index 0364ded60..856fa0976 100644 --- a/swiftpkg/internal/starlark_codegen.bzl +++ b/swiftpkg/internal/starlark_codegen.bzl @@ -107,7 +107,7 @@ def _process_complex_types(out): return " " * padding + value # buildifier: disable=print - print("*** DEBUG _process_complet_types out: ") + print("*** DEBUG _process_complex_types out: ") for idx, item in enumerate(out): # buildifier: disable=print print("*** DEBUG", _pad_str(3, idx), ":", _pad_str(7, type(item)), ":", item) From 8d6806e50950f110cee8e57870136f0d585a3449 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 8 Sep 2024 12:28:28 -0600 Subject: [PATCH 07/21] Add language standard to copts. --- swiftpkg/internal/swiftpkg_build_files.bzl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index b8c1c20fb..44ea22899 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -241,11 +241,6 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): "-DSWIFT_PACKAGE=1", ] - def _if_not_empty(list_value, transform_fn = None): - if not list_value: - return None - return transform_fn(list_value) if transform_fn else list_value - # Do not add the srcs from the clang_src_info, yet. We will do that at the # end of this function where we will create separate targets based upon the # type of source file. @@ -457,6 +452,10 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): clang_src_info.organized_srcs.other_srcs, attrs.get("srcs", []), ]) + if pkg_ctx.pkg_info.c_language_standard: + copts = c_attrs.get("copts", []) + copts.append("-std={}".format(pkg_ctx.pkg_info.c_language_standard)) + c_attrs["copts"] = copts decls.append( build_decls.new( clang_kinds.library, @@ -474,6 +473,10 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): clang_src_info.organized_srcs.other_srcs, attrs.get("srcs", []), ]) + if pkg_ctx.pkg_info.cxx_language_standard: + copts = cxx_attrs.get("copts", []) + copts.append("-std={}".format(pkg_ctx.pkg_info.cxx_language_standard)) + cxx_attrs["copts"] = copts decls.append( build_decls.new( clang_kinds.library, From a23ca7a8f11703335dc357250427795d87f6663e Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 8 Sep 2024 12:33:10 -0600 Subject: [PATCH 08/21] Remove obsolete flag from interesting_deps. --- examples/interesting_deps/.bazelrc | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/interesting_deps/.bazelrc b/examples/interesting_deps/.bazelrc index a4f1d5fdd..e9769fc7b 100644 --- a/examples/interesting_deps/.bazelrc +++ b/examples/interesting_deps/.bazelrc @@ -6,6 +6,3 @@ import %workspace%/../../ci.bazelrc # Try to import a local.rc file; typically, written by CI try-import %workspace%/../../local.bazelrc - -# # Required by geos -# build --cxxopt='-std=c++11' From b50d75e226c5bf6cf494c98d55635977e3d7b04b Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sat, 21 Sep 2024 16:09:16 -0600 Subject: [PATCH 09/21] Split ObjC and ObjC++ targets. Fix missing linkopts. --- swiftpkg/internal/clang_files.bzl | 11 +- swiftpkg/internal/swiftpkg_build_files.bzl | 115 +++++++++++++++++---- 2 files changed, 102 insertions(+), 24 deletions(-) diff --git a/swiftpkg/internal/clang_files.bzl b/swiftpkg/internal/clang_files.bzl index 089335e1d..f96757b14 100644 --- a/swiftpkg/internal/clang_files.bzl +++ b/swiftpkg/internal/clang_files.bzl @@ -20,7 +20,9 @@ _C_SRC_EXTS = [".c"] _CXX_SRC_EXTS = [".cc", ".cpp"] # Objective-C source extensions -_OBJC_SRC_EXTS = [".m", ".mm"] +_OBJC_SRC_EXTS = [".m"] + +_OBJCXX_SRC_EXTS = [".mm"] # Assembly source extensions _ASSEMBLY_SRC_EXTS = [".S"] @@ -33,7 +35,8 @@ _OTHER_SRC_EXTS = [".so", ".o", ".inc"] # https://bazel.build/reference/be/objective-c#objc_library.srcs # NOTE: From examples found so far, .inc files tend to include source, not # header declarations. -_SRC_EXTS = _C_SRC_EXTS + _CXX_SRC_EXTS + _OBJC_SRC_EXTS + _ASSEMBLY_SRC_EXTS + _OTHER_SRC_EXTS +_SRC_EXTS = _C_SRC_EXTS + _CXX_SRC_EXTS + _OBJC_SRC_EXTS + _OBJCXX_SRC_EXTS + \ + _ASSEMBLY_SRC_EXTS + _OTHER_SRC_EXTS def _is_hdr(path): _root, ext = paths.split_extension(path) @@ -342,6 +345,7 @@ def _organize_srcs(srcs): c_srcs = [] cxx_srcs = [] objc_srcs = [] + objcxx_srcs = [] assembly_srcs = [] other_srcs = [] for src in srcs: @@ -352,6 +356,8 @@ def _organize_srcs(srcs): cxx_srcs.append(src) elif ext in _OBJC_SRC_EXTS: objc_srcs.append(src) + elif ext in _OBJCXX_SRC_EXTS: + objcxx_srcs.append(src) elif ext in _ASSEMBLY_SRC_EXTS: assembly_srcs.append(src) else: @@ -360,6 +366,7 @@ def _organize_srcs(srcs): c_srcs = c_srcs, cxx_srcs = cxx_srcs, objc_srcs = objc_srcs, + objcxx_srcs = objcxx_srcs, assembly_srcs = assembly_srcs, other_srcs = other_srcs, ) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index 44ea22899..a4e816e5d 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -247,6 +247,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): srcs = [] data = [] + res_copts = [] if target.resources: clang_apple_res_bundle_info = _apple_resource_bundle_for_clang( pkg_ctx, @@ -270,7 +271,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): clang_apple_res_bundle_info.objc_accessor_impl_label_name, ), ]) - copts.append("-include$(location :{})".format( + res_copts.append("-include$(location :{})".format( clang_apple_res_bundle_info.objc_accessor_hdr_label_name, )) @@ -349,6 +350,8 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): pkginfo_target_deps.bzl_select_list(pkg_ctx, td) for td in target.dependencies ]) + if linkopts: + attrs["linkopts"] = linkopts if deps: attrs["deps"] = deps if data: @@ -362,13 +365,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): # Enable clang module support. # https://bazel.build/reference/be/objective-c#objc_library.enable_modules attrs["enable_modules"] = True - attrs["module_name"] = target.c99name - - attrs["srcs"] = lists.flatten([ - clang_src_info.organized_srcs.objc_srcs, - clang_src_info.organized_srcs.other_srcs, - attrs.get("srcs", []), - ]) + # attrs["module_name"] = target.c99name sdk_framework_bzl_selects = [] for sf in target.objc_src_info.builtin_frameworks: @@ -381,9 +378,8 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): condition = pc, ), ) - attrs["sdk_frameworks"] = sdk_framework_bzl_selects - - attrs["copts"].append("-fmodule-name={}".format(target.c99name)) + if sdk_framework_bzl_selects: + attrs["sdk_frameworks"] = sdk_framework_bzl_selects # There is a known issue with Objective-C library targets not # supporting the `@import` of modules defined in other Objective-C @@ -416,17 +412,89 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): "visibility": ["//:__subpackages__"], } decls = [ - build_decls.new( - objc_kinds.library, - bzl_target_name, - attrs = _starlarkify_clang_attrs(repository_ctx, attrs), - ), build_decls.new( kind = swiftpkg_kinds.generate_modulemap, name = modulemap_target_name, attrs = modulemap_attrs, ), ] + + child_dep_names = [] + if clang_src_info.organized_srcs.objc_srcs: + objc_name = "{}_objc".format(bzl_target_name) + child_dep_names.append(objc_name) + objc_attrs = dict(**attrs) + child_copts = list(objc_attrs.get("copts", [])) + if res_copts: + child_copts.extend(res_copts) + objc_attrs["srcs"] = lists.flatten([ + clang_src_info.organized_srcs.objc_srcs, + clang_src_info.organized_srcs.other_srcs, + attrs.get("srcs", []), + ]) + if pkg_ctx.pkg_info.c_language_standard: + child_copts.append("-std={}".format( + pkg_ctx.pkg_info.c_language_standard, + )) + objc_attrs["copts"] = child_copts + decls.append( + build_decls.new( + objc_kinds.library, + objc_name, + attrs = _starlarkify_clang_attrs( + repository_ctx, + objc_attrs, + ), + ), + ) + + if clang_src_info.organized_srcs.objcxx_srcs: + objcxx_name = "{}_objcxx".format(bzl_target_name) + child_dep_names.append(objcxx_name) + objcxx_attrs = dict(**attrs) + child_copts = list(objcxx_attrs.get("copts", [])) + if res_copts: + child_copts.extend(res_copts) + objcxx_attrs["srcs"] = lists.flatten([ + clang_src_info.organized_srcs.objcxx_srcs, + clang_src_info.organized_srcs.other_srcs, + attrs.get("srcs", []), + ]) + if pkg_ctx.pkg_info.cxx_language_standard: + child_copts.append("-std={}".format( + pkg_ctx.pkg_info.cxx_language_standard, + )) + objcxx_attrs["copts"] = child_copts + decls.append( + build_decls.new( + objc_kinds.library, + objcxx_name, + attrs = _starlarkify_clang_attrs( + repository_ctx, + objcxx_attrs, + ), + ), + ) + + # Add the cc_library that brings all of the child targets together. + uber_attrs = dicts.omit(attrs, ["srcs"]) | { + "deps": [ + ":{}".format(dname) + for dname in child_dep_names + ], + } + uber_attrs["module_name"] = target.c99name + copts = uber_attrs.get("copts", []) + copts.append("-fmodule-name={}".format(target.c99name)) + uber_attrs["copts"] = copts + decls.append( + build_decls.new( + objc_kinds.library, + bzl_target_name, + attrs = _starlarkify_clang_attrs(repository_ctx, uber_attrs), + ), + ) + else: aspect_hint_target_name = pkginfo_targets.swift_hint_label_name( bzl_target_name, @@ -453,9 +521,9 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): attrs.get("srcs", []), ]) if pkg_ctx.pkg_info.c_language_standard: - copts = c_attrs.get("copts", []) - copts.append("-std={}".format(pkg_ctx.pkg_info.c_language_standard)) - c_attrs["copts"] = copts + c_attrs["copts"].append("-std={}".format( + pkg_ctx.pkg_info.c_language_standard, + )) decls.append( build_decls.new( clang_kinds.library, @@ -474,9 +542,9 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): attrs.get("srcs", []), ]) if pkg_ctx.pkg_info.cxx_language_standard: - copts = cxx_attrs.get("copts", []) - copts.append("-std={}".format(pkg_ctx.pkg_info.cxx_language_standard)) - cxx_attrs["copts"] = copts + cxx_attrs["copts"].append("-std={}".format( + pkg_ctx.pkg_info.cxx_language_standard, + )) decls.append( build_decls.new( clang_kinds.library, @@ -629,6 +697,9 @@ expected: {expected}\ kind = kind, name = pkginfo_targets.bazel_label_name(target), attrs = { + # Firebase example requires that GoogleAppMeasurement symbols + # are passed along. + "alwayslink": True, "visibility": ["//:__subpackages__"], "xcframework_imports": glob, }, From 5e442b2c4073eecc7a63d71814933976053501ca Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sat, 21 Sep 2024 16:41:03 -0600 Subject: [PATCH 10/21] Generate a resource bundle accessor for ObjC and ObjC++. --- .../objc_resource_bundle_accessor.bzl | 13 ++++-- swiftpkg/internal/pkginfo_targets.bzl | 13 ++++++ swiftpkg/internal/swiftpkg_build_files.bzl | 40 +++++++++++++++++-- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/swiftpkg/internal/objc_resource_bundle_accessor.bzl b/swiftpkg/internal/objc_resource_bundle_accessor.bzl index 04c760d4f..1e0185105 100644 --- a/swiftpkg/internal/objc_resource_bundle_accessor.bzl +++ b/swiftpkg/internal/objc_resource_bundle_accessor.bzl @@ -31,9 +31,12 @@ Generate an ObjC header file with an SPM-specific `SWIFTPM_MODULE_BUNDLE` macro. ) def _objc_resource_bundle_accessor_impl_impl(ctx): - accessor_impl = ctx.actions.declare_file("{}_ObjcResourceBundleAccessor.m".format( - ctx.label.name, - )) + accessor_impl = ctx.actions.declare_file( + "{label}_ObjcResourceBundleAccessor.{ext}".format( + ext = ctx.attr.extension, + label = ctx.label.name, + ), + ) ctx.actions.expand_template( template = ctx.file._impl_template, output = accessor_impl, @@ -52,6 +55,10 @@ objc_resource_bundle_accessor_impl = rule( mandatory = True, doc = "The name of the resource bundle.", ), + "extension": attr.string( + default = "m", + doc = "The extension for the accessor implementation file.", + ), "module_name": attr.string( mandatory = True, doc = "The name of the module.", diff --git a/swiftpkg/internal/pkginfo_targets.bzl b/swiftpkg/internal/pkginfo_targets.bzl index 40faa9f7b..f1b7aef92 100644 --- a/swiftpkg/internal/pkginfo_targets.bzl +++ b/swiftpkg/internal/pkginfo_targets.bzl @@ -7,6 +7,7 @@ _modulemap_suffix = "_modulemap" _resource_bundle_suffix = "_resource_bundle" _objc_resource_bundle_accessor_hdr_suffix = "_objc_resource_bundle_accessor_hdr" _objc_resource_bundle_accessor_impl_suffix = "_objc_resource_bundle_accessor_impl" +_objcxx_resource_bundle_accessor_impl_suffix = "_objcxx_resource_bundle_accessor_impl" _resource_bundle_accessor_suffix = "_resource_bundle_accessor" _resource_bundle_infoplist_suffix = "_resource_bundle_infoplist" _swift_hint_suffix = "_swift_hint" @@ -196,6 +197,17 @@ def _objc_resource_bundle_accessor_impl_label_name(target_name): """ return target_name + _objc_resource_bundle_accessor_impl_suffix +def _objcxx_resource_bundle_accessor_impl_label_name(target_name): + """Returns the name of the related `objc_resource_bundle_accessor` target. + + Args: + target_name: The publicly advertised name for the Swift target. + + Returns: + The name of the `resource_bundle_accessor` as a `string`. + """ + return target_name + _objcxx_resource_bundle_accessor_impl_suffix + def _resource_bundle_accessor_label_name(target_name): """Returns the name of the related `resource_bundle_accessor` target. @@ -275,6 +287,7 @@ def make_pkginfo_targets(bazel_labels): modulemap_label_name = _modulemap_label_name, objc_resource_bundle_accessor_hdr_label_name = _objc_resource_bundle_accessor_hdr_label_name, objc_resource_bundle_accessor_impl_label_name = _objc_resource_bundle_accessor_impl_label_name, + objcxx_resource_bundle_accessor_impl_label_name = _objcxx_resource_bundle_accessor_impl_label_name, resource_bundle_accessor_label_name = _resource_bundle_accessor_label_name, resource_bundle_infoplist_label_name = _resource_bundle_infoplist_label_name, resource_bundle_label_name = _resource_bundle_label_name, diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index a4e816e5d..0932781e1 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -248,6 +248,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): data = [] res_copts = [] + clang_apple_res_bundle_info = None if target.resources: clang_apple_res_bundle_info = _apple_resource_bundle_for_clang( pkg_ctx, @@ -267,9 +268,13 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): ":{}".format( clang_apple_res_bundle_info.objc_accessor_hdr_label_name, ), - ":{}".format( - clang_apple_res_bundle_info.objc_accessor_impl_label_name, - ), + + # NOTE: We will add the implementation below based upon what + # type of target is using the implementation. + + # ":{}".format( + # clang_apple_res_bundle_info.objc_accessor_impl_label_name, + # ), ]) res_copts.append("-include$(location :{})".format( clang_apple_res_bundle_info.objc_accessor_hdr_label_name, @@ -427,9 +432,16 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): child_copts = list(objc_attrs.get("copts", [])) if res_copts: child_copts.extend(res_copts) + res_srcs = [] + if clang_apple_res_bundle_info and \ + clang_apple_res_bundle_info.objc_accessor_impl_label_name: + res_srcs.append( + ":" + clang_apple_res_bundle_info.objc_accessor_impl_label_name, + ) objc_attrs["srcs"] = lists.flatten([ clang_src_info.organized_srcs.objc_srcs, clang_src_info.organized_srcs.other_srcs, + res_srcs, attrs.get("srcs", []), ]) if pkg_ctx.pkg_info.c_language_standard: @@ -455,9 +467,16 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): child_copts = list(objcxx_attrs.get("copts", [])) if res_copts: child_copts.extend(res_copts) + res_srcs = [] + if clang_apple_res_bundle_info and \ + clang_apple_res_bundle_info.objcxx_accessor_impl_label_name: + res_srcs.append( + ":" + clang_apple_res_bundle_info.objcxx_accessor_impl_label_name, + ) objcxx_attrs["srcs"] = lists.flatten([ clang_src_info.organized_srcs.objcxx_srcs, clang_src_info.organized_srcs.other_srcs, + res_srcs, attrs.get("srcs", []), ]) if pkg_ctx.pkg_info.cxx_language_standard: @@ -797,6 +816,7 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): all_build_files = [apple_res_bundle_info.build_file] objc_accessor_hdr_label_name = None objc_accessor_impl_label_name = None + objcxx_accessor_impl_label_name = None if target.objc_src_info: bzl_target_name = pkginfo_targets.bazel_label_name(target) objc_accessor_hdr_label_name = pkginfo_targets.objc_resource_bundle_accessor_hdr_label_name( @@ -805,6 +825,9 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): objc_accessor_impl_label_name = pkginfo_targets.objc_resource_bundle_accessor_impl_label_name( bzl_target_name, ) + objcxx_accessor_impl_label_name = pkginfo_targets.objcxx_resource_bundle_accessor_impl_label_name( + bzl_target_name, + ) all_build_files.append( build_files.new( load_stmts = [ @@ -824,6 +847,16 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): name = objc_accessor_impl_label_name, attrs = { "bundle_name": apple_res_bundle_info.bundle_name, + "extension": "m", + "module_name": target.c99name, + }, + ), + build_decls.new( + kind = swiftpkg_kinds.objc_resource_bundle_accessor_impl, + name = objcxx_accessor_impl_label_name, + attrs = { + "bundle_name": apple_res_bundle_info.bundle_name, + "extension": "mm", "module_name": target.c99name, }, ), @@ -834,6 +867,7 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): bundle_label_name = apple_res_bundle_info.bundle_label_name, objc_accessor_hdr_label_name = objc_accessor_hdr_label_name, objc_accessor_impl_label_name = objc_accessor_impl_label_name, + objcxx_accessor_impl_label_name = objcxx_accessor_impl_label_name, build_file = build_files.merge(*all_build_files), ) From 52654918f9d87e5470a095da8c2168b94e2d5046 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 22 Sep 2024 12:08:24 -0600 Subject: [PATCH 11/21] Include C in ObjC targets and C++ in ObjC++ targets. --- swiftpkg/internal/swiftpkg_build_files.bzl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index 0932781e1..a29c0064f 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -439,6 +439,8 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): ":" + clang_apple_res_bundle_info.objc_accessor_impl_label_name, ) objc_attrs["srcs"] = lists.flatten([ + # There could be C sources mixed in. + clang_src_info.organized_srcs.c_srcs, clang_src_info.organized_srcs.objc_srcs, clang_src_info.organized_srcs.other_srcs, res_srcs, @@ -474,6 +476,8 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): ":" + clang_apple_res_bundle_info.objcxx_accessor_impl_label_name, ) objcxx_attrs["srcs"] = lists.flatten([ + # There could be C++ sources mixed in. + clang_src_info.organized_srcs.cxx_srcs, clang_src_info.organized_srcs.objcxx_srcs, clang_src_info.organized_srcs.other_srcs, res_srcs, From aa42238145ae5bc1a9f3f6035954f336f10b1aac Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 22 Sep 2024 14:28:41 -0600 Subject: [PATCH 12/21] Create a separate objc_library for the resource bundle accessor. --- swiftpkg/internal/pkginfo_targets.bzl | 12 +-- swiftpkg/internal/starlark_codegen.bzl | 1 - swiftpkg/internal/swiftpkg_build_files.bzl | 104 +++++++++++---------- 3 files changed, 62 insertions(+), 55 deletions(-) diff --git a/swiftpkg/internal/pkginfo_targets.bzl b/swiftpkg/internal/pkginfo_targets.bzl index f1b7aef92..4bee70733 100644 --- a/swiftpkg/internal/pkginfo_targets.bzl +++ b/swiftpkg/internal/pkginfo_targets.bzl @@ -7,7 +7,7 @@ _modulemap_suffix = "_modulemap" _resource_bundle_suffix = "_resource_bundle" _objc_resource_bundle_accessor_hdr_suffix = "_objc_resource_bundle_accessor_hdr" _objc_resource_bundle_accessor_impl_suffix = "_objc_resource_bundle_accessor_impl" -_objcxx_resource_bundle_accessor_impl_suffix = "_objcxx_resource_bundle_accessor_impl" +_objc_resource_bundle_accessor_library_suffix = "_objc_resource_bundle_accessor_library" _resource_bundle_accessor_suffix = "_resource_bundle_accessor" _resource_bundle_infoplist_suffix = "_resource_bundle_infoplist" _swift_hint_suffix = "_swift_hint" @@ -197,16 +197,16 @@ def _objc_resource_bundle_accessor_impl_label_name(target_name): """ return target_name + _objc_resource_bundle_accessor_impl_suffix -def _objcxx_resource_bundle_accessor_impl_label_name(target_name): - """Returns the name of the related `objc_resource_bundle_accessor` target. +def _objc_resource_bundle_accessor_library_label_name(target_name): + """Returns the name of the related `objc_library` target. Args: target_name: The publicly advertised name for the Swift target. Returns: - The name of the `resource_bundle_accessor` as a `string`. + The name of the `objc_library` as a `string`. """ - return target_name + _objcxx_resource_bundle_accessor_impl_suffix + return target_name + _objc_resource_bundle_accessor_library_suffix def _resource_bundle_accessor_label_name(target_name): """Returns the name of the related `resource_bundle_accessor` target. @@ -287,7 +287,7 @@ def make_pkginfo_targets(bazel_labels): modulemap_label_name = _modulemap_label_name, objc_resource_bundle_accessor_hdr_label_name = _objc_resource_bundle_accessor_hdr_label_name, objc_resource_bundle_accessor_impl_label_name = _objc_resource_bundle_accessor_impl_label_name, - objcxx_resource_bundle_accessor_impl_label_name = _objcxx_resource_bundle_accessor_impl_label_name, + objc_resource_bundle_accessor_library_label_name = _objc_resource_bundle_accessor_library_label_name, resource_bundle_accessor_label_name = _resource_bundle_accessor_label_name, resource_bundle_infoplist_label_name = _resource_bundle_infoplist_label_name, resource_bundle_label_name = _resource_bundle_label_name, diff --git a/swiftpkg/internal/starlark_codegen.bzl b/swiftpkg/internal/starlark_codegen.bzl index 856fa0976..a6b5c28a9 100644 --- a/swiftpkg/internal/starlark_codegen.bzl +++ b/swiftpkg/internal/starlark_codegen.bzl @@ -116,7 +116,6 @@ def _process_complex_types(out): finished = True new_out = [] - # for v in out: for idx, v in enumerate(out): v_type = type(v) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index a29c0064f..826a3d8d2 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -246,6 +246,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): # type of source file. srcs = [] data = [] + deps = [] res_copts = [] clang_apple_res_bundle_info = None @@ -259,26 +260,23 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): clang_apple_res_bundle_info.bundle_label_name, )) if clang_apple_res_bundle_info.objc_accessor_hdr_label_name: - # SPM provides a SWIFTPM_MODULE_BUNDLE macro to access the bundle for - # ObjC code. The header file contains the macro definition. It needs - # to be available in every Objc source file. So, we specify the - # -include flag specifying the header path. - # https://github.com/apple/swift-package-manager/blob/8387798811c6cc43761c5e1b48df2d3412dc5de4/Sources/Build/BuildDescription/ClangTargetBuildDescription.swift#L390 - srcs.extend([ - ":{}".format( - clang_apple_res_bundle_info.objc_accessor_hdr_label_name, - ), - - # NOTE: We will add the implementation below based upon what - # type of target is using the implementation. - - # ":{}".format( - # clang_apple_res_bundle_info.objc_accessor_impl_label_name, - # ), - ]) - res_copts.append("-include$(location :{})".format( - clang_apple_res_bundle_info.objc_accessor_hdr_label_name, - )) + # srcs.extend([ + # ":{}".format( + # clang_apple_res_bundle_info.objc_accessor_hdr_label_name, + # ), + # # NOTE: We add the implementation below based upon what + # # type of target is using the implementation. + # ]) + deps.append(":" + clang_apple_res_bundle_info.objc_accessor_library_label_name) + + # # SPM provides a SWIFTPM_MODULE_BUNDLE macro to access the bundle for + # # ObjC code. The header file contains the macro definition. It needs + # # to be available in every Objc source file. So, we specify the + # # -include flag specifying the header path. + # # https://github.com/apple/swift-package-manager/blob/8387798811c6cc43761c5e1b48df2d3412dc5de4/Sources/Build/BuildDescription/ClangTargetBuildDescription.swift#L390 + # res_copts.append("-include$(location :{})".format( + # clang_apple_res_bundle_info.objc_accessor_hdr_label_name, + # )) local_includes = [ bzl_selects.new(value = p, kind = _condition_kinds.private_includes) @@ -351,10 +349,19 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): attrs["includes"] = clang_src_info.public_includes if clang_src_info.textual_hdrs: attrs["textual_hdrs"] = clang_src_info.textual_hdrs - deps = lists.flatten([ - pkginfo_target_deps.bzl_select_list(pkg_ctx, td) - for td in target.dependencies - ]) + + # deps = lists.flatten([ + # pkginfo_target_deps.bzl_select_list(pkg_ctx, td) + # for td in target.dependencies + # # for td in target.dependencies + deps + # ]) + + deps.extend( + lists.flatten([ + pkginfo_target_deps.bzl_select_list(pkg_ctx, td) + for td in target.dependencies + ]), + ) if linkopts: attrs["linkopts"] = linkopts if deps: @@ -370,7 +377,6 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): # Enable clang module support. # https://bazel.build/reference/be/objective-c#objc_library.enable_modules attrs["enable_modules"] = True - # attrs["module_name"] = target.c99name sdk_framework_bzl_selects = [] for sf in target.objc_src_info.builtin_frameworks: @@ -432,18 +438,19 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): child_copts = list(objc_attrs.get("copts", [])) if res_copts: child_copts.extend(res_copts) - res_srcs = [] - if clang_apple_res_bundle_info and \ - clang_apple_res_bundle_info.objc_accessor_impl_label_name: - res_srcs.append( - ":" + clang_apple_res_bundle_info.objc_accessor_impl_label_name, - ) + + # res_srcs = [] + # if clang_apple_res_bundle_info and \ + # clang_apple_res_bundle_info.objc_accessor_impl_label_name: + # res_srcs.append( + # ":" + clang_apple_res_bundle_info.objc_accessor_impl_label_name, + # ) objc_attrs["srcs"] = lists.flatten([ # There could be C sources mixed in. clang_src_info.organized_srcs.c_srcs, clang_src_info.organized_srcs.objc_srcs, clang_src_info.organized_srcs.other_srcs, - res_srcs, + # res_srcs, attrs.get("srcs", []), ]) if pkg_ctx.pkg_info.c_language_standard: @@ -469,18 +476,19 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): child_copts = list(objcxx_attrs.get("copts", [])) if res_copts: child_copts.extend(res_copts) - res_srcs = [] - if clang_apple_res_bundle_info and \ - clang_apple_res_bundle_info.objcxx_accessor_impl_label_name: - res_srcs.append( - ":" + clang_apple_res_bundle_info.objcxx_accessor_impl_label_name, - ) + + # res_srcs = [] + # if clang_apple_res_bundle_info and \ + # clang_apple_res_bundle_info.objcxx_accessor_impl_label_name: + # res_srcs.append( + # ":" + clang_apple_res_bundle_info.objcxx_accessor_impl_label_name, + # ) objcxx_attrs["srcs"] = lists.flatten([ # There could be C++ sources mixed in. clang_src_info.organized_srcs.cxx_srcs, clang_src_info.organized_srcs.objcxx_srcs, clang_src_info.organized_srcs.other_srcs, - res_srcs, + # res_srcs, attrs.get("srcs", []), ]) if pkg_ctx.pkg_info.cxx_language_standard: @@ -820,7 +828,7 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): all_build_files = [apple_res_bundle_info.build_file] objc_accessor_hdr_label_name = None objc_accessor_impl_label_name = None - objcxx_accessor_impl_label_name = None + objc_accessor_library_label_name = None if target.objc_src_info: bzl_target_name = pkginfo_targets.bazel_label_name(target) objc_accessor_hdr_label_name = pkginfo_targets.objc_resource_bundle_accessor_hdr_label_name( @@ -829,7 +837,7 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): objc_accessor_impl_label_name = pkginfo_targets.objc_resource_bundle_accessor_impl_label_name( bzl_target_name, ) - objcxx_accessor_impl_label_name = pkginfo_targets.objcxx_resource_bundle_accessor_impl_label_name( + objc_accessor_library_label_name = pkginfo_targets.objc_resource_bundle_accessor_library_label_name( bzl_target_name, ) all_build_files.append( @@ -856,12 +864,11 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): }, ), build_decls.new( - kind = swiftpkg_kinds.objc_resource_bundle_accessor_impl, - name = objcxx_accessor_impl_label_name, + kind = objc_kinds.library, + name = objc_accessor_library_label_name, attrs = { - "bundle_name": apple_res_bundle_info.bundle_name, - "extension": "mm", - "module_name": target.c99name, + "hdrs": [":" + objc_accessor_hdr_label_name], + "srcs": [":" + objc_accessor_impl_label_name], }, ), ], @@ -870,8 +877,7 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): return struct( bundle_label_name = apple_res_bundle_info.bundle_label_name, objc_accessor_hdr_label_name = objc_accessor_hdr_label_name, - objc_accessor_impl_label_name = objc_accessor_impl_label_name, - objcxx_accessor_impl_label_name = objcxx_accessor_impl_label_name, + objc_accessor_library_label_name = objc_accessor_library_label_name, build_file = build_files.merge(*all_build_files), ) @@ -880,6 +886,8 @@ def _apple_resource_bundle_for_clang(pkg_ctx, target): def _collect_modulemap_deps(deps): modulemap_deps = [] for dep in deps: + if type(dep) == type(""): + continue mm_values = [ v for v in dep.value From 647433052e6c7e940afa1eb0a157d12a708b0522 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 22 Sep 2024 14:33:21 -0600 Subject: [PATCH 13/21] Remove lock file for google_maps_example. --- .../google_maps_example/MODULE.bazel.lock | 529 ------------------ 1 file changed, 529 deletions(-) delete mode 100644 examples/google_maps_example/MODULE.bazel.lock diff --git a/examples/google_maps_example/MODULE.bazel.lock b/examples/google_maps_example/MODULE.bazel.lock deleted file mode 100644 index fe63fa3a1..000000000 --- a/examples/google_maps_example/MODULE.bazel.lock +++ /dev/null @@ -1,529 +0,0 @@ -{ - "lockFileVersion": 11, - "registryFileHashes": { - "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", - "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", - "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", - "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/source.json": "7e3a9adf473e9af076ae485ed649d5641ad50ec5c11718103f34de03170d94ad", - "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", - "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", - "https://bcr.bazel.build/modules/apple_support/1.16.0/MODULE.bazel": "e785295d21ccab339c3af131752bfbe50fc33dd8215b357492d05bfad0232400", - "https://bcr.bazel.build/modules/apple_support/1.16.0/source.json": "c9b56c85f6f9136ceacaa248565fbfb86686ab37a097a7e32d93f6822f21083b", - "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", - "https://bcr.bazel.build/modules/bazel_features/1.1.0/MODULE.bazel": "cfd42ff3b815a5f39554d97182657f8c4b9719568eb7fded2b9135f084bf760b", - "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", - "https://bcr.bazel.build/modules/bazel_features/1.10.0/MODULE.bazel": "f75e8807570484a99be90abcd52b5e1f390362c258bcb73106f4544957a48101", - "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", - "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", - "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", - "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", - "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", - "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", - "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", - "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", - "https://bcr.bazel.build/modules/bazel_skylib/1.4.1/MODULE.bazel": "a0dcb779424be33100dcae821e9e27e4f2901d9dfd5333efe5ac6a8d7ab75e1d", - "https://bcr.bazel.build/modules/bazel_skylib/1.4.2/MODULE.bazel": "3bd40978e7a1fac911d5989e6b09d8f64921865a45822d8b09e815eaa726a651", - "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", - "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", - "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", - "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", - "https://bcr.bazel.build/modules/bazel_skylib_gazelle_plugin/1.7.1/MODULE.bazel": "c76b9d256c77c31754c5ac306d395fd47946d8d7470bea2474c3add17b334c3d", - "https://bcr.bazel.build/modules/bazel_skylib_gazelle_plugin/1.7.1/source.json": "25a87991a554369633d706f924f67ca3eb4d9200af1bba7e57dceb85eb9198e4", - "https://bcr.bazel.build/modules/buildifier_prebuilt/6.0.0.1/MODULE.bazel": "5d23708e6a5527ab4f151da7accabc22808cb5fb579c8cc4cd4a292da57a5c97", - "https://bcr.bazel.build/modules/buildifier_prebuilt/6.0.0.1/source.json": "57bc8b05bd4bb2736efe1b41f9f4bf551cdced8314e8d20420b8a0e5a0751b30", - "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", - "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", - "https://bcr.bazel.build/modules/cgrindel_bazel_starlib/0.21.0/MODULE.bazel": "6184e95b48699a8864d0ece97efe544488ad2e8dc5abc6e57561466d921c68d7", - "https://bcr.bazel.build/modules/cgrindel_bazel_starlib/0.21.0/source.json": "e5bd0650c438cff88fd8ac5db9694e0b81c8f904dd5295c7060da4cd4a1412d3", - "https://bcr.bazel.build/modules/gazelle/0.27.0/MODULE.bazel": "3446abd608295de6d90b4a8a118ed64a9ce11dcb3dda2dc3290a22056bd20996", - "https://bcr.bazel.build/modules/gazelle/0.29.0/MODULE.bazel": "a8c809839caeb52995de3f46bbc60cfd327fadfdbfa9f19ee297c8bc8500be45", - "https://bcr.bazel.build/modules/gazelle/0.32.0/MODULE.bazel": "b499f58a5d0d3537f3cf5b76d8ada18242f64ec474d8391247438bf04f58c7b8", - "https://bcr.bazel.build/modules/gazelle/0.33.0/MODULE.bazel": "a13a0f279b462b784fb8dd52a4074526c4a2afe70e114c7d09066097a46b3350", - "https://bcr.bazel.build/modules/gazelle/0.34.0/MODULE.bazel": "abdd8ce4d70978933209db92e436deb3a8b737859e9354fb5fd11fb5c2004c8a", - "https://bcr.bazel.build/modules/gazelle/0.36.0/MODULE.bazel": "e375d5d6e9a6ca59b0cb38b0540bc9a05b6aa926d322f2de268ad267a2ee74c0", - "https://bcr.bazel.build/modules/gazelle/0.37.0/MODULE.bazel": "d1327ba0907d0275ed5103bfbbb13518f6c04955b402213319d0d6c0ce9839d4", - "https://bcr.bazel.build/modules/gazelle/0.38.0/MODULE.bazel": "51bb3ca009bc9320492894aece6ba5f50aae68a39fff2567844b77fc12e2d0a5", - "https://bcr.bazel.build/modules/gazelle/0.38.0/source.json": "7fedf9b531bcbbe90b009e4d3aef478a2defb8b8a6e31e931445231e425fc37c", - "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", - "https://bcr.bazel.build/modules/googletest/1.11.0/source.json": "c73d9ef4268c91bd0c1cd88f1f9dfa08e814b1dbe89b5f594a9f08ba0244d206", - "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", - "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9", - "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", - "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", - "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", - "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", - "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", - "https://bcr.bazel.build/modules/platforms/0.0.9/source.json": "cd74d854bf16a9e002fb2ca7b1a421f4403cda29f824a765acd3a8c56f8d43e6", - "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", - "https://bcr.bazel.build/modules/protobuf/21.7/source.json": "bbe500720421e582ff2d18b0802464205138c06056f443184de39fbb8187b09b", - "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", - "https://bcr.bazel.build/modules/protobuf/3.19.2/MODULE.bazel": "532ffe5f2186b69fdde039efe6df13ba726ff338c6bc82275ad433013fa10573", - "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", - "https://bcr.bazel.build/modules/rules_apple/3.6.0/MODULE.bazel": "7e3979510cbb7d6a20e8523a116cfc1252fe71821236c7340ca5bfd3a74b4479", - "https://bcr.bazel.build/modules/rules_apple/3.8.0/MODULE.bazel": "b0ecef90c460f956e67d36ae42d1879e46ec8f182fa87683b0e53a8f3982dd37", - "https://bcr.bazel.build/modules/rules_apple/3.8.0/source.json": "32d89098572a1f0c77eeb8a24dce8d8a2cae301633f99e3942d580b4b1523724", - "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", - "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", - "https://bcr.bazel.build/modules/rules_cc/0.0.6/MODULE.bazel": "abf360251023dfe3efcef65ab9d56beefa8394d4176dd29529750e1c57eaa33f", - "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", - "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", - "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", - "https://bcr.bazel.build/modules/rules_go/0.33.0/MODULE.bazel": "a2b11b64cd24bf94f57454f53288a5dacfe6cb86453eee7761b7637728c1910c", - "https://bcr.bazel.build/modules/rules_go/0.37.0/MODULE.bazel": "7639dae065f071efebbe73c03dc8330c3293206cf073af7c7084add4e0120aba", - "https://bcr.bazel.build/modules/rules_go/0.41.0/MODULE.bazel": "55861d8e8bb0e62cbd2896f60ff303f62ffcb0eddb74ecb0e5c0cbe36fc292c8", - "https://bcr.bazel.build/modules/rules_go/0.42.0/MODULE.bazel": "8cfa875b9aa8c6fce2b2e5925e73c1388173ea3c32a0db4d2b4804b453c14270", - "https://bcr.bazel.build/modules/rules_go/0.46.0/MODULE.bazel": "3477df8bdcc49e698b9d25f734c4f3a9f5931ff34ee48a2c662be168f5f2d3fd", - "https://bcr.bazel.build/modules/rules_go/0.47.0/MODULE.bazel": "e425890d2a4d668abc0f59d8388b70bf63ad025edec76a385c35d85882519417", - "https://bcr.bazel.build/modules/rules_go/0.47.0/source.json": "24525061cea6a0829d989b00d90f1da6b225f4c39cdd512f8e406616cb29e044", - "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", - "https://bcr.bazel.build/modules/rules_java/6.3.0/MODULE.bazel": "a97c7678c19f236a956ad260d59c86e10a463badb7eb2eda787490f4c969b963", - "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", - "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", - "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", - "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", - "https://bcr.bazel.build/modules/rules_jvm_external/5.2/source.json": "10572111995bc349ce31c78f74b3c147f6b3233975c7fa5eff9211f6db0d34d9", - "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", - "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", - "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", - "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", - "https://bcr.bazel.build/modules/rules_pkg/0.7.0/source.json": "c2557066e0c0342223ba592510ad3d812d4963b9024831f7f66fd0584dd8c66c", - "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", - "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", - "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/source.json": "d57902c052424dfda0e71646cb12668d39c4620ee0544294d9d941e7d12bc3a9", - "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", - "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", - "https://bcr.bazel.build/modules/rules_python/0.22.1/source.json": "57226905e783bae7c37c2dd662be078728e48fa28ee4324a7eabcafb5a43d014", - "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", - "https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca", - "https://bcr.bazel.build/modules/rules_swift/1.18.0/MODULE.bazel": "a6aba73625d0dc64c7b4a1e831549b6e375fbddb9d2dde9d80c9de6ec45b24c9", - "https://bcr.bazel.build/modules/rules_swift/2.1.1/MODULE.bazel": "494900a80f944fc7aa61500c2073d9729dff0b764f0e89b824eb746959bc1046", - "https://bcr.bazel.build/modules/rules_swift/2.1.1/source.json": "40fc69dfaac64deddbb75bd99cdac55f4427d9ca0afbe408576a65428427a186", - "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", - "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", - "https://bcr.bazel.build/modules/stardoc/0.6.2/MODULE.bazel": "7060193196395f5dd668eda046ccbeacebfd98efc77fed418dbe2b82ffaa39fd", - "https://bcr.bazel.build/modules/stardoc/0.6.2/source.json": "d2ff8063b63b4a85e65fe595c4290f99717434fa9f95b4748a79a7d04dfed349", - "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91", - "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/source.json": "32bd87e5f4d7acc57c5b2ff7c325ae3061d5e242c0c4c214ae87e0f1c13e54cb", - "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", - "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", - "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", - "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", - "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", - "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" - }, - "selectedYankedVersions": {}, - "moduleExtensions": { - "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { - "general": { - "bzlTransitiveDigest": "7ii+gFxWSxHhQPrBxfMEHhtrGvHmBTvsh+KOyGunP/s=", - "usagesDigest": "tLubr0Kliq79zXS+7Oamcrp1U+OPkktN7EbVoRiOWms=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "local_config_apple_cc": { - "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf", - "attributes": {} - }, - "local_config_apple_cc_toolchains": { - "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf_toolchains", - "attributes": {} - } - }, - "recordedRepoMappingEntries": [ - [ - "apple_support~", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, - "@@buildifier_prebuilt~//:defs.bzl%buildifier_prebuilt_deps_extension": { - "general": { - "bzlTransitiveDigest": "OoWi5m9k5b1vcdkzlL5LgptXPW6UHcvdioFl1jYehOU=", - "usagesDigest": "XfKr5E71RWCdeHzfpN7UfG8Uh5FTpmmLv0mGGeiymYM=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "buildozer_darwin_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "urls": [ - "https://github.com/bazelbuild/buildtools/releases/download/6.0.0/buildozer-darwin-amd64" - ], - "downloaded_file_path": "buildozer", - "executable": true, - "sha256": "17c97b23ebf0aa59c3c457800090e5d9b937511bafbe91d22aec972fbdf588d0" - } - }, - "buildifier_linux_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "urls": [ - "https://github.com/bazelbuild/buildtools/releases/download/6.0.0/buildifier-linux-amd64" - ], - "downloaded_file_path": "buildifier", - "executable": true, - "sha256": "7ff82176879c0c13bc682b6b0e482d670fbe13bbb20e07915edb0ad11be50502" - } - }, - "buildozer_darwin_arm64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "urls": [ - "https://github.com/bazelbuild/buildtools/releases/download/6.0.0/buildozer-darwin-arm64" - ], - "downloaded_file_path": "buildozer", - "executable": true, - "sha256": "8d5e26446cd5a945588b1e0c72854d2cc367fac98d16ddeccbc59b0c87a9a05e" - } - }, - "buildozer_linux_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "urls": [ - "https://github.com/bazelbuild/buildtools/releases/download/6.0.0/buildozer-linux-amd64" - ], - "downloaded_file_path": "buildozer", - "executable": true, - "sha256": "b46c12c81ab45306d3bbb4b3a6cd795532d1c3036ed126fbc43fde23d6c35f2d" - } - }, - "buildozer_linux_arm64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "urls": [ - "https://github.com/bazelbuild/buildtools/releases/download/6.0.0/buildozer-linux-arm64" - ], - "downloaded_file_path": "buildozer", - "executable": true, - "sha256": "548c3a6c890ef5cc4398d5afeb1399717b43740eb910f7488a36b76440ca0383" - } - }, - "buildifier_prebuilt_toolchains": { - "bzlFile": "@@buildifier_prebuilt~//:defs.bzl", - "ruleClassName": "_buildifier_toolchain_setup", - "attributes": { - "assets_json": "[{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"darwin\",\"sha256\":\"3f8ab7dd5d5946ce44695f29c3b895ad11a9a6776c247ad5273e9c8480216ae1\",\"version\":\"6.0.0\"},{\"arch\":\"arm64\",\"name\":\"buildifier\",\"platform\":\"darwin\",\"sha256\":\"21fa0d48ef0b7251eb6e3521cbe25d1e52404763cd2a43aa29f69b5380559dd1\",\"version\":\"6.0.0\"},{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"linux\",\"sha256\":\"7ff82176879c0c13bc682b6b0e482d670fbe13bbb20e07915edb0ad11be50502\",\"version\":\"6.0.0\"},{\"arch\":\"arm64\",\"name\":\"buildifier\",\"platform\":\"linux\",\"sha256\":\"9ffa62ea1f55f420c36eeef1427f71a34a5d24332cb861753b2b59c66d6343e2\",\"version\":\"6.0.0\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"darwin\",\"sha256\":\"17c97b23ebf0aa59c3c457800090e5d9b937511bafbe91d22aec972fbdf588d0\",\"version\":\"6.0.0\"},{\"arch\":\"arm64\",\"name\":\"buildozer\",\"platform\":\"darwin\",\"sha256\":\"8d5e26446cd5a945588b1e0c72854d2cc367fac98d16ddeccbc59b0c87a9a05e\",\"version\":\"6.0.0\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"linux\",\"sha256\":\"b46c12c81ab45306d3bbb4b3a6cd795532d1c3036ed126fbc43fde23d6c35f2d\",\"version\":\"6.0.0\"},{\"arch\":\"arm64\",\"name\":\"buildozer\",\"platform\":\"linux\",\"sha256\":\"548c3a6c890ef5cc4398d5afeb1399717b43740eb910f7488a36b76440ca0383\",\"version\":\"6.0.0\"}]" - } - }, - "buildifier_darwin_amd64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "urls": [ - "https://github.com/bazelbuild/buildtools/releases/download/6.0.0/buildifier-darwin-amd64" - ], - "downloaded_file_path": "buildifier", - "executable": true, - "sha256": "3f8ab7dd5d5946ce44695f29c3b895ad11a9a6776c247ad5273e9c8480216ae1" - } - }, - "buildifier_darwin_arm64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "urls": [ - "https://github.com/bazelbuild/buildtools/releases/download/6.0.0/buildifier-darwin-arm64" - ], - "downloaded_file_path": "buildifier", - "executable": true, - "sha256": "21fa0d48ef0b7251eb6e3521cbe25d1e52404763cd2a43aa29f69b5380559dd1" - } - }, - "buildifier_linux_arm64": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_file", - "attributes": { - "urls": [ - "https://github.com/bazelbuild/buildtools/releases/download/6.0.0/buildifier-linux-arm64" - ], - "downloaded_file_path": "buildifier", - "executable": true, - "sha256": "9ffa62ea1f55f420c36eeef1427f71a34a5d24332cb861753b2b59c66d6343e2" - } - } - }, - "recordedRepoMappingEntries": [ - [ - "buildifier_prebuilt~", - "bazel_skylib", - "bazel_skylib~" - ], - [ - "buildifier_prebuilt~", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, - "@@platforms//host:extension.bzl%host_platform": { - "general": { - "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", - "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "host_platform": { - "bzlFile": "@@platforms//host:extension.bzl", - "ruleClassName": "host_platform_repo", - "attributes": {} - } - }, - "recordedRepoMappingEntries": [] - } - }, - "@@rules_swift_package_manager~//:extensions.bzl%swift_deps": { - "general": { - "bzlTransitiveDigest": "insHu8VXmPgJ+/dOFRIJTSKcawBKosO50cZ8cu9vCcA=", - "usagesDigest": "kY8Ux+hv19p9YrqOeww2DgZWEHYJRfYSWw4kQ1TXDB8=", - "recordedFileInputs": { - "@@//Package.resolved": "fc1e531b9f62b8195c8ed27f24402c60388d332550b2aed3d47ea09554a628ba", - "@@//Package.swift": "5c7f9e572c6558b5ba87517c229123ded1b0aa543333352b92da670ac7fa80fa" - }, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "swiftpkg_ios_maps_sdk": { - "bzlFile": "@@rules_swift_package_manager~//swiftpkg/internal:swift_package.bzl", - "ruleClassName": "swift_package", - "attributes": { - "bazel_package_name": "swiftpkg_ios_maps_sdk", - "commit": "0cd72dd45109b0225dd920ff17e0362a96489ec0", - "remote": "https://github.com/googlemaps/ios-maps-sdk", - "init_submodules": false, - "recursive_init_submodules": true, - "patch_args": [ - "-p1" - ], - "patch_cmds": [], - "patch_cmds_win": [], - "patch_tool": "", - "patches": [ - "@@//third-party/google-maps-ios-sdk:0001-Remove-import-GoogleMaps.patch" - ] - } - }, - "swift_deps_info": { - "bzlFile": "@@rules_swift_package_manager~//swiftpkg/internal:swift_deps_info.bzl", - "ruleClassName": "swift_deps_info", - "attributes": { - "direct_dep_pkg_infos": { - "@swiftpkg_ios_maps_sdk//:pkg_info.json": "ios-maps-sdk" - } - } - } - }, - "moduleExtensionMetadata": { - "explicitRootModuleDirectDeps": [ - "swiftpkg_ios_maps_sdk", - "swift_deps_info" - ], - "explicitRootModuleDirectDevDeps": [], - "useAllRepos": "NO", - "reproducible": false - }, - "recordedRepoMappingEntries": [ - [ - "rules_swift_package_manager~", - "bazel_skylib", - "bazel_skylib~" - ], - [ - "rules_swift_package_manager~", - "bazel_tools", - "bazel_tools" - ], - [ - "rules_swift_package_manager~", - "cgrindel_bazel_starlib", - "cgrindel_bazel_starlib~" - ] - ] - } - }, - "@@rules_swift~//swift:extensions.bzl%non_module_deps": { - "general": { - "bzlTransitiveDigest": "SMlSpPt7J3akRjdCKkCLB4onHNyplTFRm/cjRcBXTK4=", - "usagesDigest": "v8pVOoO9zhy1k73hpXrq8i5itmO9MQIRw5rQZKguitI=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "com_github_apple_swift_docc_symbolkit": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-docc-symbolkit/archive/refs/tags/swift-5.10-RELEASE.tar.gz" - ], - "sha256": "de1d4b6940468ddb53b89df7aa1a81323b9712775b0e33e8254fa0f6f7469a97", - "strip_prefix": "swift-docc-symbolkit-swift-5.10-RELEASE", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_docc_symbolkit/BUILD.overlay" - } - }, - "com_github_apple_swift_nio_http2": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-nio-http2/archive/1.26.0.tar.gz" - ], - "sha256": "f0edfc9d6a7be1d587e5b403f2d04264bdfae59aac1d74f7d974a9022c6d2b25", - "strip_prefix": "swift-nio-http2-1.26.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_http2/BUILD.overlay" - } - }, - "build_bazel_rules_swift_index_import": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "build_file": "@@rules_swift~//third_party:build_bazel_rules_swift_index_import/BUILD.overlay", - "canonical_id": "index-import-5.8", - "urls": [ - "https://github.com/MobileNativeFoundation/index-import/releases/download/5.8.0.1/index-import.tar.gz" - ], - "sha256": "28c1ffa39d99e74ed70623899b207b41f79214c498c603915aef55972a851a15" - } - }, - "com_github_apple_swift_log": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-log/archive/1.4.4.tar.gz" - ], - "sha256": "48fe66426c784c0c20031f15dc17faf9f4c9037c192bfac2f643f65cb2321ba0", - "strip_prefix": "swift-log-1.4.4/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_log/BUILD.overlay" - } - }, - "com_github_apple_swift_collections": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-collections/archive/1.0.4.tar.gz" - ], - "sha256": "d9e4c8a91c60fb9c92a04caccbb10ded42f4cb47b26a212bc6b39cc390a4b096", - "strip_prefix": "swift-collections-1.0.4/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_collections/BUILD.overlay" - } - }, - "com_github_grpc_grpc_swift": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/grpc/grpc-swift/archive/1.16.0.tar.gz" - ], - "sha256": "58b60431d0064969f9679411264b82e40a217ae6bd34e17096d92cc4e47556a5", - "strip_prefix": "grpc-swift-1.16.0/", - "build_file": "@@rules_swift~//third_party:com_github_grpc_grpc_swift/BUILD.overlay" - } - }, - "com_github_apple_swift_nio_extras": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-nio-extras/archive/1.4.0.tar.gz" - ], - "sha256": "4684b52951d9d9937bb3e8ccd6b5daedd777021ef2519ea2f18c4c922843b52b", - "strip_prefix": "swift-nio-extras-1.4.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_extras/BUILD.overlay" - } - }, - "com_github_apple_swift_protobuf": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-protobuf/archive/1.20.2.tar.gz" - ], - "sha256": "3fb50bd4d293337f202d917b6ada22f9548a0a0aed9d9a4d791e6fbd8a246ebb", - "strip_prefix": "swift-protobuf-1.20.2/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_protobuf/BUILD.overlay" - } - }, - "com_github_apple_swift_nio_ssl": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-nio-ssl/archive/2.23.0.tar.gz" - ], - "sha256": "4787c63f61dd04d99e498adc3d1a628193387e41efddf8de19b8db04544d016d", - "strip_prefix": "swift-nio-ssl-2.23.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_ssl/BUILD.overlay" - } - }, - "com_github_apple_swift_atomics": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-atomics/archive/1.1.0.tar.gz" - ], - "sha256": "1bee7f469f7e8dc49f11cfa4da07182fbc79eab000ec2c17bfdce468c5d276fb", - "strip_prefix": "swift-atomics-1.1.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_atomics/BUILD.overlay" - } - }, - "com_github_apple_swift_nio_transport_services": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-nio-transport-services/archive/1.15.0.tar.gz" - ], - "sha256": "f3498dafa633751a52b9b7f741f7ac30c42bcbeb3b9edca6d447e0da8e693262", - "strip_prefix": "swift-nio-transport-services-1.15.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_transport_services/BUILD.overlay" - } - }, - "com_github_apple_swift_nio": { - "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "urls": [ - "https://github.com/apple/swift-nio/archive/2.42.0.tar.gz" - ], - "sha256": "e3304bc3fb53aea74a3e54bd005ede11f6dc357117d9b1db642d03aea87194a0", - "strip_prefix": "swift-nio-2.42.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio/BUILD.overlay" - } - }, - "build_bazel_rules_swift_local_config": { - "bzlFile": "@@rules_swift~//swift/internal:swift_autoconfiguration.bzl", - "ruleClassName": "swift_autoconfiguration", - "attributes": {} - } - }, - "recordedRepoMappingEntries": [ - [ - "rules_swift~", - "bazel_tools", - "bazel_tools" - ], - [ - "rules_swift~", - "build_bazel_rules_swift", - "rules_swift~" - ] - ] - } - } - } -} From 6bba7a3f8341d74a98d3bc344a06babbf57788c5 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 22 Sep 2024 14:43:27 -0600 Subject: [PATCH 14/21] Fix clang_files_tests. --- swiftpkg/tests/clang_files_tests.bzl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/swiftpkg/tests/clang_files_tests.bzl b/swiftpkg/tests/clang_files_tests.bzl index 26145e363..0c5e84ae7 100644 --- a/swiftpkg/tests/clang_files_tests.bzl +++ b/swiftpkg/tests/clang_files_tests.bzl @@ -250,8 +250,10 @@ def _organize_srcs_test(ctx): expected = struct( c_srcs = ["foo.c"], cxx_srcs = ["foo.cc", "foo.cpp"], - objc_srcs = ["foo.m", "foo.mm"], - other_srcs = ["foo.inc", "foo.so", "foo.o", "foo.S"], + objc_srcs = ["foo.m"], + objcxx_srcs = ["foo.mm"], + assembly_srcs = ["foo.S"], + other_srcs = ["foo.inc", "foo.so", "foo.o"], ) asserts.equals(env, expected, actual) From 71cac08f452f76eb9348e3f8b2d78099e76e3e5f Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 22 Sep 2024 14:53:01 -0600 Subject: [PATCH 15/21] Fix swiftpkg_build_files_tests. --- swiftpkg/tests/swiftpkg_build_files_tests.bzl | 160 +++++++++++++++++- 1 file changed, 151 insertions(+), 9 deletions(-) diff --git a/swiftpkg/tests/swiftpkg_build_files_tests.bzl b/swiftpkg/tests/swiftpkg_build_files_tests.bzl index cd4b23b4f..359ae91fb 100644 --- a/swiftpkg/tests/swiftpkg_build_files_tests.bzl +++ b/swiftpkg/tests/swiftpkg_build_files_tests.bzl @@ -584,7 +584,28 @@ cc_library( "-fblocks", "-fobjc-arc", "-fPIC", + "-DSWIFT_PACKAGE=1", + "-DPLATFORM_POSIX=1", + "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", + "-Iexternal/bzlmodmangled~swiftpkg_mypackage", "-fmodule-name=ClangLibrary", + ] + select({ + "@rules_swift_package_manager//config_settings/spm/configuration:release": ["-danger"], + "//conditions:default": [], + }), + deps = [":ClangLibrary.rspm_cxx"], + hdrs = ["include/external.h"], + includes = ["include"], + textual_hdrs = ["src/foo.cc"], + visibility = ["//:__subpackages__"], +) + +cc_library( + name = "ClangLibrary.rspm_cxx", + copts = [ + "-fblocks", + "-fobjc-arc", + "-fPIC", "-DSWIFT_PACKAGE=1", "-DPLATFORM_POSIX=1", "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", @@ -630,7 +651,41 @@ objc_library( "-fblocks", "-fobjc-arc", "-fPIC", + "-DSWIFT_PACKAGE=1", + "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", "-fmodule-name=ObjcLibrary", + ], + deps = [":ObjcLibrary.rspm_objc"], + enable_modules = True, + hdrs = ["include/external.h"], + includes = ["include"], + module_name = "ObjcLibrary", + sdk_frameworks = select({ + "@rules_swift_package_manager//config_settings/spm/platform:ios": [ + "Foundation", + "UIKit", + ], + "@rules_swift_package_manager//config_settings/spm/platform:macos": ["Foundation"], + "@rules_swift_package_manager//config_settings/spm/platform:tvos": [ + "Foundation", + "UIKit", + ], + "@rules_swift_package_manager//config_settings/spm/platform:watchos": [ + "Foundation", + "UIKit", + ], + "//conditions:default": [], + }), + textual_hdrs = ["src/foo.m"], + visibility = ["//:__subpackages__"], +) + +objc_library( + name = "ObjcLibrary.rspm_objc", + copts = [ + "-fblocks", + "-fobjc-arc", + "-fPIC", "-DSWIFT_PACKAGE=1", "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", ], @@ -641,7 +696,6 @@ objc_library( enable_modules = True, hdrs = ["include/external.h"], includes = ["include"], - module_name = "ObjcLibrary", sdk_frameworks = select({ "@rules_swift_package_manager//config_settings/spm/platform:ios": [ "Foundation", @@ -659,8 +713,8 @@ objc_library( "//conditions:default": [], }), srcs = [ - "src/foo.h", "src/foo.m", + "src/foo.h", ], textual_hdrs = ["src/foo.m"], visibility = ["//:__subpackages__"], @@ -688,7 +742,41 @@ objc_library( "-fblocks", "-fobjc-arc", "-fPIC", + "-DSWIFT_PACKAGE=1", + "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", "-fmodule-name=ObjcLibraryWithModulemap", + ], + deps = [":ObjcLibraryWithModulemap.rspm_objc"], + enable_modules = True, + hdrs = ["include/external.h"], + includes = ["include"], + module_name = "ObjcLibraryWithModulemap", + sdk_frameworks = select({ + "@rules_swift_package_manager//config_settings/spm/platform:ios": [ + "Foundation", + "UIKit", + ], + "@rules_swift_package_manager//config_settings/spm/platform:macos": ["Foundation"], + "@rules_swift_package_manager//config_settings/spm/platform:tvos": [ + "Foundation", + "UIKit", + ], + "@rules_swift_package_manager//config_settings/spm/platform:watchos": [ + "Foundation", + "UIKit", + ], + "//conditions:default": [], + }), + textual_hdrs = ["src/foo.m"], + visibility = ["//:__subpackages__"], +) + +objc_library( + name = "ObjcLibraryWithModulemap.rspm_objc", + copts = [ + "-fblocks", + "-fobjc-arc", + "-fPIC", "-DSWIFT_PACKAGE=1", "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", ], @@ -699,7 +787,6 @@ objc_library( enable_modules = True, hdrs = ["include/external.h"], includes = ["include"], - module_name = "ObjcLibraryWithModulemap", sdk_frameworks = select({ "@rules_swift_package_manager//config_settings/spm/platform:ios": [ "Foundation", @@ -717,8 +804,8 @@ objc_library( "//conditions:default": [], }), srcs = [ - "src/foo.h", "src/foo.m", + "src/foo.h", ], textual_hdrs = ["src/foo.m"], visibility = ["//:__subpackages__"], @@ -761,7 +848,23 @@ cc_library( "-fblocks", "-fobjc-arc", "-fPIC", + "-DSWIFT_PACKAGE=1", + "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", "-fmodule-name=ClangLibraryWithConditionalDep", + ], + deps = [":ClangLibraryWithConditionalDep.rspm_cxx"], + hdrs = ["include/external.h"], + includes = ["include"], + textual_hdrs = ["src/foo.cc"], + visibility = ["//:__subpackages__"], +) + +cc_library( + name = "ClangLibraryWithConditionalDep.rspm_cxx", + copts = [ + "-fblocks", + "-fobjc-arc", + "-fPIC", "-DSWIFT_PACKAGE=1", "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", ], @@ -890,12 +993,12 @@ objc_library( "-fblocks", "-fobjc-arc", "-fPIC", - "-fmodule-name=ObjcLibraryWithResources", - "-include$(location :ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_hdr)", "-DSWIFT_PACKAGE=1", "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", + "-fmodule-name=ObjcLibraryWithResources", ], data = [":ObjcLibraryWithResources.rspm_resource_bundle"], + deps = [":ObjcLibraryWithResources.rspm_objc"], enable_modules = True, hdrs = ["include/external.h"], includes = ["include"], @@ -916,16 +1019,54 @@ objc_library( ], "//conditions:default": [], }), + textual_hdrs = ["src/foo.m"], + visibility = ["//:__subpackages__"], +) + +objc_library( + name = "ObjcLibraryWithResources.rspm_objc", + copts = [ + "-fblocks", + "-fobjc-arc", + "-fPIC", + "-DSWIFT_PACKAGE=1", + "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", + ], + data = [":ObjcLibraryWithResources.rspm_resource_bundle"], + deps = [":ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_library"], + enable_modules = True, + hdrs = ["include/external.h"], + includes = ["include"], + sdk_frameworks = select({ + "@rules_swift_package_manager//config_settings/spm/platform:ios": [ + "Foundation", + "UIKit", + ], + "@rules_swift_package_manager//config_settings/spm/platform:macos": ["Foundation"], + "@rules_swift_package_manager//config_settings/spm/platform:tvos": [ + "Foundation", + "UIKit", + ], + "@rules_swift_package_manager//config_settings/spm/platform:watchos": [ + "Foundation", + "UIKit", + ], + "//conditions:default": [], + }), srcs = [ - "src/foo.h", "src/foo.m", - ":ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_hdr", - ":ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_impl", + "src/foo.h", ], textual_hdrs = ["src/foo.m"], visibility = ["//:__subpackages__"], ) +objc_library( + name = "ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_library", + hdrs = [":ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_hdr"], + srcs = [":ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_impl"], +) + objc_resource_bundle_accessor_hdr( name = "ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_hdr", module_name = "ObjcLibraryWithResources", @@ -934,6 +1075,7 @@ objc_resource_bundle_accessor_hdr( objc_resource_bundle_accessor_impl( name = "ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_impl", bundle_name = "MyPackage_ObjcLibraryWithResources", + extension = "m", module_name = "ObjcLibraryWithResources", ) From cd20d8d8c0bd8cafb4d8fa08007e3dd32c3a9d3b Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 22 Sep 2024 14:59:07 -0600 Subject: [PATCH 16/21] Address buildifier warnings. --- swiftpkg/internal/starlark_codegen.bzl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swiftpkg/internal/starlark_codegen.bzl b/swiftpkg/internal/starlark_codegen.bzl index a6b5c28a9..8e071e9da 100644 --- a/swiftpkg/internal/starlark_codegen.bzl +++ b/swiftpkg/internal/starlark_codegen.bzl @@ -108,8 +108,12 @@ def _process_complex_types(out): # buildifier: disable=print print("*** DEBUG _process_complex_types out: ") + + # Not sure why buildifier is complaining about idx not being initialized. + # buildifier: disable=uninitialized for idx, item in enumerate(out): # buildifier: disable=print + # buildifier: disable=uninitialized print("*** DEBUG", _pad_str(3, idx), ":", _pad_str(7, type(item)), ":", item) fail(msg) From bc4974c38c6fd8002935c64c24f3893d37250abf Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sat, 28 Sep 2024 08:26:04 -0600 Subject: [PATCH 17/21] Avoid duplicate declaration by not passing along the hdrs to the uber target. --- swiftpkg/internal/swiftpkg_build_files.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index 826a3d8d2..f00ab59f8 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -508,7 +508,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): ) # Add the cc_library that brings all of the child targets together. - uber_attrs = dicts.omit(attrs, ["srcs"]) | { + uber_attrs = dicts.omit(attrs, ["srcs", "hdrs"]) | { "deps": [ ":{}".format(dname) for dname in child_dep_names From 8b0a7176d2b045e46799cf9f639920e4b8dfdef5 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sat, 28 Sep 2024 09:32:08 -0600 Subject: [PATCH 18/21] Exclude textual_hdrs from the uber targets. --- swiftpkg/internal/swiftpkg_build_files.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index f00ab59f8..935f1bcf3 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -508,7 +508,7 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): ) # Add the cc_library that brings all of the child targets together. - uber_attrs = dicts.omit(attrs, ["srcs", "hdrs"]) | { + uber_attrs = dicts.omit(attrs, ["srcs", "hdrs", "textual_hdrs"]) | { "deps": [ ":{}".format(dname) for dname in child_dep_names From 73d1268a10d2397509a278df47ffe793b57943ac Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sat, 28 Sep 2024 10:20:19 -0600 Subject: [PATCH 19/21] Fix incorrectly adding alwayslink to apple_dynamic_xcframework_import. --- swiftpkg/internal/swiftpkg_build_files.bzl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index 935f1bcf3..4e8e22839 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -696,9 +696,14 @@ def _system_library_build_file(target): # MARK: - Apple xcframework Targets def _xcframework_import_build_file(target, artifact_info): + attrs = {} if artifact_info.link_type == link_types.static: load_stmts = [apple_static_xcframework_import_load_stmt] kind = apple_kinds.static_xcframework_import + + # Firebase example requires that GoogleAppMeasurement symbols are + # passed along. + attrs["alwayslink"] = True elif artifact_info.link_type == link_types.dynamic: load_stmts = [apple_dynamic_xcframework_import_load_stmt] kind = apple_kinds.dynamic_xcframework_import @@ -727,10 +732,7 @@ expected: {expected}\ build_decls.new( kind = kind, name = pkginfo_targets.bazel_label_name(target), - attrs = { - # Firebase example requires that GoogleAppMeasurement symbols - # are passed along. - "alwayslink": True, + attrs = attrs | { "visibility": ["//:__subpackages__"], "xcframework_imports": glob, }, From 42a936b2cd0c421faf2f1094626bf81cfb9a180e Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sat, 28 Sep 2024 10:58:42 -0600 Subject: [PATCH 20/21] Add back the special handling the for the SWIFTPM_MODULE_BUNDLE. --- swiftpkg/internal/swiftpkg_build_files.bzl | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/swiftpkg/internal/swiftpkg_build_files.bzl b/swiftpkg/internal/swiftpkg_build_files.bzl index 4e8e22839..db893ada3 100644 --- a/swiftpkg/internal/swiftpkg_build_files.bzl +++ b/swiftpkg/internal/swiftpkg_build_files.bzl @@ -260,23 +260,23 @@ def _clang_target_build_file(repository_ctx, pkg_ctx, target): clang_apple_res_bundle_info.bundle_label_name, )) if clang_apple_res_bundle_info.objc_accessor_hdr_label_name: - # srcs.extend([ - # ":{}".format( - # clang_apple_res_bundle_info.objc_accessor_hdr_label_name, - # ), - # # NOTE: We add the implementation below based upon what - # # type of target is using the implementation. - # ]) + srcs.extend([ + ":{}".format( + clang_apple_res_bundle_info.objc_accessor_hdr_label_name, + ), + # NOTE: We add the implementation as a dependency on a target + # that compiles the implementation. + ]) deps.append(":" + clang_apple_res_bundle_info.objc_accessor_library_label_name) - # # SPM provides a SWIFTPM_MODULE_BUNDLE macro to access the bundle for - # # ObjC code. The header file contains the macro definition. It needs - # # to be available in every Objc source file. So, we specify the - # # -include flag specifying the header path. - # # https://github.com/apple/swift-package-manager/blob/8387798811c6cc43761c5e1b48df2d3412dc5de4/Sources/Build/BuildDescription/ClangTargetBuildDescription.swift#L390 - # res_copts.append("-include$(location :{})".format( - # clang_apple_res_bundle_info.objc_accessor_hdr_label_name, - # )) + # SPM provides a SWIFTPM_MODULE_BUNDLE macro to access the bundle for + # ObjC code. The header file contains the macro definition. It needs + # to be available in every Objc source file. So, we specify the + # -include flag specifying the header path. + # https://github.com/apple/swift-package-manager/blob/8387798811c6cc43761c5e1b48df2d3412dc5de4/Sources/Build/BuildDescription/ClangTargetBuildDescription.swift#L390 + res_copts.append("-include$(location :{})".format( + clang_apple_res_bundle_info.objc_accessor_hdr_label_name, + )) local_includes = [ bzl_selects.new(value = p, kind = _condition_kinds.private_includes) From f0a8e2d1bce76799671de8bacfa96526a93c2fc8 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Sun, 29 Sep 2024 14:56:58 -0600 Subject: [PATCH 21/21] Update the swiftpkg_build_files_tests. --- swiftpkg/tests/swiftpkg_build_files_tests.bzl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/swiftpkg/tests/swiftpkg_build_files_tests.bzl b/swiftpkg/tests/swiftpkg_build_files_tests.bzl index 359ae91fb..9c6316716 100644 --- a/swiftpkg/tests/swiftpkg_build_files_tests.bzl +++ b/swiftpkg/tests/swiftpkg_build_files_tests.bzl @@ -657,7 +657,6 @@ objc_library( ], deps = [":ObjcLibrary.rspm_objc"], enable_modules = True, - hdrs = ["include/external.h"], includes = ["include"], module_name = "ObjcLibrary", sdk_frameworks = select({ @@ -676,7 +675,6 @@ objc_library( ], "//conditions:default": [], }), - textual_hdrs = ["src/foo.m"], visibility = ["//:__subpackages__"], ) @@ -748,7 +746,6 @@ objc_library( ], deps = [":ObjcLibraryWithModulemap.rspm_objc"], enable_modules = True, - hdrs = ["include/external.h"], includes = ["include"], module_name = "ObjcLibraryWithModulemap", sdk_frameworks = select({ @@ -767,7 +764,6 @@ objc_library( ], "//conditions:default": [], }), - textual_hdrs = ["src/foo.m"], visibility = ["//:__subpackages__"], ) @@ -1000,7 +996,6 @@ objc_library( data = [":ObjcLibraryWithResources.rspm_resource_bundle"], deps = [":ObjcLibraryWithResources.rspm_objc"], enable_modules = True, - hdrs = ["include/external.h"], includes = ["include"], module_name = "ObjcLibraryWithResources", sdk_frameworks = select({ @@ -1019,7 +1014,6 @@ objc_library( ], "//conditions:default": [], }), - textual_hdrs = ["src/foo.m"], visibility = ["//:__subpackages__"], ) @@ -1031,6 +1025,7 @@ objc_library( "-fPIC", "-DSWIFT_PACKAGE=1", "-Iexternal/bzlmodmangled~swiftpkg_mypackage/src", + "-include$(location :ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_hdr)", ], data = [":ObjcLibraryWithResources.rspm_resource_bundle"], deps = [":ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_library"], @@ -1056,6 +1051,7 @@ objc_library( srcs = [ "src/foo.m", "src/foo.h", + ":ObjcLibraryWithResources.rspm_objc_resource_bundle_accessor_hdr", ], textual_hdrs = ["src/foo.m"], visibility = ["//:__subpackages__"],