mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Add server category for dart2js
Change-Id: I077da86aff4420aba1323e98d6cde08ac871f6f1 Reviewed-on: https://dart-review.googlesource.com/47721 Commit-Queue: Sigmund Cherem <sigmund@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
ea1d1d7621
commit
07d2c9f287
|
@ -14,38 +14,13 @@ import '../native/native.dart' show maybeEnableNative;
|
|||
/// A kernel [Target] to configure the Dart Front End for dart2js.
|
||||
class Dart2jsTarget extends Target {
|
||||
final TargetFlags flags;
|
||||
final String name;
|
||||
|
||||
Dart2jsTarget(this.flags);
|
||||
Dart2jsTarget(this.name, this.flags);
|
||||
|
||||
bool get strongMode => flags.strongMode;
|
||||
|
||||
String get name => 'dart2js';
|
||||
|
||||
List<String> get extraRequiredLibraries => const <String>[
|
||||
'dart:_chrome',
|
||||
'dart:_foreign_helper',
|
||||
'dart:_interceptors',
|
||||
'dart:_internal',
|
||||
'dart:_isolate_helper',
|
||||
'dart:_js_embedded_names',
|
||||
'dart:_js_helper',
|
||||
'dart:_js_mirrors',
|
||||
'dart:_js_names',
|
||||
'dart:_native_typed_data',
|
||||
'dart:async',
|
||||
'dart:collection',
|
||||
'dart:html',
|
||||
'dart:html_common',
|
||||
'dart:indexed_db',
|
||||
'dart:io',
|
||||
'dart:js',
|
||||
'dart:js_util',
|
||||
'dart:mirrors',
|
||||
'dart:svg',
|
||||
'dart:web_audio',
|
||||
'dart:web_gl',
|
||||
'dart:web_sql',
|
||||
];
|
||||
List<String> get extraRequiredLibraries => _requiredLibraries[name];
|
||||
|
||||
@override
|
||||
bool mayDefineRestrictedType(Uri uri) =>
|
||||
|
@ -96,3 +71,50 @@ class Dart2jsTarget extends Target {
|
|||
return new InvalidExpression(null);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(sigmund): this "extraRequiredLibraries" needs to be removed...
|
||||
// compile-platform should just specify which libraries to compile instead.
|
||||
const _requiredLibraries = const <String, List<String>>{
|
||||
'dart2js': const <String>[
|
||||
'dart:_chrome',
|
||||
'dart:_foreign_helper',
|
||||
'dart:_interceptors',
|
||||
'dart:_internal',
|
||||
'dart:_isolate_helper',
|
||||
'dart:_js_embedded_names',
|
||||
'dart:_js_helper',
|
||||
'dart:_js_mirrors',
|
||||
'dart:_js_names',
|
||||
'dart:_native_typed_data',
|
||||
'dart:async',
|
||||
'dart:collection',
|
||||
'dart:html',
|
||||
'dart:html_common',
|
||||
'dart:indexed_db',
|
||||
'dart:io',
|
||||
'dart:js',
|
||||
'dart:js_util',
|
||||
'dart:mirrors',
|
||||
'dart:svg',
|
||||
'dart:web_audio',
|
||||
'dart:web_gl',
|
||||
'dart:web_sql',
|
||||
],
|
||||
'dart2js_server': const <String>[
|
||||
'dart:_foreign_helper',
|
||||
'dart:_interceptors',
|
||||
'dart:_internal',
|
||||
'dart:_isolate_helper',
|
||||
'dart:_js_embedded_names',
|
||||
'dart:_js_helper',
|
||||
'dart:_js_mirrors',
|
||||
'dart:_js_names',
|
||||
'dart:_native_typed_data',
|
||||
'dart:async',
|
||||
'dart:collection',
|
||||
'dart:io',
|
||||
'dart:js',
|
||||
'dart:js_util',
|
||||
'dart:mirrors',
|
||||
]
|
||||
};
|
||||
|
|
|
@ -871,12 +871,15 @@ class KernelLibraryLoaderTask extends CompilerTask
|
|||
new BinaryBuilder(input.data).readComponent(component);
|
||||
} else {
|
||||
bool strongMode = _elementMap.options.strongMode;
|
||||
String targetName =
|
||||
_elementMap.options.compileForServer ? "dart2js_server" : "dart2js";
|
||||
String platform = strongMode
|
||||
? 'dart2js_platform_strong.dill'
|
||||
: 'dart2js_platform.dill';
|
||||
? '${targetName}_platform_strong.dill'
|
||||
: '${targetName}_platform.dill';
|
||||
initializedCompilerState = fe.initializeCompiler(
|
||||
initializedCompilerState,
|
||||
new Dart2jsTarget(new TargetFlags(strongMode: strongMode)),
|
||||
new Dart2jsTarget(
|
||||
targetName, new TargetFlags(strongMode: strongMode)),
|
||||
librariesSpecification,
|
||||
platformBinaries.resolve(platform),
|
||||
_packageConfig);
|
||||
|
|
|
@ -100,6 +100,10 @@ class CompilerOptions implements DiagnosticOptions {
|
|||
/// and in the emitted output of the compiler.
|
||||
bool get hasBuildId => buildId != _UNDETERMINED_BUILD_ID;
|
||||
|
||||
/// Whether to compile for the server category. This is used to compile to JS
|
||||
/// that is intended to be run on server-side VMs like nodejs.
|
||||
final bool compileForServer;
|
||||
|
||||
/// Location where to generate a map containing details of how deferred
|
||||
/// libraries are subdivided.
|
||||
final Uri deferredMapUri;
|
||||
|
@ -309,6 +313,7 @@ class CompilerOptions implements DiagnosticOptions {
|
|||
analyzeSignaturesOnly: _hasOption(options, Flags.analyzeSignaturesOnly),
|
||||
buildId: _extractStringOption(
|
||||
options, '--build-id=', _UNDETERMINED_BUILD_ID),
|
||||
compileForServer: _resolveCompileForServerFromOptions(options),
|
||||
deferredMapUri: _extractUriOption(options, '--deferred-map='),
|
||||
fatalWarnings: _hasOption(options, Flags.fatalWarnings),
|
||||
terseDiagnostics: _hasOption(options, Flags.terse),
|
||||
|
@ -387,6 +392,7 @@ class CompilerOptions implements DiagnosticOptions {
|
|||
bool analyzeOnly: false,
|
||||
bool analyzeSignaturesOnly: false,
|
||||
String buildId: _UNDETERMINED_BUILD_ID,
|
||||
bool compileForServer: false,
|
||||
Uri deferredMapUri: null,
|
||||
bool fatalWarnings: false,
|
||||
bool terseDiagnostics: false,
|
||||
|
@ -469,6 +475,7 @@ class CompilerOptions implements DiagnosticOptions {
|
|||
analyzeOnly || analyzeSignaturesOnly || analyzeAll || resolveOnly,
|
||||
analyzeSignaturesOnly: analyzeSignaturesOnly,
|
||||
buildId: buildId,
|
||||
compileForServer: compileForServer,
|
||||
deferredMapUri: deferredMapUri,
|
||||
fatalWarnings: fatalWarnings,
|
||||
terseDiagnostics: terseDiagnostics,
|
||||
|
@ -527,6 +534,7 @@ class CompilerOptions implements DiagnosticOptions {
|
|||
this.analyzeOnly: false,
|
||||
this.analyzeSignaturesOnly: false,
|
||||
this.buildId: _UNDETERMINED_BUILD_ID,
|
||||
this.compileForServer: false,
|
||||
this.deferredMapUri: null,
|
||||
this.fatalWarnings: false,
|
||||
this.terseDiagnostics: false,
|
||||
|
@ -591,6 +599,7 @@ class CompilerOptions implements DiagnosticOptions {
|
|||
analyzeOnly,
|
||||
analyzeSignaturesOnly,
|
||||
buildId,
|
||||
compileForServer,
|
||||
deferredMapUri,
|
||||
fatalWarnings,
|
||||
terseDiagnostics,
|
||||
|
@ -654,6 +663,7 @@ class CompilerOptions implements DiagnosticOptions {
|
|||
analyzeSignaturesOnly:
|
||||
analyzeSignaturesOnly ?? options.analyzeSignaturesOnly,
|
||||
buildId: buildId ?? options.buildId,
|
||||
compileForServer: compileForServer ?? options.compileForServer,
|
||||
deferredMapUri: deferredMapUri ?? options.deferredMapUri,
|
||||
fatalWarnings: fatalWarnings ?? options.fatalWarnings,
|
||||
terseDiagnostics: terseDiagnostics ?? options.terseDiagnostics,
|
||||
|
@ -801,6 +811,11 @@ Uri _resolvePlatformConfig(
|
|||
}
|
||||
}
|
||||
|
||||
bool _resolveCompileForServerFromOptions(List<String> options) {
|
||||
var categories = _extractCsvOption(options, '--categories=');
|
||||
return categories.length == 1 && categories.single == 'Server';
|
||||
}
|
||||
|
||||
Uri _resolvePlatformConfigFromOptions(Uri libraryRoot, List<String> options) {
|
||||
return _resolvePlatformConfig(
|
||||
libraryRoot,
|
||||
|
|
|
@ -23,7 +23,7 @@ import 'package:kernel/target/targets.dart';
|
|||
main(List<String> args) async {
|
||||
ArgResults flags = _argParser.parse(args);
|
||||
var options = new CompilerOptions()
|
||||
..target = new Dart2jsTarget(new TargetFlags())
|
||||
..target = new Dart2jsTarget("dart2js", new TargetFlags())
|
||||
..packagesFileUri = Uri.base.resolve('.packages')
|
||||
..setExitCodeOnProblem = true
|
||||
..linkedDependencies = [
|
||||
|
|
|
@ -38,7 +38,10 @@ import 'command_line.dart' show withGlobalOptions;
|
|||
const int iterations = const int.fromEnvironment("iterations", defaultValue: 1);
|
||||
|
||||
Future main(List<String> arguments) async {
|
||||
targets["dart2js"] = (TargetFlags flags) => new Dart2jsTarget(flags);
|
||||
targets["dart2js"] =
|
||||
(TargetFlags flags) => new Dart2jsTarget("dart2js", flags);
|
||||
targets["dart2js_server"] =
|
||||
(TargetFlags flags) => new Dart2jsTarget("dart2js_server", flags);
|
||||
targets["dart_runner"] = (TargetFlags flags) => new DartRunnerTarget(flags);
|
||||
targets["flutter_runner"] =
|
||||
(TargetFlags flags) => new FlutterRunnerTarget(flags);
|
||||
|
|
|
@ -49,7 +49,10 @@ const bool summary = const bool.fromEnvironment("summary", defaultValue: false);
|
|||
const int iterations = const int.fromEnvironment("iterations", defaultValue: 1);
|
||||
|
||||
compileEntryPoint(List<String> arguments) async {
|
||||
targets["dart2js"] = (TargetFlags flags) => new Dart2jsTarget(flags);
|
||||
targets["dart2js"] =
|
||||
(TargetFlags flags) => new Dart2jsTarget("dart2js", flags);
|
||||
targets["dart2js_server"] =
|
||||
(TargetFlags flags) => new Dart2jsTarget("dart2js_server", flags);
|
||||
|
||||
// Timing results for each iteration
|
||||
List<double> elapsedTimes = <double>[];
|
||||
|
|
|
@ -65,7 +65,9 @@ declare_args() {
|
|||
#.........spec.sum
|
||||
#.........strong.sum
|
||||
#.........dart2js_platform.dill
|
||||
#.........dart2js_server_platform.dill
|
||||
#.........dart2js_platform_strong.dill
|
||||
#.........dart2js_server_platform_strong.dill
|
||||
#.........vm_outline.dill
|
||||
#.........vm_outline_strong.dill
|
||||
#.........vm_platform.dill
|
||||
|
@ -549,11 +551,15 @@ copy("copy_dart2js_dill_files") {
|
|||
deps = [
|
||||
":copy_libraries",
|
||||
"../utils/compiler:compile_dart2js_platform",
|
||||
"../utils/compiler:compile_dart2js_server_platform",
|
||||
"../utils/compiler:compile_dart2js_platform_strong",
|
||||
"../utils/compiler:compile_dart2js_server_platform_strong",
|
||||
]
|
||||
sources = [
|
||||
"$root_out_dir/dart2js_platform.dill",
|
||||
"$root_out_dir/dart2js_server_platform.dill",
|
||||
"$root_out_dir/dart2js_platform_strong.dill",
|
||||
"$root_out_dir/dart2js_server_platform_strong.dill",
|
||||
]
|
||||
outputs = [
|
||||
"$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}",
|
||||
|
|
|
@ -266,5 +266,100 @@
|
|||
"uri": "svg/dart2js/svg_dart2js.dart"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dart2js_server": {
|
||||
"environment_overrides": {
|
||||
"mirrors": false,
|
||||
"io": false
|
||||
},
|
||||
"libraries": {
|
||||
"async": {
|
||||
"patches": "_internal/js_runtime/lib/async_patch.dart",
|
||||
"uri": "async/async.dart"
|
||||
},
|
||||
"mirrors": {
|
||||
"patches": "_internal/js_runtime/lib/mirrors_patch_cfe.dart",
|
||||
"uri": "mirrors/mirrors.dart"
|
||||
},
|
||||
"_interceptors": {
|
||||
"uri": "_internal/js_runtime/lib/interceptors.dart"
|
||||
},
|
||||
"_js_embedded_names": {
|
||||
"uri": "_internal/js_runtime/lib/shared/embedded_names.dart"
|
||||
},
|
||||
"io": {
|
||||
"patches": "_internal/js_runtime/lib/io_patch.dart",
|
||||
"uri": "io/io.dart"
|
||||
},
|
||||
"_internal": {
|
||||
"patches": "_internal/js_runtime/lib/internal_patch.dart",
|
||||
"uri": "internal/internal.dart"
|
||||
},
|
||||
"_async_await_error_codes": {
|
||||
"uri": "_internal/js_runtime/lib/shared/async_await_error_codes.dart"
|
||||
},
|
||||
"_http": {
|
||||
"uri": "_http/http.dart"
|
||||
},
|
||||
"_js_helper": {
|
||||
"uri": "_internal/js_runtime/lib/js_helper.dart"
|
||||
},
|
||||
"_js_primitives": {
|
||||
"uri": "_internal/js_runtime/lib/js_primitives.dart"
|
||||
},
|
||||
"js": {
|
||||
"uri": "js/dart2js/js_dart2js.dart"
|
||||
},
|
||||
"_js_mirrors": {
|
||||
"uri": "_internal/js_runtime/lib/js_mirrors.dart"
|
||||
},
|
||||
"_native_typed_data": {
|
||||
"uri": "_internal/js_runtime/lib/native_typed_data.dart"
|
||||
},
|
||||
"core": {
|
||||
"patches": "_internal/js_runtime/lib/core_patch.dart",
|
||||
"uri": "core/core.dart"
|
||||
},
|
||||
"_js_names": {
|
||||
"uri": "_internal/js_runtime/lib/js_names.dart"
|
||||
},
|
||||
"js_util": {
|
||||
"uri": "js_util/dart2js/js_util_dart2js.dart"
|
||||
},
|
||||
"collection": {
|
||||
"patches": "_internal/js_runtime/lib/collection_patch.dart",
|
||||
"uri": "collection/collection.dart"
|
||||
},
|
||||
"typed_data": {
|
||||
"patches": "_internal/js_runtime/lib/typed_data_patch.dart",
|
||||
"uri": "typed_data/typed_data.dart"
|
||||
},
|
||||
"isolate": {
|
||||
"patches": "_internal/js_runtime/lib/isolate_patch.dart",
|
||||
"uri": "isolate/isolate.dart"
|
||||
},
|
||||
"developer": {
|
||||
"patches": "_internal/js_runtime/lib/developer_patch.dart",
|
||||
"uri": "developer/developer.dart"
|
||||
},
|
||||
"_js": {
|
||||
"patches": "js/_js_server.dart",
|
||||
"uri": "js/_js.dart"
|
||||
},
|
||||
"convert": {
|
||||
"patches": "_internal/js_runtime/lib/convert_patch.dart",
|
||||
"uri": "convert/convert.dart"
|
||||
},
|
||||
"_isolate_helper": {
|
||||
"uri": "_internal/js_runtime/lib/isolate_helper.dart"
|
||||
},
|
||||
"math": {
|
||||
"patches": "_internal/js_runtime/lib/math_patch.dart",
|
||||
"uri": "math/math.dart"
|
||||
},
|
||||
"_foreign_helper": {
|
||||
"uri": "_internal/js_runtime/lib/foreign_helper.dart"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -263,3 +263,96 @@ dart2js:
|
|||
environment_overrides:
|
||||
io: false
|
||||
mirrors: false
|
||||
|
||||
dart2js_server:
|
||||
libraries:
|
||||
async:
|
||||
uri: "async/async.dart"
|
||||
patches: "_internal/js_runtime/lib/async_patch.dart"
|
||||
|
||||
collection:
|
||||
uri: "collection/collection.dart"
|
||||
patches: "_internal/js_runtime/lib/collection_patch.dart"
|
||||
|
||||
convert:
|
||||
uri: "convert/convert.dart"
|
||||
patches: "_internal/js_runtime/lib/convert_patch.dart"
|
||||
|
||||
core:
|
||||
uri: "core/core.dart"
|
||||
patches: "_internal/js_runtime/lib/core_patch.dart"
|
||||
|
||||
developer:
|
||||
uri: "developer/developer.dart"
|
||||
patches: "_internal/js_runtime/lib/developer_patch.dart"
|
||||
|
||||
_http:
|
||||
uri: "_http/http.dart"
|
||||
|
||||
io:
|
||||
uri: "io/io.dart"
|
||||
patches: "_internal/js_runtime/lib/io_patch.dart"
|
||||
|
||||
isolate:
|
||||
uri: "isolate/isolate.dart"
|
||||
patches: "_internal/js_runtime/lib/isolate_patch.dart"
|
||||
|
||||
js:
|
||||
uri: "js/dart2js/js_dart2js.dart"
|
||||
|
||||
_js:
|
||||
uri: "js/_js.dart"
|
||||
patches: "js/_js_server.dart"
|
||||
|
||||
js_util:
|
||||
uri: "js_util/dart2js/js_util_dart2js.dart"
|
||||
|
||||
math:
|
||||
uri: "math/math.dart"
|
||||
patches: "_internal/js_runtime/lib/math_patch.dart"
|
||||
|
||||
mirrors:
|
||||
uri: "mirrors/mirrors.dart"
|
||||
patches: "_internal/js_runtime/lib/mirrors_patch_cfe.dart"
|
||||
|
||||
typed_data:
|
||||
uri: "typed_data/typed_data.dart"
|
||||
patches: "_internal/js_runtime/lib/typed_data_patch.dart"
|
||||
|
||||
_native_typed_data:
|
||||
uri: "_internal/js_runtime/lib/native_typed_data.dart"
|
||||
|
||||
_internal:
|
||||
uri: "internal/internal.dart"
|
||||
patches: "_internal/js_runtime/lib/internal_patch.dart"
|
||||
|
||||
_js_helper:
|
||||
uri: "_internal/js_runtime/lib/js_helper.dart"
|
||||
|
||||
_interceptors:
|
||||
uri: "_internal/js_runtime/lib/interceptors.dart"
|
||||
|
||||
_foreign_helper:
|
||||
uri: "_internal/js_runtime/lib/foreign_helper.dart"
|
||||
|
||||
_isolate_helper:
|
||||
uri: "_internal/js_runtime/lib/isolate_helper.dart"
|
||||
|
||||
_js_mirrors:
|
||||
uri: "_internal/js_runtime/lib/js_mirrors.dart"
|
||||
|
||||
_js_names:
|
||||
uri: "_internal/js_runtime/lib/js_names.dart"
|
||||
|
||||
_js_primitives:
|
||||
uri: "_internal/js_runtime/lib/js_primitives.dart"
|
||||
|
||||
_js_embedded_names:
|
||||
uri: "_internal/js_runtime/lib/shared/embedded_names.dart"
|
||||
|
||||
_async_await_error_codes:
|
||||
uri: "_internal/js_runtime/lib/shared/async_await_error_codes.dart"
|
||||
|
||||
environment_overrides:
|
||||
io: false
|
||||
mirrors: false
|
||||
|
|
|
@ -43,7 +43,7 @@ main() {
|
|||
Uri entryPoint = Uri.parse('memory:main.dill');
|
||||
|
||||
var options = new CompilerOptions()
|
||||
..target = new Dart2jsTarget(new TargetFlags())
|
||||
..target = new Dart2jsTarget("dart2js", new TargetFlags())
|
||||
..packagesFileUri = Uri.base.resolve('.packages')
|
||||
..linkedDependencies = <Uri>[
|
||||
computePlatformBinariesLocation().resolve("dart2js_platform.dill"),
|
||||
|
|
|
@ -139,7 +139,7 @@ Future _main(List<String> argv) async {
|
|||
break;
|
||||
|
||||
case 'dart2js':
|
||||
target = new Dart2jsTarget(flags);
|
||||
target = new Dart2jsTarget("dart2js", flags);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -110,3 +110,36 @@ compile_platform("compile_dart2js_platform_strong") {
|
|||
"dart:core",
|
||||
]
|
||||
}
|
||||
|
||||
compile_platform("compile_dart2js_server_platform") {
|
||||
sources = [
|
||||
"../../sdk/lib/libraries.json",
|
||||
]
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/dart2js_server_platform.dill",
|
||||
"$root_out_dir/dart2js_server_outline.dill",
|
||||
]
|
||||
|
||||
args = [
|
||||
"--target=dart2js_server",
|
||||
"dart:core",
|
||||
]
|
||||
}
|
||||
|
||||
compile_platform("compile_dart2js_server_platform_strong") {
|
||||
sources = [
|
||||
"../../sdk/lib/libraries.json",
|
||||
]
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/dart2js_server_platform_strong.dill",
|
||||
"$root_out_dir/dart2js_server_outline_strong.dill",
|
||||
]
|
||||
|
||||
args = [
|
||||
"--target=dart2js_server",
|
||||
"--strong",
|
||||
"dart:core",
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue