Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ class ReleaseCopyFlutterBundle extends CopyFlutterBundle {
}

/// Generate a snapshot of the dart code used in the program.
///
/// This target depends on the `.dart_tool/package_config.json` file
/// even though it is not listed as an input. Pub inserts a timestamp into
/// the file which causes unnecessary rebuilds, so instead a subset of the contents
/// are used an input instead.
class KernelSnapshot extends Target {
const KernelSnapshot();

Expand All @@ -140,7 +135,7 @@ class KernelSnapshot extends Target {

@override
List<Source> get inputs => const <Source>[
Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config_subset'),
Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config.json'),
Source.pattern(
'{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/common.dart',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class DartPluginRegistrantTarget extends Target {

@override
List<Source> get inputs => <Source>[
const Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config_subset'),
const Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config.json'),
];

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ abstract class DartBuild extends Target {
'{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/native_assets.dart',
),
// If different packages are resolved, different native assets might need to be built.
Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config_subset'),
Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config.json'),
// TODO(mosuem): Should consume resources.json. https://github.com/flutter/flutter/issues/146263
];

Expand Down Expand Up @@ -178,7 +178,7 @@ class InstallCodeAssets extends Target {
'{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/native_assets.dart',
),
// If different packages are resolved, different native assets might need to be built.
Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config_subset'),
Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config.json'),
];

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ abstract class Dart2WebTarget extends Target {
const Source.hostArtifact(HostArtifact.flutterWebSdk),
const Source.artifact(Artifact.engineDartBinary),
const Source.pattern('{BUILD_DIR}/main.dart'),
const Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config_subset'),
const Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config.json'),
];

@override
Expand Down
21 changes: 0 additions & 21 deletions packages/flutter_tools/lib/src/dart/pub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,6 @@ class _DefaultPub implements Pub {

/// Update the package configuration file in [project].
///
/// Creates a corresponding `package_config_subset` file that is used by the
/// build system to avoid rebuilds caused by an updated pub timestamp.
///
/// if `project.generateSyntheticPackage` is `true` then insert flutter_gen
/// synthetic package into the package configuration. This is used by the l10n
/// localization tooling to insert a new reference into the package_config
Expand All @@ -715,10 +712,6 @@ class _DefaultPub implements Pub {
logger: _logger,
);

packageConfigFile.parent
.childFile('package_config_subset')
.writeAsStringSync(_computePackageConfigSubset(packageConfig, _fileSystem));

// If we aren't generating localizations, short-circuit.
if (!project.manifest.generateLocalizations) {
return;
Expand Down Expand Up @@ -760,18 +753,4 @@ class _DefaultPub implements Pub {

packageConfigFile.writeAsStringSync(json.encode(jsonContents));
}

// Subset the package config file to only the parts that are relevant for
// rerunning the dart compiler.
String _computePackageConfigSubset(PackageConfig packageConfig, FileSystem fileSystem) {
final StringBuffer buffer = StringBuffer();
for (final Package package in packageConfig.packages) {
buffer.writeln(package.name);
buffer.writeln(package.languageVersion);
buffer.writeln(package.root);
buffer.writeln(package.packageUriRoot);
}
buffer.writeln(packageConfig.version);
return buffer.toString();
}
}
54 changes: 0 additions & 54 deletions packages/flutter_tools/test/general.shard/dart/pub_get_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -988,60 +988,6 @@ exit code: 66
expect(processManager, hasNoRemainingExpectations);
});

testUsingContext(
'package_config_subset file is generated from packages and not timestamp',
() async {
final FileSystem fileSystem = MemoryFileSystem.test();
final Pub pub = Pub.test(
fileSystem: fileSystem,
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
botDetector: const FakeBotDetector(false),
stdio: FakeStdio(),
platform: FakePlatform(
environment: const <String, String>{'PUB_CACHE': 'custom/pub-cache/path'},
),
);
fileSystem.file('version').createSync();
fileSystem.file('pubspec.yaml')
..createSync()
..writeAsStringSync('''
flutter:
generate: true
''');
fileSystem.file('.dart_tool/package_config.json')
..createSync(recursive: true)
..writeAsStringSync('''
{"configVersion": 2,"packages": [
{
"name": "flutter_tools",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.7"
}
],"generated":"some-time"}
''');

await pub.get(
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
context: PubContext.flutterTests,
);

expect(
fileSystem.file('.dart_tool/package_config_subset').readAsStringSync(),
'flutter_tools\n'
'2.7\n'
'file:///\n'
'file:///lib/\n'
'2\n',
);
},
overrides: <Type, Generator>{
// ignore: avoid_redundant_argument_values
FeatureFlags: () => TestFeatureFlags(isExplicitPackageDependenciesEnabled: false),
},
);

testUsingContext(
'cannot use `generate: true` with a workspace without --explicit-package-dependencies',
() async {
Expand Down