diff --git a/.bazelrc b/.bazelrc index 653c018cb..bf69ff1b7 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,10 +2,6 @@ # TODO: While supporting Bazel 5 we need to keep experimental flag vs using "--enable_bzlmod" common --experimental_enable_bzlmod -# We can't create a bzl_library for rules-swift because of its visibility, -# so circumvent by not using the sandbox -build --strategy=Stardoc=standalone - # Spawn strategy required for some tests build --spawn_strategy=standalone diff --git a/.bazelversion b/.bazelversion index 5e3254243..91e4a9f26 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.1.2 +6.3.2 diff --git a/MODULE.bazel b/MODULE.bazel index 043c2b1a6..31bad3026 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -55,9 +55,9 @@ bazel_dep( ) bazel_dep( name = "stardoc", - version = "0.6.2", - repo_name = "io_bazel_stardoc", + version = "0.5.6", dev_dependency = True, + repo_name = "io_bazel_stardoc", ) # Load non-bzlmod dependencies from rules_ios diff --git a/data/BUILD.bazel b/data/BUILD.bazel index 30f12bc97..45c22d0bc 100644 --- a/data/BUILD.bazel +++ b/data/BUILD.bazel @@ -1,6 +1,17 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + package(default_visibility = ["//rules/library:__pkg__"]) exports_files( ["xcspecs.bzl"], visibility = ["//docs:__pkg__"], ) + +bzl_library( + name = "xcspecs", + srcs = [ + "xcspec_evals.bzl", + "xcspecs.bzl", + ], + visibility = ["//visibility:public"], +) diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 5da1ca132..1bf88a693 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -1,50 +1,48 @@ load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") package(default_visibility = ["//visibility:private"]) -_RULES = [ +# Targets to document. +# Must have a coressponding `bzl_library` target in `//rules:BUILD.bazel`. +_DOC_SRCS = [ "app_clip", "app", - "apple_patched", "extension", + "features", + "force_load_direct_deps", "framework", "hmap", + "import_middleman", "library", "plists", "precompiled_apple_resource_bundle", + "providers", "substitute_build_settings", "test", "transition_support", + "vfs_overlay.doc", + "xcconfig.doc", ] -bzl_library( - name = "data", - srcs = [ - "//data:xcspecs.bzl", - ], - tags = ["manual"], - visibility = ["//visibility:private"], -) +# Create stardoc targets for each documentation target defined [ stardoc( - name = "%s-docs" % name, - out = "%s_doc.md" % name, - input = "//rules:%s.bzl" % name, - tags = ["manual"], - visibility = ["//:__pkg__"], - deps = [ - ":data", - "@build_bazel_rules_apple//apple", + name = file + "_doc", + out = file + ".gen.md", + input = "//rules:%s.bzl" % file, + tags = [ + "no-cache", + "no-sandbox", # https://github.com/bazelbuild/stardoc/issues/112 ], + deps = ["//rules:" + file], ) - for name in _RULES + for file in _DOC_SRCS ] filegroup( name = "_all_docs", - srcs = ["%s-docs" % name for name in _RULES], + srcs = ["%s.gen.md" % name for name in _DOC_SRCS], tags = ["manual"], ) @@ -60,7 +58,9 @@ genrule( echo "#!/bin/bash" > $(OUTS) echo "set -eu" > $(OUTS) echo 'function copy() { - dest="$${BUILD_WORKSPACE_DIRECTORY}/docs/$$(basename $$1)" + src_name=$$(basename "$$1") + dest_name=$${src_name%.gen.md}_doc.md # replace '.gen.md' with '_doc.md' + dest="$${BUILD_WORKSPACE_DIRECTORY}/docs/$${dest_name}" cp "$$1" "$$dest" chmod +w "$$dest" }' >> $(OUTS) @@ -71,3 +71,42 @@ done executable = 1, tags = ["manual"], ) + +# _RULES = [ +# "app_clip", +# "app", +# "apple_patched", +# "extension", +# "framework", +# "hmap", +# "library", +# "plists", +# "precompiled_apple_resource_bundle", +# "substitute_build_settings", +# "test", +# "transition_support", +# ] + +# bzl_library( +# name = "data", +# srcs = [ +# "//data:xcspecs.bzl", +# ], +# tags = ["manual"], +# visibility = ["//visibility:private"], +# ) + +# [ +# stardoc( +# name = "%s-docs" % name, +# out = "%s_doc.md" % name, +# input = "//rules:%s.bzl" % name, +# tags = ["manual"], +# visibility = ["//:__pkg__"], +# deps = [ +# ":data", +# "@build_bazel_rules_apple//apple", +# ], +# ) +# for name in _RULES +# ] diff --git a/docs/features_doc.md b/docs/features_doc.md new file mode 100755 index 000000000..9b2497e56 --- /dev/null +++ b/docs/features_doc.md @@ -0,0 +1,18 @@ + + + +Defines features specific to rules_ios + +- `apple.virtualize_frameworks` + - Virtualize means that swift,clang read from llvm's in-memory file system + +- `xcode.compile_with_xcode` + - Some of the rules need to work sligntly differently under pure Xcode mode + +- `apple.arm64_simulator_use_device_deps` + - Use the ARM deps for the simulator - see rules/import_middleman.bzl + +- `swift.swift_disable_import_underlying_module` + - When set disable passing the `-import-underlying-module` copt to `swift_library` targets + + diff --git a/docs/force_load_direct_deps_doc.md b/docs/force_load_direct_deps_doc.md new file mode 100755 index 000000000..3478f9953 --- /dev/null +++ b/docs/force_load_direct_deps_doc.md @@ -0,0 +1,49 @@ + + + + + + +## force_load_direct_deps + +
+force_load_direct_deps(name, deps, should_force_load)
+
+ + +A rule to link with `-force_load` for direct`deps` + +ld has different behavior when loading members of a static library VS objects +as far as visibility. Under `-dynamic` +- linked _swift object files_ can have public visibility +- symbols from _swift static libraries_ are omitted unless used, and not +visible otherwise + +By using `-force_load`, we can load static libraries in the attributes of an +application's direct depenencies. These args need go at the _front_ of the +linker invocation otherwise these arguments don't work with lds logic. + +Why not put it into `rules_apple`? Ideally it could be, and perhaps consider a +PR to there .The underlying java rule, `AppleBinary.linkMultiArchBinary` +places `extraLinkopts` at the end of the linker invocation. At the time of +writing these args need to go into the current rule context where +`AppleBinary.linkMultiArchBinary` is called. + +One use case of this is that iOS developers want to load above mentioned +symbols from applications. Another alternate could be to create an aspect, +that actually generates a different application and linker invocation instead +of force loading symbols. This could be more complicated from an integration +perspective so it isn't used. + + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| deps | - | List of labels | optional | [] | +| should_force_load | Allows parametrically enabling the functionality in this rule. | Boolean | optional | True | + + diff --git a/docs/import_middleman_doc.md b/docs/import_middleman_doc.md new file mode 100755 index 000000000..5909d0e7a --- /dev/null +++ b/docs/import_middleman_doc.md @@ -0,0 +1,78 @@ + + + + + + +## import_middleman + +
+import_middleman(name, deps, test_deps, update_in_place)
+
+ + +This rule adds the ability to update the Mach-o header on imported +libraries and frameworks to get arm64 binaires running on Apple silicon +simulator. For rules_ios, it's added in `app.bzl` and `test.bzl` + +Why bother doing this? Well some apps have many dependencies which could take +along time on vendors or other parties to update. Because the M1 chip has the +same ISA as ARM64, most binaries will run transparently. Most iOS developers +code is high level enough and isn't specifc to a device or simulator. There are +many caveats and eceptions but getting it running is better than nothing. ( e.g. +`TARGET_OS_SIMULATOR` ) + +This solves the problem at the build system level with the power of bazel. The +idea is pretty straight forward: +1. collect all imported paths +2. update the macho headers with Apples vtool and arm64-to-sim +3. update the linker invocation to use the new libs + +Now it updates all of the inputs automatically - the action can be taught to do +all of this conditionally if necessary. + +Note: The action happens in a rule for a few reasons. This has an interesting +propery: you get a single path for framework lookups at linktime. Perhaps this +can be updated to work without the other behavior + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| deps | - | List of labels | optional | [] | +| test_deps | - | List of labels | optional | [] | +| update_in_place | - | Label | optional | //tools/m1_utils:update_in_place | + + + + +## find_imports + +
+find_imports(name)
+
+ + +Internal aspect for the `import_middleman` see below for a description. + + +**ASPECT ATTRIBUTES** + + +| Name | Type | +| :------------- | :------------- | +| transitve_deps| String | +| deps| String | + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | + + diff --git a/docs/library_doc.md b/docs/library_doc.md index 31ab9cfdf..504129253 100755 --- a/docs/library_doc.md +++ b/docs/library_doc.md @@ -24,26 +24,6 @@ Extends a modulemap with a Swift submodule | swift_header | - | String | optional | "" | - - -## write_file - -
-write_file(name, content, destination)
-
- -Writes out a file verbatim - -**ATTRIBUTES** - - -| Name | Description | Type | Mandatory | Default | -| :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this target. | Name | required | | -| content | - | String | required | | -| destination | - | Label | required | | - - ## PrivateHeadersInfo diff --git a/docs/providers_doc.md b/docs/providers_doc.md new file mode 100755 index 000000000..84541ee90 --- /dev/null +++ b/docs/providers_doc.md @@ -0,0 +1,47 @@ + + + + + + +## AvoidDepsInfo + +
+AvoidDepsInfo(libraries, link_dynamic)
+
+ + + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| libraries | Libraries to avoid | +| link_dynamic | Weather or not if this dep is dynamic | + + + + +## FrameworkInfo + +
+FrameworkInfo(vfsoverlay_infos, binary, headers, private_headers, modulemap, swiftmodule, swiftdoc)
+
+ + + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| vfsoverlay_infos | Merged VFS overlay infos, present when virtual frameworks enabled | +| binary | The binary of the framework | +| headers | Headers of the framework's public interface | +| private_headers | Private headers of the framework | +| modulemap | The module map of the framework | +| swiftmodule | The swiftmodule | +| swiftdoc | The Swift doc | + + diff --git a/docs/vfs_overlay.doc_doc.md b/docs/vfs_overlay.doc_doc.md new file mode 100755 index 000000000..b80732369 --- /dev/null +++ b/docs/vfs_overlay.doc_doc.md @@ -0,0 +1,59 @@ + + + + + + +## framework_vfs_overlay + +
+framework_vfs_overlay(name, deps, extra_search_paths, framework_name, has_swift, hdrs, modulemap,
+                      private_hdrs, swiftmodules)
+
+ + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| name | A unique name for this target. | Name | required | | +| deps | - | List of labels | optional | [] | +| extra_search_paths | - | String | optional | "" | +| framework_name | - | String | required | | +| has_swift | Set to True only if there are Swift source files | Boolean | optional | False | +| hdrs | - | List of labels | optional | [] | +| modulemap | - | Label | optional | None | +| private_hdrs | - | List of labels | optional | [] | +| swiftmodules | Everything under a .swiftmodule dir if exists | List of labels | optional | [] | + + + + +## make_vfsoverlay + +
+make_vfsoverlay(ctx, hdrs, module_map, private_hdrs, has_swift, swiftmodules, merge_vfsoverlays,
+                extra_search_paths, output, framework_name)
+
+ + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| ctx |

-

| none | +| hdrs |

-

| none | +| module_map |

-

| none | +| private_hdrs |

-

| none | +| has_swift |

-

| none | +| swiftmodules |

-

| [] | +| merge_vfsoverlays |

-

| [] | +| extra_search_paths |

-

| None | +| output |

-

| None | +| framework_name |

-

| None | + + diff --git a/docs/xcconfig.doc_doc.md b/docs/xcconfig.doc_doc.md new file mode 100755 index 000000000..76a1d0261 --- /dev/null +++ b/docs/xcconfig.doc_doc.md @@ -0,0 +1,86 @@ + + + + + + +## build_setting_name + +
+build_setting_name(build_setting)
+
+ +Returns the name of a given bazel build setting from the fully-qualified label + +Fails if 'build_setting' is not in the expected format + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| build_setting | The fully-qualified label for a bazel build setting, e.g., '@repo_name//path/to/package:target_name' | none | + +**RETURNS** + +The string 'target_name' in '@repo_name//path/to/package:target_name' + + + + +## copts_by_build_setting_with_defaults + +
+copts_by_build_setting_with_defaults(xcconfig, fetch_default_xcconfig, xcconfig_by_build_setting)
+
+ +Creates a struct containing different configurable copts + +Each returned copts is a 'select()' statement keyed by the bazel build settings in 'xcconfig_by_build_setting' and each +resolved value is the result of merging 'xcconfig' with the respective build setting xcconfig and applying the +default values from 'fetch_default_xcconfig' if necessary. + +For the default value to be resolved ('//conditions:default') this macro follows the same logic described above without +the 'merging' step, so 'xcconfig' plus default values from 'fetch_default_xcconfig' if necessary. + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| xcconfig | A dictionary of Xcode build settings to be converted to different copt attributes. | {} | +| fetch_default_xcconfig | A dictionary of default Xcode build settings to be applied for the keys that are not set. | {} | +| xcconfig_by_build_setting | A dictionary where the keys are build settings names and the values are the respective dictionaries of Xcode build settings | {} | + +**RETURNS** + +Struct with different copts behind 'select()' statements + + + + +## merge_xcconfigs + +
+merge_xcconfigs(xcconfigs)
+
+ +Merges a list of xcconfigs into a single dictionary + +Overrides keys from the first xcconfig with the values from the latest one if they match. + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| xcconfigs | A list of dictionaries of Xcode build settings | none | + +**RETURNS** + +A dictionary of Xcode build settings + + diff --git a/rules/BUILD.bazel b/rules/BUILD.bazel index 0c5555608..ba3ff190b 100644 --- a/rules/BUILD.bazel +++ b/rules/BUILD.bazel @@ -12,15 +12,185 @@ genrule( ) bzl_library( - name = "bzl", - srcs = [ - "app.bzl", - "extension.bzl", - "framework.bzl", - "hmap.bzl", - "library.bzl", - "test.bzl", + name = "providers", + srcs = ["providers.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "transition_support", + srcs = ["transition_support.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "hmap", + srcs = ["hmap.bzl"], + visibility = ["//visibility:public"], + deps = ["@build_bazel_rules_swift//swift"], +) + +bzl_library( + name = "features", + srcs = ["features.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "substitute_build_settings", + srcs = ["substitute_build_settings.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "force_load_direct_deps", + srcs = ["force_load_direct_deps.bzl"], + visibility = ["//visibility:public"], + deps = [":providers"], +) + +bzl_library( + name = "xcconfig.doc", + srcs = ["xcconfig.doc.bzl"], + visibility = ["//visibility:public"], + deps = ["//rules/library:xcconfig"], +) + +bzl_library( + name = "plists", + srcs = ["plists.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":substitute_build_settings", + "//rules/library:xcconfig", + "@bazel_skylib//lib:sets", + "@bazel_skylib//lib:types", + "@bazel_skylib//rules:write_file", + ], +) + +bzl_library( + name = "vfs_overlay.doc", + srcs = ["vfs_overlay.doc.bzl"], + visibility = ["//visibility:public"], + deps = ["//rules/framework:vfs_overlay"], +) + +bzl_library( + name = "precompiled_apple_resource_bundle", + srcs = ["precompiled_apple_resource_bundle.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":transition_support", + ":utils.bzl", + "@bazel_skylib//lib:partial", + "@bazel_skylib//lib:paths", + "@build_bazel_apple_support//lib:apple_support", + "@build_bazel_rules_apple//apple", + ], +) + +bzl_library( + name = "import_middleman", + srcs = ["import_middleman.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":features", + "//rules/internal:objc_provider_utils", + "@build_bazel_rules_apple//apple", + ], +) + +bzl_library( + name = "library", + srcs = ["library.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":hmap", + ":import_middleman", + ":precompiled_apple_resource_bundle", + ":utils.bzl", + "//rules/framework:vfs_overlay", + "//rules/library:resources", + "//rules/library:xcconfig", + "@bazel_skylib//lib:paths", + "@bazel_skylib//lib:selects", + "@bazel_skylib//lib:sets", + "@bazel_skylib//rules:write_file", + "@build_bazel_rules_apple//apple", + "@build_bazel_rules_apple//apple:apple_static_library", + "@build_bazel_rules_apple//apple:resources", + "@build_bazel_rules_swift//swift", + ], +) + +bzl_library( + name = "framework", + srcs = ["framework.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":features", + ":force_load_direct_deps", + ":library", + ":plists", + ":providers", + ":transition_support", + "//rules/framework:vfs_overlay", + "//rules/internal:objc_provider_utils", + "@bazel_skylib//lib:partial", + "@bazel_skylib//lib:paths", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", + "@build_bazel_rules_apple//apple", + "@build_bazel_rules_swift//swift", + ], +) + +bzl_library( + name = "app_clip", + srcs = ["app_clip.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":force_load_direct_deps", + ":plists", + "//rules/internal:framework_middleman", + "@build_bazel_rules_apple//apple:ios", + ], +) + +bzl_library( + name = "app", + srcs = ["app.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":force_load_direct_deps", + ":library", + ":plists", + "//rules/internal:framework_middleman", + "@build_bazel_rules_apple//apple:ios", ], +) + +bzl_library( + name = "extension", + srcs = ["extension.bzl"], visibility = ["//visibility:public"], - deps = ["@build_bazel_rules_apple//apple"], + deps = [ + ":force_load_direct_deps", + ":plists", + "//rules/internal:framework_middleman", + "@build_bazel_rules_apple//apple:ios", + ], +) + +bzl_library( + name = "test", + srcs = ["test.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":library", + ":plists", + "//rules/internal:framework_middleman", + "@bazel_skylib//lib:types", + "@build_bazel_rules_apple//apple:ios", + ], ) diff --git a/rules/features.bzl b/rules/features.bzl index 64d21e594..8e261d8e9 100644 --- a/rules/features.bzl +++ b/rules/features.bzl @@ -1,3 +1,19 @@ +""" +Defines features specific to rules_ios + +- `apple.virtualize_frameworks` + - Virtualize means that swift,clang read from llvm's in-memory file system + +- `xcode.compile_with_xcode` + - Some of the rules need to work sligntly differently under pure Xcode mode + +- `apple.arm64_simulator_use_device_deps` + - Use the ARM deps for the simulator - see rules/import_middleman.bzl + +- `swift.swift_disable_import_underlying_module` + - When set disable passing the `-import-underlying-module` copt to `swift_library` targets +""" + feature_names = struct( # Virtualize means that swift,clang read from llvm's in-memory file system virtualize_frameworks = "apple.virtualize_frameworks", diff --git a/rules/framework/BUILD.bazel b/rules/framework/BUILD.bazel index f22529b26..5db75a589 100644 --- a/rules/framework/BUILD.bazel +++ b/rules/framework/BUILD.bazel @@ -1,7 +1,20 @@ load("@rules_python//python:defs.bzl", "py_binary") +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") py_binary( name = "framework_packaging", srcs = ["framework_packaging.py"], visibility = ["//visibility:public"], ) + +bzl_library( + name = "vfs_overlay", + srcs = ["vfs_overlay.bzl"], + visibility = ["//rules:__pkg__"], + deps = [ + "//rules:features", + "//rules:providers", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", + "@build_bazel_rules_swift//swift", + ], +) diff --git a/rules/internal/BUILD.bazel b/rules/internal/BUILD.bazel index e69de29bb..7c6d1528d 100644 --- a/rules/internal/BUILD.bazel +++ b/rules/internal/BUILD.bazel @@ -0,0 +1,18 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +bzl_library( + name = "objc_provider_utils", + srcs = ["objc_provider_utils.bzl"], + visibility = ["//rules:__pkg__"], +) + +bzl_library( + name = "framework_middleman", + srcs = ["framework_middleman.bzl"], + visibility = ["//rules:__pkg__"], + deps = [ + ":objc_provider_utils", + "@bazel_skylib//lib:partial", + "@build_bazel_rules_apple//apple", + ], +) diff --git a/rules/library.bzl b/rules/library.bzl index 86bac105c..db84353a9 100644 --- a/rules/library.bzl +++ b/rules/library.bzl @@ -3,7 +3,8 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//lib:sets.bzl", "sets") load("@bazel_skylib//lib:selects.bzl", "selects") -load("@build_bazel_rules_apple//apple:apple.bzl", "apple_dynamic_framework_import", "apple_static_framework_import") +load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("@build_bazel_rules_apple//apple/internal:apple_framework_import.bzl", "apple_dynamic_framework_import", "apple_static_framework_import") load("@build_bazel_rules_apple//apple/internal/resource_rules:apple_intent_library.bzl", "apple_intent_library") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") load("//rules:precompiled_apple_resource_bundle.bzl", "precompiled_apple_resource_bundle") @@ -45,21 +46,6 @@ _private_headers = rule( }, ) -def _write_file_impl(ctx): - ctx.actions.write( - output = ctx.outputs.destination, - content = ctx.attr.content, - ) - -write_file = rule( - implementation = _write_file_impl, - attrs = { - "content": attr.string(mandatory = True), - "destination": attr.output(mandatory = True), - }, - doc = "Writes out a file verbatim", -) - def _extend_modulemap_impl(ctx): args = ctx.actions.args() args.add(""" @@ -120,8 +106,8 @@ module {module_name} {{ write_file( name = basename + "~", - destination = destination, - content = content, + out = destination, + content = content.split("\n"), tags = _MANUAL, ) return destination @@ -170,8 +156,8 @@ FOUNDATION_EXPORT const unsigned char {module_name}VersionString[]; write_file( name = basename + "~", - destination = destination, - content = content, + out = destination, + content = content.split("\n"), tags = _MANUAL, ) return destination diff --git a/rules/library/BUILD.bazel b/rules/library/BUILD.bazel index 8c6ad0682..69d8263c0 100644 --- a/rules/library/BUILD.bazel +++ b/rules/library/BUILD.bazel @@ -1,4 +1,24 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + exports_files([ "common.pch", "resource_bundle.plist", ]) + +bzl_library( + name = "xcconfig", + srcs = ["xcconfig.bzl"], + visibility = ["//rules:__pkg__"], + deps = [ + "//data:xcspecs", + "@bazel_skylib//lib:dicts", + "@bazel_skylib//lib:shell", + "@bazel_skylib//lib:types", + ], +) + +bzl_library( + name = "resources", + srcs = ["resources.bzl"], + visibility = ["//rules:__pkg__"], +) diff --git a/rules/library/xcconfig.bzl b/rules/library/xcconfig.bzl index 8f37ea0d3..c3e47705a 100644 --- a/rules/library/xcconfig.bzl +++ b/rules/library/xcconfig.bzl @@ -257,6 +257,7 @@ def build_setting_name(build_setting): Args: build_setting: The fully-qualified label for a bazel build setting, e.g., '@repo_name//path/to/package:target_name' + Returns: The string 'target_name' in '@repo_name//path/to/package:target_name' """ @@ -284,6 +285,7 @@ def copts_by_build_setting_with_defaults(xcconfig = {}, fetch_default_xcconfig = to be applied for the keys that are not set. xcconfig_by_build_setting: A dictionary where the keys are build settings names and the values are the respective dictionaries of Xcode build settings + Returns: Struct with different copts behind 'select()' statements """ @@ -333,6 +335,7 @@ def merge_xcconfigs(*xcconfigs): Args: *xcconfigs: A list of dictionaries of Xcode build settings + Returns: A dictionary of Xcode build settings """ diff --git a/rules/plists.bzl b/rules/plists.bzl index e3532b09e..d62717373 100644 --- a/rules/plists.bzl +++ b/rules/plists.bzl @@ -4,8 +4,8 @@ Defines macros for working with plist files. load("@bazel_skylib//lib:types.bzl", "types") load("@bazel_skylib//lib:sets.bzl", "sets") +load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@build_bazel_rules_ios//rules:substitute_build_settings.bzl", "substitute_build_settings") -load("//rules:library.bzl", "write_file") load("//rules/library:xcconfig.bzl", "build_setting_name", "merge_xcconfigs") def process_infoplists(name, infoplists, infoplists_by_build_setting, xcconfig, xcconfig_by_build_setting): @@ -109,8 +109,8 @@ def write_info_plists_if_needed(name, plists): plist_name = "{name}.infoplist.{idx}".format(name = name, idx = idx) write_file( name = plist_name, - destination = plist_name + ".plist", - content = struct(**plist).to_json(), + out = plist_name + ".plist", + content = [struct(**plist).to_json()], ) written_plists.append(plist_name) else: diff --git a/rules/vfs_overlay.doc.bzl b/rules/vfs_overlay.doc.bzl new file mode 100644 index 000000000..ec7a28e51 --- /dev/null +++ b/rules/vfs_overlay.doc.bzl @@ -0,0 +1,8 @@ +load( + "//rules/framework:vfs_overlay.bzl", + _framework_vfs_overlay = "framework_vfs_overlay", + _make_vfsoverlay = "make_vfsoverlay", +) + +framework_vfs_overlay = _framework_vfs_overlay +make_vfsoverlay = _make_vfsoverlay diff --git a/rules/xcconfig.doc.bzl b/rules/xcconfig.doc.bzl new file mode 100644 index 000000000..30367e168 --- /dev/null +++ b/rules/xcconfig.doc.bzl @@ -0,0 +1,10 @@ +load( + "//rules/library:xcconfig.bzl", + _build_setting_name = "build_setting_name", + _copts_by_build_setting_with_defaults = "copts_by_build_setting_with_defaults", + _merge_xcconfigs = "merge_xcconfigs", +) + +build_setting_name = _build_setting_name +copts_by_build_setting_with_defaults = _copts_by_build_setting_with_defaults +merge_xcconfigs = _merge_xcconfigs