Skip to content

Commit

Permalink
Ocmock dylib (flutter#21786)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
dnfield committed Oct 13, 2020
1 parent 0332d5e commit 6ba6d81
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
12 changes: 4 additions & 8 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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/")

Expand All @@ -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 = [
Expand All @@ -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",
Expand All @@ -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",
]
Expand Down
43 changes: 41 additions & 2 deletions testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<group>"; };
0AC232F724BA71D300A85907 /* FlutterEngineTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEngineTest.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 = (
);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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",
);
Expand Down Expand Up @@ -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",
);
Expand Down

0 comments on commit 6ba6d81

Please sign in to comment.