mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[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:
parent
3518d69d2a
commit
11cb29174f
@ -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();
|
||||
|
@ -106,6 +106,51 @@ void main() {
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('deletes entitlements.txt and without_entitlements.txt files after copying', () async {
|
||||
binary.createSync(recursive: true);
|
||||
final File entitlements = environment.outputDir.childFile('entitlements.txt');
|
||||
final File withoutEntitlements = environment.outputDir.childFile('without_entitlements.txt');
|
||||
final File nestedEntitlements = environment
|
||||
.outputDir
|
||||
.childDirectory('first_level')
|
||||
.childDirectory('second_level')
|
||||
.childFile('entitlements.txt')
|
||||
..createSync(recursive: true);
|
||||
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
'rsync',
|
||||
'-av',
|
||||
'--delete',
|
||||
'--filter',
|
||||
'- .DS_Store/',
|
||||
// source
|
||||
'Artifact.flutterMacOSFramework.debug',
|
||||
// destination
|
||||
environment.outputDir.path,
|
||||
],
|
||||
onRun: () {
|
||||
entitlements.writeAsStringSync('foo');
|
||||
withoutEntitlements.writeAsStringSync('bar');
|
||||
nestedEntitlements.writeAsStringSync('somefile.bin');
|
||||
},
|
||||
),
|
||||
lipoInfoNonFatCommand,
|
||||
lipoVerifyX86_64Command,
|
||||
]);
|
||||
|
||||
await const DebugUnpackMacOS().build(environment);
|
||||
expect(entitlements.existsSync(), isFalse);
|
||||
expect(withoutEntitlements.existsSync(), isFalse);
|
||||
expect(nestedEntitlements.existsSync(), isFalse);
|
||||
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('thinning fails when framework missing', () async {
|
||||
processManager.addCommand(copyFrameworkCommand);
|
||||
await expectLater(
|
||||
|
Loading…
Reference in New Issue
Block a user