Deprecate chaseDependencies option.

The option is not used by any client at this time and removing it simplifies the
next stack of changes I'll be making on how we compose file systems.

I also don't believe we will necessarily add this back as an option, but instead
it might be that clients requriing hermeticity will provide a custom file system
that helps with that.

Change-Id: I401efb042920d234382b6c041b13d40ffae5c908
Reviewed-on: https://dart-review.googlesource.com/56462
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
This commit is contained in:
Sigmund Cherem 2018-05-24 04:57:01 +00:00 committed by commit-bot@chromium.org
parent 05f96af05a
commit 9b44fc39c8
28 changed files with 46 additions and 156 deletions

View file

@ -412,7 +412,7 @@ f() {
// print(problem.formatted);
};
options = new ProcessedOptions(optionBuilder, false, [entryPoint]);
options = new ProcessedOptions(optionBuilder, [entryPoint]);
UriTranslatorImpl uriTranslator = await options.getUriTranslator();

View file

@ -189,7 +189,6 @@ Future compileKernelSummary(
..packagesFileUri = _uriInRepo(".packages")
..strongMode = true
..debugDump = true
..chaseDependencies = true
..onError = errorHandler
..reportMessages = true
..target = new DevCompilerTarget();

View file

@ -31,7 +31,6 @@ Future main(List<String> args) async {
var target = new DevCompilerTarget();
var options = new CompilerOptions()
..compileSdk = true
..chaseDependencies = true
..packagesFileUri = path.toUri(path.absolute('../../.packages'))
..sdkRoot = path.toUri(inputPath)
..target = target;

View file

@ -131,19 +131,7 @@ class CompilerOptions {
/// When this option is `true`, [sdkSummary] must be null.
bool compileSdk = false;
/// Whether the compiler should read files that are discovered as
/// dependencies, or only access the files listed explicitly.
///
/// This option has different defaults depending on the API.
///
/// For modular APIs like `kernelForComponent` and `summaryFor` the default
/// behavior is `false`. These APIs want to ensure that builds are hermetic,
/// where all files that will be compiled are listed explicitly and all other
/// dependencies are covered by summary files.
///
/// For whole-program APIs like `kernelForProgram`, this option is true by
/// default, so they can treat any dependency that is not described in a
/// summary as if it was explicitly listed as an input.
@deprecated
bool chaseDependencies;
/// Whether to interpret Dart sources in strong-mode.

View file

@ -21,7 +21,7 @@ abstract class IncrementalKernelGenerator {
factory IncrementalKernelGenerator(CompilerOptions options, Uri entryPoint,
[Uri initializeFromDillUri]) {
return new IncrementalCompiler(
new CompilerContext(new ProcessedOptions(options, false, [entryPoint])),
new CompilerContext(new ProcessedOptions(options, [entryPoint])),
initializeFromDillUri);
}

View file

@ -43,7 +43,7 @@ import 'compiler_options.dart' show CompilerOptions;
/// an error is reported.
// TODO(sigmund): rename to kernelForScript?
Future<Component> kernelForProgram(Uri source, CompilerOptions options) async {
var pOptions = new ProcessedOptions(options, false, [source]);
var pOptions = new ProcessedOptions(options, [source]);
return await CompilerContext.runWithOptions(pOptions, (context) async {
var component = (await generateKernelInternal())?.component;
if (component == null) return null;
@ -66,19 +66,10 @@ Future<Component> kernelForProgram(Uri source, CompilerOptions options) async {
/// dependencies, build unit dependencies must be acyclic.
///
/// This API is intended for modular compilation. Dependencies to other build
/// units are specified using [CompilerOptions.inputSummaries].
///
/// By default, the compilation process is hermetic, meaning that the only files
/// which will be read are those listed in [sources],
/// [CompilerOptions.inputSummaries], and [CompilerOptions.sdkSummary]. If a
/// source file attempts to refer to a file which is not obtainable from these
/// URIs, that will result in an error, even if the file exists on the
/// filesystem.
///
/// When [CompilerOptions.chaseDependencies] is true, this default behavior
/// changes, and any dependency of [sources] that is not listed in
/// [CompilerOptions.inputSummaries] and [CompilerOptions.sdkSummary] is treated
/// as an additional source file for the build unit.
/// units are specified using [CompilerOptions.inputSummaries]. Any dependency
/// of [sources] that is not listed in [CompilerOptions.inputSummaries] and
/// [CompilerOptions.sdkSummary] is treated as an additional source file for the
/// build unit.
///
/// Any `part` declarations found in [sources] must refer to part files which
/// are also listed in the build unit sources, otherwise an error results. (It
@ -89,6 +80,6 @@ Future<Component> kernelForProgram(Uri source, CompilerOptions options) async {
/// summaries.
Future<Component> kernelForComponent(
List<Uri> sources, CompilerOptions options) async {
return (await generateKernel(new ProcessedOptions(options, true, sources)))
return (await generateKernel(new ProcessedOptions(options, sources)))
?.component;
}

View file

@ -16,18 +16,7 @@ import '../kernel_generator_impl.dart';
///
/// Intended to be a part of a modular compilation process.
///
/// [sources] should be the complete set of source files for a build unit
/// (including both library and part files).
///
/// By default, the compilation process is hermetic, meaning that the only files
/// which will be read are those listed in [sources],
/// [CompilerOptions.inputSummaries], and [CompilerOptions.sdkSummary]. If a
/// source file attempts to refer to a file which is not obtainable from these
/// URIs, that will result in an error, even if the file exists on the
/// filesystem.
///
/// When [CompilerOptions.chaseDependencies] is true, this default behavior
/// changes, and any dependency of [sources] that is not listed in
/// Any dependency of [sources] that is not listed in
/// [CompilerOptions.inputSummaries] and [CompilerOptions.sdkSummary] is treated
/// as an additional source file for the build unit.
///
@ -42,7 +31,7 @@ import '../kernel_generator_impl.dart';
/// The return value is a list of bytes to write to the summary file.
Future<List<int>> summaryFor(List<Uri> sources, CompilerOptions options,
{bool truncate: false}) async {
return (await generateKernel(new ProcessedOptions(options, true, sources),
return (await generateKernel(new ProcessedOptions(options, sources),
buildSummary: true, buildComponent: false, truncateSummary: truncate))
?.summary;
}

View file

@ -47,7 +47,7 @@ InitializedCompilerState initializeCompiler(
..librariesSpecificationUri = librariesSpecificationUri
..packagesFileUri = packagesFileUri;
ProcessedOptions processedOpts = new ProcessedOptions(options, false, []);
ProcessedOptions processedOpts = new ProcessedOptions(options, []);
return new InitializedCompilerState(options, processedOpts);
}

View file

@ -66,10 +66,9 @@ Future<InitializedCompilerState> initializeCompiler(
..inputSummaries = inputSummaries
..target = target
..fileSystem = fileSystem ?? StandardFileSystem.instance
..chaseDependencies = true
..reportMessages = true;
ProcessedOptions processedOpts = new ProcessedOptions(options, true, []);
ProcessedOptions processedOpts = new ProcessedOptions(options, []);
return new InitializedCompilerState(options, processedOpts);
}

View file

@ -38,10 +38,9 @@ Future<InitializedCompilerState> initializeCompiler(
..packagesFileUri = packagesFile
..inputSummaries = inputSummaries
..target = target
..fileSystem = fileSystem
..chaseDependencies = true;
..fileSystem = fileSystem;
ProcessedOptions processedOpts = new ProcessedOptions(options, true, []);
ProcessedOptions processedOpts = new ProcessedOptions(options, []);
return new InitializedCompilerState(options, processedOpts);
}

View file

@ -172,15 +172,6 @@ class ProcessedOptions {
bool get throwOnNitsForDebugging => _raw.throwOnNitsForDebugging;
/// Like [CompilerOptions.chaseDependencies] but with the appropriate default
/// value filled in.
bool get chaseDependencies => _raw.chaseDependencies ?? !_modularApi;
/// Whether the compiler was invoked with a modular API.
///
/// Used to determine the default behavior for [chaseDependencies].
final bool _modularApi;
/// The entry-points provided to the compiler.
final List<Uri> inputs;
@ -189,7 +180,7 @@ class ProcessedOptions {
/// Initializes a [ProcessedOptions] object wrapping the given [rawOptions].
ProcessedOptions(CompilerOptions rawOptions,
[this._modularApi = false, this.inputs = const [], this.output])
[this.inputs = const [], this.output])
: this._raw = rawOptions,
// TODO(sigmund, ahe): create ticker even earlier or pass in a stopwatch
// collecting time since the start of the VM.
@ -596,31 +587,8 @@ class ProcessedOptions {
}
/// Create a [FileSystem] specific to the current options.
///
/// If [chaseDependencies] is false, the resulting file system will be
/// hermetic.
FileSystem _createFileSystem() {
var result = _raw.fileSystem;
if (!chaseDependencies) {
var allInputs = inputs.toSet();
allInputs.addAll(_raw.inputSummaries);
allInputs.addAll(_raw.linkedDependencies);
if (sdkSummary != null) allInputs.add(sdkSummary);
if (_raw.sdkRoot != null) {
// TODO(sigmund): refine this, we should be more explicit about when
// sdkRoot and libraries.json are allowed to be used.
allInputs.add(sdkRoot);
allInputs.add(sdkRoot.resolve("lib/libraries.json"));
}
/// Note: Searching the file-system for the package-config is not
/// supported in hermetic builds.
if (_raw.packagesFileUri != null) allInputs.add(_raw.packagesFileUri);
result = new HermeticFileSystem(allInputs, result);
}
return result;
return _raw.fileSystem;
}
String debugString() {
@ -648,9 +616,6 @@ class ProcessedOptions {
writeList('Input Summaries', _raw.inputSummaries);
writeList('Linked Dependencies', _raw.linkedDependencies);
sb.writeln('Modular: ${_modularApi}');
sb.writeln('Hermetic: ${!chaseDependencies} (provided: '
'${_raw.chaseDependencies == null ? null : !_raw.chaseDependencies})');
sb.writeln('Packages uri: ${_raw.packagesFileUri}');
sb.writeln('Packages: ${_packages}');

View file

@ -37,7 +37,7 @@ Future<List<Uri>> getDependencies(Uri script,
..packagesFileUri = packages
..sdkSummary = platform
..sdkRoot = sdk;
var pOptions = new ProcessedOptions(options, false, <Uri>[script]);
var pOptions = new ProcessedOptions(options, <Uri>[script]);
return await CompilerContext.runWithOptions(pOptions,
(CompilerContext c) async {
FileSystem fileSystem = c.options.fileSystem;

View file

@ -370,7 +370,7 @@ Future<Context> createContext(
};
final ProcessedOptions options =
new ProcessedOptions(optionBuilder, false, [entryPoint]);
new ProcessedOptions(optionBuilder, [entryPoint]);
final ExternalStateSnapshot snapshot =
new ExternalStateSnapshot(await options.loadSdkSummary(null));

View file

@ -50,7 +50,7 @@ test({bool sdkFromSource}) async {
final Uri helloDart = Uri.base.resolve("pkg/front_end/testcases/hello.dart");
final ProcessedOptions options =
new ProcessedOptions(optionBuilder, false, [helloDart]);
new ProcessedOptions(optionBuilder, [helloDart]);
IncrementalCompiler compiler =
new IncrementalCompiler(new CompilerContext(options));

View file

@ -227,7 +227,7 @@ Future<Context> createContext(
};
final ProcessedOptions options =
new ProcessedOptions(optionBuilder, false, [entryPoint]);
new ProcessedOptions(optionBuilder, [entryPoint]);
final ExternalStateSnapshot snapshot =
new ExternalStateSnapshot(await options.loadSdkSummary(null));

View file

@ -444,9 +444,7 @@ class TestIncrementalCompiler extends IncrementalCompiler {
TestIncrementalCompiler(CompilerOptions options, Uri entryPoint,
[Uri initializeFrom])
: super(
new CompilerContext(
new ProcessedOptions(options, false, [entryPoint])),
: super(new CompilerContext(new ProcessedOptions(options, [entryPoint])),
initializeFrom);
@override

View file

@ -177,26 +177,9 @@ main() {
expect(errors, isEmpty);
});
test('compiler by default is hermetic', () async {
test('compiler is not hermetic by default', () async {
var errors = [];
var options = new CompilerOptions()..onError = (e) => errors.add(e);
var sources = {
'a.dart': 'import "b.dart"; a() => print("hi");',
'b.dart': ''
};
await compileUnit(['a.dart'], sources, options: options);
expect(errors.first.message, contains('Invalid access'));
errors.clear();
await compileUnit(['a.dart', 'b.dart'], sources, options: options);
expect(errors, isEmpty);
});
test('chaseDependencies=true removes hermetic restriction', () async {
var errors = [];
var options = new CompilerOptions()
..chaseDependencies = true
..onError = (e) => errors.add(e);
await compileUnit([
'a.dart'
], {

View file

@ -239,8 +239,8 @@ class ProcessedOptionsTest {
.entityForUri(Uri.parse('org-dartlang-test:///base/location/.packages'))
.writeAsStringSync('foo:baz\n');
var raw = new CompilerOptions()..fileSystem = fileSystem;
var processed = new ProcessedOptions(raw, false,
[Uri.parse('org-dartlang-test:///base/location/script.dart')]);
var processed = new ProcessedOptions(
raw, [Uri.parse('org-dartlang-test:///base/location/script.dart')]);
var uriTranslator = await processed.getUriTranslator();
checkPackageExpansion('foo', 'base/location/baz', uriTranslator.packages);
}
@ -259,8 +259,8 @@ class ProcessedOptionsTest {
.entityForUri(Uri.parse('org-dartlang-test:///base/.packages'))
.writeAsStringSync('foo:baz\n');
var raw = new CompilerOptions()..fileSystem = fileSystem;
var processed = new ProcessedOptions(raw, false,
[Uri.parse('org-dartlang-test:///base/location/script.dart')]);
var processed = new ProcessedOptions(
raw, [Uri.parse('org-dartlang-test:///base/location/script.dart')]);
var uriTranslator = await processed.getUriTranslator();
checkPackageExpansion('foo', 'base/baz', uriTranslator.packages);
}
@ -282,8 +282,8 @@ class ProcessedOptionsTest {
.entityForUri(Uri.parse('org-dartlang-test:///base/.packages'))
.writeAsStringSync('foo:baz\n');
var raw = new CompilerOptions()..fileSystem = fileSystem;
var processed = new ProcessedOptions(raw, false,
[Uri.parse('org-dartlang-test:///base/location/script.dart')]);
var processed = new ProcessedOptions(
raw, [Uri.parse('org-dartlang-test:///base/location/script.dart')]);
var uriTranslator = await processed.getUriTranslator();
checkPackageExpansion(
'foo', 'base/location/packages/foo', uriTranslator.packages);
@ -299,8 +299,8 @@ class ProcessedOptionsTest {
var raw = new CompilerOptions()
..fileSystem = fileSystem
..onError = (e) => errors.add(e);
var processed = new ProcessedOptions(raw, false,
[Uri.parse('org-dartlang-test:///base/location/script.dart')]);
var processed = new ProcessedOptions(
raw, [Uri.parse('org-dartlang-test:///base/location/script.dart')]);
var uriTranslator = await processed.getUriTranslator();
expect(errors, isEmpty);
expect(uriTranslator.packages.asMap(), isEmpty);
@ -342,7 +342,7 @@ class ProcessedOptionsTest {
var raw = new CompilerOptions()
..fileSystem = fileSystem
..onError = (e) => errors.add(e);
var options = new ProcessedOptions(raw, false, [Uri.parse('foo.dart')]);
var options = new ProcessedOptions(raw, [Uri.parse('foo.dart')]);
var result = await options.validateOptions();
expect(errors.single.message,
startsWith(_stringPrefixOf(templateInputFileNotFound)));
@ -368,7 +368,7 @@ class ProcessedOptionsTest {
..sdkRoot = sdkRoot
..fileSystem = fileSystem
..onError = (e) => errors.add(e);
var options = new ProcessedOptions(raw, false, [Uri.parse('foo.dart')]);
var options = new ProcessedOptions(raw, [Uri.parse('foo.dart')]);
var result = await options.validateOptions();
// Note: we check this first so test failures show the cause directly.
expect(errors, isEmpty);
@ -385,7 +385,7 @@ class ProcessedOptionsTest {
..sdkRoot = sdkRoot
..fileSystem = fileSystem
..onError = (e) => errors.add(e);
var options = new ProcessedOptions(raw, false, [Uri.parse('foo.dart')]);
var options = new ProcessedOptions(raw, [Uri.parse('foo.dart')]);
expect(await options.validateOptions(), isFalse);
expect(errors.first.message,
startsWith(_stringPrefixOf(templateSdkRootNotFound)));
@ -403,7 +403,7 @@ class ProcessedOptionsTest {
..sdkSummary = sdkSummary
..fileSystem = fileSystem
..onError = (e) => errors.add(e);
var options = new ProcessedOptions(raw, false, [Uri.parse('foo.dart')]);
var options = new ProcessedOptions(raw, [Uri.parse('foo.dart')]);
var result = await options.validateOptions();
expect(errors, isEmpty);
expect(result, isTrue);
@ -419,7 +419,7 @@ class ProcessedOptionsTest {
..sdkSummary = sdkSummary
..fileSystem = fileSystem
..onError = (e) => errors.add(e);
var options = new ProcessedOptions(raw, false, [Uri.parse('foo.dart')]);
var options = new ProcessedOptions(raw, [Uri.parse('foo.dart')]);
expect(await options.validateOptions(), isFalse);
expect(errors.single.message,
startsWith(_stringPrefixOf(templateSdkSummaryNotFound)));
@ -440,7 +440,7 @@ class ProcessedOptionsTest {
..sdkRoot = sdkRoot
..fileSystem = fileSystem
..onError = (e) => errors.add(e);
var options = new ProcessedOptions(raw, false, [Uri.parse('foo.dart')]);
var options = new ProcessedOptions(raw, [Uri.parse('foo.dart')]);
var result = await options.validateOptions();
expect(errors, isEmpty);
expect(result, isTrue);
@ -458,7 +458,7 @@ class ProcessedOptionsTest {
..sdkSummary = sdkSummary
..fileSystem = fileSystem
..onError = (e) => errors.add(e);
var options = new ProcessedOptions(raw, false, [Uri.parse('foo.dart')]);
var options = new ProcessedOptions(raw, [Uri.parse('foo.dart')]);
expect(await options.validateOptions(), isFalse);
expect(errors.single.message,
startsWith(_stringPrefixOf(templateSdkSummaryNotFound)));

View file

@ -987,7 +987,6 @@ import 'b.dart';
..fileSystem = fileSystem
..sdkRoot = Uri.parse('org-dartlang-test:///sdk/')
..compileSdk = true
..chaseDependencies = true
..strongMode = true
..target = new NoneTarget(new TargetFlags(strongMode: true));
var inputs = [Uri.parse('dart:core')];

View file

@ -118,14 +118,10 @@ main() {
component.libraries.single.importUri.path.endsWith('b.dart'), isTrue);
});
test('summarization by default is hermetic', () async {
test('summarization by default is not hermetic', () async {
var errors = [];
var options = new CompilerOptions()..onError = (e) => errors.add(e);
await summarize(['b.dart'], allSources, options: options);
expect(errors.first.toString(), contains('Invalid access'));
errors.clear();
await summarize(['a.dart', 'b.dart'], allSources, options: options);
expect(errors, isEmpty);
});

View file

@ -43,7 +43,6 @@ class BulkCompiler {
..fileSystem = (new FileBackedMemoryFileSystem()
..entities[mainUri.path] =
(new MemoryFileSystemEntity(mainUri)..bytes = <int>[])),
false,
<Uri>[mainUri]);
Future<Null> compile(String source) {

View file

@ -300,7 +300,6 @@ ProcessedOptions analyzeCommandLine(
..sdkSummary = options["--platform"]
..librariesSpecificationUri = resolveFile(arguments[1])
..setExitCodeOnProblem = true
..chaseDependencies = true
..packagesFileUri = packages
..strongMode = strongMode
..target = target
@ -311,7 +310,6 @@ ProcessedOptions analyzeCommandLine(
..debugDump = dumpIr
..verbose = verbose
..verify = verify,
false,
<Uri>[Uri.parse(arguments[0])],
resolveFile(arguments[2]));
} else if (arguments.isEmpty) {
@ -352,7 +350,7 @@ ProcessedOptions analyzeCommandLine(
inputs.add(resolveFile(argument));
}
}
return new ProcessedOptions(compilerOptions, false, inputs, output);
return new ProcessedOptions(compilerOptions, inputs, output);
}
dynamic withGlobalOptions(

View file

@ -129,8 +129,7 @@ class BatchCompiler {
Future<bool> batchCompile(CompilerOptions options, Uri input, Uri output) {
return CompilerContext.runWithOptions(
new ProcessedOptions(options, false, <Uri>[input], output),
batchCompileImpl);
new ProcessedOptions(options, <Uri>[input], output), batchCompileImpl);
}
Future<bool> batchCompileImpl(CompilerContext c) async {

View file

@ -233,7 +233,6 @@ generateKernel(Uri entryUri,
..onError = onErrorHandler(strongMode)
..strongMode = strongMode
..target = createTarget(isFlutter: false, strongMode: strongMode)
..chaseDependencies = true
..packagesFileUri = Uri.base.resolve('.packages')
..compileSdk = compileSdk;
if (!compileSdk) {

View file

@ -127,8 +127,7 @@ Future benchmark(
var dir = Directory.systemTemp.createTempSync("ikg-cache");
compilerOptions.byteStore = createByteStore(cache, dir.path);
final processedOptions =
new ProcessedOptions(compilerOptions, false, [entryUri]);
final processedOptions = new ProcessedOptions(compilerOptions, [entryUri]);
final UriTranslator uriTranslator = await processedOptions.getUriTranslator();
collector.start("Initial compilation");

View file

@ -178,7 +178,7 @@ class SingleShotCompilerWrapper extends Compiler {
Future<Component> compileInternal(Uri script) async {
return requireMain
? kernelForProgram(script, options)
: kernelForComponent([script], options..chaseDependencies = true);
: kernelForComponent([script], options);
}
}

View file

@ -145,8 +145,7 @@ Future _performConstantEvaluation(
final vmConstants =
new vm_constants.VmConstantsBackend(environmentDefines, coreTypes);
final processedOptions =
new ProcessedOptions(compilerOptions, false, [source]);
final processedOptions = new ProcessedOptions(compilerOptions, [source]);
// Run within the context, so we have uri source tokens...
await CompilerContext.runWithOptions(processedOptions,

View file

@ -200,19 +200,11 @@ Future<List<Uri>> compilePlatform(
..compileSdk = true
..sdkRoot = patchedSdk
..packagesFileUri = packages
..chaseDependencies = true
..target = target;
var inputs = [Uri.parse('dart:core')];
var result = await generateKernel(
new ProcessedOptions(
options,
// TODO(sigmund): pass all sdk libraries needed here, and make this
// hermetic.
false,
inputs),
buildSummary: true,
buildComponent: true);
var result = await generateKernel(new ProcessedOptions(options, inputs),
buildSummary: true, buildComponent: true);
await writeComponentToFile(result.component, output);
return result.deps;
}