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
d71f324e
Unverified
Commit
d71f324e
authored
Mar 26, 2019
by
Jonah Williams
Committed by
GitHub
Mar 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lazy cache 4 (#29785)
parent
6e50ccc8
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
363 additions
and
190 deletions
+363
-190
build.dart
packages/flutter_tools/lib/src/base/build.dart
+1
-2
cache.dart
packages/flutter_tools/lib/src/cache.dart
+293
-159
analyze.dart
packages/flutter_tools/lib/src/commands/analyze.dart
+5
-0
build_web.dart
packages/flutter_tools/lib/src/commands/build_web.dart
+7
-1
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+1
-1
ide_config.dart
packages/flutter_tools/lib/src/commands/ide_config.dart
+1
-1
precache.dart
packages/flutter_tools/lib/src/commands/precache.dart
+24
-6
compile.dart
packages/flutter_tools/lib/src/compile.dart
+1
-2
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+1
-3
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+16
-2
cache_test.dart
packages/flutter_tools/test/cache_test.dart
+12
-12
flutter_command_test.dart
packages/flutter_tools/test/runner/flutter_command_test.dart
+1
-1
No files found.
packages/flutter_tools/lib/src/base/build.dart
View file @
d71f324e
...
...
@@ -85,7 +85,6 @@ class AOTSnapshotter {
if
(
fs
.
file
(
'pubspec.yaml'
).
existsSync
())
{
flutterProject
=
await
FlutterProject
.
current
();
}
final
FlutterEngine
engine
=
FlutterEngine
(
cache
);
if
(!
_isValidAotPlatform
(
platform
,
buildMode
))
{
printError
(
'
${getNameForTargetPlatform(platform)}
does not support AOT compilation.'
);
return
1
;
...
...
@@ -187,7 +186,7 @@ class AOTSnapshotter {
'entryPoint'
:
mainPath
,
'sharedLib'
:
buildSharedLibrary
.
toString
(),
'extraGenSnapshotOptions'
:
extraGenSnapshotOptions
.
join
(
' '
),
'engineHash'
:
engine
.
ver
sion
,
'engineHash'
:
Cache
.
instance
.
engineRevi
sion
,
'buildersUsed'
:
'
${flutterProject != null ? flutterProject.hasBuilders : false}
'
,
},
depfilePaths:
<
String
>[],
...
...
packages/flutter_tools/lib/src/cache.dart
View file @
d71f324e
...
...
@@ -15,6 +15,30 @@ import 'base/os.dart';
import
'base/platform.dart'
;
import
'globals.dart'
;
/// A tag for a set of development artifacts that need to be cached.
enum
DevelopmentArtifact
{
/// Artifacts required for Android development.
android
,
/// Artifacts required for iOS development.
iOS
,
/// Artifacts required for web development,
web
,
/// Artifacts required for desktop macOS.
macOS
,
/// Artifacts required for desktop Windows.
windows
,
/// Artifacts required for desktop linux.
linux
,
/// Artifacts required by all developments.
universal
,
}
/// A wrapper around the `bin/cache/` directory.
class
Cache
{
/// [rootOverride] is configurable for testing.
...
...
@@ -22,9 +46,11 @@ class Cache {
Cache
({
Directory
rootOverride
,
List
<
CachedArtifact
>
artifacts
})
:
_rootOverride
=
rootOverride
{
if
(
artifacts
==
null
)
{
_artifacts
.
add
(
MaterialFonts
(
this
));
_artifacts
.
add
(
FlutterEngine
(
this
));
_artifacts
.
add
(
AndroidEngineArtifacts
(
this
));
_artifacts
.
add
(
IOSEngineArtifacts
(
this
));
_artifacts
.
add
(
GradleWrapper
(
this
));
_artifacts
.
add
(
FlutterWebSdk
(
this
));
_artifacts
.
add
(
FlutterSdk
(
this
));
}
else
{
_artifacts
.
addAll
(
artifacts
);
}
...
...
@@ -194,7 +220,7 @@ class Cache {
return
isOlderThanReference
(
entity:
entity
,
referenceFile:
flutterToolsStamp
);
}
bool
isUpToDate
(
)
=>
_artifacts
.
every
((
CachedArtifact
artifact
)
=>
artifact
.
isUpToDate
(
));
bool
isUpToDate
(
Set
<
DevelopmentArtifact
>
requiredArtifacts
)
=>
_artifacts
.
every
((
CachedArtifact
artifact
)
=>
artifact
.
isUpToDate
(
requiredArtifacts
));
Future
<
String
>
getThirdPartyFile
(
String
urlStr
,
String
serviceName
)
async
{
final
Uri
url
=
Uri
.
parse
(
urlStr
);
...
...
@@ -217,13 +243,16 @@ class Cache {
return
cachedFile
.
path
;
}
Future
<
void
>
updateAll
()
async
{
if
(!
_lockEnabled
)
/// Update the cache to contain all `requiredArtifacts`.
Future
<
void
>
updateAll
(
Set
<
DevelopmentArtifact
>
requiredArtifacts
)
async
{
if
(!
_lockEnabled
)
{
return
;
}
try
{
for
(
CachedArtifact
artifact
in
_artifacts
)
{
if
(!
artifact
.
isUpToDate
(
))
if
(!
artifact
.
isUpToDate
(
requiredArtifacts
))
{
await
artifact
.
update
();
}
}
}
on
SocketException
catch
(
e
)
{
if
(
_hostsBlockedInChina
.
contains
(
e
.
address
?.
host
))
{
...
...
@@ -237,15 +266,34 @@ class Cache {
rethrow
;
}
}
Future
<
bool
>
areRemoteArtifactsAvailable
({
String
engineVersion
,
bool
includeAllPlatforms
=
true
,
})
async
{
final
bool
includeAllPlatformsState
=
cache
.
includeAllPlatforms
;
bool
allAvailible
=
true
;
cache
.
includeAllPlatforms
=
includeAllPlatforms
;
for
(
CachedArtifact
cachedArtifact
in
_artifacts
)
{
if
(
cachedArtifact
is
EngineCachedArtifact
)
{
allAvailible
&=
await
cachedArtifact
.
checkForArtifacts
(
engineVersion
);
}
}
cache
.
includeAllPlatforms
=
includeAllPlatformsState
;
return
allAvailible
;
}
}
/// An artifact managed by the cache.
abstract
class
CachedArtifact
{
CachedArtifact
(
this
.
name
,
this
.
cache
);
CachedArtifact
(
this
.
name
,
this
.
cache
,
this
.
developmentArtifacts
);
final
String
name
;
final
Cache
cache
;
/// All development artifacts this cache provides.
final
Set
<
DevelopmentArtifact
>
developmentArtifacts
;
Directory
get
location
=>
cache
.
getArtifactDirectory
(
name
);
String
get
version
=>
cache
.
getVersionFor
(
name
);
...
...
@@ -255,18 +303,25 @@ abstract class CachedArtifact {
/// starting from scratch.
final
List
<
File
>
_downloadedFiles
=
<
File
>[];
bool
isUpToDate
()
{
if
(!
location
.
existsSync
())
bool
isUpToDate
(
Set
<
DevelopmentArtifact
>
requiredArtifacts
)
{
// If the set of required artifacts does not include any from this cache,
// then we can claim we are up to date to skip downloading.
if
(!
requiredArtifacts
.
any
(
developmentArtifacts
.
contains
))
{
return
true
;
}
if
(!
location
.
existsSync
())
{
return
false
;
if
(
version
!=
cache
.
getStampFor
(
name
))
}
if
(
version
!=
cache
.
getStampFor
(
name
))
{
return
false
;
}
return
isUpToDateInner
();
}
Future
<
void
>
update
()
async
{
if
(
location
.
existsSync
())
location
.
dele
teSync
(
recursive:
true
);
location
.
createSync
(
recursive:
true
);
if
(
!
location
.
existsSync
())
{
location
.
crea
teSync
(
recursive:
true
);
}
await
updateInner
();
cache
.
setStampFor
(
name
,
version
);
_removeDownloadedFiles
();
...
...
@@ -355,7 +410,11 @@ void _maybeWarnAboutStorageOverride(String overrideUrl) {
/// A cached artifact containing fonts used for Material Design.
class
MaterialFonts
extends
CachedArtifact
{
MaterialFonts
(
Cache
cache
)
:
super
(
'material_fonts'
,
cache
);
MaterialFonts
(
Cache
cache
)
:
super
(
'material_fonts'
,
cache
,
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
},
);
@override
Future
<
void
>
updateInner
()
{
...
...
@@ -369,7 +428,11 @@ class MaterialFonts extends CachedArtifact {
///
/// This SDK references code within the regular Dart sdk to reduce download size.
class
FlutterWebSdk
extends
CachedArtifact
{
FlutterWebSdk
(
Cache
cache
)
:
super
(
'flutter_web_sdk'
,
cache
);
FlutterWebSdk
(
Cache
cache
)
:
super
(
'flutter_web_sdk'
,
cache
,
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
web
},
);
@override
Directory
get
location
=>
cache
.
getWebSdkDirectory
();
...
...
@@ -405,130 +468,37 @@ class FlutterWebSdk extends CachedArtifact {
}
}
/// A cached artifact containing the Flutter engine binaries.
class
FlutterEngine
extends
CachedArtifact
{
FlutterEngine
(
Cache
cache
)
:
super
(
'engine'
,
cache
);
List
<
String
>
_getPackageDirs
()
=>
const
<
String
>[
'sky_engine'
];
// Return a list of (cache directory path, download URL path) tuples.
List
<
List
<
String
>>
_getBinaryDirs
()
{
final
List
<
List
<
String
>>
binaryDirs
=
<
List
<
String
>>[];
binaryDirs
.
add
(<
String
>[
'common'
,
'flutter_patched_sdk.zip'
]);
if
(
cache
.
includeAllPlatforms
)
binaryDirs
..
addAll
(
_osxBinaryDirs
)
..
addAll
(
_linuxBinaryDirs
)
..
addAll
(
_windowsBinaryDirs
)
..
addAll
(
_androidBinaryDirs
)
..
addAll
(
_iosBinaryDirs
)
..
addAll
(
_dartSdks
);
else
if
(
platform
.
isLinux
)
binaryDirs
..
addAll
(
_linuxBinaryDirs
)
..
addAll
(
_androidBinaryDirs
);
else
if
(
platform
.
isMacOS
)
binaryDirs
..
addAll
(
_osxBinaryDirs
)
..
addAll
(
_androidBinaryDirs
)
..
addAll
(
_iosBinaryDirs
);
else
if
(
platform
.
isWindows
)
binaryDirs
..
addAll
(
_windowsBinaryDirs
)
..
addAll
(
_androidBinaryDirs
);
return
binaryDirs
;
}
List
<
List
<
String
>>
get
_osxBinaryDirs
=>
<
List
<
String
>>[
<
String
>[
'darwin-x64'
,
'darwin-x64/artifacts.zip'
],
<
String
>[
'android-arm-profile/darwin-x64'
,
'android-arm-profile/darwin-x64.zip'
],
<
String
>[
'android-arm-release/darwin-x64'
,
'android-arm-release/darwin-x64.zip'
],
<
String
>[
'android-arm64-profile/darwin-x64'
,
'android-arm64-profile/darwin-x64.zip'
],
<
String
>[
'android-arm64-release/darwin-x64'
,
'android-arm64-release/darwin-x64.zip'
],
<
String
>[
'android-arm-dynamic-profile/darwin-x64'
,
'android-arm-dynamic-profile/darwin-x64.zip'
],
<
String
>[
'android-arm-dynamic-release/darwin-x64'
,
'android-arm-dynamic-release/darwin-x64.zip'
],
<
String
>[
'android-arm64-dynamic-profile/darwin-x64'
,
'android-arm64-dynamic-profile/darwin-x64.zip'
],
<
String
>[
'android-arm64-dynamic-release/darwin-x64'
,
'android-arm64-dynamic-release/darwin-x64.zip'
],
];
abstract
class
EngineCachedArtifact
extends
CachedArtifact
{
EngineCachedArtifact
(
Cache
cache
,
Set
<
DevelopmentArtifact
>
requiredArtifacts
,
)
:
super
(
'engine'
,
cache
,
requiredArtifacts
);
List
<
List
<
String
>>
get
_linuxBinaryDirs
=>
<
List
<
String
>>[
<
String
>[
'linux-x64'
,
'linux-x64/artifacts.zip'
],
<
String
>[
'android-arm-profile/linux-x64'
,
'android-arm-profile/linux-x64.zip'
],
<
String
>[
'android-arm-release/linux-x64'
,
'android-arm-release/linux-x64.zip'
],
<
String
>[
'android-arm64-profile/linux-x64'
,
'android-arm64-profile/linux-x64.zip'
],
<
String
>[
'android-arm64-release/linux-x64'
,
'android-arm64-release/linux-x64.zip'
],
<
String
>[
'android-arm-dynamic-profile/linux-x64'
,
'android-arm-dynamic-profile/linux-x64.zip'
],
<
String
>[
'android-arm-dynamic-release/linux-x64'
,
'android-arm-dynamic-release/linux-x64.zip'
],
<
String
>[
'android-arm64-dynamic-profile/linux-x64'
,
'android-arm64-dynamic-profile/linux-x64.zip'
],
<
String
>[
'android-arm64-dynamic-release/linux-x64'
,
'android-arm64-dynamic-release/linux-x64.zip'
],
];
/// Return a list of (directory path, download URL path) tuples.
List
<
List
<
String
>>
getBinaryDirs
();
List
<
List
<
String
>>
get
_windowsBinaryDirs
=>
<
List
<
String
>>[
<
String
>[
'windows-x64'
,
'windows-x64/artifacts.zip'
],
<
String
>[
'android-arm-profile/windows-x64'
,
'android-arm-profile/windows-x64.zip'
],
<
String
>[
'android-arm-release/windows-x64'
,
'android-arm-release/windows-x64.zip'
],
<
String
>[
'android-arm64-profile/windows-x64'
,
'android-arm64-profile/windows-x64.zip'
],
<
String
>[
'android-arm64-release/windows-x64'
,
'android-arm64-release/windows-x64.zip'
],
<
String
>[
'android-arm-dynamic-profile/windows-x64'
,
'android-arm-dynamic-profile/windows-x64.zip'
],
<
String
>[
'android-arm-dynamic-release/windows-x64'
,
'android-arm-dynamic-release/windows-x64.zip'
],
<
String
>[
'android-arm64-dynamic-profile/windows-x64'
,
'android-arm64-dynamic-profile/windows-x64.zip'
],
<
String
>[
'android-arm64-dynamic-release/windows-x64'
,
'android-arm64-dynamic-release/windows-x64.zip'
],
];
/// A list of cache directory paths to which the LICENSE file should be copied.
List
<
String
>
getLicenseDirs
();
List
<
List
<
String
>>
get
_androidBinaryDirs
=>
<
List
<
String
>>[
<
String
>[
'android-x86'
,
'android-x86/artifacts.zip'
],
<
String
>[
'android-x64'
,
'android-x64/artifacts.zip'
],
<
String
>[
'android-arm'
,
'android-arm/artifacts.zip'
],
<
String
>[
'android-arm-profile'
,
'android-arm-profile/artifacts.zip'
],
<
String
>[
'android-arm-release'
,
'android-arm-release/artifacts.zip'
],
<
String
>[
'android-arm64'
,
'android-arm64/artifacts.zip'
],
<
String
>[
'android-arm64-profile'
,
'android-arm64-profile/artifacts.zip'
],
<
String
>[
'android-arm64-release'
,
'android-arm64-release/artifacts.zip'
],
<
String
>[
'android-arm-dynamic-profile'
,
'android-arm-dynamic-profile/artifacts.zip'
],
<
String
>[
'android-arm-dynamic-release'
,
'android-arm-dynamic-release/artifacts.zip'
],
<
String
>[
'android-arm64-dynamic-profile'
,
'android-arm64-dynamic-profile/artifacts.zip'
],
<
String
>[
'android-arm64-dynamic-release'
,
'android-arm64-dynamic-release/artifacts.zip'
],
];
List
<
List
<
String
>>
get
_iosBinaryDirs
=>
<
List
<
String
>>[
<
String
>[
'ios'
,
'ios/artifacts.zip'
],
<
String
>[
'ios-profile'
,
'ios-profile/artifacts.zip'
],
<
String
>[
'ios-release'
,
'ios-release/artifacts.zip'
],
];
List
<
List
<
String
>>
get
_dartSdks
=>
<
List
<
String
>>
[
<
String
>[
'darwin-x64'
,
'dart-sdk-darwin-x64.zip'
],
<
String
>[
'linux-x64'
,
'dart-sdk-linux-x64.zip'
],
<
String
>[
'windows-x64'
,
'dart-sdk-windows-x64.zip'
],
];
// A list of cache directory paths to which the LICENSE file should be copied.
List
<
String
>
_getLicenseDirs
()
{
if
(
cache
.
includeAllPlatforms
||
platform
.
isMacOS
)
{
return
const
<
String
>[
'ios'
,
'ios-profile'
,
'ios-release'
];
}
return
const
<
String
>[];
}
/// A list of the dart package directories to download.
List
<
String
>
getPackageDirs
();
@override
bool
isUpToDateInner
()
{
final
Directory
pkgDir
=
cache
.
getCacheDir
(
'pkg'
);
for
(
String
pkgName
in
_
getPackageDirs
())
{
for
(
String
pkgName
in
getPackageDirs
())
{
final
String
pkgPath
=
fs
.
path
.
join
(
pkgDir
.
path
,
pkgName
);
if
(!
fs
.
directory
(
pkgPath
).
existsSync
())
return
false
;
}
for
(
List
<
String
>
toolsDir
in
_
getBinaryDirs
())
{
for
(
List
<
String
>
toolsDir
in
getBinaryDirs
())
{
final
Directory
dir
=
fs
.
directory
(
fs
.
path
.
join
(
location
.
path
,
toolsDir
[
0
]));
if
(!
dir
.
existsSync
())
return
false
;
}
for
(
String
licenseDir
in
_
getLicenseDirs
())
{
for
(
String
licenseDir
in
getLicenseDirs
())
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
location
.
path
,
licenseDir
,
'LICENSE'
));
if
(!
file
.
existsSync
())
return
false
;
...
...
@@ -541,15 +511,16 @@ class FlutterEngine extends CachedArtifact {
final
String
url
=
'
$_storageBaseUrl
/flutter_infra/flutter/
$version
/'
;
final
Directory
pkgDir
=
cache
.
getCacheDir
(
'pkg'
);
for
(
String
pkgName
in
_
getPackageDirs
())
{
for
(
String
pkgName
in
getPackageDirs
())
{
final
String
pkgPath
=
fs
.
path
.
join
(
pkgDir
.
path
,
pkgName
);
final
Directory
dir
=
fs
.
directory
(
pkgPath
);
if
(
dir
.
existsSync
())
if
(
dir
.
existsSync
())
{
dir
.
deleteSync
(
recursive:
true
);
}
await
_downloadZipArchive
(
'Downloading package
$pkgName
...'
,
Uri
.
parse
(
url
+
pkgName
+
'.zip'
),
pkgDir
);
}
for
(
List
<
String
>
toolsDir
in
_
getBinaryDirs
())
{
for
(
List
<
String
>
toolsDir
in
getBinaryDirs
())
{
final
String
cacheDir
=
toolsDir
[
0
];
final
String
urlPath
=
toolsDir
[
1
];
final
Directory
dir
=
fs
.
directory
(
fs
.
path
.
join
(
location
.
path
,
cacheDir
));
...
...
@@ -566,48 +537,35 @@ class FlutterEngine extends CachedArtifact {
}
final
File
licenseSource
=
fs
.
file
(
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'LICENSE'
));
for
(
String
licenseDir
in
_
getLicenseDirs
())
{
for
(
String
licenseDir
in
getLicenseDirs
())
{
final
String
licenseDestinationPath
=
fs
.
path
.
join
(
location
.
path
,
licenseDir
,
'LICENSE'
);
await
licenseSource
.
copy
(
licenseDestinationPath
);
}
}
Future
<
bool
>
areRemoteArtifactsAvailable
({
String
engineVersion
,
bool
includeAllPlatforms
=
true
,
})
async
{
final
bool
includeAllPlatformsState
=
cache
.
includeAllPlatforms
;
cache
.
includeAllPlatforms
=
includeAllPlatforms
;
Future
<
bool
>
checkForArtifacts
(
String
engineVersion
)
async
{
engineVersion
??=
version
;
final
String
url
=
'
$_storageBaseUrl
/flutter_infra/flutter/
$engineVersion
/'
;
Future
<
bool
>
checkForArtifacts
(
String
engineVersion
)
async
{
engineVersion
??=
version
;
final
String
url
=
'
$_storageBaseUrl
/flutter_infra/flutter/
$engineVersion
/'
;
bool
exists
=
false
;
for
(
String
pkgName
in
_getPackageDirs
())
{
exists
=
await
_doesRemoteExist
(
'Checking package
$pkgName
is available...'
,
Uri
.
parse
(
url
+
pkgName
+
'.zip'
));
if
(!
exists
)
{
return
false
;
}
bool
exists
=
false
;
for
(
String
pkgName
in
getPackageDirs
())
{
exists
=
await
_doesRemoteExist
(
'Checking package
$pkgName
is available...'
,
Uri
.
parse
(
url
+
pkgName
+
'.zip'
));
if
(!
exists
)
{
return
false
;
}
}
for
(
List
<
String
>
toolsDir
in
_getBinaryDirs
())
{
final
String
cacheDir
=
toolsDir
[
0
];
final
String
urlPath
=
toolsDir
[
1
];
exists
=
await
_doesRemoteExist
(
'Checking
$cacheDir
tools are available...'
,
Uri
.
parse
(
url
+
urlPath
));
if
(!
exists
)
{
return
false
;
}
for
(
List
<
String
>
toolsDir
in
getBinaryDirs
())
{
final
String
cacheDir
=
toolsDir
[
0
];
final
String
urlPath
=
toolsDir
[
1
];
exists
=
await
_doesRemoteExist
(
'Checking
$cacheDir
tools are available...'
,
Uri
.
parse
(
url
+
urlPath
));
if
(!
exists
)
{
return
false
;
}
return
true
;
}
final
bool
result
=
await
checkForArtifacts
(
engineVersion
);
cache
.
includeAllPlatforms
=
includeAllPlatformsState
;
return
result
;
return
true
;
}
...
...
@@ -622,9 +580,123 @@ class FlutterEngine extends CachedArtifact {
}
}
/// A cached artifact containing the dart:ui source code.
class
FlutterSdk
extends
EngineCachedArtifact
{
FlutterSdk
(
Cache
cache
)
:
super
(
cache
,
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
},
);
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[
'sky_engine'
];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
final
List
<
List
<
String
>>
binaryDirs
=
<
List
<
String
>>[
<
String
>[
'common'
,
'flutter_patched_sdk.zip'
],
];
if
(
cache
.
includeAllPlatforms
)
{
binaryDirs
.
addAll
(<
List
<
String
>>[
<
String
>[
'windows-x64'
,
'windows-x64/artifacts.zip'
],
<
String
>[
'linux-x64'
,
'linux-x64/artifacts.zip'
],
<
String
>[
'darwin-x64'
,
'darwin-x64/artifacts.zip'
],
]);
}
else
if
(
platform
.
isWindows
)
{
binaryDirs
.
addAll
(<
List
<
String
>>[
<
String
>[
'windows-x64'
,
'windows-x64/artifacts.zip'
],
]);
}
else
if
(
platform
.
isMacOS
)
{
binaryDirs
.
addAll
(<
List
<
String
>>[
<
String
>[
'darwin-x64'
,
'darwin-x64/artifacts.zip'
],
]);
}
else
if
(
platform
.
isLinux
)
{
binaryDirs
.
addAll
(<
List
<
String
>>[
<
String
>[
'linux-x64'
,
'linux-x64/artifacts.zip'
],
]);
}
return
binaryDirs
;
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
class
AndroidEngineArtifacts
extends
EngineCachedArtifact
{
AndroidEngineArtifacts
(
Cache
cache
)
:
super
(
cache
,
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
android
},
);
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
final
List
<
List
<
String
>>
binaryDirs
=
<
List
<
String
>>[];
if
(
cache
.
includeAllPlatforms
)
{
binaryDirs
..
addAll
(
_osxBinaryDirs
)
..
addAll
(
_linuxBinaryDirs
)
..
addAll
(
_windowsBinaryDirs
)
..
addAll
(
_androidBinaryDirs
)
..
addAll
(
_dartSdks
);
}
else
if
(
platform
.
isWindows
)
{
binaryDirs
..
addAll
(
_windowsBinaryDirs
)
..
addAll
(
_androidBinaryDirs
);
}
else
if
(
platform
.
isMacOS
)
{
binaryDirs
..
addAll
(
_osxBinaryDirs
)
..
addAll
(
_androidBinaryDirs
);
}
else
if
(
platform
.
isLinux
)
{
binaryDirs
..
addAll
(
_linuxBinaryDirs
)
..
addAll
(
_androidBinaryDirs
);
}
return
binaryDirs
;
}
@override
List
<
String
>
getLicenseDirs
()
{
return
<
String
>[];
}
}
class
IOSEngineArtifacts
extends
EngineCachedArtifact
{
IOSEngineArtifacts
(
Cache
cache
)
:
super
(
cache
,
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
iOS
},
);
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
final
List
<
List
<
String
>>
binaryDirs
=
<
List
<
String
>>[];
if
(
platform
.
isMacOS
||
cache
.
includeAllPlatforms
)
{
binaryDirs
.
addAll
(
_iosBinaryDirs
);
}
return
binaryDirs
;
}
@override
List
<
String
>
getLicenseDirs
()
{
if
(
cache
.
includeAllPlatforms
||
platform
.
isMacOS
)
{
return
const
<
String
>[
'ios'
,
'ios-profile'
,
'ios-release'
];
}
return
const
<
String
>[];
}
@override
List
<
String
>
getPackageDirs
()
{
return
<
String
>[];
}
}
/// A cached artifact containing Gradle Wrapper scripts and binaries.
class
GradleWrapper
extends
CachedArtifact
{
GradleWrapper
(
Cache
cache
)
:
super
(
'gradle_wrapper'
,
cache
);
GradleWrapper
(
Cache
cache
)
:
super
(
'gradle_wrapper'
,
cache
,
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
android
},
);
List
<
String
>
get
_gradleScripts
=>
<
String
>[
'gradlew'
,
'gradlew.bat'
];
...
...
@@ -644,8 +716,9 @@ class GradleWrapper extends CachedArtifact {
@override
bool
isUpToDateInner
()
{
final
Directory
wrapperDir
=
cache
.
getCacheDir
(
fs
.
path
.
join
(
'artifacts'
,
'gradle_wrapper'
));
if
(!
fs
.
directory
(
wrapperDir
).
existsSync
())
if
(!
fs
.
directory
(
wrapperDir
).
existsSync
())
{
return
false
;
}
for
(
String
scriptName
in
_gradleScripts
)
{
final
File
scriptFile
=
fs
.
file
(
fs
.
path
.
join
(
wrapperDir
.
path
,
scriptName
));
if
(!
scriptFile
.
existsSync
())
...
...
@@ -706,6 +779,67 @@ Future<bool> _doesRemoteExist(String message, Uri url) async {
/// Create the given [directory] and parents, as necessary.
void
_ensureExists
(
Directory
directory
)
{
if
(!
directory
.
existsSync
())
if
(!
directory
.
existsSync
())
{
directory
.
createSync
(
recursive:
true
);
}
}
const
List
<
List
<
String
>>
_osxBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'android-arm-profile/darwin-x64'
,
'android-arm-profile/darwin-x64.zip'
],
<
String
>[
'android-arm-release/darwin-x64'
,
'android-arm-release/darwin-x64.zip'
],
<
String
>[
'android-arm64-profile/darwin-x64'
,
'android-arm64-profile/darwin-x64.zip'
],
<
String
>[
'android-arm64-release/darwin-x64'
,
'android-arm64-release/darwin-x64.zip'
],
<
String
>[
'android-arm-dynamic-profile/darwin-x64'
,
'android-arm-dynamic-profile/darwin-x64.zip'
],
<
String
>[
'android-arm-dynamic-release/darwin-x64'
,
'android-arm-dynamic-release/darwin-x64.zip'
],
<
String
>[
'android-arm64-dynamic-profile/darwin-x64'
,
'android-arm64-dynamic-profile/darwin-x64.zip'
],
<
String
>[
'android-arm64-dynamic-release/darwin-x64'
,
'android-arm64-dynamic-release/darwin-x64.zip'
],
];
const
List
<
List
<
String
>>
_linuxBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'android-arm-profile/linux-x64'
,
'android-arm-profile/linux-x64.zip'
],
<
String
>[
'android-arm-release/linux-x64'
,
'android-arm-release/linux-x64.zip'
],
<
String
>[
'android-arm64-profile/linux-x64'
,
'android-arm64-profile/linux-x64.zip'
],
<
String
>[
'android-arm64-release/linux-x64'
,
'android-arm64-release/linux-x64.zip'
],
<
String
>[
'android-arm-dynamic-profile/linux-x64'
,
'android-arm-dynamic-profile/linux-x64.zip'
],
<
String
>[
'android-arm-dynamic-release/linux-x64'
,
'android-arm-dynamic-release/linux-x64.zip'
],
<
String
>[
'android-arm64-dynamic-profile/linux-x64'
,
'android-arm64-dynamic-profile/linux-x64.zip'
],
<
String
>[
'android-arm64-dynamic-release/linux-x64'
,
'android-arm64-dynamic-release/linux-x64.zip'
],
];
const
List
<
List
<
String
>>
_windowsBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'android-arm-profile/windows-x64'
,
'android-arm-profile/windows-x64.zip'
],
<
String
>[
'android-arm-release/windows-x64'
,
'android-arm-release/windows-x64.zip'
],
<
String
>[
'android-arm64-profile/windows-x64'
,
'android-arm64-profile/windows-x64.zip'
],
<
String
>[
'android-arm64-release/windows-x64'
,
'android-arm64-release/windows-x64.zip'
],
<
String
>[
'android-arm-dynamic-profile/windows-x64'
,
'android-arm-dynamic-profile/windows-x64.zip'
],
<
String
>[
'android-arm-dynamic-release/windows-x64'
,
'android-arm-dynamic-release/windows-x64.zip'
],
<
String
>[
'android-arm64-dynamic-profile/windows-x64'
,
'android-arm64-dynamic-profile/windows-x64.zip'
],
<
String
>[
'android-arm64-dynamic-release/windows-x64'
,
'android-arm64-dynamic-release/windows-x64.zip'
],
];
const
List
<
List
<
String
>>
_androidBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'android-x86'
,
'android-x86/artifacts.zip'
],
<
String
>[
'android-x64'
,
'android-x64/artifacts.zip'
],
<
String
>[
'android-arm'
,
'android-arm/artifacts.zip'
],
<
String
>[
'android-arm-profile'
,
'android-arm-profile/artifacts.zip'
],
<
String
>[
'android-arm-release'
,
'android-arm-release/artifacts.zip'
],
<
String
>[
'android-arm64'
,
'android-arm64/artifacts.zip'
],
<
String
>[
'android-arm64-profile'
,
'android-arm64-profile/artifacts.zip'
],
<
String
>[
'android-arm64-release'
,
'android-arm64-release/artifacts.zip'
],
<
String
>[
'android-arm-dynamic-profile'
,
'android-arm-dynamic-profile/artifacts.zip'
],
<
String
>[
'android-arm-dynamic-release'
,
'android-arm-dynamic-release/artifacts.zip'
],
<
String
>[
'android-arm64-dynamic-profile'
,
'android-arm64-dynamic-profile/artifacts.zip'
],
<
String
>[
'android-arm64-dynamic-release'
,
'android-arm64-dynamic-release/artifacts.zip'
],
];
const
List
<
List
<
String
>>
_iosBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'ios'
,
'ios/artifacts.zip'
],
<
String
>[
'ios-profile'
,
'ios-profile/artifacts.zip'
],
<
String
>[
'ios-release'
,
'ios-release/artifacts.zip'
],
];
const
List
<
List
<
String
>>
_dartSdks
=
<
List
<
String
>>
[
<
String
>[
'darwin-x64'
,
'dart-sdk-darwin-x64.zip'
],
<
String
>[
'linux-x64'
,
'dart-sdk-linux-x64.zip'
],
<
String
>[
'windows-x64'
,
'dart-sdk-windows-x64.zip'
],
];
packages/flutter_tools/lib/src/commands/analyze.dart
View file @
d71f324e
...
...
@@ -64,6 +64,11 @@ class AnalyzeCommand extends FlutterCommand {
@override
String
get
description
=>
"Analyze the project's Dart code."
;
@override
Set
<
DevelopmentArtifact
>
get
requiredArtifacts
=>
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
,
};
@override
bool
get
shouldRunPub
{
// If they're not analyzing the current project.
...
...
packages/flutter_tools/lib/src/commands/build_web.dart
View file @
d71f324e
...
...
@@ -8,7 +8,7 @@ import '../base/common.dart';
import
'../base/logger.dart'
;
import
'../build_info.dart'
;
import
'../globals.dart'
;
import
'../runner/flutter_command.dart'
show
FlutterCommandResult
;
import
'../runner/flutter_command.dart'
show
DevelopmentArtifact
,
FlutterCommandResult
;
import
'../web/compile.dart'
;
import
'build.dart'
;
...
...
@@ -19,6 +19,12 @@ class BuildWebCommand extends BuildSubCommand {
defaultBuildMode
=
BuildMode
.
release
;
}
@override
Set
<
DevelopmentArtifact
>
get
requiredArtifacts
=>
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
,
DevelopmentArtifact
.
web
,
};
@override
final
String
name
=
'web'
;
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
d71f324e
...
...
@@ -245,7 +245,7 @@ class CreateCommand extends FlutterCommand {
throwToolExit
(
'Neither the --flutter-root command line flag nor the FLUTTER_ROOT environment '
'variable was specified. Unable to find package:flutter.'
,
exitCode:
2
);
await
Cache
.
instance
.
updateAll
();
await
Cache
.
instance
.
updateAll
(
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
}
);
final
String
flutterRoot
=
fs
.
path
.
absolute
(
Cache
.
flutterRoot
);
...
...
packages/flutter_tools/lib/src/commands/ide_config.dart
View file @
d71f324e
...
...
@@ -223,7 +223,7 @@ class IdeConfigCommand extends FlutterCommand {
throwToolExit
(
'Currently, the only supported IDE is IntelliJ
\n
$usage
'
,
exitCode:
2
);
}
await
Cache
.
instance
.
updateAll
();
await
Cache
.
instance
.
updateAll
(
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
}
);
if
(
argResults
[
'update-templates'
])
{
_handleTemplateUpdate
();
...
...
packages/flutter_tools/lib/src/commands/precache.dart
View file @
d71f324e
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'../cache.dart'
;
import
'../globals.dart'
;
import
'../runner/flutter_command.dart'
;
...
...
@@ -11,6 +12,12 @@ class PrecacheCommand extends FlutterCommand {
PrecacheCommand
()
{
argParser
.
addFlag
(
'all-platforms'
,
abbr:
'a'
,
negatable:
false
,
help:
'Precache artifacts for all platforms.'
);
argParser
.
addFlag
(
'android'
,
negatable:
true
,
defaultsTo:
true
,
help:
'Precache artifacts for Android development'
);
argParser
.
addFlag
(
'ios'
,
negatable:
true
,
defaultsTo:
true
,
help:
'Precache artifacts for iOS developemnt'
);
argParser
.
addFlag
(
'web'
,
negatable:
true
,
defaultsTo:
false
,
help:
'Precache artifacts for web development'
);
}
@override
...
...
@@ -24,14 +31,25 @@ class PrecacheCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
argResults
[
'all-platforms'
])
if
(
argResults
[
'all-platforms'
])
{
cache
.
includeAllPlatforms
=
true
;
if
(
cache
.
isUpToDate
())
}
final
Set
<
DevelopmentArtifact
>
requiredArtifacts
=
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
};
if
(
argResults
[
'android'
])
{
requiredArtifacts
.
add
(
DevelopmentArtifact
.
android
);
}
if
(
argResults
[
'ios'
])
{
requiredArtifacts
.
add
(
DevelopmentArtifact
.
iOS
);
}
if
(
argResults
[
'web'
])
{
requiredArtifacts
.
add
(
DevelopmentArtifact
.
web
);
}
if
(
cache
.
isUpToDate
(
requiredArtifacts
))
{
printStatus
(
'Already up-to-date.'
);
else
await
cache
.
updateAll
();
}
else
{
await
cache
.
updateAll
(
requiredArtifacts
);
}
return
null
;
}
}
packages/flutter_tools/lib/src/compile.dart
View file @
d71f324e
...
...
@@ -232,7 +232,6 @@ class KernelCompiler {
if
(
fs
.
file
(
'pubspec.yaml'
).
existsSync
())
{
flutterProject
=
await
FlutterProject
.
current
();
}
final
FlutterEngine
engine
=
FlutterEngine
(
cache
);
// TODO(cbracken): eliminate pathFilter.
// Currently the compiler emits buildbot paths for the core libs in the
...
...
@@ -246,7 +245,7 @@ class KernelCompiler {
'entryPoint'
:
mainPath
,
'trackWidgetCreation'
:
trackWidgetCreation
.
toString
(),
'linkPlatformKernelIn'
:
linkPlatformKernelIn
.
toString
(),
'engineHash'
:
engine
.
ver
sion
,
'engineHash'
:
Cache
.
instance
.
engineRevi
sion
,
'buildersUsed'
:
'
${flutterProject != null ? flutterProject.hasBuilders : false}
'
,
},
depfilePaths:
<
String
>[
depFilePath
],
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
d71f324e
...
...
@@ -170,9 +170,7 @@ class Doctor {
}
Future
<
bool
>
checkRemoteArtifacts
(
String
engineRevision
)
async
{
final
Cache
cache
=
Cache
();
final
FlutterEngine
engine
=
FlutterEngine
(
cache
);
return
await
engine
.
areRemoteArtifactsAvailable
(
engineVersion:
engineRevision
);
return
Cache
.
instance
.
areRemoteArtifactsAvailable
(
engineVersion:
engineRevision
);
}
/// Print information about the state of installed tooling.
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
d71f324e
...
...
@@ -19,6 +19,7 @@ import '../base/user_messages.dart';
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../bundle.dart'
as
bundle
;
import
'../cache.dart'
;
import
'../dart/package_map.dart'
;
import
'../dart/pub.dart'
;
import
'../device.dart'
;
...
...
@@ -28,6 +29,8 @@ import '../project.dart';
import
'../usage.dart'
;
import
'flutter_command_runner.dart'
;
export
'../cache.dart'
show
DevelopmentArtifact
;
enum
ExitStatus
{
success
,
warning
,
...
...
@@ -530,8 +533,9 @@ abstract class FlutterCommand extends Command<void> {
// Populate the cache. We call this before pub get below so that the sky_engine
// package is available in the flutter cache for pub to find.
if
(
shouldUpdateCache
)
await
cache
.
updateAll
();
if
(
shouldUpdateCache
)
{
await
cache
.
updateAll
(
requiredArtifacts
);
}
if
(
shouldRunPub
)
{
await
pubGet
(
context:
PubContext
.
getVerifyContext
(
name
));
...
...
@@ -549,6 +553,16 @@ abstract class FlutterCommand extends Command<void> {
return
await
runCommand
();
}
/// The set of development artifacts required for this command.
///
/// Defaults to [DevelopmentArtifact.universal],
/// [DevelopmentArtifact.android], and [DevelopmentArtifact.iOS].
Set
<
DevelopmentArtifact
>
get
requiredArtifacts
=>
const
<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
,
DevelopmentArtifact
.
iOS
,
DevelopmentArtifact
.
android
,
};
/// Subclasses must implement this to execute the command.
/// Optionally provide a [FlutterCommandResult] to send more details about the
/// execution for analytics.
...
...
packages/flutter_tools/test/cache_test.dart
View file @
d71f324e
...
...
@@ -84,34 +84,34 @@ void main() {
test
(
'should not be up to date, if some cached artifact is not'
,
()
{
final
CachedArtifact
artifact1
=
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
()).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
()).
thenReturn
(
false
);
when
(
artifact1
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
)).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
)).
thenReturn
(
false
);
final
Cache
cache
=
Cache
(
artifacts:
<
CachedArtifact
>[
artifact1
,
artifact2
]);
expect
(
cache
.
isUpToDate
(),
isFalse
);
expect
(
cache
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
),
isFalse
);
});
test
(
'should be up to date, if all cached artifacts are'
,
()
{
final
CachedArtifact
artifact1
=
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
()).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
()).
thenReturn
(
true
);
when
(
artifact1
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
)).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
)).
thenReturn
(
true
);
final
Cache
cache
=
Cache
(
artifacts:
<
CachedArtifact
>[
artifact1
,
artifact2
]);
expect
(
cache
.
isUpToDate
(),
isTrue
);
expect
(
cache
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
),
isTrue
);
});
test
(
'should update cached artifacts which are not up to date'
,
()
async
{
final
CachedArtifact
artifact1
=
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
()).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
()).
thenReturn
(
false
);
when
(
artifact1
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
)).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
)).
thenReturn
(
false
);
final
Cache
cache
=
Cache
(
artifacts:
<
CachedArtifact
>[
artifact1
,
artifact2
]);
await
cache
.
updateAll
();
await
cache
.
updateAll
(
const
<
DevelopmentArtifact
>{}
);
verifyNever
(
artifact1
.
update
());
verify
(
artifact2
.
update
());
});
testUsingContext
(
'failed storage.googleapis.com download shows China warning'
,
()
async
{
final
CachedArtifact
artifact1
=
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
()).
thenReturn
(
false
);
when
(
artifact2
.
isUpToDate
()).
thenReturn
(
false
);
when
(
artifact1
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
)).
thenReturn
(
false
);
when
(
artifact2
.
isUpToDate
(
const
<
DevelopmentArtifact
>{}
)).
thenReturn
(
false
);
final
MockInternetAddress
address
=
MockInternetAddress
();
when
(
address
.
host
).
thenReturn
(
'storage.googleapis.com'
);
when
(
artifact1
.
update
()).
thenThrow
(
SocketException
(
...
...
@@ -120,7 +120,7 @@ void main() {
));
final
Cache
cache
=
Cache
(
artifacts:
<
CachedArtifact
>[
artifact1
,
artifact2
]);
try
{
await
cache
.
updateAll
();
await
cache
.
updateAll
(
const
<
DevelopmentArtifact
>{}
);
fail
(
'Mock thrown exception expected'
);
}
catch
(
e
)
{
verify
(
artifact1
.
update
());
...
...
packages/flutter_tools/test/runner/flutter_command_test.dart
View file @
d71f324e
...
...
@@ -42,7 +42,7 @@ void main() {
testUsingContext
(
'honors shouldUpdateCache true'
,
()
async
{
final
DummyFlutterCommand
flutterCommand
=
DummyFlutterCommand
(
shouldUpdateCache:
true
);
await
flutterCommand
.
run
();
verify
(
cache
.
updateAll
()).
called
(
1
);
verify
(
cache
.
updateAll
(
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
...
...
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