From 75d75bfaec96ae2b756a9b8423f48956698be0c1 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Sat, 25 May 2019 19:47:17 -0700 Subject: [PATCH] fix relative paths and snapshot logic in tool (#33283) --- dev/integration_tests/codegen/pubspec.yaml | 3 +- .../lib/src/build_runner/build_runner.dart | 36 +++++++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/dev/integration_tests/codegen/pubspec.yaml b/dev/integration_tests/codegen/pubspec.yaml index ef7d6ddbc3..c9708faecc 100644 --- a/dev/integration_tests/codegen/pubspec.yaml +++ b/dev/integration_tests/codegen/pubspec.yaml @@ -68,9 +68,8 @@ dev_dependencies: yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" builders: - # Note: path is relative from generated directory simple_codegen: - path: ../../../simple_codegen + path: ../simple_codegen flutter: uses-material-design: true diff --git a/packages/flutter_tools/lib/src/build_runner/build_runner.dart b/packages/flutter_tools/lib/src/build_runner/build_runner.dart index fbc7598427..d9ac81656f 100644 --- a/packages/flutter_tools/lib/src/build_runner/build_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/build_runner.dart @@ -83,7 +83,20 @@ class BuildRunner extends CodeGenerator { if (builders != null) { for (String name in builders.keys) { final Object node = builders[name]; - stringBuffer.writeln(' $name: $node'); + // For relative paths, make sure it is accounted for + // parent directories. + if (node is YamlMap && node['path'] != null) { + final String path = node['path']; + if (fs.path.isRelative(path)) { + final String convertedPath = fs.path.join('..', '..', node['path']); + stringBuffer.writeln(' $name:'); + stringBuffer.writeln(' path: $convertedPath'); + } else { + stringBuffer.writeln(' $name: $node'); + } + } else { + stringBuffer.writeln(' $name: $node'); + } } } stringBuffer.writeln(' build_runner: ^$kMinimumBuildRunnerVersion'); @@ -149,7 +162,13 @@ class BuildRunner extends CodeGenerator { '--skip-build-script-check', '--delete-conflicting-outputs' ]; - buildDaemonClient = await BuildDaemonClient.connect(flutterProject.directory.path, command, logHandler: (ServerLog log) => printTrace(log.toString())); + buildDaemonClient = await BuildDaemonClient.connect( + flutterProject.directory.path, + command, + logHandler: (ServerLog log) { + printTrace(log.toString()); + } + ); } finally { status.stop(); } @@ -198,10 +217,15 @@ List _produceScriptId(YamlMap builders) { if (builders == null || builders.isEmpty) { return md5.convert(platform.version.codeUnits).bytes; } - final List orderedBuilders = builders.keys + final List orderedBuilderNames = builders.keys .cast() .toList()..sort(); - return md5.convert(orderedBuilders - .followedBy([platform.version]) - .join('').codeUnits).bytes; + final List orderedBuilderValues = builders.values + .map((dynamic value) => value.toString()) + .toList()..sort(); + return md5.convert([ + ...orderedBuilderNames, + ...orderedBuilderValues, + platform.version, + ].join('').codeUnits).bytes; }