Unverified Commit 270878fc authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

fix copy command and remove resolve sync for macOS assemble (#40294)

parent b9399216
...@@ -146,11 +146,11 @@ abstract class Target { ...@@ -146,11 +146,11 @@ abstract class Target {
final File stamp = _findStampFile(environment); final File stamp = _findStampFile(environment);
final List<String> inputPaths = <String>[]; final List<String> inputPaths = <String>[];
for (File input in inputs) { for (File input in inputs) {
inputPaths.add(input.resolveSymbolicLinksSync()); inputPaths.add(input.path);
} }
final List<String> outputPaths = <String>[]; final List<String> outputPaths = <String>[];
for (File output in outputs) { for (File output in outputs) {
outputPaths.add(output.resolveSymbolicLinksSync()); outputPaths.add(output.path);
} }
final Map<String, Object> result = <String, Object>{ final Map<String, Object> result = <String, Object>{
'inputs': inputPaths, 'inputs': inputPaths,
...@@ -502,7 +502,7 @@ class _BuildInstance { ...@@ -502,7 +502,7 @@ class _BuildInstance {
outputFiles[output.path] = output; outputFiles[output.path] = output;
} }
} else { } else {
printStatus('${node.target.name}: Starting'); printStatus('${node.target.name}: Starting due to ${node.invalidatedReasons}');
await node.target.build(environment); await node.target.build(environment);
printStatus('${node.target.name}: Complete'); printStatus('${node.target.name}: Complete');
...@@ -653,9 +653,14 @@ class Node { ...@@ -653,9 +653,14 @@ class Node {
/// Output file paths from the previous invocation of this build node. /// Output file paths from the previous invocation of this build node.
final Set<String> previousOutputs = <String>{}; final Set<String> previousOutputs = <String>{};
/// Inout file paths from the previous invocation of this build node. /// Input file paths from the previous invocation of this build node.
final Set<String> previousInputs = <String>{}; final Set<String> previousInputs = <String>{};
/// One or more reasons why a task was invalidated.
///
/// May be empty if the task was skipped.
final Set<InvalidedReason> invalidatedReasons = <InvalidedReason>{};
/// Whether this node needs an action performed. /// Whether this node needs an action performed.
bool get dirty => _dirty; bool get dirty => _dirty;
bool _dirty = false; bool _dirty = false;
...@@ -685,6 +690,7 @@ class Node { ...@@ -685,6 +690,7 @@ class Node {
if (fileHashStore.currentHashes.containsKey(absolutePath)) { if (fileHashStore.currentHashes.containsKey(absolutePath)) {
final String currentHash = fileHashStore.currentHashes[absolutePath]; final String currentHash = fileHashStore.currentHashes[absolutePath];
if (currentHash != previousHash) { if (currentHash != previousHash) {
invalidatedReasons.add(InvalidedReason.inputChanged);
_dirty = true; _dirty = true;
} }
} else { } else {
...@@ -698,11 +704,13 @@ class Node { ...@@ -698,11 +704,13 @@ class Node {
// output paths changed. // output paths changed.
if (!currentOutputPaths.contains(previousOutput)) { if (!currentOutputPaths.contains(previousOutput)) {
_dirty = true; _dirty = true;
invalidatedReasons.add(InvalidedReason.outputSetChanged);
// if this isn't a current output file there is no reason to compute the hash. // if this isn't a current output file there is no reason to compute the hash.
continue; continue;
} }
final File file = fs.file(previousOutput); final File file = fs.file(previousOutput);
if (!file.existsSync()) { if (!file.existsSync()) {
invalidatedReasons.add(InvalidedReason.outputMissing);
_dirty = true; _dirty = true;
continue; continue;
} }
...@@ -711,6 +719,7 @@ class Node { ...@@ -711,6 +719,7 @@ class Node {
if (fileHashStore.currentHashes.containsKey(absolutePath)) { if (fileHashStore.currentHashes.containsKey(absolutePath)) {
final String currentHash = fileHashStore.currentHashes[absolutePath]; final String currentHash = fileHashStore.currentHashes[absolutePath];
if (currentHash != previousHash) { if (currentHash != previousHash) {
invalidatedReasons.add(InvalidedReason.outputChanged);
_dirty = true; _dirty = true;
} }
} else { } else {
...@@ -728,9 +737,25 @@ class Node { ...@@ -728,9 +737,25 @@ class Node {
if (sourcesToHash.isNotEmpty) { if (sourcesToHash.isNotEmpty) {
final List<File> dirty = await fileHashStore.hashFiles(sourcesToHash); final List<File> dirty = await fileHashStore.hashFiles(sourcesToHash);
if (dirty.isNotEmpty) { if (dirty.isNotEmpty) {
invalidatedReasons.add(InvalidedReason.inputChanged);
_dirty = true; _dirty = true;
} }
} }
return !_dirty; return !_dirty;
} }
} }
/// A description of why a task was rerun.
enum InvalidedReason {
/// An input file has an updated hash.
inputChanged,
/// An output file has an updated hash.
outputChanged,
/// An output file that is expected is missing.
outputMissing,
/// The set of expected output files changed.
outputSetChanged,
}
...@@ -122,7 +122,9 @@ abstract class UnpackMacOS extends Target { ...@@ -122,7 +122,9 @@ abstract class UnpackMacOS extends Target {
final Directory targetDirectory = environment final Directory targetDirectory = environment
.outputDir .outputDir
.childDirectory('FlutterMacOS.framework'); .childDirectory('FlutterMacOS.framework');
if (targetDirectory.existsSync()) {
targetDirectory.deleteSync(recursive: true);
}
final ProcessResult result = await processManager final ProcessResult result = await processManager
.run(<String>['cp', '-R', basePath, targetDirectory.path]); .run(<String>['cp', '-R', basePath, targetDirectory.path]);
if (result.exitCode != 0) { if (result.exitCode != 0) {
...@@ -285,6 +287,7 @@ abstract class MacOSBundleFlutterAssets extends Target { ...@@ -285,6 +287,7 @@ abstract class MacOSBundleFlutterAssets extends Target {
@override @override
List<Source> get inputs => const <Source>[ List<Source> get inputs => const <Source>[
Source.pattern('{PROJECT_DIR}/pubspec.yaml'), Source.pattern('{PROJECT_DIR}/pubspec.yaml'),
Source.pattern('{BUILD_DIR}/App.framework/App'),
Source.behavior(MacOSAssetBehavior()) Source.behavior(MacOSAssetBehavior())
]; ];
......
...@@ -149,7 +149,7 @@ void writeListIfChanged(List<File> files, String path) { ...@@ -149,7 +149,7 @@ void writeListIfChanged(List<File> files, String path) {
final StringBuffer buffer = StringBuffer(); final StringBuffer buffer = StringBuffer();
// These files are already sorted. // These files are already sorted.
for (File file in files) { for (File file in files) {
buffer.writeln(file.resolveSymbolicLinksSync()); buffer.writeln(file.path);
} }
final String newContents = buffer.toString(); final String newContents = buffer.toString();
if (!file.existsSync()) { if (!file.existsSync()) {
......
...@@ -85,11 +85,21 @@ void main() { ...@@ -85,11 +85,21 @@ void main() {
for (File input in inputs) { for (File input in inputs) {
input.createSync(recursive: true); input.createSync(recursive: true);
} }
// Create output directory so we can test that it is deleted.
environment.outputDir.childDirectory(_kOutputPrefix)
.createSync(recursive: true);
when(processManager.run(any)).thenAnswer((Invocation invocation) async { when(processManager.run(any)).thenAnswer((Invocation invocation) async {
final List<String> arguments = invocation.positionalArguments.first; final List<String> arguments = invocation.positionalArguments.first;
final Directory source = fs.directory(arguments[arguments.length - 2]); final String sourcePath = arguments[arguments.length - 2];
final Directory target = fs.directory(arguments.last) final String targetPath = arguments.last;
..createSync(recursive: true); final Directory source = fs.directory(sourcePath);
final Directory target = fs.directory(targetPath);
// verify directory was deleted by command.
expect(target.existsSync(), false);
target.createSync(recursive: true);
for (FileSystemEntity entity in source.listSync(recursive: true)) { for (FileSystemEntity entity in source.listSync(recursive: true)) {
if (entity is File) { if (entity is File) {
final String relative = fs.path.relative(entity.path, from: source.path); final String relative = fs.path.relative(entity.path, from: source.path);
...@@ -163,6 +173,26 @@ void main() { ...@@ -163,6 +173,26 @@ void main() {
expect(fs.file(precompiledIsolate).existsSync(), false); expect(fs.file(precompiledIsolate).existsSync(), false);
})); }));
test('release/profile macOS application updates when App.framework updates', () => testbed.run(() async {
fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'vm_isolate_snapshot.bin')).createSync(recursive: true);
fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64',
'isolate_snapshot.bin')).createSync(recursive: true);
final File inputFramework = fs.file(fs.path.join(environment.buildDir.path, 'App.framework', 'App'))
..createSync(recursive: true)
..writeAsStringSync('ABC');
await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile');
final File outputFramework = fs.file(fs.path.join(environment.outputDir.path, 'App.framework', 'App'));
expect(outputFramework.readAsStringSync(), 'ABC');
inputFramework.writeAsStringSync('DEF');
await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile');
expect(outputFramework.readAsStringSync(), 'DEF');
}));
test('release/profile macOS compilation uses correct gen_snapshot', () => testbed.run(() async { test('release/profile macOS compilation uses correct gen_snapshot', () => testbed.run(() async {
when(genSnapshot.run( when(genSnapshot.run(
snapshotType: anyNamed('snapshotType'), snapshotType: anyNamed('snapshotType'),
......
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