From 740932c899a3a978f75bfa8092e7b02f1740bf62 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 1 Mar 2023 09:55:33 +0100 Subject: [PATCH] Make remaining objc test jobs to pass on MacOS monterey (#32493) Make remaining objC jobs compatible with kokoro monterey workers and prepare for boringssl upgrade. The changes here are taken from https://github.com/grpc/grpc/pull/32357, but they should be merged in a separate PR (we need the changes to be able to upgrade to monterey anyway and there's no reason to make the boringssl upgrade PR more complicated by bundling more fixes into it). I've checked that the grpc_basictests_objc_examples and grpc_ios_binary_size are green if switched to monterey. Unfortunately it's hard to make grpc_basictests_objc_examples pass on both monterey and mojave, so I suggest merging this PR at the same time as CL to upgrade the kokoro jobs to monterey. - that way both PR and continuous runs will remain green - older branches would need a backport anyway --------- Co-authored-by: Hannah Shi --- src/objective-c/BoringSSL-GRPC.podspec | 55 -------- .../examples/InterceptorSample/Podfile | 5 - .../RemoteTestClient/RemoteTest.podspec | 33 ++--- src/objective-c/examples/Sample/Podfile | 5 - src/objective-c/examples/SwiftSample/Podfile | 2 +- .../examples/SwiftSample/ViewController.swift | 1 + src/objective-c/examples/tvOS-sample/Podfile | 2 - .../examples/watchOS-sample/Podfile | 2 - .../BoringSSL-GRPC.podspec.template | 55 -------- .../helper_scripts/prepare_build_macos_rc | 2 +- tools/profiling/ios_bin/binary_size.py | 123 ++++++++---------- tools/run_tests/run_tests.py | 5 +- 12 files changed, 65 insertions(+), 225 deletions(-) diff --git a/src/objective-c/BoringSSL-GRPC.podspec b/src/objective-c/BoringSSL-GRPC.podspec index c63e9f25921..fdb3dadf6bb 100644 --- a/src/objective-c/BoringSSL-GRPC.podspec +++ b/src/objective-c/BoringSSL-GRPC.podspec @@ -103,11 +103,6 @@ Pod::Spec.new do |s| # following lets users write `#include `. s.header_dir = name - # The module map and umbrella header created automatically by Cocoapods don't work for C libraries - # like this one. The following file, and a correct umbrella header, are created on the fly by the - # `prepare_command` of this pod. - s.module_map = 'src/include/openssl/BoringSSL.modulemap' - # We don't need to inhibit all warnings; only -Wno-shorten-64-to-32. But Cocoapods' linter doesn't # want that for some reason. s.compiler_flags = '-DOPENSSL_NO_ASM', '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w', '-DBORINGSSL_PREFIX=GRPC' @@ -153,56 +148,6 @@ Pod::Spec.new do |s| s.prepare_command = <<-END_OF_COMMAND set -e - # Add a module map and an umbrella header - mkdir -p src/include/openssl - cat > src/include/openssl/umbrella.h < src/include/openssl/BoringSSL.modulemap < false -# Default to use framework, so that providing no 'FRAMEWORK' env parameter works consistently -# for all Samples, specifically because Swift only supports framework. -# Only effective for examples/ -use_frameworks! if ENV['FRAMEWORKS'] != 'NO' - ROOT_DIR = '../../../..' target 'InterceptorSample' do diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec index b5f831e308a..cf5cdef91c3 100644 --- a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec +++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec @@ -24,30 +24,15 @@ Pod::Spec.new do |s| # Since we switched to importing full path, -I needs to be set to the directory # from which the imported file can be found, which is the grpc's root here - if ENV['FRAMEWORKS'] != 'NO' then - s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'USE_FRAMEWORKS=1' } - s.prepare_command = <<-CMD - # Cannot find file if using *.proto. Maybe files' paths must match the -I flags - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=. \ - --grpc_out=generate_for_named_framework=#{s.name}:. \ - --objc_opt=generate_for_named_framework=#{s.name} \ - -I #{repo_root} \ - -I #{well_known_types_dir} \ - #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto - CMD - else - s.prepare_command = <<-CMD - #{protoc} \ - --plugin=protoc-gen-grpc=#{plugin} \ - --objc_out=. \ - --grpc_out=. \ - -I #{repo_root} \ - -I #{well_known_types_dir} \ - #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto - CMD - end + s.prepare_command = <<-CMD + #{protoc} \ + --plugin=protoc-gen-grpc=#{plugin} \ + --objc_out=. \ + --grpc_out=. \ + -I #{repo_root} \ + -I #{well_known_types_dir} \ + #{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto + CMD s.subspec 'Messages' do |ms| ms.source_files = 'src/objective-c/examples/RemoteTestClient/*.pbobjc.{h,m}' diff --git a/src/objective-c/examples/Sample/Podfile b/src/objective-c/examples/Sample/Podfile index 6f1b5f3d10d..14184d49f63 100644 --- a/src/objective-c/examples/Sample/Podfile +++ b/src/objective-c/examples/Sample/Podfile @@ -3,11 +3,6 @@ platform :ios, '9.0' install! 'cocoapods', :deterministic_uuids => false -# Default to use framework, so that providing no 'FRAMEWORK' env parameter works consistently -# for all Samples, specifically because Swift only supports framework. -# Only effective for examples/ -use_frameworks! if ENV['FRAMEWORKS'] != 'NO' - # Location of gRPC's repo root relative to this file. GRPC_LOCAL_SRC = '../../../..' diff --git a/src/objective-c/examples/SwiftSample/Podfile b/src/objective-c/examples/SwiftSample/Podfile index 619e7e5aedb..abe5adcca73 100644 --- a/src/objective-c/examples/SwiftSample/Podfile +++ b/src/objective-c/examples/SwiftSample/Podfile @@ -3,7 +3,7 @@ platform :ios, '9.0' install! 'cocoapods', :deterministic_uuids => false -use_frameworks! +use_modular_headers! # Location of gRPC's repo root relative to this file. GRPC_LOCAL_SRC = '../../../..' diff --git a/src/objective-c/examples/SwiftSample/ViewController.swift b/src/objective-c/examples/SwiftSample/ViewController.swift index 4ed10266a4d..8925afcd80a 100644 --- a/src/objective-c/examples/SwiftSample/ViewController.swift +++ b/src/objective-c/examples/SwiftSample/ViewController.swift @@ -19,6 +19,7 @@ import UIKit import RemoteTest +import RxLibrary class ViewController: UIViewController { diff --git a/src/objective-c/examples/tvOS-sample/Podfile b/src/objective-c/examples/tvOS-sample/Podfile index 03b421bad10..4b65f07b48f 100644 --- a/src/objective-c/examples/tvOS-sample/Podfile +++ b/src/objective-c/examples/tvOS-sample/Podfile @@ -2,8 +2,6 @@ platform :tvos, '10.0' install! 'cocoapods', :deterministic_uuids => false -use_frameworks! if ENV['FRAMEWORKS'] != 'NO' - ROOT_DIR = '../../../..' target 'tvOS-sample' do diff --git a/src/objective-c/examples/watchOS-sample/Podfile b/src/objective-c/examples/watchOS-sample/Podfile index 05439ef2c4e..0de6e71a253 100644 --- a/src/objective-c/examples/watchOS-sample/Podfile +++ b/src/objective-c/examples/watchOS-sample/Podfile @@ -1,7 +1,5 @@ install! 'cocoapods', :deterministic_uuids => false -use_frameworks! if ENV['FRAMEWORKS'] != 'NO' - ROOT_DIR = '../../../..' def grpc_deps diff --git a/templates/src/objective-c/BoringSSL-GRPC.podspec.template b/templates/src/objective-c/BoringSSL-GRPC.podspec.template index fef43313350..6fe70a1af67 100644 --- a/templates/src/objective-c/BoringSSL-GRPC.podspec.template +++ b/templates/src/objective-c/BoringSSL-GRPC.podspec.template @@ -133,11 +133,6 @@ # following lets users write `#include `. s.header_dir = name - # The module map and umbrella header created automatically by Cocoapods don't work for C libraries - # like this one. The following file, and a correct umbrella header, are created on the fly by the - # `prepare_command` of this pod. - s.module_map = 'src/include/openssl/BoringSSL.modulemap' - # We don't need to inhibit all warnings; only -Wno-shorten-64-to-32. But Cocoapods' linter doesn't # want that for some reason. s.compiler_flags = '-DOPENSSL_NO_ASM', '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w', '-DBORINGSSL_PREFIX=GRPC' @@ -183,56 +178,6 @@ s.prepare_command = <<-END_OF_COMMAND set -e - # Add a module map and an umbrella header - mkdir -p src/include/openssl - cat > src/include/openssl/umbrella.h < src/include/openssl/BoringSSL.modulemap <= _DIFF_THRESHOLD: - has_diff = True - diff_sign = _diff_sign(new_size[i], - old_size[i], - diff_threshold=_DIFF_THRESHOLD) - text += _render_row(new_size[i], _SIZE_LABELS[i] + diff_sign, - old_size[i]) - - # render the "Total" - i = len(_SIZE_LABELS) - 1 - diff_sign = _diff_sign(new_size[i], old_size[i]) - # skip line before rendering "Total" - text += '\n' + +text += '**********************STATIC******************\n' +text += _render_row('New size', '', 'Old size') +if old_size == None: + for i in range(0, len(_SIZE_LABELS)): + if i == len(_SIZE_LABELS) - 1: + # skip line before rendering "Total" + text += '\n' + text += _render_row(new_size[i], _SIZE_LABELS[i], '') +else: + has_diff = False + # go through all labels but "Total" + for i in range(0, len(_SIZE_LABELS) - 1): + if abs(new_size[i] - old_size[i]) >= _DIFF_THRESHOLD: + has_diff = True + diff_sign = _diff_sign(new_size[i], + old_size[i], + diff_threshold=_DIFF_THRESHOLD) text += _render_row(new_size[i], _SIZE_LABELS[i] + diff_sign, old_size[i]) - if not has_diff: - text += '\n No significant differences in binary sizes\n' + + # render the "Total" + i = len(_SIZE_LABELS) - 1 + diff_sign = _diff_sign(new_size[i], old_size[i]) + # skip line before rendering "Total" text += '\n' + text += _render_row(new_size[i], _SIZE_LABELS[i] + diff_sign, old_size[i]) + if not has_diff: + text += '\n No significant differences in binary sizes\n' +text += '\n' print(text) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index cc4a6e3eabe..d81e35525cb 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -967,18 +967,15 @@ class ObjCLanguage(object): def test_specs(self): out = [] - # Currently not supporting compiling as frameworks in Bazel - # TODO(jtattermusch): verify the above claim is still accurate. out.append( self.config.job_spec( ['src/objective-c/tests/build_one_example.sh'], timeout_seconds=20 * 60, - shortname='ios-buildtest-example-sample-frameworks', + shortname='ios-buildtest-example-sample', cpu_cost=1e6, environ={ 'SCHEME': 'Sample', 'EXAMPLE_PATH': 'src/objective-c/examples/Sample', - 'FRAMEWORKS': 'YES' })) # TODO(jtattermusch): Create bazel target for the sample and remove the test task from here. out.append(