Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9e952497
Unverified
Commit
9e952497
authored
May 13, 2020
by
Jonah Williams
Committed by
GitHub
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] introduce a BuildSystem interface (#56946)
parent
073126fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
14 deletions
+49
-14
build_system.dart
...ages/flutter_tools/lib/src/build_system/build_system.dart
+27
-8
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+1
-1
build_system_test.dart
...ls/test/general.shard/build_system/build_system_test.dart
+21
-5
No files found.
packages/flutter_tools/lib/src/build_system/build_system.dart
View file @
9e952497
...
...
@@ -486,8 +486,30 @@ class BuildResult {
}
/// The build system is responsible for invoking and ordering [Target]s.
class
BuildSystem
{
const
BuildSystem
({
abstract
class
BuildSystem
{
/// Const constructor to allow subclasses to be const.
const
BuildSystem
();
/// Build [target] and all of its dependencies.
Future
<
BuildResult
>
build
(
Target
target
,
Environment
environment
,
{
BuildSystemConfig
buildSystemConfig
=
const
BuildSystemConfig
(),
});
/// Perform an incremental build of [target] and all of its dependencies.
///
/// If [previousBuild] is not provided, a new incremental build is
/// initialized.
Future
<
BuildResult
>
buildIncremental
(
Target
target
,
Environment
environment
,
BuildResult
previousBuild
,
);
}
class
FlutterBuildSystem
extends
BuildSystem
{
const
FlutterBuildSystem
({
@required
FileSystem
fileSystem
,
@required
Platform
platform
,
@required
Logger
logger
,
...
...
@@ -499,7 +521,7 @@ class BuildSystem {
final
Platform
_platform
;
final
Logger
_logger
;
/// Build `target` and all of its dependencies.
@override
Future
<
BuildResult
>
build
(
Target
target
,
Environment
environment
,
{
...
...
@@ -572,10 +594,7 @@ class BuildSystem {
static
final
Expando
<
FileStore
>
_incrementalFileStore
=
Expando
<
FileStore
>();
/// Perform an incremental build of `target` and all of its dependencies.
///
/// If [previousBuild] is not provided, a new incremental build is
/// initialized.
@override
Future
<
BuildResult
>
buildIncremental
(
Target
target
,
Environment
environment
,
...
...
@@ -631,7 +650,7 @@ class BuildSystem {
/// cleanup is only necessary when multiple different build configurations
/// output to the same directory.
@visibleForTesting
static
void
trackSharedBuildDirectory
(
void
trackSharedBuildDirectory
(
Environment
environment
,
FileSystem
fileSystem
,
Map
<
String
,
File
>
currentOutputs
,
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
9e952497
...
...
@@ -88,7 +88,7 @@ Future<T> runInContext<T>(
platform:
globals
.
platform
,
),
AssetBundleFactory:
()
=>
AssetBundleFactory
.
defaultInstance
,
BuildSystem:
()
=>
BuildSystem
(
BuildSystem:
()
=>
Flutter
BuildSystem
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
platform:
globals
.
platform
,
...
...
packages/flutter_tools/test/general.shard/build_system/build_system_test.dart
View file @
9e952497
...
...
@@ -464,7 +464,11 @@ void main() {
});
testWithoutContext
(
'trackSharedBuildDirectory handles a missing .last_build_id'
,
()
{
BuildSystem
.
trackSharedBuildDirectory
(
environment
,
fileSystem
,
<
String
,
File
>{});
FlutterBuildSystem
(
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(),
).
trackSharedBuildDirectory
(
environment
,
fileSystem
,
<
String
,
File
>{});
expect
(
environment
.
outputDir
.
childFile
(
'.last_build_id'
),
exists
);
expect
(
environment
.
outputDir
.
childFile
(
'.last_build_id'
).
readAsStringSync
(),
...
...
@@ -475,7 +479,11 @@ void main() {
environment
.
outputDir
.
childFile
(
'.last_build_id'
)
..
writeAsStringSync
(
'6666cd76f96956469e7be39d750cc7d9'
)
..
setLastModifiedSync
(
DateTime
(
1991
,
8
,
23
));
BuildSystem
.
trackSharedBuildDirectory
(
environment
,
fileSystem
,
<
String
,
File
>{});
FlutterBuildSystem
(
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(),
).
trackSharedBuildDirectory
(
environment
,
fileSystem
,
<
String
,
File
>{});
expect
(
environment
.
outputDir
.
childFile
(
'.last_build_id'
).
lastModifiedSync
(),
DateTime
(
1991
,
8
,
23
));
...
...
@@ -491,7 +499,11 @@ void main() {
environment
.
outputDir
.
childFile
(
'stale'
)
.
createSync
();
BuildSystem
.
trackSharedBuildDirectory
(
environment
,
fileSystem
,
<
String
,
File
>{});
FlutterBuildSystem
(
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(),
).
trackSharedBuildDirectory
(
environment
,
fileSystem
,
<
String
,
File
>{});
expect
(
environment
.
outputDir
.
childFile
(
'.last_build_id'
).
readAsStringSync
(),
'6666cd76f96956469e7be39d750cc7d9'
);
...
...
@@ -510,7 +522,11 @@ void main() {
..
createSync
();
otherBuildDir
.
childFile
(
'outputs.json'
)
.
writeAsStringSync
(
json
.
encode
(<
String
>[
staleFile
.
absolute
.
path
]));
BuildSystem
.
trackSharedBuildDirectory
(
environment
,
fileSystem
,
<
String
,
File
>{});
FlutterBuildSystem
(
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(),
).
trackSharedBuildDirectory
(
environment
,
fileSystem
,
<
String
,
File
>{});
expect
(
environment
.
outputDir
.
childFile
(
'.last_build_id'
).
readAsStringSync
(),
'6666cd76f96956469e7be39d750cc7d9'
);
...
...
@@ -568,7 +584,7 @@ void main() {
}
BuildSystem
setUpBuildSystem
(
FileSystem
fileSystem
)
{
return
BuildSystem
(
return
Flutter
BuildSystem
(
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(
operatingSystem:
'linux'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment