Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use workspaces #3717

Merged
merged 16 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pubspec.lock
/*/build/

# Include .packages files from tests which are hand coded
!build_runner_core/test/fixtures/**/.packages
!build_runner_core/test/fixtures/**/.dart_tool/
!build_runner_core/test/fixtures/**/pubspec.lock

# Extra files from dart2js that we don't want
Expand Down
2 changes: 1 addition & 1 deletion _test/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis/analysis_options.yaml
include: ../analysis_options.yaml
2 changes: 1 addition & 1 deletion _test/pkgs/provides_builder/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: provides_builder

resolution: workspace
environment:
sdk: ^3.5.0-259.0.dev

Expand Down
24 changes: 1 addition & 23 deletions _test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: _test
publish_to: none
resolution: workspace

environment:
sdk: ^3.5.0-259.0.dev
Expand All @@ -14,32 +15,9 @@ dev_dependencies:
build_runner_core: any
build_test: any
build_web_compilers: any
dart_flutter_team_lints: ^3.1.0
io: ^1.0.0
path: ^1.8.0
provides_builder:
path: pkgs/provides_builder/
test: ^1.16.0
test_process: ^2.0.0

dependency_overrides:
build:
path: ../build
build_config:
path: ../build_config
build_daemon:
path: ../build_daemon
build_modules:
path: ../build_modules
build_resolvers:
path: ../build_resolvers
build_runner:
path: ../build_runner
build_runner_core:
path: ../build_runner_core
build_test:
path: ../build_test
build_web_compilers:
path: ../build_web_compilers
scratch_space:
path: ../scratch_space
6 changes: 4 additions & 2 deletions _test/test/common/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:isolate';

import 'package:path/path.dart' as p;
import 'package:test/test.dart';
Expand All @@ -30,11 +31,12 @@ Future<ProcessResult> runCommand(List<String> args) =>
/// build to complete.
///
/// To ensure a clean build, set [ensureCleanBuild] to `true`.
Future<void> startServer({bool? ensureCleanBuild, List<String>? buildArgs}) =>
Future<void> startServer(
{bool? ensureCleanBuild, List<String>? buildArgs}) async =>
_startServer(
'dart',
[
'--packages=.dart_tool/package_config.json',
'--packages=${(await Isolate.packageConfig).toString()}',
p.join('..', 'build_runner', 'bin', 'build_runner.dart'),
'serve',
'--verbose',
Expand Down
2 changes: 1 addition & 1 deletion _test_common/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis/analysis_options.yaml
include: ../analysis_options.yaml
4 changes: 2 additions & 2 deletions _test_common/lib/package_graphs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ PackageNode package(String packageName,
DependencyType? type,
LanguageVersion? languageVersion}) =>
PackageNode(packageName, path ?? '/$packageName',
type ?? DependencyType.path, languageVersion ?? LanguageVersion(0, 0));
type ?? DependencyType.path, languageVersion);

PackageNode rootPackage(String packageName,
{String? path, LanguageVersion? languageVersion}) =>
PackageNode(packageName, path ?? '/$packageName', DependencyType.path,
languageVersion ?? LanguageVersion(0, 0),
languageVersion,
isRoot: true);
16 changes: 1 addition & 15 deletions _test_common/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: _test_common
publish_to: none
description: Test infra for writing build tests. Is not published.
resolution: workspace

environment:
sdk: ^3.5.0-259.0.dev
Expand All @@ -18,18 +19,3 @@ dependencies:
test: ^1.16.0
test_descriptor: ^2.0.0
watcher: ^1.0.0

dev_dependencies:
dart_flutter_team_lints: ^3.1.0

dependency_overrides:
build:
path: ../build
build_config:
path: ../build_config
build_resolvers:
path: ../build_resolvers
build_runner_core:
path: ../build_runner_core
build_test:
path: ../build_test
8 changes: 0 additions & 8 deletions analysis/pubspec.yaml

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion build/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis/analysis_options.yaml
include: ../analysis_options.yaml
2 changes: 1 addition & 1 deletion build/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: build
version: 2.4.2-wip
description: A package for authoring build_runner compatible code generators.
repository: https://github.com/dart-lang/build/tree/master/build
resolution: workspace

environment:
sdk: ^3.5.0-259.0.dev
Expand All @@ -20,7 +21,6 @@ dependencies:
dev_dependencies:
build_resolvers: ^2.4.0
build_test: ^2.0.0
dart_flutter_team_lints: ^3.1.0
test: ^1.16.0

topics:
Expand Down
7 changes: 0 additions & 7 deletions build/pubspec_overrides.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion build_config/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis/analysis_options.yaml
include: ../analysis_options.yaml
2 changes: 1 addition & 1 deletion build_config/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: 1.1.2-wip
description: >-
Format definition and support for parsing `build.yaml` configuration.
repository: https://github.com/dart-lang/build/tree/master/build_config
resolution: workspace

environment:
sdk: ^3.5.0-259.0.dev
Expand All @@ -16,7 +17,6 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.0
dart_flutter_team_lints: ^3.1.0
json_serializable: ^6.0.0
term_glyph: ^1.2.0
test: ^1.16.0
Expand Down
15 changes: 0 additions & 15 deletions build_config/pubspec_overrides.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion build_daemon/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis/analysis_options.yaml
include: ../analysis_options.yaml
6 changes: 1 addition & 5 deletions build_daemon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: build_daemon
version: 4.0.3-wip
description: A daemon for running Dart builds.
repository: https://github.com/dart-lang/build/tree/master/build_daemon
resolution: workspace

environment:
sdk: ^3.5.0-259.0.dev
Expand All @@ -25,15 +26,10 @@ dev_dependencies:
build_runner: ^2.0.0
# TODO: untangle analyzer dependency
built_value_generator: ^8.1.0
dart_flutter_team_lints: ^3.1.0
mockito: ^5.0.0
test: ^1.25.5
test_descriptor: ^2.0.0
uuid: ^3.0.0

dependency_overrides:
build_runner:
path: ../build_runner

topics:
- build-runner
17 changes: 0 additions & 17 deletions build_daemon/pubspec_overrides.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion build_modules/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis/analysis_options.yaml
include: ../analysis_options.yaml
8 changes: 6 additions & 2 deletions build_modules/lib/src/scratch_space.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:isolate';
import 'dart:math' as math;

import 'package:build/build.dart';
Expand All @@ -22,15 +23,15 @@ final scratchSpace = ScratchSpace();

/// A shared [Resource] for a [ScratchSpace], which cleans up the contents of
/// the [ScratchSpace] in dispose, but doesn't delete it entirely.
final scratchSpaceResource = Resource<ScratchSpace>(() {
final scratchSpaceResource = Resource<ScratchSpace>(() async {
if (!scratchSpace.exists) {
scratchSpace.tempDir.createSync(recursive: true);
scratchSpace.exists = true;
}
var packageConfigFile = File(
p.join(scratchSpace.tempDir.path, '.dart_tool', 'package_config.json'));
if (!packageConfigFile.existsSync()) {
var originalConfigFile = File(p.join('.dart_tool', 'package_config.json'));
var originalConfigFile = File.fromUri((await Isolate.packageConfig)!);
var packageConfigContents = _scratchSpacePackageConfig(
originalConfigFile.readAsStringSync(), originalConfigFile.absolute.uri);
packageConfigFile
Expand Down Expand Up @@ -94,6 +95,9 @@ String _scratchSpacePackageConfig(String rootConfig, Uri packageConfigUri) {
var foundRoot = false;
for (var package in packages) {
var rootUri = packageConfigUri.resolve(package['rootUri'] as String);
if (!rootUri.path.endsWith('/') && _currentDirUri.path.endsWith('/')) {
rootUri = rootUri.replace(path: '${rootUri.path}/');
}
// We expect to see exactly one package where the root uri is equal to
// the current directory, and that is the current packge.
if (rootUri == _currentDirUri) {
Expand Down
4 changes: 2 additions & 2 deletions build_modules/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ description: >-
Builders to analyze and split Dart code into individually compilable modules
based on imports.
repository: https://github.com/dart-lang/build/tree/master/build_modules
resolution: workspace

environment:
sdk: '>=3.0.0 <3.6.0'
sdk: '>=3.5.0-259.0.dev <3.6.0'

dependencies:
analyzer: '>=5.1.0 <7.0.0'
Expand All @@ -32,7 +33,6 @@ dev_dependencies:
# Used inside tests
build_runner: ^2.0.0
build_test: ^2.0.0
dart_flutter_team_lints: ^3.1.0
json_serializable: ^6.0.0
test: ^1.16.0

Expand Down
17 changes: 0 additions & 17 deletions build_modules/pubspec_overrides.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion build_modules/test/fixtures/a/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: a

resolution: workspace
environment:
sdk: ^3.5.0-259.0.dev

Expand Down
2 changes: 1 addition & 1 deletion build_modules/test/fixtures/b/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: b

resolution: workspace
environment:
sdk: ^3.5.0-259.0.dev

Expand Down
2 changes: 1 addition & 1 deletion build_resolvers/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis/analysis_options.yaml
include: ../analysis_options.yaml
2 changes: 1 addition & 1 deletion build_resolvers/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: build_resolvers
version: 2.4.3-wip
description: Resolve Dart code in a Builder
repository: https://github.com/dart-lang/build/tree/master/build_resolvers
resolution: workspace

environment:
sdk: ^3.5.0-259.0.dev
Expand All @@ -24,7 +25,6 @@ dependencies:

dev_dependencies:
build_test: ^2.0.0
dart_flutter_team_lints: ^3.1.0
test: ^1.16.0

topics:
Expand Down
7 changes: 0 additions & 7 deletions build_resolvers/pubspec_overrides.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion build_runner/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis/analysis_options.yaml
include: ../analysis_options.yaml
10 changes: 8 additions & 2 deletions build_runner/lib/src/generate/watch_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,14 @@ class WatchImpl implements BuildState {
() async {
await logTimedAsync(_logger, 'Waiting for all file watchers to be ready',
() => graphWatcher.ready);
originalRootPackageConfigDigest = md5.convert(
await watcherEnvironment.reader.readAsBytes(rootPackageConfigId));
if (await watcherEnvironment.reader.canRead(rootPackageConfigId)) {
originalRootPackageConfigDigest = md5.convert(
await watcherEnvironment.reader.readAsBytes(rootPackageConfigId));
} else {
_logger.warning(
'Root package config not readable, manual restarts will be needed '
'after running `pub upgrade`.');
}

BuildResult firstBuild;
BuildImpl? build;
Expand Down
2 changes: 1 addition & 1 deletion build_runner/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: build_runner
version: 2.4.12-wip
description: A build system for Dart code generation and modular compilation.
repository: https://github.com/dart-lang/build/tree/master/build_runner
resolution: workspace

environment:
sdk: ^3.5.0-259.0.dev
Expand Down Expand Up @@ -52,7 +53,6 @@ dev_dependencies:
path: ../_test_common
build_test: ^2.0.0
build_web_compilers: ^4.0.0
dart_flutter_team_lints: ^3.1.0
stream_channel: ^2.0.0
test: ^1.25.5
test_descriptor: ^2.0.0
Expand Down
Loading
Loading