[flutter_tools] delete entitlements files after copying to macos build dir (#127417)

Fixes https://github.com/flutter/flutter/issues/126705

Follow up fix after https://github.com/flutter/flutter/pull/126875 did NOT work.
This commit is contained in:
Christopher Fujino
2023-05-23 12:12:11 -07:00
committed by GitHub
parent 3518d69d2a
commit 11cb29174f
2 changed files with 60 additions and 0 deletions

View File

@@ -62,6 +62,8 @@ abstract class UnpackMacOS extends Target {
basePath,
environment.outputDir.path,
]);
_removeDenylistedFiles(environment.outputDir);
if (result.exitCode != 0) {
throw Exception(
'Failed to copy framework (exit ${result.exitCode}:\n'
@@ -81,6 +83,19 @@ abstract class UnpackMacOS extends Target {
_thinFramework(environment, frameworkBinaryPath);
}
static const List<String> _copyDenylist = <String>['entitlements.txt', 'without_entitlements.txt'];
void _removeDenylistedFiles(Directory directory) {
for (final FileSystemEntity entity in directory.listSync(recursive: true)) {
if (entity is! File) {
continue;
}
if (_copyDenylist.contains(entity.basename)) {
entity.deleteSync();
}
}
}
void _thinFramework(Environment environment, String frameworkBinaryPath) {
final String archs = environment.defines[kDarwinArchs] ?? 'x86_64 arm64';
final List<String> archList = archs.split(' ').toList();