Skip to content

Commit 35f35ff

Browse files
committed
Merge pull request #555 from TheBosZ/master
Fix file separators on Windows
2 parents c2e170f + c3b43ac commit 35f35ff

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/dev_compiler/lib/src/compiler/code_generator.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import 'package:analyzer/src/summary/summarize_elements.dart'
2424
show PackageBundleAssembler;
2525
import 'package:analyzer/src/task/strong/info.dart' show DynamicInvoke;
2626
import 'package:source_maps/source_maps.dart';
27+
import 'package:path/path.dart' show separator;
2728

2829
import '../closure/closure_annotator.dart' show ClosureAnnotator;
2930
import '../js_ast/js_ast.dart' as JS;
@@ -145,8 +146,8 @@ class CodeGenerator extends GeneralizingAstVisitor
145146
List<String> errors) {
146147
_buildUnit = unit;
147148
_buildRoot = _buildUnit.buildRoot;
148-
if (!_buildRoot.endsWith('/')) {
149-
_buildRoot = '$_buildRoot/';
149+
if (!_buildRoot.endsWith(separator)) {
150+
_buildRoot = '$_buildRoot${separator}';
150151
}
151152

152153
var jsTree = _emitModule(compilationUnits);
@@ -4359,12 +4360,12 @@ String jsLibraryName(String buildRoot, LibraryElement library) {
43594360
// TODO(vsm): This is not unique if an escaped '/'appears in a filename.
43604361
// E.g., "foo/bar.dart" and "foo$47bar.dart" would collide.
43614362
qualifiedPath = uri.pathSegments.skip(1).join(separator);
4362-
} else if (uri.path.startsWith(buildRoot)) {
4363+
} else if (uri.toFilePath().startsWith(buildRoot)) {
43634364
qualifiedPath =
43644365
uri.path.substring(buildRoot.length).replaceAll('/', separator);
43654366
} else {
43664367
// We don't have a unique name.
4367-
throw 'Invalid build root. $buildRoot does not contain ${uri.path}';
4368+
throw 'Invalid build root. $buildRoot does not contain ${uri.toFilePath()}';
43684369
}
43694370
return pathToJSIdentifier(qualifiedPath);
43704371
}

0 commit comments

Comments
 (0)