-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update stardoc for bzlmod #776
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,3 @@ | |
# This file will generally be kept empty in favor of using MODULE.bazel fully. | ||
|
||
workspace(name = "build_bazel_rules_ios") | ||
|
||
# TODO: stardoc doesn't currently support bzlmod: https://github.com/bazelbuild/stardoc/issues/117 | ||
# Once that closes we should depend on it via the WORKSPACE file. | ||
# In the meantime, this is a workaround to at least allow building. | ||
# Note however that updating docs with bzlmod will not work until the above is resolved. | ||
# Until then use: --noenable_bzlmod | ||
load( | ||
"@bazel_tools//tools/build_defs/repo:git.bzl", | ||
"git_repository", | ||
) | ||
|
||
git_repository( | ||
name = "io_bazel_stardoc", | ||
commit = "6f274e903009158504a9d9130d7f7d5f3e9421ed", | ||
remote = "https://github.com/bazelbuild/stardoc.git", | ||
shallow_since = "1667581897 -0400", | ||
) | ||
|
||
load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") | ||
|
||
stardoc_repositories() | ||
Comment on lines
6
to
-27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now fully bzlmod 🎉 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,49 @@ | ||
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 corresponding `bzl_library` target in `//rules:BUILD.bazel`. | ||
_DOC_SRCS = [ | ||
"app_clip", | ||
"app", | ||
"apple_patched", | ||
luispadron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"extension", | ||
"features", | ||
"force_load_direct_deps", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A number of the files are internal ones we don't consider upholding an API contract for or have quality starlark doc comments about said internal components; though if other people really want to have this I'm not opposed - nor do I think it will change the lack of some API contract beyond There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Features seems useful and imo more of the public API than some of the other things we've said are. Do you have a specific list you'd want me to remove? |
||
"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 +59,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%%.*}_doc.md # replace generated extension with '_doc.md' | ||
dest="$${BUILD_WORKSPACE_DIRECTORY}/docs/$${dest_name}" | ||
cp "$$1" "$$dest" | ||
chmod +w "$$dest" | ||
}' >> $(OUTS) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
||
|
||
|
||
<a id="force_load_direct_deps"></a> | ||
|
||
## force_load_direct_deps | ||
|
||
<pre> | ||
force_load_direct_deps(<a href="#force_load_direct_deps-name">name</a>, <a href="#force_load_direct_deps-deps">deps</a>, <a href="#force_load_direct_deps-should_force_load">should_force_load</a>) | ||
</pre> | ||
|
||
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 | | ||
| :------------- | :------------- | :------------- | :------------- | :------------- | | ||
| <a id="force_load_direct_deps-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | | ||
| <a id="force_load_direct_deps-deps"></a>deps | - | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | | ||
| <a id="force_load_direct_deps-should_force_load"></a>should_force_load | Allows parametrically enabling the functionality in this rule. | Boolean | optional | `True` | | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required by new stardoc versions