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
d3fd8ddd
Commit
d3fd8ddd
authored
Aug 17, 2016
by
Konstantin Scheglov
Committed by
GitHub
Aug 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build sky_engine Dart SDK summary bundle on FlutterEngine.download(). (#5460)
parent
0892f6a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
4 deletions
+103
-4
cache.dart
packages/flutter_tools/lib/src/cache.dart
+27
-4
summary.dart
packages/flutter_tools/lib/src/dart/summary.dart
+76
-0
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
d3fd8ddd
...
...
@@ -5,6 +5,8 @@
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/dart/summary.dart'
;
import
'package:path/path.dart'
as
path
;
import
'base/context.dart'
;
...
...
@@ -236,13 +238,17 @@ class MaterialFonts {
}
class
FlutterEngine
{
FlutterEngine
(
this
.
cache
);
static
const
String
kName
=
'engine'
;
static
const
String
kSkyEngine
=
'sky_engine'
;
static
const
String
kSkyServices
=
'sky_services'
;
static
const
String
kSdkBundle
=
'sdk.ds'
;
final
Cache
cache
;
List
<
String
>
_getPackageDirs
()
=>
<
String
>[
'sky_engine'
,
'sky_services'
];
List
<
String
>
_getPackageDirs
()
=>
const
<
String
>[
kSkyEngine
,
kSkyServices
];
List
<
String
>
_getEngineDirs
()
{
List
<
String
>
dirs
=
<
String
>[
...
...
@@ -292,11 +298,17 @@ class FlutterEngine {
bool
isUpToDate
()
{
Directory
pkgDir
=
cache
.
getCacheDir
(
'pkg'
);
for
(
String
pkgName
in
_getPackageDirs
())
{
Directory
dir
=
new
Directory
(
path
.
join
(
pkgDir
.
path
,
pkgName
));
if
(!
dir
.
existsSync
())
String
pkgPath
=
path
.
join
(
pkgDir
.
path
,
pkgName
);
String
dotPackagesPath
=
path
.
join
(
pkgPath
,
'.packages'
);
if
(!
new
Directory
(
pkgPath
).
existsSync
())
return
false
;
if
(!
new
File
(
dotPackagesPath
).
existsSync
())
return
false
;
}
if
(!
new
File
(
path
.
join
(
pkgDir
.
path
,
kSkyEngine
,
kSdkBundle
)).
existsSync
())
return
false
;
Directory
engineDir
=
cache
.
getArtifactDirectory
(
kName
);
for
(
String
dirName
in
_getEngineDirs
())
{
Directory
dir
=
new
Directory
(
path
.
join
(
engineDir
.
path
,
dirName
));
...
...
@@ -319,10 +331,21 @@ class FlutterEngine {
Directory
pkgDir
=
cache
.
getCacheDir
(
'pkg'
);
for
(
String
pkgName
in
_getPackageDirs
())
{
Directory
dir
=
new
Directory
(
path
.
join
(
pkgDir
.
path
,
pkgName
));
String
pkgPath
=
path
.
join
(
pkgDir
.
path
,
pkgName
);
Directory
dir
=
new
Directory
(
pkgPath
);
if
(
dir
.
existsSync
())
dir
.
deleteSync
(
recursive:
true
);
await
_downloadItem
(
'Downloading package
$pkgName
...'
,
url
+
pkgName
+
'.zip'
,
pkgDir
);
await
pubGet
(
directory:
pkgPath
);
}
Status
summaryStatus
=
logger
.
startProgress
(
'Building Dart SDK summary...'
);
try
{
String
skyEnginePath
=
path
.
join
(
pkgDir
.
path
,
kSkyEngine
);
String
skyServicesPath
=
path
.
join
(
pkgDir
.
path
,
kSkyServices
);
buildSkyEngineSdkSummary
(
skyEnginePath
,
skyServicesPath
,
kSdkBundle
);
}
finally
{
summaryStatus
.
stop
(
showElapsedTime:
true
);
}
Directory
engineDir
=
cache
.
getArtifactDirectory
(
kName
);
...
...
packages/flutter_tools/lib/src/dart/summary.dart
0 → 100644
View file @
d3fd8ddd
import
'dart:io'
as
io
;
import
'package:analyzer/file_system/file_system.dart'
;
import
'package:analyzer/file_system/physical_file_system.dart'
;
import
'package:analyzer/source/sdk_ext.dart'
;
import
'package:analyzer/src/context/builder.dart'
;
// ignore: implementation_imports
import
'package:analyzer/src/dart/sdk/sdk.dart'
;
// ignore: implementation_imports
import
'package:analyzer/src/generated/engine.dart'
;
// ignore: implementation_imports
import
'package:analyzer/src/generated/source.dart'
;
// ignore: implementation_imports
import
'package:analyzer/src/summary/summary_file_builder.dart'
;
// ignore: implementation_imports
import
'package:flutter_tools/src/globals.dart'
;
import
'package:package_config/packages.dart'
;
import
'package:path/path.dart'
as
pathos
;
import
'package:yaml/src/yaml_node.dart'
;
// ignore: implementation_imports
/// Given the [skyEnginePath] and [skyServicesPath], locate corresponding
/// `_embedder.yaml` and `_sdkext`, compose the full embedded Dart SDK, and
/// build the [outBundleName] file with its linked summary.
void
buildSkyEngineSdkSummary
(
String
skyEnginePath
,
String
skyServicesPath
,
String
outBundleName
)
{
ResourceProvider
resourceProvider
=
PhysicalResourceProvider
.
INSTANCE
;
ContextBuilder
builder
=
new
ContextBuilder
(
resourceProvider
,
null
,
null
);
Packages
packages
=
builder
.
createPackageMap
(
skyServicesPath
);
Map
<
String
,
List
<
Folder
>>
packageMap
=
builder
.
convertPackagesToMap
(
packages
);
if
(
packageMap
==
null
)
{
printError
(
'The expected .packages was not found in
$skyServicesPath
.'
);
return
;
}
packageMap
[
'sky_engine'
]
=
<
Folder
>[
resourceProvider
.
getFolder
(
pathos
.
join
(
skyEnginePath
,
'lib'
))
];
//
// Read the `_embedder.yaml` file.
//
EmbedderYamlLocator
yamlLocator
=
new
EmbedderYamlLocator
(
packageMap
);
Map
<
Folder
,
YamlMap
>
embedderYamls
=
yamlLocator
.
embedderYamls
;
if
(
embedderYamls
.
length
!=
1
)
{
printError
(
'Exactly one _embedder.yaml was expected in
$packageMap
, '
'but
$embedderYamls
found.'
);
return
;
}
//
// Read the `_sdkext` file.
//
SdkExtUriResolver
extResolver
=
new
SdkExtUriResolver
(
packageMap
);
Map
<
String
,
String
>
urlMappings
=
extResolver
.
urlMappings
;
if
(
embedderYamls
.
length
!=
1
)
{
printError
(
'Exactly one extension library was expected in
$packageMap
, '
'but
$urlMappings
found.'
);
return
;
}
//
// Create the EmbedderSdk instance.
//
EmbedderSdk
sdk
=
new
EmbedderSdk
(
resourceProvider
,
embedderYamls
);
sdk
.
addExtensions
(
urlMappings
);
sdk
.
analysisOptions
=
new
AnalysisOptionsImpl
()..
strongMode
=
true
;
//
// Gather sources.
//
List
<
Source
>
sources
=
sdk
.
uris
.
map
(
sdk
.
mapDartUri
).
toList
();
//
// Build.
//
SummaryBuildConfig
config
=
new
SummaryBuildConfig
(
strongMode:
true
);
BuilderOutput
output
=
new
SummaryBuilder
(
sources
,
sdk
.
context
,
config
).
build
();
String
outputPath
=
pathos
.
join
(
skyEnginePath
,
outBundleName
);
new
io
.
File
(
outputPath
).
writeAsBytesSync
(
output
.
sum
);
}
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