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
8f834cf1
Unverified
Commit
8f834cf1
authored
Jul 15, 2022
by
Lau Ching Jun
Committed by
GitHub
Jul 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read dart_plugin_registrant path from FlutterProject to support non-standard path. (#107617)
parent
cdf4a6a2
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
376 additions
and
212 deletions
+376
-212
compile.dart
packages/flutter_tools/lib/src/compile.dart
+20
-22
devfs.dart
packages/flutter_tools/lib/src/devfs.dart
+2
-0
devfs_web.dart
packages/flutter_tools/lib/src/isolated/devfs_web.dart
+2
-0
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+1
-0
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+1
-0
compile_incremental_test.dart
...er_tools/test/general.shard/compile_incremental_test.dart
+38
-0
devfs_test.dart
packages/flutter_tools/test/general.shard/devfs_test.dart
+1
-1
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+2
-0
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+307
-189
test_compiler_test.dart
...ter_tools/test/general.shard/test/test_compiler_test.dart
+1
-0
devfs_web_test.dart
.../flutter_tools/test/general.shard/web/devfs_web_test.dart
+1
-0
No files found.
packages/flutter_tools/lib/src/compile.dart
View file @
8f834cf1
...
@@ -328,7 +328,7 @@ class KernelCompiler {
...
@@ -328,7 +328,7 @@ class KernelCompiler {
dartPluginRegistrant
.
path
,
dartPluginRegistrant
.
path
,
'--source'
,
'--source'
,
'package:flutter/src/dart_plugin_registrant.dart'
,
'package:flutter/src/dart_plugin_registrant.dart'
,
'-Dflutter.dart_plugin_registrant=
${
dartPluginRegistrant.uri
}
'
,
'-Dflutter.dart_plugin_registrant=
${
toMultiRootPath(dartPluginRegistrant.uri, _fileSystemScheme, _fileSystemRoots, _fileSystem.path.separator == r'\')
}
'
,
],
],
// See: https://github.com/flutter/flutter/issues/103994
// See: https://github.com/flutter/flutter/issues/103994
'--verbosity=error'
,
'--verbosity=error'
,
...
@@ -375,7 +375,7 @@ class _RecompileRequest extends _CompilationRequest {
...
@@ -375,7 +375,7 @@ class _RecompileRequest extends _CompilationRequest {
this
.
outputPath
,
this
.
outputPath
,
this
.
packageConfig
,
this
.
packageConfig
,
this
.
suppressErrors
,
this
.
suppressErrors
,
{
this
.
additionalSource
}
{
this
.
additionalSource
Uri
}
);
);
Uri
mainUri
;
Uri
mainUri
;
...
@@ -383,7 +383,7 @@ class _RecompileRequest extends _CompilationRequest {
...
@@ -383,7 +383,7 @@ class _RecompileRequest extends _CompilationRequest {
String
outputPath
;
String
outputPath
;
PackageConfig
packageConfig
;
PackageConfig
packageConfig
;
bool
suppressErrors
;
bool
suppressErrors
;
final
String
?
additionalSource
;
final
Uri
?
additionalSourceUri
;
@override
@override
Future
<
CompilerOutput
?>
_run
(
DefaultResidentCompiler
compiler
)
async
=>
Future
<
CompilerOutput
?>
_run
(
DefaultResidentCompiler
compiler
)
async
=>
...
@@ -499,6 +499,7 @@ abstract class ResidentCompiler {
...
@@ -499,6 +499,7 @@ abstract class ResidentCompiler {
String
?
projectRootPath
,
String
?
projectRootPath
,
bool
suppressErrors
=
false
,
bool
suppressErrors
=
false
,
bool
checkDartPluginRegistry
=
false
,
bool
checkDartPluginRegistry
=
false
,
File
?
dartPluginRegistrant
,
});
});
Future
<
CompilerOutput
?>
compileExpression
(
Future
<
CompilerOutput
?>
compileExpression
(
...
@@ -642,6 +643,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
...
@@ -642,6 +643,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
required
PackageConfig
packageConfig
,
required
PackageConfig
packageConfig
,
bool
suppressErrors
=
false
,
bool
suppressErrors
=
false
,
bool
checkDartPluginRegistry
=
false
,
bool
checkDartPluginRegistry
=
false
,
File
?
dartPluginRegistrant
,
String
?
projectRootPath
,
String
?
projectRootPath
,
FileSystem
?
fs
,
FileSystem
?
fs
,
})
async
{
})
async
{
...
@@ -649,20 +651,10 @@ class DefaultResidentCompiler implements ResidentCompiler {
...
@@ -649,20 +651,10 @@ class DefaultResidentCompiler implements ResidentCompiler {
if
(!
_controller
.
hasListener
)
{
if
(!
_controller
.
hasListener
)
{
_controller
.
stream
.
listen
(
_handleCompilationRequest
);
_controller
.
stream
.
listen
(
_handleCompilationRequest
);
}
}
String
?
additionalSource
;
Uri
?
additionalSourceUri
;
// `dart_plugin_registrant.dart` contains the Dart plugin registry.
// `dart_plugin_registrant.dart` contains the Dart plugin registry.
if
(
checkDartPluginRegistry
&&
projectRootPath
!=
null
&&
fs
!=
null
)
{
if
(
checkDartPluginRegistry
&&
dartPluginRegistrant
!=
null
&&
dartPluginRegistrant
.
existsSync
())
{
final
File
dartPluginRegistrantDart
=
fs
.
file
(
additionalSourceUri
=
dartPluginRegistrant
.
uri
;
fs
.
path
.
join
(
projectRootPath
,
'.dart_tool'
,
'flutter_build'
,
'dart_plugin_registrant.dart'
,
),
);
if
(
dartPluginRegistrantDart
!=
null
&&
dartPluginRegistrantDart
.
existsSync
())
{
additionalSource
=
dartPluginRegistrantDart
.
path
;
}
}
}
final
Completer
<
CompilerOutput
?>
completer
=
Completer
<
CompilerOutput
?>();
final
Completer
<
CompilerOutput
?>
completer
=
Completer
<
CompilerOutput
?>();
_controller
.
add
(
_RecompileRequest
(
_controller
.
add
(
_RecompileRequest
(
...
@@ -672,7 +664,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
...
@@ -672,7 +664,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
outputPath
,
outputPath
,
packageConfig
,
packageConfig
,
suppressErrors
,
suppressErrors
,
additionalSource
:
additionalSource
,
additionalSource
Uri:
additionalSourceUri
,
));
));
return
completer
.
future
;
return
completer
.
future
;
}
}
...
@@ -685,9 +677,15 @@ class DefaultResidentCompiler implements ResidentCompiler {
...
@@ -685,9 +677,15 @@ class DefaultResidentCompiler implements ResidentCompiler {
final
String
mainUri
=
request
.
packageConfig
.
toPackageUri
(
request
.
mainUri
)?.
toString
()
??
final
String
mainUri
=
request
.
packageConfig
.
toPackageUri
(
request
.
mainUri
)?.
toString
()
??
toMultiRootPath
(
request
.
mainUri
,
fileSystemScheme
,
fileSystemRoots
,
_platform
.
isWindows
);
toMultiRootPath
(
request
.
mainUri
,
fileSystemScheme
,
fileSystemRoots
,
_platform
.
isWindows
);
String
?
additionalSourceUri
;
if
(
request
.
additionalSourceUri
!=
null
)
{
additionalSourceUri
=
request
.
packageConfig
.
toPackageUri
(
request
.
additionalSourceUri
!)?.
toString
()
??
toMultiRootPath
(
request
.
additionalSourceUri
!,
fileSystemScheme
,
fileSystemRoots
,
_platform
.
isWindows
);
}
final
Process
?
server
=
_server
;
final
Process
?
server
=
_server
;
if
(
server
==
null
)
{
if
(
server
==
null
)
{
return
_compile
(
mainUri
,
request
.
outputPath
,
additionalSource
:
request
.
additionalSource
);
return
_compile
(
mainUri
,
request
.
outputPath
,
additionalSource
Uri:
additionalSourceUri
);
}
}
final
String
inputKey
=
Uuid
().
generateV4
();
final
String
inputKey
=
Uuid
().
generateV4
();
...
@@ -733,7 +731,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
...
@@ -733,7 +731,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
Future
<
CompilerOutput
?>
_compile
(
Future
<
CompilerOutput
?>
_compile
(
String
scriptUri
,
String
scriptUri
,
String
?
outputPath
,
String
?
outputPath
,
{
String
?
additionalSource
}
{
String
?
additionalSource
Uri
}
)
async
{
)
async
{
final
String
frontendServer
=
_artifacts
.
getArtifactPath
(
final
String
frontendServer
=
_artifacts
.
getArtifactPath
(
Artifact
.
frontendServerSnapshotForEngineDartSdk
Artifact
.
frontendServerSnapshotForEngineDartSdk
...
@@ -786,12 +784,12 @@ class DefaultResidentCompiler implements ResidentCompiler {
...
@@ -786,12 +784,12 @@ class DefaultResidentCompiler implements ResidentCompiler {
initializeFromDill
!,
initializeFromDill
!,
],
],
if
(
assumeInitializeFromDillUpToDate
)
'--assume-initialize-from-dill-up-to-date'
,
if
(
assumeInitializeFromDillUpToDate
)
'--assume-initialize-from-dill-up-to-date'
,
if
(
additionalSource
!=
null
)
...<
String
>[
if
(
additionalSource
Uri
!=
null
)
...<
String
>[
'--source'
,
'--source'
,
additionalSource
,
additionalSource
Uri
,
'--source'
,
'--source'
,
'package:flutter/src/dart_plugin_registrant.dart'
,
'package:flutter/src/dart_plugin_registrant.dart'
,
'-Dflutter.dart_plugin_registrant=
$
{Uri.file(additionalSource)}
'
,
'-Dflutter.dart_plugin_registrant=
$
additionalSourceUri
'
,
],
],
if
(
platformDill
!=
null
)
...<
String
>[
if
(
platformDill
!=
null
)
...<
String
>[
'--platform'
,
'--platform'
,
...
...
packages/flutter_tools/lib/src/devfs.dart
View file @
8f834cf1
...
@@ -581,6 +581,7 @@ class DevFS {
...
@@ -581,6 +581,7 @@ class DevFS {
bool
bundleFirstUpload
=
false
,
bool
bundleFirstUpload
=
false
,
bool
fullRestart
=
false
,
bool
fullRestart
=
false
,
String
?
projectRootPath
,
String
?
projectRootPath
,
File
?
dartPluginRegistrant
,
})
async
{
})
async
{
assert
(
trackWidgetCreation
!=
null
);
assert
(
trackWidgetCreation
!=
null
);
assert
(
generator
!=
null
);
assert
(
generator
!=
null
);
...
@@ -610,6 +611,7 @@ class DevFS {
...
@@ -610,6 +611,7 @@ class DevFS {
projectRootPath:
projectRootPath
,
projectRootPath:
projectRootPath
,
packageConfig:
packageConfig
,
packageConfig:
packageConfig
,
checkDartPluginRegistry:
true
,
// The entry point is assumed not to have changed.
checkDartPluginRegistry:
true
,
// The entry point is assumed not to have changed.
dartPluginRegistrant:
dartPluginRegistrant
,
).
then
((
CompilerOutput
?
result
)
{
).
then
((
CompilerOutput
?
result
)
{
compileTimer
.
stop
();
compileTimer
.
stop
();
return
result
;
return
result
;
...
...
packages/flutter_tools/lib/src/isolated/devfs_web.dart
View file @
8f834cf1
...
@@ -799,6 +799,7 @@ class WebDevFS implements DevFS {
...
@@ -799,6 +799,7 @@ class WebDevFS implements DevFS {
bool
bundleFirstUpload
=
false
,
bool
bundleFirstUpload
=
false
,
bool
fullRestart
=
false
,
bool
fullRestart
=
false
,
String
?
projectRootPath
,
String
?
projectRootPath
,
File
?
dartPluginRegistrant
,
})
async
{
})
async
{
assert
(
trackWidgetCreation
!=
null
);
assert
(
trackWidgetCreation
!=
null
);
assert
(
generator
!=
null
);
assert
(
generator
!=
null
);
...
@@ -866,6 +867,7 @@ class WebDevFS implements DevFS {
...
@@ -866,6 +867,7 @@ class WebDevFS implements DevFS {
packageConfig:
packageConfig
,
packageConfig:
packageConfig
,
projectRootPath:
projectRootPath
,
projectRootPath:
projectRootPath
,
fs:
globals
.
fs
,
fs:
globals
.
fs
,
dartPluginRegistrant:
dartPluginRegistrant
,
);
);
if
(
compilerOutput
==
null
||
compilerOutput
.
errorCount
>
0
)
{
if
(
compilerOutput
==
null
||
compilerOutput
.
errorCount
>
0
)
{
return
UpdateFSReport
();
return
UpdateFSReport
();
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
8f834cf1
...
@@ -563,6 +563,7 @@ class FlutterDevice {
...
@@ -563,6 +563,7 @@ class FlutterDevice {
invalidatedFiles:
invalidatedFiles
,
invalidatedFiles:
invalidatedFiles
,
packageConfig:
packageConfig
,
packageConfig:
packageConfig
,
devFSWriter:
devFSWriter
,
devFSWriter:
devFSWriter
,
dartPluginRegistrant:
FlutterProject
.
current
().
dartPluginRegistrant
,
);
);
}
on
DevFSException
{
}
on
DevFSException
{
devFSStatus
.
cancel
();
devFSStatus
.
cancel
();
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
8f834cf1
...
@@ -373,6 +373,7 @@ class HotRunner extends ResidentRunner {
...
@@ -373,6 +373,7 @@ class HotRunner extends ResidentRunner {
// should only be displayed once.
// should only be displayed once.
suppressErrors:
applicationBinary
==
null
,
suppressErrors:
applicationBinary
==
null
,
checkDartPluginRegistry:
true
,
checkDartPluginRegistry:
true
,
dartPluginRegistrant:
FlutterProject
.
current
().
dartPluginRegistrant
,
outputPath:
dillOutputPath
,
outputPath:
dillOutputPath
,
packageConfig:
debuggingOptions
.
buildInfo
.
packageConfig
,
packageConfig:
debuggingOptions
.
buildInfo
.
packageConfig
,
projectRootPath:
FlutterProject
.
current
().
directory
.
absolute
.
path
,
projectRootPath:
FlutterProject
.
current
().
directory
.
absolute
.
path
,
...
...
packages/flutter_tools/test/general.shard/compile_incremental_test.dart
View file @
8f834cf1
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'dart:async'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/async_guard.dart'
;
import
'package:flutter_tools/src/base/async_guard.dart'
;
...
@@ -394,6 +395,43 @@ void main() {
...
@@ -394,6 +395,43 @@ void main() {
'line2
\n
line3
\n
'
'line2
\n
line3
\n
'
));
));
});
});
testWithoutContext
(
'incremental compile with dartPluginRegistrant'
,
()
async
{
fakeProcessManager
.
addCommand
(
FakeCommand
(
command:
const
<
String
>[
...
frontendServerCommand
,
'--filesystem-root'
,
'/foo/bar/fizz'
,
'--filesystem-scheme'
,
'scheme'
,
'--source'
,
'some/dir/plugin_registrant.dart'
,
'--source'
,
'package:flutter/src/dart_plugin_registrant.dart'
,
'-Dflutter.dart_plugin_registrant=some/dir/plugin_registrant.dart'
,
'--verbosity=error'
,
],
stdout:
'result abc
\n
line1
\n
line2
\n
abc
\n
abc /path/to/main.dart.dill 0'
,
stdin:
frontendServerStdIn
,
));
final
MemoryFileSystem
fs
=
MemoryFileSystem
();
final
File
dartPluginRegistrant
=
fs
.
file
(
'some/dir/plugin_registrant.dart'
)..
createSync
(
recursive:
true
);
final
CompilerOutput
?
output
=
await
generatorWithScheme
.
recompile
(
Uri
.
parse
(
'file:///foo/bar/fizz/main.dart'
),
null
/* invalidatedFiles */
,
outputPath:
'/build/'
,
packageConfig:
PackageConfig
.
empty
,
fs:
fs
,
projectRootPath:
''
,
checkDartPluginRegistry:
true
,
dartPluginRegistrant:
dartPluginRegistrant
,
);
expect
(
frontendServerStdIn
.
getAndClear
(),
'compile scheme:///main.dart
\n
'
);
expect
(
testLogger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
output
?.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
});
}
}
Future
<
void
>
_recompile
(
Future
<
void
>
_recompile
(
...
...
packages/flutter_tools/test/general.shard/devfs_test.dart
View file @
8f834cf1
...
@@ -581,7 +581,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
...
@@ -581,7 +581,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
Future
<
CompilerOutput
>
Function
(
Uri
mainUri
,
List
<
Uri
>?
invalidatedFiles
)?
onRecompile
;
Future
<
CompilerOutput
>
Function
(
Uri
mainUri
,
List
<
Uri
>?
invalidatedFiles
)?
onRecompile
;
@override
@override
Future
<
CompilerOutput
>
recompile
(
Uri
mainUri
,
List
<
Uri
>?
invalidatedFiles
,
{
String
?
outputPath
,
PackageConfig
?
packageConfig
,
String
?
projectRootPath
,
FileSystem
?
fs
,
bool
suppressErrors
=
false
,
bool
checkDartPluginRegistry
=
false
})
{
Future
<
CompilerOutput
>
recompile
(
Uri
mainUri
,
List
<
Uri
>?
invalidatedFiles
,
{
String
?
outputPath
,
PackageConfig
?
packageConfig
,
String
?
projectRootPath
,
FileSystem
?
fs
,
bool
suppressErrors
=
false
,
bool
checkDartPluginRegistry
=
false
,
File
?
dartPluginRegistrant
})
{
return
onRecompile
?.
call
(
mainUri
,
invalidatedFiles
)
return
onRecompile
?.
call
(
mainUri
,
invalidatedFiles
)
??
Future
<
CompilerOutput
>.
value
(
const
CompilerOutput
(
''
,
1
,
<
Uri
>[]));
??
Future
<
CompilerOutput
>.
value
(
const
CompilerOutput
(
''
,
1
,
<
Uri
>[]));
}
}
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
8f834cf1
...
@@ -2464,6 +2464,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
...
@@ -2464,6 +2464,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
@required
FileSystem
fs
,
@required
FileSystem
fs
,
bool
suppressErrors
=
false
,
bool
suppressErrors
=
false
,
bool
checkDartPluginRegistry
=
false
,
bool
checkDartPluginRegistry
=
false
,
File
dartPluginRegistrant
,
})
async
{
})
async
{
didSuppressErrors
=
suppressErrors
;
didSuppressErrors
=
suppressErrors
;
return
nextOutput
??
const
CompilerOutput
(
'foo.dill'
,
0
,
<
Uri
>[]);
return
nextOutput
??
const
CompilerOutput
(
'foo.dill'
,
0
,
<
Uri
>[]);
...
@@ -2623,6 +2624,7 @@ class FakeDevFS extends Fake implements DevFS {
...
@@ -2623,6 +2624,7 @@ class FakeDevFS extends Fake implements DevFS {
bool
bundleFirstUpload
=
false
,
bool
bundleFirstUpload
=
false
,
bool
fullRestart
=
false
,
bool
fullRestart
=
false
,
String
projectRootPath
,
String
projectRootPath
,
File
dartPluginRegistrant
,
})
async
{
})
async
{
return
nextUpdateReport
;
return
nextUpdateReport
;
}
}
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
8f834cf1
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/test/test_compiler_test.dart
View file @
8f834cf1
...
@@ -200,6 +200,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
...
@@ -200,6 +200,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
FileSystem
?
fs
,
FileSystem
?
fs
,
bool
suppressErrors
=
false
,
bool
suppressErrors
=
false
,
bool
checkDartPluginRegistry
=
false
,
bool
checkDartPluginRegistry
=
false
,
File
?
dartPluginRegistrant
,
})
async
{
})
async
{
if
(
compilerOutput
!=
null
)
{
if
(
compilerOutput
!=
null
)
{
fileSystem
!.
file
(
compilerOutput
!.
outputFilename
).
createSync
(
recursive:
true
);
fileSystem
!.
file
(
compilerOutput
!.
outputFilename
).
createSync
(
recursive:
true
);
...
...
packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
View file @
8f834cf1
...
@@ -1120,6 +1120,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
...
@@ -1120,6 +1120,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
FileSystem
fs
,
FileSystem
fs
,
bool
suppressErrors
=
false
,
bool
suppressErrors
=
false
,
bool
checkDartPluginRegistry
=
false
,
bool
checkDartPluginRegistry
=
false
,
File
dartPluginRegistrant
,
})
async
{
})
async
{
return
output
;
return
output
;
}
}
...
...
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