Skip to content
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

Add CI tests for Build without the Bytes #884

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .github/workflows/preflight_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ if [[ "$*" == *--no-bzlmod* ]]; then
echo "build --noenable_bzlmod" >> user.bazelrc
fi

# If `RULES_APPLE_SWIFT_VERSION` is set to `latest` use the master branch of rules_swift and rules_apple.
if [[ "${RULES_APPLE_RULES_SWIFT_VERSION}" == "latest" ]]; then
gh repo clone bazelbuild/rules_swift /tmp/rules_swift
gh repo clone bazelbuild/rules_apple /tmp/rules_apple
echo "common --override_module=rules_swift=/tmp/rules_swift" >> user.bazelrc
echo "common --override_module=rules_apple=/tmp/rules_apple" >> user.bazelrc
fi

# Add the ci config override.
echo "common --config=ci" >> user.bazelrc

Expand Down
66 changes: 65 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
fail-fast: false
matrix:
bazel_version: [6.5.0, 7.1.0]
xcode_version: [15.2]
virtual_frameworks: [true, false]
xcode_version: [15.2]
env:
XCODE_VERSION: ${{ matrix.xcode_version }}
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
Expand Down Expand Up @@ -155,3 +155,67 @@ jobs:
--config=ios_multi_arch_test \
-- \
tests/ios/app/App

build_without_the_bytes:
name: Build without the Bytes (Bazel ${{ matrix.bazel_version }} / Outputs level ${{matrix.download_outputs_level}} / rule versions ${{ matrix.rule_versions }} / Xcode ${{ matrix.xcode_version }})
runs-on: macos-14
strategy:
fail-fast: false
matrix:
bazel_version: [7.1.0]
download_outputs_level: ["minimal", "toplevel"]
rule_versions: ["current", "latest"]
xcode_version: [15.2]
env:
GH_TOKEN: ${{ github.token }}
RULES_APPLE_RULES_SWIFT_VERSION: ${{ matrix.rule_versions }}
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
XCODE_VERSION: ${{ matrix.xcode_version }}
steps:
- uses: actions/checkout@v4
- name: Preflight Env
run: .github/workflows/preflight_env.sh
- name: Build using Build without the Bytes
run: |
# non-iOS
bazelisk build \
--remote_download_outputs=${{matrix.download_outputs_level}} \
--disk_cache="/tmp/bazel-rules_ios-bwtb-cache" \
--remote_cache= \
-- \
//... \
-//tests/ios/...
# Clean the caches to test that BwtB works
bazel clean --expunge
# Run the same build again
bazelisk build \
--remote_download_outputs=${{matrix.download_outputs_level}} \
--disk_cache="/tmp/bazel-rules_ios-bwtb-cache" \
--remote_cache= \
-- \
//... \
-//tests/ios/...

# iOS
bazelisk build \
--config=ios \
--remote_download_outputs=${{matrix.download_outputs_level}} \
--disk_cache="/tmp/bazel-rules_ios-bwtb-ios-cache" \
--remote_cache= \
-- \
//tests/ios/...
# Clean the caches to test that BwtB works
bazel clean --expunge
# Run the same build again
bazelisk build \
--config=ios \
--remote_download_outputs=${{matrix.download_outputs_level}} \
--disk_cache="/tmp/bazel-rules_ios-bwtb-ios-cache" \
--remote_cache= \
-- \
//tests/ios/...
- uses: actions/upload-artifact@v4
if: failure()
with:
name: bazel-testlogs
path: bazel-testlogs
12 changes: 5 additions & 7 deletions rules/framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,11 @@ def _apple_framework_packaging_impl(ctx):
objc_provider_utils.add_to_dict_if_present(compilation_context_fields, "headers", depset(
direct = outputs.headers + outputs.private_headers + outputs.modulemaps,
))
objc_provider_utils.add_to_dict_if_present(
compilation_context_fields,
"direct_public_headers",
outputs.headers + outputs.modulemaps,
)
objc_provider_utils.add_to_dict_if_present(compilation_context_fields, "defines", depset(
direct = [],
transitive = [getattr(cc_info.compilation_context, "defines") for cc_info in dep_cc_infos],
Expand Down Expand Up @@ -1211,13 +1216,6 @@ that this target depends on.
""",
cfg = transition_support.apple_platform_split_transition,
),
"_headermap_builder": attr.label(
executable = True,
cfg = "exec",
default = Label(
"//rules/hmap:hmaptool",
),
),
"stamp": attr.int(
mandatory = False,
default = 0,
Expand Down
11 changes: 7 additions & 4 deletions rules/framework/vfs_overlay.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ def _framework_vfs_overlay_impl(ctx):
if VFSOverlayInfo in dep:
vfsoverlays.append(dep[VFSOverlayInfo].vfs_info)

vfs_overlay_file = ctx.actions.declare_file(ctx.label.name + ".yaml")

vfs = make_vfsoverlay(
ctx,
hdrs = ctx.files.hdrs,
Expand All @@ -275,17 +277,21 @@ def _framework_vfs_overlay_impl(ctx):
has_swift = ctx.attr.has_swift,
swiftmodules = ctx.files.swiftmodules,
merge_vfsoverlays = vfsoverlays,
output = ctx.outputs.vfsoverlay_file,
output = vfs_overlay_file,
extra_search_paths = ctx.attr.extra_search_paths,
)

headers = depset([vfs.vfsoverlay_file])
cc_info = CcInfo(
compilation_context = cc_common.create_compilation_context(
headers = headers,
direct_public_headers = [vfs.vfsoverlay_file],
),
)
return [
DefaultInfo(
files = depset([vfs_overlay_file]),
),
apple_common.new_objc_provider(),
cc_info,
VFSOverlayInfo(
Expand Down Expand Up @@ -446,7 +452,4 @@ toolchain (such as `clang`) will be retrieved.
fragments = [
"apple",
],
outputs = {
"vfsoverlay_file": "%{name}.yaml",
},
)
26 changes: 17 additions & 9 deletions rules/hmap.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ def _make_hmap(actions, headermap_builder, output, namespace, hdrs_lists):
args.set_param_file_format(format = "multiline")
args.use_param_file("@%s")

headers = [
header
for header_list in hdrs_lists
for header in header_list
]

actions.run(
mnemonic = "HmapCreate",
arguments = [args],
inputs = headers,
executable = headermap_builder,
outputs = [output],
)
Expand Down Expand Up @@ -63,32 +70,34 @@ def _make_headermap_impl(ctx):
# means neither apple_common.Objc nor CcInfo in hdr provider target
fail("direct_hdr_provider %s must contain either 'CcInfo' or 'objc' provider" % provider)

headermap = ctx.actions.declare_file(ctx.label.name + ".hmap")

hmap.make_hmap(
actions = ctx.actions,
headermap_builder = ctx.executable._headermap_builder,
output = ctx.outputs.headermap,
output = headermap,
namespace = ctx.attr.namespace,
hdrs_lists = hdrs_lists,
)

cc_info_provider = CcInfo(
compilation_context = cc_common.create_compilation_context(
headers = depset([ctx.outputs.headermap]),
headers = depset([headermap]),
),
)

providers = [
DefaultInfo(
files = depset([headermap]),
),
apple_common.new_objc_provider(),
cc_info_provider,
swift_common.create_swift_info(),
HeaderMapInfo(
files = depset([headermap]),
),
]

hdrs_lists = [l for l in hdrs_lists if l]
if len(hdrs_lists) > 0:
providers.append(HeaderMapInfo(
files = depset([ctx.outputs.headermap]),
))

return providers

# Derive a headermap from transitive headermaps
Expand Down Expand Up @@ -119,7 +128,6 @@ headermap = rule(
),
),
},
outputs = {"headermap": "%{name}.hmap"},
doc = """\
Creates a binary headermap file from the given headers,
suitable for passing to clang.
Expand Down
6 changes: 3 additions & 3 deletions rules/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def apple_library(
hdrs = objc_hdrs,
tags = _MANUAL,
)
private_dep_names.append(public_hmap_name)
deps += [public_hmap_name]
additional_objc_copts, additional_swift_copts, additional_cc_copts = _append_headermap_copts(public_hmap_name, "-I", additional_objc_copts, additional_swift_copts, additional_cc_copts)

if len(objc_non_exported_hdrs + objc_private_hdrs) > 0:
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def apple_library(
tags = _MANUAL,
testonly = testonly,
)
private_dep_names.append(swift_doublequote_hmap_name)
deps += [swift_doublequote_hmap_name]
additional_objc_copts, additional_swift_copts, additional_cc_copts = _append_headermap_copts(swift_doublequote_hmap_name, "-iquote", additional_objc_copts, additional_swift_copts, additional_cc_copts)

# Add generated swift header to header maps for angle bracket imports
Expand All @@ -1046,7 +1046,7 @@ def apple_library(
tags = _MANUAL,
testonly = testonly,
)
private_dep_names.append(swift_angle_bracket_hmap_name)
deps += [swift_angle_bracket_hmap_name]
additional_objc_copts, additional_swift_copts, additional_cc_copts = _append_headermap_copts(swift_angle_bracket_hmap_name, "-I", additional_objc_copts, additional_swift_copts, additional_cc_copts)

if cpp_sources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apple_framework(
"Sources/*.swift",
],
),
module_map = "Module Map/CustomModuleMap.modulemap",
module_map = "ModuleMap/CustomModuleMap.modulemap",
objc_copts = ["-fcxx-modules"],
platforms = {"ios": "13.0"},
private_headers = ["Sources/PleaseDontImport.h"],
Expand Down
Loading