Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Merge 0.23.0 from upstream to textnow branch #3

Merged
merged 153 commits into from
Sep 21, 2021
Merged
Changes from 1 commit
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
616439c
Add .clang-format (#467)
keith Aug 11, 2020
b255732
Add error for no Linux swiftc path (#466)
keith Aug 11, 2020
d93238e
Update dump_toolchains to support home dir (#471)
keith Aug 11, 2020
e87aace
Run clang-format on everything (#470)
keith Aug 11, 2020
fe0a881
Update README instructions (#472)
keith Aug 11, 2020
49de7e5
Ensure that `swift_module_alias` propagates instrumented file info fr…
allevato Aug 6, 2020
fc74b43
Allow generated headers with path separators (#439)
michaeleisel Aug 13, 2020
4bc7405
Delete CONTRIBUTORS (#475)
keith Aug 13, 2020
44e8c29
Various changes related to explicit module compilation: (#477)
keith Aug 22, 2020
d5eb04f
Use a parameter file when linking Swift libraries when the host machi…
thii Aug 24, 2020
a59b8d1
Read the `custom_malloc` configuration field in `swift_{binary,test}`…
keith Aug 31, 2020
28365f0
No need to check if we're on macOS for non-Darwin Swift toolchain (#479)
thii Aug 31, 2020
8015d0e
Update protobuf deps (#480)
keith Sep 1, 2020
9110727
Run //test/... on Linux CI (#463)
keith Sep 2, 2020
57058aa
Ensure that intermediate outputs created for Swift source files (such…
allevato Sep 2, 2020
beb3a30
Update bzl_library targets (#482)
segiddins Sep 4, 2020
48f1b57
Add a feature flag to enable generation from raw proto sources.
thomasvl Sep 8, 2020
9eef33f
Honor the feature flag to enable generation from raw proto sources.
thomasvl Sep 9, 2020
6ae82f5
Remove unused value.
thomasvl Sep 9, 2020
4f4b7f0
Don't propagate an empty module map for `{cc,objc}_library` targets t…
allevato Sep 17, 2020
d2efe38
Added helper macro for declaring transitive dependencies
UebelAndre Sep 13, 2020
b7a2693
Update README shas
keith Sep 21, 2020
9d472c1
Fix buildifier warning
keith Oct 8, 2020
abc377e
Update rules_swift to use the toolchain transition.
a-googler Sep 30, 2020
8e3715a
Update apple_support
keith Oct 8, 2020
3ad9d41
Implement -coverage-prefix-map feature (#489)
keith Oct 13, 2020
cfd9e36
Update worker docstring with example (#505)
keith Oct 14, 2020
dcc5235
Introduce feature to register a separate action to generate swift der…
ghvg1313 Oct 20, 2020
3dcf6f1
Fix index while building with derived files (#506)
keith Oct 20, 2020
f1e125c
Fix derive files with bitcode (#509)
keith Oct 21, 2020
cd66dc7
Output command lines of failed action command line tests (#508)
keith Oct 21, 2020
320d0a3
Add swift.remap_xcode_path feature (#511)
keith Oct 22, 2020
410d8ed
Only read output_file_map if it's going to be written
Apr 21, 2020
ed81c15
Create a build setting to allow forcing a Swift target to Apple with …
keith Oct 30, 2020
17126a9
Update apple_support (#517)
keith Nov 4, 2020
2279303
Update README with new URLs (#518)
keith Nov 4, 2020
aff1754
Migrate to the modern Starlark linker input API. (#512)
benjaminp Nov 6, 2020
8141f74
Update README with new URLs (#520)
keith Nov 10, 2020
77afbc2
Update protobuf (#524)
keith Nov 14, 2020
64c7b95
Clean up some old TODOs.
thomasvl Nov 25, 2020
fe9d08e
Remove the `swift.implicit_modules` feature.
allevato Dec 1, 2020
420cc7a
Stop computing transitive_generated_headers.
thomasvl Nov 30, 2020
a277fe4
Standardize on FIXTURE_TAGS, ensure all targets tagged.
thomasvl Dec 1, 2020
efc75e0
Deduplicate module map flags in Swift compilation
thii Oct 9, 2020
cd67dae
Revert "Migrate to the modern Starlark linker input API. (#512)"
keith Nov 11, 2020
2e1d299
Migrate Swift build rules to the new C++ `LinkerInput` APIs.
allevato Nov 11, 2020
989430f
Fix tests
keith Dec 1, 2020
7fdbb71
Make the `srcs` attribute of `swift_library` mandatory and non-empty.
allevato Dec 2, 2020
0f77332
Update README with new URLs
keith Dec 2, 2020
eca50db
Migration off SwiftInfo.module_name.
thomasvl Dec 2, 2020
768bfe3
Add the SDK's `Developer/Library/Frameworks` directory to the compile…
allevato Dec 10, 2020
92ce702
Require `name` to be a named argument.
thomasvl Dec 11, 2020
bdb2a7b
Retire `module_name` from create_swift_info.
thomasvl Dec 11, 2020
134370d
Allow `optional_implicit_deps` and `required_implicit_deps` to be set…
allevato Dec 16, 2020
e46ae72
Fix XCTest -I for derived files
keith Dec 17, 2020
c512f8e
Remove SwiftInfo.module_name, it was deprecated a while ago.
thomasvl Dec 17, 2020
c517a72
Ignore a feature when a `SwiftToolchainInfo` says it does not support…
allevato Dec 17, 2020
d916037
Uniquify `-fmodule-map-file=` flags passed to `swiftc`.
allevato Dec 18, 2020
ca8fe5b
Work around https://github.com/bazelbuild/stardoc/issues/78.
thomasvl Dec 22, 2020
329a810
Update README with new URLs
keith Jan 7, 2021
d701900
Allow modules propagated by `SwiftInfo` to indicate whether they are …
allevato Jan 15, 2021
5a4f76d
Stop computing/tracking defines.
thomasvl Jan 13, 2021
3d1f6a3
Remove swift_version.
thomasvl Jan 13, 2021
08e3036
Add a `swift_explicit_module` output group to the `swift_clang_module…
allevato Jan 21, 2021
d0b6a7e
Lessen restrictions on when implicit modules can be used:
allevato Jan 25, 2021
4de93c1
Fix header selection when falling back to implicit modules.
allevato Jan 27, 2021
c2eb110
Simplify the paths to module maps generated by the Swift build rules.
allevato Jan 27, 2021
fb60b54
Automated rollback of commit 71998c865b827828c17dbd24bf48bb856523d4f5.
allevato Jan 27, 2021
aa54225
Simplify the paths to module maps generated by the Swift build rules.
allevato Jan 28, 2021
1ef4601
Use released protoc binaries where possible (#555)
thii Feb 1, 2021
18b48c2
Add disable system index feature (#563)
keith Feb 8, 2021
dadd121
Don't re-export the modules imported by a Swift generated header.
allevato Feb 8, 2021
9e743aa
Explicitly set --macos_minimum_os=10.15 to make `swift_{binary,test}`…
thii Feb 17, 2021
3d59e85
Move toolchain- and command-line-provided compiler flags into action …
allevato Feb 3, 2021
3c7ed71
Fix incorrect param name
thii Feb 22, 2021
daf7baa
Fix non-threaded mode WMO
thii Feb 23, 2021
a84b2c6
No longer scan for `-num-threads=X` (specifically the form with the e…
allevato Feb 4, 2021
87b4d41
Unconditionally add `ObjcProvider.umbrella_header` files to compiler …
allevato Feb 4, 2021
ad39543
Compile an explicit module for the generated header of a `swift_libra…
allevato Feb 19, 2021
ff33061
Pass framework search paths directly to clang for pcms
brentleyjones Feb 25, 2021
22a2472
Pass `-no-clang-module-breadcrumbs` to frontend jobs (#574)
thii Feb 26, 2021
5fc096e
Add remotely debuggable Swift document (#576)
keith Mar 12, 2021
6ebb0f0
Update apple_support (#577)
keith Mar 12, 2021
0e84c1e
Update README for new URL (#578)
keith Mar 12, 2021
2a20daa
Support "Make" variable expansion in `copts` and `linkopts`
omarzl Mar 16, 2021
d8d688c
Add a `generates_header` attribute to `swift_library` to control Obje…
allevato Mar 12, 2021
f1c30a2
Internal change.
allevato Apr 2, 2021
9cba5ec
Switch to XcodeVersionConfig.execution_info().
thomasvl Mar 24, 2021
e7ec735
Distinguish between direct and transitive information when creating t…
allevato Mar 17, 2021
03dd9ab
Delete support for compiler performance stats collection.
allevato Mar 19, 2021
97221ad
Simplify and cleanup how implicit toolchain dependencies are managed.
allevato Apr 6, 2021
430311c
Update examples/tests with `generates_header = True` where necessary …
allevato Mar 15, 2021
f81fa6f
Make `swift_library` not generate an Objective-C header by default.
allevato Apr 6, 2021
006a981
Update apple_support to new release
keith Apr 7, 2021
9c8d8f7
Update README with new URLs
keith Apr 7, 2021
a62e084
Add -Werror for C++
keith Apr 7, 2021
5bf6ef7
Fix skylib branch name
keith Apr 19, 2021
21b1541
Add first stardoc API docgen target (#598)
alexeagle Apr 30, 2021
4ee4be0
Generate providers.md from sources (#599)
alexeagle Apr 30, 2021
ec1c3ff
Add `swift_common.create_swift_interop_info`.
allevato Apr 7, 2021
3009fc2
Move swift_clang_module_aspect out of swift_common and directly expos…
thomasvl Apr 9, 2021
29f26cd
Update the module name derivation algorithm to handle any sequence of…
allevato Apr 12, 2021
dea7e72
API changes to `create_swift_interop_info`.
allevato Apr 15, 2021
5f6154d
Factor out Bazel placeholder substitution functionality into a separa…
allevato Apr 2, 2021
65af062
Support older C++ versions
keith Apr 6, 2021
26f81ca
Sort headers in the module maps generated by `swift_clang_module_aspe…
allevato Apr 7, 2021
b1cc212
Remove top level functions for now
keith May 4, 2021
e77df5b
Use cpp fragment, instead of objc fragment, to determine whether to g…
googlewalt Apr 28, 2021
1b4e4c0
Add support for older bazel versions for now
keith May 4, 2021
728528d
Add Xcode toolchain support for an optional binary that can rewrite t…
allevato Apr 19, 2021
bb2efe2
Disable generated_header_rewriter for now
keith May 4, 2021
b44baa3
Make the strict include paths from `objc_proto_library` targets avail…
a-googler Apr 28, 2021
0004011
Rename `swift.strict_modules` to `swift.layering_check` to match the …
allevato May 3, 2021
ee7e6e3
Add a user settable build setting to specify additional swiftcopts fo…
a-googler May 3, 2021
51a8f82
Disable allow_multiple for per_module_swiftcopt_flag
keith May 4, 2021
52827d9
Update README with new URLs
keith May 4, 2021
aab5e21
Use target_compatible_with for macOS only tests (#514)
keith May 4, 2021
83d2fb7
Add `swift.global_module_cache_uses_tmpdir` feature (#581)
brentleyjones May 13, 2021
e64d472
Stop passing `uses_swift` to `new_objc_provider`.
allevato May 14, 2021
c674b9d
Enable CI testing for docgen (#617)
alexeagle May 18, 2021
ae0c5bd
Generate api.md from sources (#618)
alexeagle May 18, 2021
9f42d75
Generate setup.md from sources (#619)
alexeagle May 19, 2021
ce67397
Update README with new URLs (#621)
keith May 27, 2021
bdf5288
Update bazel_skylib (#620)
keith May 27, 2021
a757f59
Update the worker protocol proto (#622)
segiddins May 27, 2021
d824463
Add ubsan support (#544)
keith May 28, 2021
7197d5a
Remove unused command_line_copts (#625)
keith May 28, 2021
4979602
Include the headers from direct dependencies of a Swift target when c…
allevato May 6, 2021
8e63bad
Use `-fsystem-module` if the compiler is new enough to support it (Xc…
allevato May 11, 2021
a0fcdeb
Add the `swift_feature_allowlist` rule that lets toolchains control w…
keith May 28, 2021
046ab58
Disable layering checks when compiling the explicit module for a Swif…
allevato May 4, 2021
021c11b
Disable layering checks for now
keith May 28, 2021
0414e01
Revert "Disable layering checks for now"
keith May 28, 2021
7688933
Get rid of the non-strict use of `-fmodules-decluse`.
allevato May 25, 2021
0487a75
Support implicit C/Objective-C dependencies that are passed when comp…
allevato May 25, 2021
bc0bd43
Update docs
keith May 28, 2021
cde2112
Get rid of spurious diagnostics when compiling system modules with Xc…
allevato May 26, 2021
3d6141f
Add buildifier pre-commit hook (#632)
alexeagle Jun 3, 2021
84286ad
Reuse swiftmodule for incremental builds (#633)
brentleyjones Jun 4, 2021
254e3fa
Add returns (#634)
brentleyjones Jun 7, 2021
914eff9
Implement global index store cache (#567)
jerrymarino Jun 9, 2021
325b91f
Modernize `xcode_swift_toolchain` features and linkopts.
allevato Jun 7, 2021
1b6b854
Remove the `-rpath` for the Xcode's developer frameworks directory fr…
allevato Jun 9, 2021
446d8f4
Propagate Swift-specific linker flags as an implicit dependency of th…
allevato Jun 7, 2021
1386592
Fix worker based error reporting for WMO (#642)
brentleyjones Jun 10, 2021
ebd6175
Fix race condition in MakeDirs (#644)
jerrymarino Jun 10, 2021
0d0f913
Error out on failed `MakeDir` (#645)
brentleyjones Jun 10, 2021
7e284a9
Delete the `swift_common.swift_runtime_linkopts` function.
allevato Jun 10, 2021
1946db6
Refer to build_bazel_rules_swift_index_import via a file rather than …
segiddins Jun 10, 2021
b630afe
Add files in third_party to :for_bazel_tests (#648)
segiddins Jun 11, 2021
334b6fd
Fix index_import label
keith Jun 11, 2021
8dd2c94
Update apple_support to 0.11.0
keith Jun 11, 2021
54cd4b0
Merge tag '0.23.0' into textnow
severnt Sep 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sort headers in the module maps generated by `swift_clang_module_aspe…
…ct`, and rewrite generation to use a multi-line `Args` object as a file writer instead of building up an analysis time string.

With this approach, each "arg" (or each entry in a list/depset of args) is treated as its own line in the output file; we use the `format_each` and `map_each` parameters to provide any additional text that should surround that value on the line.

More importantly, this adds support for expanding tree artifacts (directories) if one is provided in a compilation context.

PiperOrigin-RevId: 367221120
(cherry picked from commit 5f7af69)
allevato authored and keith committed May 4, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 26f81cac555e3d0b22d01fc11ad0b0362538a12e
145 changes: 84 additions & 61 deletions swift/internal/module_maps.bzl
Original file line number Diff line number Diff line change
@@ -14,8 +14,6 @@

"""Logic for generating Clang module map files."""

load("@bazel_skylib//lib:paths.bzl", "paths")

def write_module_map(
actions,
module_map_file,
@@ -55,69 +53,93 @@ def write_module_map(
written in the module map file should be relative to the workspace
or relative to the module map file.
"""
content = 'module "{}" {{\n'.format(module_name)
if exported_module_ids:
content += "".join([
" export {}\n".format(module_id)
for module_id in exported_module_ids
])
content += "\n"

content += "".join([
' header "{}"\n'.format(_header_path(
header_file = header_file,
module_map_file = module_map_file,
workspace_relative = workspace_relative,
))
for header_file in public_headers
])
content += "".join([
' private header "{}"\n'.format(_header_path(
header_file = header_file,
module_map_file = module_map_file,
workspace_relative = workspace_relative,
))
for header_file in private_headers
])
content += "".join([
' textual header "{}"\n'.format(_header_path(
header_file = header_file,
module_map_file = module_map_file,
workspace_relative = workspace_relative,
))
for header_file in public_textual_headers
])
content += "".join([
' private textual header "{}"\n'.format(_header_path(
header_file = header_file,
module_map_file = module_map_file,
workspace_relative = workspace_relative,
))
for header_file in private_textual_headers
])

content += "".join([
' use "{}"\n'.format(name)
for name in dependent_module_names
])

content += "}\n"

# In the non-workspace-relative case, precompute the relative-to-dir and the
# repeated `../` string used to go back up to the workspace root instead of
# recomputing it every time a header path is written.
if workspace_relative:
relative_to_dir = None
back_to_root_path = None
else:
relative_to_dir = module_map_file.dirname
back_to_root_path = "../" * len(relative_to_dir.split("/"))

content = actions.args()
content.set_param_file_format("multiline")

content.add(module_name, format = 'module "%s" {')

# Write an `export` declaration for each of the module identifiers that
# should be re-exported by this module.
content.add_all(exported_module_ids, format_each = " export %s")
content.add("")

def _add_headers(*, headers, kind):
# Each header is added to the `Args` object as a tuple along with
# `relative_to_dir` and `back_to_root_path`. This gives the mapping
# function the information it needs to relativize the header paths even
# when they're expanded from a tree artifact (and thus not known at
# analysis time).
content.add_all(
[(file, relative_to_dir, back_to_root_path) for file in headers],
format_each = ' {} "%s"'.format(kind),
map_each = _header_info_mapper,
)

_add_headers(headers = public_headers, kind = "header")
_add_headers(headers = private_headers, kind = "private header")
_add_headers(headers = public_textual_headers, kind = "textual header")
_add_headers(
headers = private_textual_headers,
kind = "private textual header",
)
content.add("")

# Write a `use` declaration for each of the module's dependencies.
content.add_all(dependent_module_names, format_each = ' use "%s"')
content.add("}")

actions.write(
content = content,
output = module_map_file,
)

def _header_path(header_file, module_map_file, workspace_relative):
def _header_info_mapper(header_info, directory_expander):
"""Maps header info passed to the `Args` object to a list of header paths.

Args:
header_info: A tuple containing three elements: a `File` representing a
header (or a directory containing headers), the path to the
directory that should be used to relativize the header paths, and
the path string consisting of repeated `../` segments that should be
used to return from the module map's directory to the workspace
root. The latter two elements will be `None` if the headers should
be written workspace-relative).
directory_expander: The object used to expand tree artifacts into the
list of files in that directory.

Returns:
A list of file paths as they should be written into the module map file.
"""
return [
_header_path(file, header_info[1], header_info[2])
for file in directory_expander.expand(header_info[0])
]

def _header_path(header_file, relative_to_dir, back_to_root_path):
"""Returns the path to a header file to be written in the module map.

Args:
header_file: A `File` representing the header whose path should be
returned.
module_map_file: A `File` representing the module map being written,
which is used during path relativization if necessary.
workspace_relative: A Boolean value indicating whether the path should
be workspace-relative or module-map-relative.
relative_to_dir: A `File` representing the module map being
written, which is used during path relativization if necessary. If
this is `None`, then no relativization is performed of the header
path and the workspace-relative path is used instead.
back_to_root_path: A path string consisting of repeated `../` segments
that should be used to return from the module map's directory to the
workspace root. This should be `None` if `relative_to_dir` is
`None`.

Returns:
The path to the header file, relative to either the workspace or the
@@ -126,20 +148,21 @@ def _header_path(header_file, module_map_file, workspace_relative):

# If the module map is workspace-relative, then the file's path is what we
# want.
if workspace_relative:
if not relative_to_dir:
return header_file.path

# Minor optimization for the generated Objective-C header of a Swift module,
# which will be in the same directory as the module map file -- we can just
# use the header's basename instead of the elaborate relative path
# computation below.
if header_file.dirname == module_map_file.dirname:
# use the header's basename instead of the elaborate relative path string
# below.
if header_file.dirname == relative_to_dir:
return header_file.basename

# Otherwise, since the module map is generated, we need to get the full path
# to it rather than just its short path (that is, the path starting with
# bazel-out/). Then, we can simply walk up the same number of parent
# directories as there are path segments, and append the header file's path
# to that.
num_segments = len(paths.dirname(module_map_file.path).split("/"))
return ("../" * num_segments) + header_file.path
# to that. The `back_to_root_path` string is guaranteed to end in a slash,
# so we use simple concatenation instead of Skylib's `paths.join` to avoid
# extra work.
return back_to_root_path + header_file.path
21 changes: 17 additions & 4 deletions swift/internal/swift_clang_module_aspect.bzl
Original file line number Diff line number Diff line change
@@ -248,15 +248,28 @@ def _generate_module_map(
actions = actions,
target_name = target.label.name,
)

# Sort dependent module names and the headers to ensure a deterministic
# order in the output file, in the event the compilation context would ever
# change this on us. For files, use the execution path as the sorting key.
def _path_sorting_key(file):
return file.path

write_module_map(
actions = actions,
dependent_module_names = dependent_module_names,
dependent_module_names = sorted(dependent_module_names),
exported_module_ids = ["*"],
module_map_file = module_map_file,
module_name = module_name,
private_headers = private_headers,
public_headers = compilation_context.direct_public_headers,
public_textual_headers = compilation_context.direct_textual_headers,
private_headers = sorted(private_headers, key = _path_sorting_key),
public_headers = sorted(
compilation_context.direct_public_headers,
key = _path_sorting_key,
),
public_textual_headers = sorted(
compilation_context.direct_textual_headers,
key = _path_sorting_key,
),
workspace_relative = workspace_relative,
)
return module_map_file