Unverified Commit d6857bc0 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Build/copy macOS frameworks to built products instead of ephemeral directory (#72378)

parent becf09c5
...@@ -416,10 +416,6 @@ ...@@ -416,10 +416,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -546,10 +542,6 @@ ...@@ -546,10 +542,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -570,10 +562,6 @@ ...@@ -570,10 +562,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
......
...@@ -421,10 +421,6 @@ ...@@ -421,10 +421,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -551,10 +547,6 @@ ...@@ -551,10 +547,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -575,10 +567,6 @@ ...@@ -575,10 +567,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
......
...@@ -361,10 +361,6 @@ ...@@ -361,10 +361,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -491,10 +487,6 @@ ...@@ -491,10 +487,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -515,10 +507,6 @@ ...@@ -515,10 +507,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
......
...@@ -361,10 +361,6 @@ ...@@ -361,10 +361,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -491,10 +487,6 @@ ...@@ -491,10 +487,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -515,10 +507,6 @@ ...@@ -515,10 +507,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
......
...@@ -98,26 +98,24 @@ BuildApp() { ...@@ -98,26 +98,24 @@ BuildApp() {
--ExtraFrontEndOptions="${EXTRA_FRONT_END_OPTIONS}" \ --ExtraFrontEndOptions="${EXTRA_FRONT_END_OPTIONS}" \
--build-inputs="${build_inputs_path}" \ --build-inputs="${build_inputs_path}" \
--build-outputs="${build_outputs_path}" \ --build-outputs="${build_outputs_path}" \
--output="${ephemeral_dir}" \ --output="${BUILT_PRODUCTS_DIR}" \
"${build_mode}_macos_bundle_flutter_assets" "${build_mode}_macos_bundle_flutter_assets"
} }
# Adds the App.framework as an embedded binary and the flutter_assets as # Adds the App.framework as an embedded binary and the flutter_assets as
# resources. # resources.
EmbedFrameworks() { EmbedFrameworks() {
local ephemeral_dir="${SOURCE_ROOT}/Flutter/ephemeral"
# Embed App.framework from Flutter into the app (after creating the Frameworks directory # Embed App.framework from Flutter into the app (after creating the Frameworks directory
# if it doesn't already exist). # if it doesn't already exist).
local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
RunCommand mkdir -p -- "${xcode_frameworks_dir}" RunCommand mkdir -p -- "${xcode_frameworks_dir}"
RunCommand rsync -av --delete --filter "- .DS_Store/" "${ephemeral_dir}/App.framework" "${xcode_frameworks_dir}" RunCommand rsync -av --delete --filter "- .DS_Store/" "${BUILT_PRODUCTS_DIR}/App.framework" "${xcode_frameworks_dir}"
# Embed the actual FlutterMacOS.framework that the Flutter app expects to run against, # Embed the actual FlutterMacOS.framework that the Flutter app expects to run against,
# which could be a local build or an arch/type specific build. # which could be a local build or an arch/type specific build.
# Copy Xcode behavior and don't copy over headers or modules. # Copy Xcode behavior and don't copy over headers or modules.
RunCommand rsync -av --delete --filter "- .DS_Store/" --filter "- Headers/" --filter "- Modules/" "${ephemeral_dir}/FlutterMacOS.framework" "${xcode_frameworks_dir}/" RunCommand rsync -av --delete --filter "- .DS_Store/" --filter "- Headers/" --filter "- Modules/" "${BUILT_PRODUCTS_DIR}/FlutterMacOS.framework" "${xcode_frameworks_dir}/"
# Sign the binaries we moved. # Sign the binaries we moved.
if [[ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" ]]; then if [[ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" ]]; then
......
...@@ -16,15 +16,12 @@ import 'assets.dart'; ...@@ -16,15 +16,12 @@ import 'assets.dart';
import 'common.dart'; import 'common.dart';
import 'icon_tree_shaker.dart'; import 'icon_tree_shaker.dart';
/// Copy the macOS framework to the correct copy dir by invoking 'cp -R'. /// Copy the macOS framework to the correct copy dir by invoking 'rsync'.
/// ///
/// This class is abstract to share logic between the three concrete /// This class is abstract to share logic between the three concrete
/// implementations. The shelling out is done to avoid complications with /// implementations. The shelling out is done to avoid complications with
/// preserving special files (e.g., symbolic links) in the framework structure. /// preserving special files (e.g., symbolic links) in the framework structure.
/// ///
/// Removes any previous version of the framework that already exists in the
/// target directory.
///
/// The real implementations are: /// The real implementations are:
/// * [DebugUnpackMacOS] /// * [DebugUnpackMacOS]
/// * [ProfileUnpackMacOS] /// * [ProfileUnpackMacOS]
...@@ -38,14 +35,13 @@ abstract class UnpackMacOS extends Target { ...@@ -38,14 +35,13 @@ abstract class UnpackMacOS extends Target {
]; ];
@override @override
List<Source> get outputs => const <Source>[]; List<Source> get outputs => const <Source>[
Source.pattern('{OUTPUT_DIR}/FlutterMacOS.framework/FlutterMacOS'),
];
@override @override
List<Target> get dependencies => <Target>[]; List<Target> get dependencies => <Target>[];
@override
List<String> get depfiles => const <String>['unpack_macos.d'];
@override @override
Future<void> build(Environment environment) async { Future<void> build(Environment environment) async {
if (environment.defines[kBuildMode] == null) { if (environment.defines[kBuildMode] == null) {
...@@ -53,38 +49,22 @@ abstract class UnpackMacOS extends Target { ...@@ -53,38 +49,22 @@ abstract class UnpackMacOS extends Target {
} }
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]); final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
final String basePath = environment.artifacts.getArtifactPath(Artifact.flutterMacOSFramework, mode: buildMode); final String basePath = environment.artifacts.getArtifactPath(Artifact.flutterMacOSFramework, mode: buildMode);
final Directory targetDirectory = environment
.outputDir final ProcessResult result = environment.processManager.runSync(<String>[
.childDirectory('FlutterMacOS.framework'); 'rsync',
// Deleting this directory is required or else the FlutterMacOS module '-av',
// cannot be found. '--delete',
if (targetDirectory.existsSync()) { '--filter',
targetDirectory.deleteSync(recursive: true); '- .DS_Store/',
} basePath,
final List<File> inputs = environment.fileSystem.directory(basePath) environment.outputDir.path,
.listSync(recursive: true) ]);
.whereType<File>()
.toList();
final List<File> outputs = inputs.map((File file) {
final String relativePath = environment.fileSystem.path.relative(file.path, from: basePath);
return environment.fileSystem.file(environment.fileSystem.path.join(targetDirectory.path, relativePath));
}).toList();
final ProcessResult result = await environment.processManager
.run(<String>['cp', '-R', basePath, targetDirectory.path]);
if (result.exitCode != 0) { if (result.exitCode != 0) {
throw Exception( throw Exception(
'Failed to copy framework (exit ${result.exitCode}:\n' 'Failed to copy framework (exit ${result.exitCode}:\n'
'${result.stdout}\n---\n${result.stderr}', '${result.stdout}\n---\n${result.stderr}',
); );
} }
final DepfileService depfileService = DepfileService(
logger: environment.logger,
fileSystem: environment.fileSystem,
);
depfileService.writeToFile(
Depfile(inputs, outputs),
environment.buildDir.childFile('unpack_macos.d'),
);
} }
} }
......
...@@ -361,10 +361,6 @@ ...@@ -361,10 +361,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -491,10 +487,6 @@ ...@@ -491,10 +487,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -515,10 +507,6 @@ ...@@ -515,10 +507,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter/ephemeral",
);
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
......
...@@ -44,13 +44,17 @@ void main() { ...@@ -44,13 +44,17 @@ void main() {
}); });
testUsingContext('Copies files to correct cache directory', () async { testUsingContext('Copies files to correct cache directory', () async {
final Directory outputDir = fileSystem.directory('output');
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand( FakeCommand(
command: <String>[ command: <String>[
'cp', 'rsync',
'-R', '-av',
'--delete',
'--filter',
'- .DS_Store/',
'Artifact.flutterMacOSFramework.debug', 'Artifact.flutterMacOSFramework.debug',
'/FlutterMacOS.framework', outputDir.path,
], ],
), ),
]); ]);
...@@ -65,19 +69,10 @@ void main() { ...@@ -65,19 +69,10 @@ void main() {
processManager: processManager, processManager: processManager,
logger: BufferLogger.test(), logger: BufferLogger.test(),
fileSystem: fileSystem, fileSystem: fileSystem,
engineVersion: '2' engineVersion: '2',
outputDir: outputDir,
); );
final Directory cacheDirectory = fileSystem.directory(
artifacts.getArtifactPath(
Artifact.flutterMacOSFramework,
mode: BuildMode.debug,
))
..createSync();
cacheDirectory.childFile('dummy').createSync();
environment.buildDir.createSync(recursive: true);
environment.outputDir.createSync(recursive: true);
await const DebugUnpackMacOS().build(environment); await const DebugUnpackMacOS().build(environment);
expect(processManager.hasRemainingExpectations, false); expect(processManager.hasRemainingExpectations, false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment