diff --git a/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart b/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart index 425c802eb..8cffcde5b 100644 --- a/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart +++ b/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart @@ -763,9 +763,12 @@ ${e.message} final depFileContents = await depFile.readAsString(); final dartSources = depFileContents .trim() + // TODO: Deal with '\ ' being part of paths. .split(' ') .skip(1) // ':' - .map(Uri.file) + // On windows, unescape backslashes. + .map((e) => Uri.file(e.replaceAll(r'\\', r'\'))) + // .map(Uri.file) .toList(); return dartSources; } diff --git a/pkgs/native_assets_builder/test/build_runner/build_dependencies_test.dart b/pkgs/native_assets_builder/test/build_runner/build_dependencies_test.dart index 7204dc7ea..f2bf5090f 100644 --- a/pkgs/native_assets_builder/test/build_runner/build_dependencies_test.dart +++ b/pkgs/native_assets_builder/test/build_runner/build_dependencies_test.dart @@ -51,12 +51,26 @@ void main() async { expect( result.dependencies, containsAll([ - tempUri.resolve('native_add/hook/build.dart'), tempUri.resolve('native_add/src/native_add.c'), - tempUri.resolve('native_subtract/hook/build.dart'), tempUri.resolve('native_subtract/src/native_subtract.c'), + if (!Platform.isWindows) ...[ + tempUri.resolve('native_add/hook/build.dart'), + tempUri.resolve('native_subtract/hook/build.dart'), + ], ]), ); + if (Platform.isWindows) { + expect( + // Deps file on windows sometimes have lowercase drive letters. + // File.exists will work, but Uri equality doesn't. + result.dependencies + .map((e) => Uri.file(e.toFilePath().toLowerCase())), + containsAll([ + tempUri.resolve('native_add/hook/build.dart'), + tempUri.resolve('native_subtract/hook/build.dart'), + ].map((e) => Uri.file(e.toFilePath().toLowerCase()))), + ); + } } }); });