From cc0929a5d634a87155e2694d5a147650c2bf5be2 Mon Sep 17 00:00:00 2001 From: Elton Gao Date: Fri, 30 Aug 2024 12:38:24 -0400 Subject: [PATCH 1/5] Add test case that broke with main To repro locally, run `bazel build //tests/ios/unit-test/test-imports-app:TestImports-App --config=ios --features apple.arm64_simulator_use_device_deps` and it fails. But success if change .bazelversion to 6.4.0 --- tests/ios/unit-test/test-imports-app/empty.swift | 3 +++ tests/ios/unit-test/test-imports-app/main.m | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tests/ios/unit-test/test-imports-app/empty.swift b/tests/ios/unit-test/test-imports-app/empty.swift index 4671d0dc6..2250c5626 100644 --- a/tests/ios/unit-test/test-imports-app/empty.swift +++ b/tests/ios/unit-test/test-imports-app/empty.swift @@ -1,9 +1,12 @@ import Foundation import SomeFramework +import Basic @objc public class EmptyClass: NSObject { @objc public static func emptyDescription() -> String { + print(BasicString) + print(EmptyClass.emptyDescription) return "" } diff --git a/tests/ios/unit-test/test-imports-app/main.m b/tests/ios/unit-test/test-imports-app/main.m index 4bf3410f1..add6ee3db 100644 --- a/tests/ios/unit-test/test-imports-app/main.m +++ b/tests/ios/unit-test/test-imports-app/main.m @@ -1,6 +1,7 @@ #import "Header.h" #import #import +#import #ifdef __IPHONE_OS_VERSION_MIN_REQUIRED @import UIKit; @@ -18,6 +19,7 @@ - (BOOL)application:(UIApplication *)__unused application didFinishLaunchingWith self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = [UIViewController new]; self.window.rootViewController.view.backgroundColor = UIColor.whiteColor; + NSLog([NSString stringWithFormat:@"%@ %ld", BasicString, BasicVal_DownloadTheApp]); NSAssert([EmptyClass emptyDescription] != nil, @"Empty class description exists"); NSAssert([[EmptyClass new] emptyDescription] != nil, @"Empty instance description exists"); [self.window makeKeyAndVisible]; From 37433c04c6ea789b14c37a86fa3dcf0d50d7efbc Mon Sep 17 00:00:00 2001 From: Elton Gao Date: Fri, 30 Aug 2024 12:38:38 -0400 Subject: [PATCH 2/5] Use exsiting compilation context instead of creating one --- rules/import_middleman.bzl | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/rules/import_middleman.bzl b/rules/import_middleman.bzl index 8f75adabb..80ea3974b 100644 --- a/rules/import_middleman.bzl +++ b/rules/import_middleman.bzl @@ -265,19 +265,13 @@ def _file_collector_rule_impl(ctx): **objc_provider_fields ) - # Create the CcInfo provider, linking information from this is used in Bazel 7+. - cc_info = None + dep_cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep] + cc_info = cc_common.merge_cc_infos(cc_infos = dep_cc_infos) if is_bazel_7: + # Need to recreate linking_context for Bazel 7 or later + # because of https://github.com/bazelbuild/bazel/issues/16939 cc_info = CcInfo( - compilation_context = cc_common.create_compilation_context( - framework_includes = depset( - transitive = [ - dep[CcInfo].compilation_context.framework_includes - for dep in ctx.attr.deps - if CcInfo in dep - ], - ), - ), + compilation_context = cc_info.compilation_context, linking_context = cc_common.create_linking_context( linker_inputs = depset([ cc_common.create_linker_input( @@ -297,10 +291,6 @@ def _file_collector_rule_impl(ctx): ]), ), ) - else: - dep_cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep] - cc_info = cc_common.merge_cc_infos(cc_infos = dep_cc_infos) - return [ DefaultInfo(files = depset(dynamic_framework_dirs + replaced_frameworks)), objc, From 0c95c65cf58a29e06d0e9eb19d06e371a113add7 Mon Sep 17 00:00:00 2001 From: Elton Gao Date: Fri, 30 Aug 2024 14:09:30 -0400 Subject: [PATCH 3/5] Add sandbox mode to the test matrix --- .github/workflows/tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4be3a0a19..24c006224 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -86,6 +86,7 @@ jobs: fail-fast: false matrix: bazel_version: [6.5.0, 7.1.0] + sandbox: [true, false] xcode_version: [15.2] env: XCODE_VERSION: ${{ matrix.xcode_version }} @@ -94,6 +95,10 @@ jobs: - uses: actions/checkout@v4 - name: Preflight Env run: .github/workflows/preflight_env.sh + - if: matrix.sandbox + name: Enable sandbox mode + run: | + echo "build --config=sandboxed" >> user.bazelrcc - name: Build and Test run: | bazelisk build \ From 92dd168039c96d95c479e15dcc10a74ec83eff2c Mon Sep 17 00:00:00 2001 From: Elton Gao Date: Tue, 3 Sep 2024 16:09:07 -0400 Subject: [PATCH 4/5] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 24c006224..94a60a33d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,7 +80,7 @@ jobs: path: bazel-testlogs build_arm64_simulator: - name: arm64 Simulator (Bazel ${{ matrix.bazel_version }} / Xcode ${{ matrix.xcode_version }}) + name: arm64 Simulator (Bazel ${{ matrix.bazel_version }} / Xcode ${{ matrix.xcode_version }}) / Sandbox ${{ matrix.sandbox }} runs-on: macos-14 strategy: fail-fast: false From 703ef620ffd3c00868d50504c3cde47990730ee3 Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Tue, 3 Sep 2024 16:22:08 -0400 Subject: [PATCH 5/5] Update .github/workflows/tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 94a60a33d..6fa86386e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,7 +80,7 @@ jobs: path: bazel-testlogs build_arm64_simulator: - name: arm64 Simulator (Bazel ${{ matrix.bazel_version }} / Xcode ${{ matrix.xcode_version }}) / Sandbox ${{ matrix.sandbox }} + name: arm64 Simulator (Bazel ${{ matrix.bazel_version }} / Xcode ${{ matrix.xcode_version }} / Sandbox ${{ matrix.sandbox }}) runs-on: macos-14 strategy: fail-fast: false