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
50f1e182
Unverified
Commit
50f1e182
authored
Mar 27, 2019
by
Jonah Williams
Committed by
GitHub
Mar 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure packages file is updated when using build_runner (#29885)
parent
3b3f6c7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
+24
-17
build_runner.dart
...ages/flutter_tools/lib/src/build_runner/build_runner.dart
+0
-14
codegen.dart
packages/flutter_tools/lib/src/codegen.dart
+24
-3
No files found.
packages/flutter_tools/lib/src/build_runner/build_runner.dart
View file @
50f1e182
...
...
@@ -21,7 +21,6 @@ import '../base/logger.dart';
import
'../base/platform.dart'
;
import
'../base/process_manager.dart'
;
import
'../codegen.dart'
;
import
'../dart/package_map.dart'
;
import
'../dart/pub.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
...
...
@@ -128,7 +127,6 @@ class BuildRunner extends CodeGenerator {
List
<
String
>
extraFrontEndOptions
=
const
<
String
>
[],
})
async
{
await
generateBuildScript
(
flutterProject
);
_generatePackages
(
flutterProject
);
final
String
engineDartBinaryPath
=
artifacts
.
getArtifactPath
(
Artifact
.
engineDartBinary
);
final
File
buildSnapshot
=
flutterProject
.
dartTool
...
...
@@ -160,18 +158,6 @@ class BuildRunner extends CodeGenerator {
}));
return
_BuildRunnerCodegenDaemon
(
buildDaemonClient
);
}
// Create generated packages file which adds a multi-root scheme to the user's
// project directory. Currently we only replace the root package with a multiroot
// scheme. To support codegen on arbitrary packages we would need to do
// this for each dependency.
void
_generatePackages
(
FlutterProject
flutterProject
)
{
final
String
oldPackagesContents
=
fs
.
file
(
PackageMap
.
globalPackagesPath
).
readAsStringSync
();
final
String
appName
=
flutterProject
.
manifest
.
appName
;
final
String
newPackagesContents
=
oldPackagesContents
.
replaceFirst
(
'
$appName
:lib/'
,
'
$appName
:
$kMultiRootScheme
:/'
);
final
String
generatedPackagesPath
=
fs
.
path
.
setExtension
(
PackageMap
.
globalPackagesPath
,
'.generated'
);
fs
.
file
(
generatedPackagesPath
).
writeAsStringSync
(
newPackagesContents
);
}
}
class
_BuildRunnerCodegenDaemon
implements
CodegenDaemon
{
...
...
packages/flutter_tools/lib/src/codegen.dart
View file @
50f1e182
...
...
@@ -41,6 +41,18 @@ abstract class CodeGenerator {
// Generates a synthetic package under .dart_tool/flutter_tool which is in turn
// used to generate a build script.
Future
<
void
>
generateBuildScript
(
FlutterProject
flutterProject
);
/// Create generated packages file which adds a multi-root scheme to the user's
/// project directory. Currently we only replace the root package with a multiroot
/// scheme. To support codegen on arbitrary packages we would need to do
/// this for each dependency.
void
updatePackages
(
FlutterProject
flutterProject
)
{
final
String
oldPackagesContents
=
fs
.
file
(
PackageMap
.
globalPackagesPath
).
readAsStringSync
();
final
String
appName
=
flutterProject
.
manifest
.
appName
;
final
String
newPackagesContents
=
oldPackagesContents
.
replaceFirst
(
'
$appName
:lib/'
,
'
$appName
:
$kMultiRootScheme
:/'
);
final
String
generatedPackagesPath
=
fs
.
path
.
setExtension
(
PackageMap
.
globalPackagesPath
,
'.generated'
);
fs
.
file
(
generatedPackagesPath
).
writeAsStringSync
(
newPackagesContents
);
}
}
class
UnsupportedCodeGenerator
extends
CodeGenerator
{
...
...
@@ -104,6 +116,7 @@ class CodeGeneratingKernelCompiler implements KernelCompiler {
'build* pipeline'
);
}
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
codeGenerator
.
updatePackages
(
flutterProject
);
final
CodegenDaemon
codegenDaemon
=
await
codeGenerator
.
daemon
(
flutterProject
);
codegenDaemon
.
startBuild
();
await
for
(
CodegenStatus
codegenStatus
in
codegenDaemon
.
buildResults
)
{
...
...
@@ -141,7 +154,7 @@ class CodeGeneratingKernelCompiler implements KernelCompiler {
/// An implementation of a [ResidentCompiler] which runs a [BuildRunner] before
/// talking to the CFE.
class
CodeGeneratingResidentCompiler
implements
ResidentCompiler
{
CodeGeneratingResidentCompiler
.
_
(
this
.
_residentCompiler
,
this
.
_codegenDaemon
);
CodeGeneratingResidentCompiler
.
_
(
this
.
_residentCompiler
,
this
.
_codegenDaemon
,
this
.
_flutterProject
);
/// Creates a new [ResidentCompiler] and configures a [BuildDaemonClient] to
/// run builds.
...
...
@@ -158,6 +171,7 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler {
String
initializeFromDill
,
bool
runCold
=
false
,
})
async
{
codeGenerator
.
updatePackages
(
flutterProject
);
final
ResidentCompiler
residentCompiler
=
ResidentCompiler
(
artifacts
.
getArtifactPath
(
Artifact
.
flutterPatchedSdkPath
),
trackWidgetCreation:
trackWidgetCreation
,
...
...
@@ -182,11 +196,12 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler {
if
(
status
==
CodegenStatus
.
Failed
)
{
printError
(
'Code generation failed, build may have compile errors.'
);
}
return
CodeGeneratingResidentCompiler
.
_
(
residentCompiler
,
codegenDaemon
);
return
CodeGeneratingResidentCompiler
.
_
(
residentCompiler
,
codegenDaemon
,
flutterProject
);
}
final
ResidentCompiler
_residentCompiler
;
final
CodegenDaemon
_codegenDaemon
;
final
FlutterProject
_flutterProject
;
@override
void
accept
()
{
...
...
@@ -206,7 +221,13 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler {
});
}
if
(
_codegenDaemon
.
lastStatus
==
CodegenStatus
.
Failed
)
{
printError
(
'Codegeneration failed, halting build.'
);
printError
(
'Code generation failed, build may have compile errors.'
);
}
// Update the generated packages file if the original packages file has changes.
if
(
fs
.
statSync
(
PackageMap
.
globalPackagesPath
).
modified
.
millisecondsSinceEpoch
>
fs
.
statSync
(
PackageMap
.
globalGeneratedPackagesPath
).
modified
.
millisecondsSinceEpoch
)
{
codeGenerator
.
updatePackages
(
_flutterProject
);
invalidatedFiles
.
add
(
fs
.
file
(
PackageMap
.
globalGeneratedPackagesPath
).
uri
);
}
return
_residentCompiler
.
recompile
(
mainPath
,
...
...
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