From 6ba6d812955cacc9fcb32d4a07293e5ec695195d Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 13 Oct 2020 09:36:29 -0700 Subject: [PATCH] Ocmock dylib (#21786) - Build OCMock as a dylib for iOS tests - Set install_name for ios_flutter_test and ocmock dylibs - Copy and sign dylibs during build process --- DEPS | 2 +- shell/platform/darwin/ios/BUILD.gn | 12 ++---- .../IosUnitTests.xcodeproj/project.pbxproj | 43 ++++++++++++++++++- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index 658dcf17b..0b09eaf96 100644 --- a/DEPS +++ b/DEPS @@ -105,7 +105,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'f83d1d75216e97fb696434bca1cb9a4e7a570fb6', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'e5b7a41ce43f8a00d5fcb9c55cb16b9c7697e8aa', # Fuchsia compatibility # diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 9bf404552..fb0a84565 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -158,7 +158,6 @@ source_set("flutter_framework_source") { } } -ios_test_flutter_path = rebase_path("$root_out_dir/libios_test_flutter.dylib") platform_frameworks_path = rebase_path("$ios_sdk_path/../../Library/Frameworks/") @@ -181,15 +180,12 @@ source_set("ios_test_flutter_mrc") { "//flutter/shell/platform/darwin/common:framework_shared", "//flutter/third_party/tonic", "//flutter/third_party/txt", - "//third_party/ocmock:ocmock", + "//third_party/ocmock:ocmock_shared", "//third_party/rapidjson", "//third_party/skia", ] } -# NOTE: This currently only supports simulator targets because of the install_name. -# TODO(54504): Switch the install_name and make the test runner copy the dynamic -# library into the testing bundle. shared_library("ios_test_flutter") { visibility = [ ":*" ] cflags = [ @@ -200,9 +196,9 @@ shared_library("ios_test_flutter") { ] ldflags = [ "-F$platform_frameworks_path", - "-Wl,-framework,XCTest", - "-Wl,-install_name,$ios_test_flutter_path", + "-Wl,-install_name,@rpath/Frameworks/libios_test_flutter.dylib", ] + libs = [ "XCTest.framework" ] configs -= [ "//build/config/gcc:symbol_visibility_hidden", "//build/config:symbol_visibility_hidden", @@ -223,7 +219,7 @@ shared_library("ios_test_flutter") { "//flutter/shell/platform/darwin/common:framework_shared", "//flutter/third_party/tonic", "//flutter/third_party/txt", - "//third_party/ocmock:ocmock", + "//third_party/ocmock:ocmock_shared", "//third_party/rapidjson", "//third_party/skia", ] diff --git a/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj b/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj index eeaef5134..dde07dacc 100644 --- a/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj +++ b/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj @@ -27,6 +27,19 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 24EBCE9E2534C400008D1687 /* Embed Libraries */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 12; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Libraries"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 0AC232F424BA71D300A85907 /* SemanticsObjectTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SemanticsObjectTest.mm; sourceTree = ""; }; 0AC232F724BA71D300A85907 /* FlutterEngineTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEngineTest.mm; sourceTree = ""; }; @@ -158,8 +171,10 @@ buildConfigurationList = 0D6AB6D222BB05E200EEE540 /* Build configuration list for PBXNativeTarget "IosUnitTests" */; buildPhases = ( 0D6AB6AD22BB05E100EEE540 /* Sources */, + 242904382534E32900F90C97 /* ShellScript */, 0D6AB6AE22BB05E100EEE540 /* Frameworks */, 0D6AB6AF22BB05E100EEE540 /* Resources */, + 24EBCE9E2534C400008D1687 /* Embed Libraries */, ); buildRules = ( ); @@ -246,6 +261,26 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 242904382534E32900F90C97 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "set -ex\nxcode_frameworks_dir=\"${TARGET_BUILD_DIR}/${PlugIns/IosUnitTestsTests.xctest/Frameworks/}\"\nmkdir -p \"${xcode_frameworks_dir}\"\nflutter_engine_rel_path=\"../../../../out/${FLUTTER_ENGINE}\"\ncp -f \"${flutter_engine_rel_path}/libios_test_flutter.dylib\" \"${xcode_frameworks_dir}\"\ncp -f \"${flutter_engine_rel_path}/libocmock_shared.dylib\" \"${xcode_frameworks_dir}\"\nif [[ -n \"${EXPANDED_CODE_SIGN_IDENTITY:-}\" ]]; then\n codesign --force --verbose --sign \"${EXPANDED_CODE_SIGN_IDENTITY}\" -- \"${xcode_frameworks_dir}/libocmock_shared.dylib\"\n codesign --force --verbose --sign \"${EXPANDED_CODE_SIGN_IDENTITY}\" -- \"${xcode_frameworks_dir}/libios_test_flutter.dylib\"\nfi\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 0D6AB6AD22BB05E100EEE540 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -475,9 +510,11 @@ ../../../../out/$FLUTTER_ENGINE, ../../../../out/$FLUTTER_ENGINE/obj/flutter/shell/platform/darwin/ios/, ../../../../out/$FLUTTER_ENGINE/obj/third_party/ocmock/, + "$(PROJECT_DIR)", ); OTHER_LDFLAGS = ( - "-locmock", + "-L../../../../out/$FLUTTER_ENGINE", + "-locmock_shared", "-ObjC", "-lios_test_flutter", ); @@ -517,9 +554,11 @@ ../../../../out/$FLUTTER_ENGINE, ../../../../out/$FLUTTER_ENGINE/obj/flutter/shell/platform/darwin/ios/, ../../../../out/$FLUTTER_ENGINE/obj/third_party/ocmock/, + "$(PROJECT_DIR)", ); OTHER_LDFLAGS = ( - "-locmock", + "-L../../../../out/$FLUTTER_ENGINE", + "-locmock_shared", "-ObjC", "-lios_test_flutter", ); -- GitLab