Skip to content

Commit

Permalink
expose librariesPath in DevCompilerBuilder (#2404)
Browse files Browse the repository at this point in the history
Only change required to resolve import issues with package:http. Mirrors the way libraries was exposed from the kernel builder.

flutter/flutter#34858
  • Loading branch information
jonahwilliams authored and jakemac53 committed Aug 12, 2019
1 parent d4bd2de commit c23f943
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions build_web_compilers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.2.0

- Make `librariesPath` configurable in `DevCompilerBuilder`.

## 2.1.5

- Add pre-emptive support for an upcoming breaking change in ddc
Expand Down
20 changes: 17 additions & 3 deletions build_web_compilers/lib/src/dev_compiler_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@ class DevCompilerBuilder implements Builder {
/// directory, which contains the platform kernel files.
final String platformSdk;

/// The absolute path to the libraries file for the current platform.
///
/// If not provided, defaults to "lib/libraries.json" in the sdk directory.
final String librariesPath;

DevCompilerBuilder(
{bool useIncrementalCompiler,
@required this.platform,
this.sdkKernelPath,
String librariesPath,
String platformSdk})
: useIncrementalCompiler = useIncrementalCompiler ?? true,
platformSdk = platformSdk ?? sdkDir,
librariesPath = librariesPath ??
p.join(platformSdk ?? sdkDir, 'lib', 'libraries.json'),
buildExtensions = {
moduleExtension(platform): [
jsModuleExtension,
Expand Down Expand Up @@ -77,7 +85,7 @@ class DevCompilerBuilder implements Builder {

try {
await _createDevCompilerModule(module, buildStep, useIncrementalCompiler,
platformSdk, sdkKernelPath);
platformSdk, sdkKernelPath, librariesPath);
} on DartDevcCompilationException catch (e) {
await handleError(e);
} on MissingModulesException catch (e) {
Expand All @@ -87,8 +95,13 @@ class DevCompilerBuilder implements Builder {
}

/// Compile [module] with the dev compiler.
Future<void> _createDevCompilerModule(Module module, BuildStep buildStep,
bool useIncrementalCompiler, String dartSdk, String sdkKernelPath,
Future<void> _createDevCompilerModule(
Module module,
BuildStep buildStep,
bool useIncrementalCompiler,
String dartSdk,
String sdkKernelPath,
String librariesPath,
{bool debugMode = true}) async {
var transitiveDeps = await buildStep.trackStage('CollectTransitiveDeps',
() => module.computeTransitiveDependencies(buildStep));
Expand Down Expand Up @@ -122,6 +135,7 @@ Future<void> _createDevCompilerModule(Module module, BuildStep buildStep,
'--multi-root=.',
'--track-widget-creation',
'--inline-source-map',
'--libraries-file=${p.toUri(librariesPath)}',
if (useIncrementalCompiler) ...[
'--reuse-compiler-result',
'--use-incremental-compiler',
Expand Down
2 changes: 1 addition & 1 deletion build_web_compilers/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build_web_compilers
version: 2.1.5
version: 2.2.0
description: Builder implementations wrapping Dart compilers.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/build/tree/master/build_web_compilers
Expand Down

0 comments on commit c23f943

Please sign in to comment.