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
26b9a015
Unverified
Commit
26b9a015
authored
Apr 05, 2021
by
Jonah Williams
Committed by
GitHub
Apr 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] split cache into API and implementation (#79580)
parent
7d74794a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
947 additions
and
906 deletions
+947
-906
cache.dart
packages/flutter_tools/lib/src/cache.dart
+45
-898
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+2
-1
flutter_cache.dart
packages/flutter_tools/lib/src/flutter_cache.dart
+894
-0
flutter_command_runner.dart
.../flutter_tools/lib/src/runner/flutter_command_runner.dart
+0
-6
local_engine.dart
packages/flutter_tools/lib/src/runner/local_engine.dart
+1
-1
artifacts_test.dart
...ages/flutter_tools/test/general.shard/artifacts_test.dart
+2
-0
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+1
-0
project_test.dart
packages/flutter_tools/test/general.shard/project_test.dart
+2
-0
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
26b9a015
...
@@ -9,10 +9,8 @@ import 'dart:async';
...
@@ -9,10 +9,8 @@ import 'dart:async';
import
'package:crypto/crypto.dart'
;
import
'package:crypto/crypto.dart'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:package_config/package_config.dart'
;
import
'package:process/process.dart'
;
import
'package:process/process.dart'
;
import
'android/android_studio.dart'
;
import
'base/common.dart'
;
import
'base/common.dart'
;
import
'base/error_handling_io.dart'
;
import
'base/error_handling_io.dart'
;
import
'base/file_system.dart'
;
import
'base/file_system.dart'
;
...
@@ -21,16 +19,16 @@ import 'base/logger.dart';
...
@@ -21,16 +19,16 @@ import 'base/logger.dart';
import
'base/net.dart'
;
import
'base/net.dart'
;
import
'base/os.dart'
show
OperatingSystemUtils
;
import
'base/os.dart'
show
OperatingSystemUtils
;
import
'base/platform.dart'
;
import
'base/platform.dart'
;
import
'base/process.dart'
;
import
'base/user_messages.dart'
;
import
'base/user_messages.dart'
;
import
'build_info.dart'
;
import
'build_info.dart'
;
import
'convert.dart'
;
import
'convert.dart'
;
import
'dart/package_map.dart'
;
import
'dart/pub.dart'
;
import
'features.dart'
;
import
'features.dart'
;
import
'globals.dart'
as
globals
;
import
'runner/flutter_command.dart'
;
const
String
kFlutterRootEnvironmentVariableName
=
'FLUTTER_ROOT'
;
// should point to //flutter/ (root of flutter/flutter repo)
import
'runner/flutter_command_runner.dart'
;
const
String
kFlutterEngineEnvironmentVariableName
=
'FLUTTER_ENGINE'
;
// should point to //engine/src/ (root of flutter/engine repo)
const
String
kSnapshotFileName
=
'flutter_tools.snapshot'
;
// in //flutter/bin/cache/
const
String
kFlutterToolsScriptFileName
=
'flutter_tools.dart'
;
// in //flutter/packages/flutter_tools/bin/
const
String
kFlutterEnginePackageName
=
'sky_engine'
;
/// A tag for a set of development artifacts that need to be cached.
/// A tag for a set of development artifacts that need to be cached.
class
DevelopmentArtifact
{
class
DevelopmentArtifact
{
...
@@ -99,6 +97,9 @@ class DevelopmentArtifact {
...
@@ -99,6 +97,9 @@ class DevelopmentArtifact {
}
}
/// A wrapper around the `bin/cache/` directory.
/// A wrapper around the `bin/cache/` directory.
///
/// This does not provide any artifacts by default. See [FlutterCache] for the default
/// artifact set.
class
Cache
{
class
Cache
{
/// [rootOverride] is configurable for testing.
/// [rootOverride] is configurable for testing.
/// [artifacts] is configurable for testing.
/// [artifacts] is configurable for testing.
...
@@ -115,37 +116,8 @@ class Cache {
...
@@ -115,37 +116,8 @@ class Cache {
_platform
=
platform
,
_platform
=
platform
,
_osUtils
=
osUtils
,
_osUtils
=
osUtils
,
_net
=
Net
(
logger:
logger
,
platform:
platform
),
_net
=
Net
(
logger:
logger
,
platform:
platform
),
_fsUtils
=
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
)
{
_fsUtils
=
FileSystemUtils
(
fileSystem:
fileSystem
,
platform:
platform
),
if
(
artifacts
==
null
)
{
_artifacts
=
artifacts
;
_artifacts
.
add
(
MaterialFonts
(
this
));
_artifacts
.
add
(
GradleWrapper
(
this
));
_artifacts
.
add
(
AndroidGenSnapshotArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
AndroidInternalBuildArtifacts
(
this
));
_artifacts
.
add
(
IOSEngineArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
FlutterWebSdk
(
this
,
platform:
_platform
));
_artifacts
.
add
(
FlutterSdk
(
this
,
platform:
_platform
));
_artifacts
.
add
(
WindowsEngineArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
MacOSEngineArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
LinuxEngineArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
LinuxFuchsiaSDKArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
MacOSFuchsiaSDKArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
FlutterRunnerSDKArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
FlutterRunnerDebugSymbols
(
this
,
platform:
_platform
));
for
(
final
String
artifactName
in
IosUsbArtifacts
.
artifactNames
)
{
_artifacts
.
add
(
IosUsbArtifacts
(
artifactName
,
this
,
platform:
_platform
));
}
_artifacts
.
add
(
FontSubsetArtifacts
(
this
,
platform:
_platform
));
_artifacts
.
add
(
PubDependencies
(
logger:
_logger
,
// flutter root and pub must be lazily initialized to avoid accessing
// before the version is determined.
flutterRoot:
()
=>
flutterRoot
,
pub:
()
=>
pub
,
));
}
else
{
_artifacts
.
addAll
(
artifacts
);
}
}
/// Create a [Cache] for testing.
/// Create a [Cache] for testing.
///
///
...
@@ -183,10 +155,19 @@ class Cache {
...
@@ -183,10 +155,19 @@ class Cache {
final
Platform
_platform
;
final
Platform
_platform
;
final
FileSystem
_fileSystem
;
final
FileSystem
_fileSystem
;
final
OperatingSystemUtils
_osUtils
;
final
OperatingSystemUtils
_osUtils
;
final
Directory
_rootOverride
;
final
List
<
ArtifactSet
>
_artifacts
;
final
Net
_net
;
final
FileSystemUtils
_fsUtils
;
ArtifactUpdater
get
_artifactUpdater
=>
__artifactUpdater
??=
_createUpdater
();
ArtifactUpdater
get
_artifactUpdater
=>
__artifactUpdater
??=
_createUpdater
();
ArtifactUpdater
__artifactUpdater
;
ArtifactUpdater
__artifactUpdater
;
@protected
void
registerArtifact
(
ArtifactSet
artifactSet
)
{
_artifacts
.
add
(
artifactSet
);
}
/// This has to be lazy because it requires FLUTTER_ROOT to be initialized.
/// This has to be lazy because it requires FLUTTER_ROOT to be initialized.
ArtifactUpdater
_createUpdater
()
{
ArtifactUpdater
_createUpdater
()
{
return
ArtifactUpdater
(
return
ArtifactUpdater
(
...
@@ -199,16 +180,10 @@ class Cache {
...
@@ -199,16 +180,10 @@ class Cache {
);
);
}
}
Net
_net
;
FileSystemUtils
_fsUtils
;
static
const
List
<
String
>
_hostsBlockedInChina
=
<
String
>
[
static
const
List
<
String
>
_hostsBlockedInChina
=
<
String
>
[
'storage.googleapis.com'
,
'storage.googleapis.com'
,
];
];
final
Directory
_rootOverride
;
final
List
<
ArtifactSet
>
_artifacts
=
<
ArtifactSet
>[];
// Initialized by FlutterCommandRunner on startup.
// Initialized by FlutterCommandRunner on startup.
static
String
flutterRoot
;
static
String
flutterRoot
;
...
@@ -718,149 +693,8 @@ abstract class CachedArtifact extends ArtifactSet {
...
@@ -718,149 +693,8 @@ abstract class CachedArtifact extends ArtifactSet {
FileSystem
fileSystem
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
OperatingSystemUtils
operatingSystemUtils
,
);
);
Uri
_toStorageUri
(
String
path
)
=>
Uri
.
parse
(
'
${cache.storageBaseUrl}
/
$path
'
);
}
/// Ensures that the source files for all of the dependencies for the
/// flutter_tool are present.
///
/// This does not handle cases where the source files are modified or the
/// directory contents are incomplete.
class
PubDependencies
extends
ArtifactSet
{
PubDependencies
({
// Needs to be lazy to avoid reading from the cache before the root is initialized.
@required
String
Function
()
flutterRoot
,
@required
Logger
logger
,
@required
Pub
Function
()
pub
,
})
:
_logger
=
logger
,
_flutterRoot
=
flutterRoot
,
_pub
=
pub
,
super
(
DevelopmentArtifact
.
universal
);
final
String
Function
()
_flutterRoot
;
final
Logger
_logger
;
final
Pub
Function
()
_pub
;
@override
Future
<
bool
>
isUpToDate
(
FileSystem
fileSystem
,
)
async
{
final
File
toolPackageConfig
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
_flutterRoot
(),
'packages'
,
'flutter_tools'
,
'.dart_tool'
,
'package_config.json'
),
);
if
(!
toolPackageConfig
.
existsSync
())
{
return
false
;
}
final
PackageConfig
packageConfig
=
await
loadPackageConfigWithLogging
(
toolPackageConfig
,
logger:
_logger
,
throwOnError:
false
,
);
if
(
packageConfig
==
null
||
packageConfig
==
PackageConfig
.
empty
)
{
return
false
;
}
for
(
final
Package
package
in
packageConfig
.
packages
)
{
if
(!
fileSystem
.
directory
(
package
.
packageUriRoot
).
existsSync
())
{
return
false
;
}
}
return
true
;
}
@override
String
get
name
=>
'pub_dependencies'
;
@override
Future
<
void
>
update
(
ArtifactUpdater
artifactUpdater
,
Logger
logger
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
await
_pub
().
get
(
context:
PubContext
.
pubGet
,
directory:
fileSystem
.
path
.
join
(
_flutterRoot
(),
'packages'
,
'flutter_tools'
),
generateSyntheticPackage:
false
,
);
}
}
/// A cached artifact containing fonts used for Material Design.
class
MaterialFonts
extends
CachedArtifact
{
MaterialFonts
(
Cache
cache
)
:
super
(
'material_fonts'
,
cache
,
DevelopmentArtifact
.
universal
,
);
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
{
final
Uri
archiveUri
=
_toStorageUri
(
version
);
return
artifactUpdater
.
downloadZipArchive
(
'Downloading Material fonts...'
,
archiveUri
,
location
);
}
}
}
/// A cached artifact containing the web dart:ui sources, platform dill files,
/// and libraries.json.
///
/// This SDK references code within the regular Dart sdk to reduce download size.
class
FlutterWebSdk
extends
CachedArtifact
{
FlutterWebSdk
(
Cache
cache
,
{
@required
Platform
platform
})
:
_platform
=
platform
,
super
(
'flutter_web_sdk'
,
cache
,
DevelopmentArtifact
.
web
,
);
final
Platform
_platform
;
@override
Directory
get
location
=>
cache
.
getWebSdkDirectory
();
@override
String
get
version
=>
cache
.
getVersionFor
(
'engine'
);
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
String
platformName
=
'flutter-web-sdk-'
;
if
(
_platform
.
isMacOS
)
{
platformName
+=
'darwin-x64'
;
}
else
if
(
_platform
.
isLinux
)
{
platformName
+=
'linux-x64'
;
}
else
if
(
_platform
.
isWindows
)
{
platformName
+=
'windows-x64'
;
}
final
Uri
url
=
Uri
.
parse
(
'
${cache.storageBaseUrl}
/flutter_infra_release/flutter/
$version
/
$platformName
.zip'
);
if
(
location
.
existsSync
())
{
location
.
deleteSync
(
recursive:
true
);
}
await
artifactUpdater
.
downloadZipArchive
(
'Downloading Web SDK...'
,
url
,
location
);
// This is a temporary work-around for not being able to safely download into a shared directory.
final
FileSystem
fileSystem
=
location
.
fileSystem
;
for
(
final
FileSystemEntity
entity
in
location
.
listSync
(
recursive:
true
))
{
if
(
entity
is
File
)
{
final
List
<
String
>
segments
=
fileSystem
.
path
.
split
(
entity
.
path
);
segments
.
remove
(
'flutter_web_sdk'
);
final
String
newPath
=
fileSystem
.
path
.
joinAll
(
segments
);
final
File
newFile
=
fileSystem
.
file
(
newPath
);
if
(!
newFile
.
existsSync
())
{
newFile
.
createSync
(
recursive:
true
);
}
entity
.
copySync
(
newPath
);
}
}
}
}
abstract
class
EngineCachedArtifact
extends
CachedArtifact
{
abstract
class
EngineCachedArtifact
extends
CachedArtifact
{
EngineCachedArtifact
(
EngineCachedArtifact
(
...
@@ -984,718 +818,6 @@ abstract class EngineCachedArtifact extends CachedArtifact {
...
@@ -984,718 +818,6 @@ abstract class EngineCachedArtifact extends CachedArtifact {
}
}
}
}
/// A cached artifact containing the dart:ui source code.
class
FlutterSdk
extends
EngineCachedArtifact
{
FlutterSdk
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'flutter_sdk'
,
cache
,
DevelopmentArtifact
.
universal
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[
'sky_engine'
];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
// Currently only Linux supports both arm64 and x64.
final
String
arch
=
cache
.
getHostPlatformArchName
();
return
<
List
<
String
>>[
<
String
>[
'common'
,
'flutter_patched_sdk.zip'
],
<
String
>[
'common'
,
'flutter_patched_sdk_product.zip'
],
if
(
cache
.
includeAllPlatforms
)
...<
List
<
String
>>[
<
String
>[
'windows-x64'
,
'windows-x64/artifacts.zip'
],
<
String
>[
'linux-
$arch
'
,
'linux-
$arch
/artifacts.zip'
],
<
String
>[
'darwin-x64'
,
'darwin-x64/artifacts.zip'
],
]
else
if
(
_platform
.
isWindows
)
<
String
>[
'windows-x64'
,
'windows-x64/artifacts.zip'
]
else
if
(
_platform
.
isMacOS
)
<
String
>[
'darwin-x64'
,
'darwin-x64/artifacts.zip'
]
else
if
(
_platform
.
isLinux
)
<
String
>[
'linux-
$arch
'
,
'linux-
$arch
/artifacts.zip'
],
];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
class
MacOSEngineArtifacts
extends
EngineCachedArtifact
{
MacOSEngineArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'macos-sdk'
,
cache
,
DevelopmentArtifact
.
macOS
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
if
(
_platform
.
isMacOS
||
ignorePlatformFiltering
)
{
return
_macOSDesktopBinaryDirs
;
}
return
const
<
List
<
String
>>[];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
/// Artifacts required for desktop Windows builds.
class
WindowsEngineArtifacts
extends
EngineCachedArtifact
{
WindowsEngineArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'windows-sdk'
,
cache
,
DevelopmentArtifact
.
windows
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
if
(
_platform
.
isWindows
||
ignorePlatformFiltering
)
{
return
_windowsDesktopBinaryDirs
;
}
return
const
<
List
<
String
>>[];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
/// Artifacts required for desktop Linux builds.
class
LinuxEngineArtifacts
extends
EngineCachedArtifact
{
LinuxEngineArtifacts
(
Cache
cache
,
{
@required
Platform
platform
})
:
_platform
=
platform
,
super
(
'linux-sdk'
,
cache
,
DevelopmentArtifact
.
linux
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
if
(
_platform
.
isLinux
||
ignorePlatformFiltering
)
{
final
String
arch
=
cache
.
getHostPlatformArchName
();
return
<
List
<
String
>>[
<
String
>[
'linux-
$arch
'
,
'linux-
$arch
/linux-
$arch
-flutter-gtk.zip'
],
<
String
>[
'linux-
$arch
-profile'
,
'linux-
$arch
-profile/linux-
$arch
-flutter-gtk.zip'
],
<
String
>[
'linux-
$arch
-release'
,
'linux-
$arch
-release/linux-
$arch
-flutter-gtk.zip'
],
];
}
return
const
<
List
<
String
>>[];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
/// The artifact used to generate snapshots for Android builds.
class
AndroidGenSnapshotArtifacts
extends
EngineCachedArtifact
{
AndroidGenSnapshotArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'android-sdk'
,
cache
,
DevelopmentArtifact
.
androidGenSnapshot
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
return
<
List
<
String
>>[
if
(
cache
.
includeAllPlatforms
)
...<
List
<
String
>>[
...
_osxBinaryDirs
,
...
_linuxBinaryDirs
,
...
_windowsBinaryDirs
,
...
_dartSdks
,
]
else
if
(
_platform
.
isWindows
)
...
_windowsBinaryDirs
else
if
(
_platform
.
isMacOS
)
...
_osxBinaryDirs
else
if
(
_platform
.
isLinux
)
...
_linuxBinaryDirs
,
];
}
@override
List
<
String
>
getLicenseDirs
()
{
return
<
String
>[];
}
}
/// A cached artifact containing the Maven dependencies used to build Android projects.
///
/// This is a no-op if the android SDK is not available.
class
AndroidMavenArtifacts
extends
ArtifactSet
{
AndroidMavenArtifacts
(
this
.
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
DevelopmentArtifact
.
androidMaven
);
final
Platform
_platform
;
final
Cache
cache
;
@override
Future
<
void
>
update
(
ArtifactUpdater
artifactUpdater
,
Logger
logger
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(
globals
.
androidSdk
==
null
)
{
return
;
}
final
Directory
tempDir
=
cache
.
getRoot
().
createTempSync
(
'flutter_gradle_wrapper.'
,
);
globals
.
gradleUtils
.
injectGradleWrapperIfNeeded
(
tempDir
);
final
Status
status
=
logger
.
startProgress
(
'Downloading Android Maven dependencies...'
);
final
File
gradle
=
tempDir
.
childFile
(
_platform
.
isWindows
?
'gradlew.bat'
:
'gradlew'
,
);
try
{
final
String
gradleExecutable
=
gradle
.
absolute
.
path
;
final
String
flutterSdk
=
globals
.
fsUtils
.
escapePath
(
Cache
.
flutterRoot
);
final
RunResult
processResult
=
await
globals
.
processUtils
.
run
(
<
String
>[
gradleExecutable
,
'-b'
,
globals
.
fs
.
path
.
join
(
flutterSdk
,
'packages'
,
'flutter_tools'
,
'gradle'
,
'resolve_dependencies.gradle'
),
'--project-cache-dir'
,
tempDir
.
path
,
'resolveDependencies'
,
],
environment:
<
String
,
String
>{
if
(
javaPath
!=
null
)
'JAVA_HOME'
:
javaPath
,
},
);
if
(
processResult
.
exitCode
!=
0
)
{
logger
.
printError
(
'Failed to download the Android dependencies'
);
}
}
finally
{
status
.
stop
();
tempDir
.
deleteSync
(
recursive:
true
);
globals
.
androidSdk
?.
reinitialize
();
}
}
@override
Future
<
bool
>
isUpToDate
(
FileSystem
fileSystem
)
async
{
// The dependencies are downloaded and cached by Gradle.
// The tool doesn't know if the dependencies are already cached at this point.
// Therefore, call Gradle to figure this out.
return
false
;
}
@override
String
get
name
=>
'android-maven-artifacts'
;
}
/// Artifacts used for internal builds. The flutter tool builds Android projects
/// using the artifacts cached by [AndroidMavenArtifacts].
class
AndroidInternalBuildArtifacts
extends
EngineCachedArtifact
{
AndroidInternalBuildArtifacts
(
Cache
cache
)
:
super
(
'android-internal-build-artifacts'
,
cache
,
DevelopmentArtifact
.
androidInternalBuild
,
);
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
return
_androidBinaryDirs
;
}
@override
List
<
String
>
getLicenseDirs
()
{
return
<
String
>[];
}
}
class
IOSEngineArtifacts
extends
EngineCachedArtifact
{
IOSEngineArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'ios-sdk'
,
cache
,
DevelopmentArtifact
.
iOS
,
);
final
Platform
_platform
;
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
return
<
List
<
String
>>[
if
(
_platform
.
isMacOS
||
ignorePlatformFiltering
)
...
_iosBinaryDirs
,
];
}
@override
List
<
String
>
getLicenseDirs
()
{
if
(
_platform
.
isMacOS
||
ignorePlatformFiltering
)
{
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.
///
/// While this is only required for Android, we need to always download it due
/// the ensurePlatformSpecificTooling logic.
class
GradleWrapper
extends
CachedArtifact
{
GradleWrapper
(
Cache
cache
)
:
super
(
'gradle_wrapper'
,
cache
,
DevelopmentArtifact
.
universal
,
);
List
<
String
>
get
_gradleScripts
=>
<
String
>[
'gradlew'
,
'gradlew.bat'
];
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
final
Uri
archiveUri
=
_toStorageUri
(
version
);
await
artifactUpdater
.
downloadZippedTarball
(
'Downloading Gradle Wrapper...'
,
archiveUri
,
location
);
// Delete property file, allowing templates to provide it.
// Remove NOTICE file. Should not be part of the template.
final
File
propertiesFile
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
location
.
path
,
'gradle'
,
'wrapper'
,
'gradle-wrapper.properties'
));
final
File
noticeFile
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
location
.
path
,
'NOTICE'
));
ErrorHandlingFileSystem
.
deleteIfExists
(
propertiesFile
);
ErrorHandlingFileSystem
.
deleteIfExists
(
noticeFile
);
}
@override
bool
isUpToDateInner
(
FileSystem
fileSystem
,
)
{
final
String
gradleWrapper
=
fileSystem
.
path
.
join
(
'gradle'
,
'wrapper'
,
'gradle-wrapper.jar'
);
final
Directory
wrapperDir
=
cache
.
getCacheDir
(
fileSystem
.
path
.
join
(
'artifacts'
,
'gradle_wrapper'
));
if
(!
fileSystem
.
directory
(
wrapperDir
).
existsSync
())
{
return
false
;
}
for
(
final
String
scriptName
in
_gradleScripts
)
{
final
File
scriptFile
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
wrapperDir
.
path
,
scriptName
));
if
(!
scriptFile
.
existsSync
())
{
return
false
;
}
}
final
File
gradleWrapperJar
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
wrapperDir
.
path
,
gradleWrapper
));
if
(!
gradleWrapperJar
.
existsSync
())
{
return
false
;
}
return
true
;
}
}
const
String
_cipdBaseUrl
=
'https://chrome-infra-packages.appspot.com/dl'
;
/// Common functionality for pulling Fuchsia SDKs.
abstract
class
_FuchsiaSDKArtifacts
extends
CachedArtifact
{
_FuchsiaSDKArtifacts
(
Cache
cache
,
String
platform
)
:
_path
=
'fuchsia/sdk/core/
$platform
-amd64'
,
super
(
'fuchsia-
$platform
'
,
cache
,
DevelopmentArtifact
.
fuchsia
,
);
final
String
_path
;
@override
Directory
get
location
=>
cache
.
getArtifactDirectory
(
'fuchsia'
);
Future
<
void
>
_doUpdate
(
ArtifactUpdater
artifactUpdater
)
{
final
String
url
=
'
$_cipdBaseUrl
/
$_path
/+/
$version
'
;
return
artifactUpdater
.
downloadZipArchive
(
'Downloading package fuchsia SDK...'
,
Uri
.
parse
(
url
),
location
);
}
}
/// The pre-built flutter runner for Fuchsia development.
class
FlutterRunnerSDKArtifacts
extends
CachedArtifact
{
FlutterRunnerSDKArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'flutter_runner'
,
cache
,
DevelopmentArtifact
.
flutterRunner
,
);
final
Platform
_platform
;
@override
Directory
get
location
=>
cache
.
getArtifactDirectory
(
'flutter_runner'
);
@override
String
get
version
=>
cache
.
getVersionFor
(
'engine'
);
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isLinux
&&
!
_platform
.
isMacOS
)
{
return
;
}
final
String
url
=
'
$_cipdBaseUrl
/flutter/fuchsia/+/git_revision:
$version
'
;
await
artifactUpdater
.
downloadZipArchive
(
'Downloading package flutter runner...'
,
Uri
.
parse
(
url
),
location
);
}
}
/// Implementations of this class can resolve URLs for packages that are versioned.
///
/// See also [CipdArchiveResolver].
abstract
class
VersionedPackageResolver
{
const
VersionedPackageResolver
();
/// Returns the URL for the artifact.
String
resolveUrl
(
String
packageName
,
String
version
);
}
/// Resolves the CIPD archive URL for a given package and version.
class
CipdArchiveResolver
extends
VersionedPackageResolver
{
const
CipdArchiveResolver
();
@override
String
resolveUrl
(
String
packageName
,
String
version
)
{
return
'
$_cipdBaseUrl
/flutter/
$packageName
/+/git_revision:
$version
'
;
}
}
/// The debug symbols for flutter runner for Fuchsia development.
class
FlutterRunnerDebugSymbols
extends
CachedArtifact
{
FlutterRunnerDebugSymbols
(
Cache
cache
,
{
@required
Platform
platform
,
this
.
packageResolver
=
const
CipdArchiveResolver
(),
})
:
_platform
=
platform
,
super
(
'flutter_runner_debug_symbols'
,
cache
,
DevelopmentArtifact
.
flutterRunner
);
final
VersionedPackageResolver
packageResolver
;
final
Platform
_platform
;
@override
Directory
get
location
=>
cache
.
getArtifactDirectory
(
name
);
@override
String
get
version
=>
cache
.
getVersionFor
(
'engine'
);
Future
<
void
>
_downloadDebugSymbols
(
String
targetArch
,
ArtifactUpdater
artifactUpdater
)
async
{
final
String
packageName
=
'fuchsia-debug-symbols-
$targetArch
'
;
final
String
url
=
packageResolver
.
resolveUrl
(
packageName
,
version
);
await
artifactUpdater
.
downloadZipArchive
(
'Downloading debug symbols for flutter runner - arch:
$targetArch
...'
,
Uri
.
parse
(
url
),
location
,
);
}
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isLinux
&&
!
_platform
.
isMacOS
)
{
return
;
}
await
_downloadDebugSymbols
(
'x64'
,
artifactUpdater
);
await
_downloadDebugSymbols
(
'arm64'
,
artifactUpdater
);
}
}
/// The Fuchsia core SDK for Linux.
class
LinuxFuchsiaSDKArtifacts
extends
_FuchsiaSDKArtifacts
{
LinuxFuchsiaSDKArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
cache
,
'linux'
);
final
Platform
_platform
;
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isLinux
)
{
return
;
}
return
_doUpdate
(
artifactUpdater
);
}
}
/// The Fuchsia core SDK for MacOS.
class
MacOSFuchsiaSDKArtifacts
extends
_FuchsiaSDKArtifacts
{
MacOSFuchsiaSDKArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
cache
,
'mac'
);
final
Platform
_platform
;
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isMacOS
)
{
return
;
}
return
_doUpdate
(
artifactUpdater
);
}
}
/// Cached artifacts for font subsetting.
class
FontSubsetArtifacts
extends
EngineCachedArtifact
{
FontSubsetArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
artifactName
,
cache
,
DevelopmentArtifact
.
universal
);
final
Platform
_platform
;
static
const
String
artifactName
=
'font-subset'
;
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
// Currently only Linux supports both arm64 and x64.
final
String
arch
=
cache
.
getHostPlatformArchName
();
final
Map
<
String
,
List
<
String
>>
artifacts
=
<
String
,
List
<
String
>>
{
'macos'
:
<
String
>[
'darwin-x64'
,
'darwin-x64/
$artifactName
.zip'
],
'linux'
:
<
String
>[
'linux-
$arch
'
,
'linux-
$arch
/
$artifactName
.zip'
],
'windows'
:
<
String
>[
'windows-x64'
,
'windows-x64/
$artifactName
.zip'
],
};
if
(
cache
.
includeAllPlatforms
)
{
return
artifacts
.
values
.
toList
();
}
else
{
final
List
<
String
>
binaryDirs
=
artifacts
[
_platform
.
operatingSystem
];
if
(
binaryDirs
==
null
)
{
throwToolExit
(
'Unsupported operating system:
${_platform.operatingSystem}
'
);
}
return
<
List
<
String
>>[
binaryDirs
];
}
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
}
/// Cached iOS/USB binary artifacts.
class
IosUsbArtifacts
extends
CachedArtifact
{
IosUsbArtifacts
(
String
name
,
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
name
,
cache
,
DevelopmentArtifact
.
universal
,
);
final
Platform
_platform
;
static
const
List
<
String
>
artifactNames
=
<
String
>[
'libimobiledevice'
,
'usbmuxd'
,
'libplist'
,
'openssl'
,
'ios-deploy'
,
];
// For unknown reasons, users are getting into bad states where libimobiledevice is
// downloaded but some executables are missing from the zip. The names here are
// used for additional download checks below, so we can re-download if they are
// missing.
static
const
Map
<
String
,
List
<
String
>>
_kExecutables
=
<
String
,
List
<
String
>>{
'libimobiledevice'
:
<
String
>[
'idevicescreenshot'
,
'idevicesyslog'
,
],
'usbmuxd'
:
<
String
>[
'iproxy'
,
],
};
@override
Map
<
String
,
String
>
get
environment
{
return
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
cache
.
getArtifactDirectory
(
name
).
path
,
};
}
@override
bool
isUpToDateInner
(
FileSystem
fileSystem
)
{
final
List
<
String
>
executables
=
_kExecutables
[
name
];
if
(
executables
==
null
)
{
return
true
;
}
for
(
final
String
executable
in
executables
)
{
if
(!
location
.
childFile
(
executable
).
existsSync
())
{
return
false
;
}
}
return
true
;
}
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isMacOS
&&
!
ignorePlatformFiltering
)
{
return
;
}
if
(
location
.
existsSync
())
{
location
.
deleteSync
(
recursive:
true
);
}
await
artifactUpdater
.
downloadZipArchive
(
'Downloading
$name
...'
,
archiveUri
,
location
);
}
@visibleForTesting
Uri
get
archiveUri
=>
Uri
.
parse
(
'
${cache.storageBaseUrl}
/flutter_infra_release/ios-usb-dependencies
${cache.useUnsignedMacBinaries ? '/unsigned' : ''}
/
$name
/
$version
/
$name
.zip'
);
}
// Many characters are problematic in filenames, especially on Windows.
final
Map
<
int
,
List
<
int
>>
_flattenNameSubstitutions
=
<
int
,
List
<
int
>>{
r'@'
.
codeUnitAt
(
0
):
'@@'
.
codeUnits
,
r'/'
.
codeUnitAt
(
0
):
'@s@'
.
codeUnits
,
r'\'
.
codeUnitAt
(
0
):
'@bs@'
.
codeUnits
,
r':'
.
codeUnitAt
(
0
):
'@c@'
.
codeUnits
,
r'%'
.
codeUnitAt
(
0
):
'@per@'
.
codeUnits
,
r'*'
.
codeUnitAt
(
0
):
'@ast@'
.
codeUnits
,
r'<'
.
codeUnitAt
(
0
):
'@lt@'
.
codeUnits
,
r'>'
.
codeUnitAt
(
0
):
'@gt@'
.
codeUnits
,
r'"'
.
codeUnitAt
(
0
):
'@q@'
.
codeUnits
,
r'|'
.
codeUnitAt
(
0
):
'@pip@'
.
codeUnits
,
r'?'
.
codeUnitAt
(
0
):
'@ques@'
.
codeUnits
,
};
/// Given a name containing slashes, colons, and backslashes, expand it into
/// something that doesn't.
String
_flattenNameNoSubdirs
(
String
fileName
)
{
final
List
<
int
>
replacedCodeUnits
=
<
int
>[
for
(
int
codeUnit
in
fileName
.
codeUnits
)
...
_flattenNameSubstitutions
[
codeUnit
]
??
<
int
>[
codeUnit
],
];
return
String
.
fromCharCodes
(
replacedCodeUnits
);
}
// TODO(jonahwilliams): upload debug desktop artifacts to host-debug and
// remove from existing host folder.
// https://github.com/flutter/flutter/issues/38935
const
List
<
List
<
String
>>
_windowsDesktopBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'windows-x64'
,
'windows-x64/windows-x64-flutter.zip'
],
<
String
>[
'windows-x64'
,
'windows-x64/flutter-cpp-client-wrapper.zip'
],
<
String
>[
'windows-x64-profile'
,
'windows-x64-profile/windows-x64-flutter.zip'
],
<
String
>[
'windows-x64-release'
,
'windows-x64-release/windows-x64-flutter.zip'
],
];
const
List
<
List
<
String
>>
_macOSDesktopBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'darwin-x64'
,
'darwin-x64/FlutterMacOS.framework.zip'
],
<
String
>[
'darwin-x64-profile'
,
'darwin-x64-profile/FlutterMacOS.framework.zip'
],
<
String
>[
'darwin-x64-profile'
,
'darwin-x64-profile/artifacts.zip'
],
<
String
>[
'darwin-x64-release'
,
'darwin-x64-release/FlutterMacOS.framework.zip'
],
<
String
>[
'darwin-x64-release'
,
'darwin-x64-release/artifacts.zip'
],
];
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-x64-profile/darwin-x64'
,
'android-x64-profile/darwin-x64.zip'
],
<
String
>[
'android-x64-release/darwin-x64'
,
'android-x64-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-x64-profile/linux-x64'
,
'android-x64-profile/linux-x64.zip'
],
<
String
>[
'android-x64-release/linux-x64'
,
'android-x64-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-x64-profile/windows-x64'
,
'android-x64-profile/windows-x64.zip'
],
<
String
>[
'android-x64-release/windows-x64'
,
'android-x64-release/windows-x64.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
>>
_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-x64-profile'
,
'android-x64-profile/artifacts.zip'
],
<
String
>[
'android-x64-release'
,
'android-x64-release/artifacts.zip'
],
<
String
>[
'android-x86-jit-release'
,
'android-x86-jit-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'
],
];
/// An API for downloading and un-archiving artifacts, such as engine binaries or
/// An API for downloading and un-archiving artifacts, such as engine binaries or
/// additional source code.
/// additional source code.
class
ArtifactUpdater
{
class
ArtifactUpdater
{
...
@@ -1970,3 +1092,28 @@ String flattenNameSubdirs(Uri url, FileSystem fileSystem){
...
@@ -1970,3 +1092,28 @@ String flattenNameSubdirs(Uri url, FileSystem fileSystem){
final
Iterable
<
String
>
convertedPieces
=
pieces
.
map
<
String
>(
_flattenNameNoSubdirs
);
final
Iterable
<
String
>
convertedPieces
=
pieces
.
map
<
String
>(
_flattenNameNoSubdirs
);
return
fileSystem
.
path
.
joinAll
(
convertedPieces
);
return
fileSystem
.
path
.
joinAll
(
convertedPieces
);
}
}
/// Given a name containing slashes, colons, and backslashes, expand it into
/// something that doesn't.
String
_flattenNameNoSubdirs
(
String
fileName
)
{
final
List
<
int
>
replacedCodeUnits
=
<
int
>[
for
(
int
codeUnit
in
fileName
.
codeUnits
)
...
_flattenNameSubstitutions
[
codeUnit
]
??
<
int
>[
codeUnit
],
];
return
String
.
fromCharCodes
(
replacedCodeUnits
);
}
// Many characters are problematic in filenames, especially on Windows.
final
Map
<
int
,
List
<
int
>>
_flattenNameSubstitutions
=
<
int
,
List
<
int
>>{
r'@'
.
codeUnitAt
(
0
):
'@@'
.
codeUnits
,
r'/'
.
codeUnitAt
(
0
):
'@s@'
.
codeUnits
,
r'\'
.
codeUnitAt
(
0
):
'@bs@'
.
codeUnits
,
r':'
.
codeUnitAt
(
0
):
'@c@'
.
codeUnits
,
r'%'
.
codeUnitAt
(
0
):
'@per@'
.
codeUnits
,
r'*'
.
codeUnitAt
(
0
):
'@ast@'
.
codeUnits
,
r'<'
.
codeUnitAt
(
0
):
'@lt@'
.
codeUnits
,
r'>'
.
codeUnitAt
(
0
):
'@gt@'
.
codeUnits
,
r'"'
.
codeUnitAt
(
0
):
'@q@'
.
codeUnits
,
r'|'
.
codeUnitAt
(
0
):
'@pip@'
.
codeUnits
,
r'?'
.
codeUnitAt
(
0
):
'@ques@'
.
codeUnits
,
};
packages/flutter_tools/lib/src/context_runner.dart
View file @
26b9a015
...
@@ -39,6 +39,7 @@ import 'doctor.dart';
...
@@ -39,6 +39,7 @@ import 'doctor.dart';
import
'emulator.dart'
;
import
'emulator.dart'
;
import
'features.dart'
;
import
'features.dart'
;
import
'flutter_application_package.dart'
;
import
'flutter_application_package.dart'
;
import
'flutter_cache.dart'
;
import
'flutter_device_manager.dart'
;
import
'flutter_device_manager.dart'
;
import
'flutter_features.dart'
;
import
'flutter_features.dart'
;
import
'fuchsia/fuchsia_device.dart'
show
FuchsiaDeviceTools
;
import
'fuchsia/fuchsia_device.dart'
show
FuchsiaDeviceTools
;
...
@@ -145,7 +146,7 @@ Future<T> runInContext<T>(
...
@@ -145,7 +146,7 @@ Future<T> runInContext<T>(
logger:
globals
.
logger
,
logger:
globals
.
logger
,
platform:
globals
.
platform
,
platform:
globals
.
platform
,
),
),
Cache:
()
=>
Cache
(
Cache:
()
=>
Flutter
Cache
(
fileSystem:
globals
.
fs
,
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
platform:
globals
.
platform
,
platform:
globals
.
platform
,
...
...
packages/flutter_tools/lib/src/flutter_cache.dart
0 → 100644
View file @
26b9a015
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'package:package_config/package_config.dart'
;
import
'android/android_studio.dart'
;
import
'base/common.dart'
;
import
'base/error_handling_io.dart'
;
import
'base/file_system.dart'
;
import
'base/logger.dart'
;
import
'base/os.dart'
show
OperatingSystemUtils
;
import
'base/platform.dart'
;
import
'base/process.dart'
;
import
'cache.dart'
;
import
'dart/package_map.dart'
;
import
'dart/pub.dart'
;
import
'globals.dart'
as
globals
;
import
'runner/flutter_command.dart'
;
/// An implementation of the [Cache] which provides all of Flutter's default artifacts.
class
FlutterCache
extends
Cache
{
/// [rootOverride] is configurable for testing.
/// [artifacts] is configurable for testing.
FlutterCache
({
@required
Logger
logger
,
@required
FileSystem
fileSystem
,
@required
Platform
platform
,
@required
OperatingSystemUtils
osUtils
,
})
:
super
(
logger:
logger
,
fileSystem:
fileSystem
,
platform:
platform
,
osUtils:
osUtils
,
artifacts:
<
ArtifactSet
>[])
{
registerArtifact
(
MaterialFonts
(
this
));
registerArtifact
(
GradleWrapper
(
this
));
registerArtifact
(
AndroidGenSnapshotArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
AndroidInternalBuildArtifacts
(
this
));
registerArtifact
(
IOSEngineArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
FlutterWebSdk
(
this
,
platform:
platform
));
registerArtifact
(
FlutterSdk
(
this
,
platform:
platform
));
registerArtifact
(
WindowsEngineArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
MacOSEngineArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
LinuxEngineArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
LinuxFuchsiaSDKArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
MacOSFuchsiaSDKArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
FlutterRunnerSDKArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
FlutterRunnerDebugSymbols
(
this
,
platform:
platform
));
for
(
final
String
artifactName
in
IosUsbArtifacts
.
artifactNames
)
{
registerArtifact
(
IosUsbArtifacts
(
artifactName
,
this
,
platform:
platform
));
}
registerArtifact
(
FontSubsetArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
PubDependencies
(
logger:
logger
,
// flutter root and pub must be lazily initialized to avoid accessing
// before the version is determined.
flutterRoot:
()
=>
Cache
.
flutterRoot
,
pub:
()
=>
pub
,
));
}
}
/// Ensures that the source files for all of the dependencies for the
/// flutter_tool are present.
///
/// This does not handle cases where the source files are modified or the
/// directory contents are incomplete.
class
PubDependencies
extends
ArtifactSet
{
PubDependencies
({
// Needs to be lazy to avoid reading from the cache before the root is initialized.
@required
String
Function
()
flutterRoot
,
@required
Logger
logger
,
@required
Pub
Function
()
pub
,
})
:
_logger
=
logger
,
_flutterRoot
=
flutterRoot
,
_pub
=
pub
,
super
(
DevelopmentArtifact
.
universal
);
final
String
Function
()
_flutterRoot
;
final
Logger
_logger
;
final
Pub
Function
()
_pub
;
@override
Future
<
bool
>
isUpToDate
(
FileSystem
fileSystem
,
)
async
{
final
File
toolPackageConfig
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
_flutterRoot
(),
'packages'
,
'flutter_tools'
,
'.dart_tool'
,
'package_config.json'
),
);
if
(!
toolPackageConfig
.
existsSync
())
{
return
false
;
}
final
PackageConfig
packageConfig
=
await
loadPackageConfigWithLogging
(
toolPackageConfig
,
logger:
_logger
,
throwOnError:
false
,
);
if
(
packageConfig
==
null
||
packageConfig
==
PackageConfig
.
empty
)
{
return
false
;
}
for
(
final
Package
package
in
packageConfig
.
packages
)
{
if
(!
fileSystem
.
directory
(
package
.
packageUriRoot
).
existsSync
())
{
return
false
;
}
}
return
true
;
}
@override
String
get
name
=>
'pub_dependencies'
;
@override
Future
<
void
>
update
(
ArtifactUpdater
artifactUpdater
,
Logger
logger
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
await
_pub
().
get
(
context:
PubContext
.
pubGet
,
directory:
fileSystem
.
path
.
join
(
_flutterRoot
(),
'packages'
,
'flutter_tools'
),
generateSyntheticPackage:
false
,
);
}
}
/// A cached artifact containing fonts used for Material Design.
class
MaterialFonts
extends
CachedArtifact
{
MaterialFonts
(
Cache
cache
)
:
super
(
'material_fonts'
,
cache
,
DevelopmentArtifact
.
universal
,
);
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
{
final
Uri
archiveUri
=
_toStorageUri
(
version
);
return
artifactUpdater
.
downloadZipArchive
(
'Downloading Material fonts...'
,
archiveUri
,
location
);
}
Uri
_toStorageUri
(
String
path
)
=>
Uri
.
parse
(
'
${cache.storageBaseUrl}
/
$path
'
);
}
/// A cached artifact containing the web dart:ui sources, platform dill files,
/// and libraries.json.
///
/// This SDK references code within the regular Dart sdk to reduce download size.
class
FlutterWebSdk
extends
CachedArtifact
{
FlutterWebSdk
(
Cache
cache
,
{
@required
Platform
platform
})
:
_platform
=
platform
,
super
(
'flutter_web_sdk'
,
cache
,
DevelopmentArtifact
.
web
,
);
final
Platform
_platform
;
@override
Directory
get
location
=>
cache
.
getWebSdkDirectory
();
@override
String
get
version
=>
cache
.
getVersionFor
(
'engine'
);
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
String
platformName
=
'flutter-web-sdk-'
;
if
(
_platform
.
isMacOS
)
{
platformName
+=
'darwin-x64'
;
}
else
if
(
_platform
.
isLinux
)
{
platformName
+=
'linux-x64'
;
}
else
if
(
_platform
.
isWindows
)
{
platformName
+=
'windows-x64'
;
}
final
Uri
url
=
Uri
.
parse
(
'
${cache.storageBaseUrl}
/flutter_infra_release/flutter/
$version
/
$platformName
.zip'
);
if
(
location
.
existsSync
())
{
location
.
deleteSync
(
recursive:
true
);
}
await
artifactUpdater
.
downloadZipArchive
(
'Downloading Web SDK...'
,
url
,
location
);
// This is a temporary work-around for not being able to safely download into a shared directory.
final
FileSystem
fileSystem
=
location
.
fileSystem
;
for
(
final
FileSystemEntity
entity
in
location
.
listSync
(
recursive:
true
))
{
if
(
entity
is
File
)
{
final
List
<
String
>
segments
=
fileSystem
.
path
.
split
(
entity
.
path
);
segments
.
remove
(
'flutter_web_sdk'
);
final
String
newPath
=
fileSystem
.
path
.
joinAll
(
segments
);
final
File
newFile
=
fileSystem
.
file
(
newPath
);
if
(!
newFile
.
existsSync
())
{
newFile
.
createSync
(
recursive:
true
);
}
entity
.
copySync
(
newPath
);
}
}
}
}
/// A cached artifact containing the dart:ui source code.
class
FlutterSdk
extends
EngineCachedArtifact
{
FlutterSdk
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'flutter_sdk'
,
cache
,
DevelopmentArtifact
.
universal
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[
'sky_engine'
];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
// Currently only Linux supports both arm64 and x64.
final
String
arch
=
cache
.
getHostPlatformArchName
();
return
<
List
<
String
>>[
<
String
>[
'common'
,
'flutter_patched_sdk.zip'
],
<
String
>[
'common'
,
'flutter_patched_sdk_product.zip'
],
if
(
cache
.
includeAllPlatforms
)
...<
List
<
String
>>[
<
String
>[
'windows-x64'
,
'windows-x64/artifacts.zip'
],
<
String
>[
'linux-
$arch
'
,
'linux-
$arch
/artifacts.zip'
],
<
String
>[
'darwin-x64'
,
'darwin-x64/artifacts.zip'
],
]
else
if
(
_platform
.
isWindows
)
<
String
>[
'windows-x64'
,
'windows-x64/artifacts.zip'
]
else
if
(
_platform
.
isMacOS
)
<
String
>[
'darwin-x64'
,
'darwin-x64/artifacts.zip'
]
else
if
(
_platform
.
isLinux
)
<
String
>[
'linux-
$arch
'
,
'linux-
$arch
/artifacts.zip'
],
];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
class
MacOSEngineArtifacts
extends
EngineCachedArtifact
{
MacOSEngineArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'macos-sdk'
,
cache
,
DevelopmentArtifact
.
macOS
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
if
(
_platform
.
isMacOS
||
ignorePlatformFiltering
)
{
return
_macOSDesktopBinaryDirs
;
}
return
const
<
List
<
String
>>[];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
/// Artifacts required for desktop Windows builds.
class
WindowsEngineArtifacts
extends
EngineCachedArtifact
{
WindowsEngineArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'windows-sdk'
,
cache
,
DevelopmentArtifact
.
windows
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
if
(
_platform
.
isWindows
||
ignorePlatformFiltering
)
{
return
_windowsDesktopBinaryDirs
;
}
return
const
<
List
<
String
>>[];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
/// Artifacts required for desktop Linux builds.
class
LinuxEngineArtifacts
extends
EngineCachedArtifact
{
LinuxEngineArtifacts
(
Cache
cache
,
{
@required
Platform
platform
})
:
_platform
=
platform
,
super
(
'linux-sdk'
,
cache
,
DevelopmentArtifact
.
linux
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
if
(
_platform
.
isLinux
||
ignorePlatformFiltering
)
{
final
String
arch
=
cache
.
getHostPlatformArchName
();
return
<
List
<
String
>>[
<
String
>[
'linux-
$arch
'
,
'linux-
$arch
/linux-
$arch
-flutter-gtk.zip'
],
<
String
>[
'linux-
$arch
-profile'
,
'linux-
$arch
-profile/linux-
$arch
-flutter-gtk.zip'
],
<
String
>[
'linux-
$arch
-release'
,
'linux-
$arch
-release/linux-
$arch
-flutter-gtk.zip'
],
];
}
return
const
<
List
<
String
>>[];
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
}
/// The artifact used to generate snapshots for Android builds.
class
AndroidGenSnapshotArtifacts
extends
EngineCachedArtifact
{
AndroidGenSnapshotArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'android-sdk'
,
cache
,
DevelopmentArtifact
.
androidGenSnapshot
,
);
final
Platform
_platform
;
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
return
<
List
<
String
>>[
if
(
cache
.
includeAllPlatforms
)
...<
List
<
String
>>[
...
_osxBinaryDirs
,
...
_linuxBinaryDirs
,
...
_windowsBinaryDirs
,
...
_dartSdks
,
]
else
if
(
_platform
.
isWindows
)
...
_windowsBinaryDirs
else
if
(
_platform
.
isMacOS
)
...
_osxBinaryDirs
else
if
(
_platform
.
isLinux
)
...
_linuxBinaryDirs
,
];
}
@override
List
<
String
>
getLicenseDirs
()
{
return
<
String
>[];
}
}
/// A cached artifact containing the Maven dependencies used to build Android projects.
///
/// This is a no-op if the android SDK is not available.
class
AndroidMavenArtifacts
extends
ArtifactSet
{
AndroidMavenArtifacts
(
this
.
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
DevelopmentArtifact
.
androidMaven
);
final
Platform
_platform
;
final
Cache
cache
;
@override
Future
<
void
>
update
(
ArtifactUpdater
artifactUpdater
,
Logger
logger
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(
globals
.
androidSdk
==
null
)
{
return
;
}
final
Directory
tempDir
=
cache
.
getRoot
().
createTempSync
(
'flutter_gradle_wrapper.'
,
);
globals
.
gradleUtils
.
injectGradleWrapperIfNeeded
(
tempDir
);
final
Status
status
=
logger
.
startProgress
(
'Downloading Android Maven dependencies...'
);
final
File
gradle
=
tempDir
.
childFile
(
_platform
.
isWindows
?
'gradlew.bat'
:
'gradlew'
,
);
try
{
final
String
gradleExecutable
=
gradle
.
absolute
.
path
;
final
String
flutterSdk
=
globals
.
fsUtils
.
escapePath
(
Cache
.
flutterRoot
);
final
RunResult
processResult
=
await
globals
.
processUtils
.
run
(
<
String
>[
gradleExecutable
,
'-b'
,
globals
.
fs
.
path
.
join
(
flutterSdk
,
'packages'
,
'flutter_tools'
,
'gradle'
,
'resolve_dependencies.gradle'
),
'--project-cache-dir'
,
tempDir
.
path
,
'resolveDependencies'
,
],
environment:
<
String
,
String
>{
if
(
javaPath
!=
null
)
'JAVA_HOME'
:
javaPath
,
},
);
if
(
processResult
.
exitCode
!=
0
)
{
logger
.
printError
(
'Failed to download the Android dependencies'
);
}
}
finally
{
status
.
stop
();
tempDir
.
deleteSync
(
recursive:
true
);
globals
.
androidSdk
?.
reinitialize
();
}
}
@override
Future
<
bool
>
isUpToDate
(
FileSystem
fileSystem
)
async
{
// The dependencies are downloaded and cached by Gradle.
// The tool doesn't know if the dependencies are already cached at this point.
// Therefore, call Gradle to figure this out.
return
false
;
}
@override
String
get
name
=>
'android-maven-artifacts'
;
}
/// Artifacts used for internal builds. The flutter tool builds Android projects
/// using the artifacts cached by [AndroidMavenArtifacts].
class
AndroidInternalBuildArtifacts
extends
EngineCachedArtifact
{
AndroidInternalBuildArtifacts
(
Cache
cache
)
:
super
(
'android-internal-build-artifacts'
,
cache
,
DevelopmentArtifact
.
androidInternalBuild
,
);
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
return
_androidBinaryDirs
;
}
@override
List
<
String
>
getLicenseDirs
()
{
return
<
String
>[];
}
}
class
IOSEngineArtifacts
extends
EngineCachedArtifact
{
IOSEngineArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'ios-sdk'
,
cache
,
DevelopmentArtifact
.
iOS
,
);
final
Platform
_platform
;
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
return
<
List
<
String
>>[
if
(
_platform
.
isMacOS
||
ignorePlatformFiltering
)
...
_iosBinaryDirs
,
];
}
@override
List
<
String
>
getLicenseDirs
()
{
if
(
_platform
.
isMacOS
||
ignorePlatformFiltering
)
{
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.
///
/// While this is only required for Android, we need to always download it due
/// the ensurePlatformSpecificTooling logic.
class
GradleWrapper
extends
CachedArtifact
{
GradleWrapper
(
Cache
cache
)
:
super
(
'gradle_wrapper'
,
cache
,
DevelopmentArtifact
.
universal
,
);
List
<
String
>
get
_gradleScripts
=>
<
String
>[
'gradlew'
,
'gradlew.bat'
];
Uri
_toStorageUri
(
String
path
)
=>
Uri
.
parse
(
'
${cache.storageBaseUrl}
/
$path
'
);
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
final
Uri
archiveUri
=
_toStorageUri
(
version
);
await
artifactUpdater
.
downloadZippedTarball
(
'Downloading Gradle Wrapper...'
,
archiveUri
,
location
);
// Delete property file, allowing templates to provide it.
// Remove NOTICE file. Should not be part of the template.
final
File
propertiesFile
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
location
.
path
,
'gradle'
,
'wrapper'
,
'gradle-wrapper.properties'
));
final
File
noticeFile
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
location
.
path
,
'NOTICE'
));
ErrorHandlingFileSystem
.
deleteIfExists
(
propertiesFile
);
ErrorHandlingFileSystem
.
deleteIfExists
(
noticeFile
);
}
@override
bool
isUpToDateInner
(
FileSystem
fileSystem
,
)
{
final
String
gradleWrapper
=
fileSystem
.
path
.
join
(
'gradle'
,
'wrapper'
,
'gradle-wrapper.jar'
);
final
Directory
wrapperDir
=
cache
.
getCacheDir
(
fileSystem
.
path
.
join
(
'artifacts'
,
'gradle_wrapper'
));
if
(!
fileSystem
.
directory
(
wrapperDir
).
existsSync
())
{
return
false
;
}
for
(
final
String
scriptName
in
_gradleScripts
)
{
final
File
scriptFile
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
wrapperDir
.
path
,
scriptName
));
if
(!
scriptFile
.
existsSync
())
{
return
false
;
}
}
final
File
gradleWrapperJar
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
wrapperDir
.
path
,
gradleWrapper
));
if
(!
gradleWrapperJar
.
existsSync
())
{
return
false
;
}
return
true
;
}
}
const
String
_cipdBaseUrl
=
'https://chrome-infra-packages.appspot.com/dl'
;
/// Common functionality for pulling Fuchsia SDKs.
abstract
class
_FuchsiaSDKArtifacts
extends
CachedArtifact
{
_FuchsiaSDKArtifacts
(
Cache
cache
,
String
platform
)
:
_path
=
'fuchsia/sdk/core/
$platform
-amd64'
,
super
(
'fuchsia-
$platform
'
,
cache
,
DevelopmentArtifact
.
fuchsia
,
);
final
String
_path
;
@override
Directory
get
location
=>
cache
.
getArtifactDirectory
(
'fuchsia'
);
Future
<
void
>
_doUpdate
(
ArtifactUpdater
artifactUpdater
)
{
final
String
url
=
'
$_cipdBaseUrl
/
$_path
/+/
$version
'
;
return
artifactUpdater
.
downloadZipArchive
(
'Downloading package fuchsia SDK...'
,
Uri
.
parse
(
url
),
location
);
}
}
/// The pre-built flutter runner for Fuchsia development.
class
FlutterRunnerSDKArtifacts
extends
CachedArtifact
{
FlutterRunnerSDKArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
'flutter_runner'
,
cache
,
DevelopmentArtifact
.
flutterRunner
,
);
final
Platform
_platform
;
@override
Directory
get
location
=>
cache
.
getArtifactDirectory
(
'flutter_runner'
);
@override
String
get
version
=>
cache
.
getVersionFor
(
'engine'
);
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isLinux
&&
!
_platform
.
isMacOS
)
{
return
;
}
final
String
url
=
'
$_cipdBaseUrl
/flutter/fuchsia/+/git_revision:
$version
'
;
await
artifactUpdater
.
downloadZipArchive
(
'Downloading package flutter runner...'
,
Uri
.
parse
(
url
),
location
);
}
}
/// Implementations of this class can resolve URLs for packages that are versioned.
///
/// See also [CipdArchiveResolver].
abstract
class
VersionedPackageResolver
{
const
VersionedPackageResolver
();
/// Returns the URL for the artifact.
String
resolveUrl
(
String
packageName
,
String
version
);
}
/// Resolves the CIPD archive URL for a given package and version.
class
CipdArchiveResolver
extends
VersionedPackageResolver
{
const
CipdArchiveResolver
();
@override
String
resolveUrl
(
String
packageName
,
String
version
)
{
return
'
$_cipdBaseUrl
/flutter/
$packageName
/+/git_revision:
$version
'
;
}
}
/// The debug symbols for flutter runner for Fuchsia development.
class
FlutterRunnerDebugSymbols
extends
CachedArtifact
{
FlutterRunnerDebugSymbols
(
Cache
cache
,
{
@required
Platform
platform
,
this
.
packageResolver
=
const
CipdArchiveResolver
(),
})
:
_platform
=
platform
,
super
(
'flutter_runner_debug_symbols'
,
cache
,
DevelopmentArtifact
.
flutterRunner
);
final
VersionedPackageResolver
packageResolver
;
final
Platform
_platform
;
@override
Directory
get
location
=>
cache
.
getArtifactDirectory
(
name
);
@override
String
get
version
=>
cache
.
getVersionFor
(
'engine'
);
Future
<
void
>
_downloadDebugSymbols
(
String
targetArch
,
ArtifactUpdater
artifactUpdater
)
async
{
final
String
packageName
=
'fuchsia-debug-symbols-
$targetArch
'
;
final
String
url
=
packageResolver
.
resolveUrl
(
packageName
,
version
);
await
artifactUpdater
.
downloadZipArchive
(
'Downloading debug symbols for flutter runner - arch:
$targetArch
...'
,
Uri
.
parse
(
url
),
location
,
);
}
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isLinux
&&
!
_platform
.
isMacOS
)
{
return
;
}
await
_downloadDebugSymbols
(
'x64'
,
artifactUpdater
);
await
_downloadDebugSymbols
(
'arm64'
,
artifactUpdater
);
}
}
/// The Fuchsia core SDK for Linux.
class
LinuxFuchsiaSDKArtifacts
extends
_FuchsiaSDKArtifacts
{
LinuxFuchsiaSDKArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
cache
,
'linux'
);
final
Platform
_platform
;
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isLinux
)
{
return
;
}
return
_doUpdate
(
artifactUpdater
);
}
}
/// The Fuchsia core SDK for MacOS.
class
MacOSFuchsiaSDKArtifacts
extends
_FuchsiaSDKArtifacts
{
MacOSFuchsiaSDKArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
cache
,
'mac'
);
final
Platform
_platform
;
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isMacOS
)
{
return
;
}
return
_doUpdate
(
artifactUpdater
);
}
}
/// Cached artifacts for font subsetting.
class
FontSubsetArtifacts
extends
EngineCachedArtifact
{
FontSubsetArtifacts
(
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
artifactName
,
cache
,
DevelopmentArtifact
.
universal
);
final
Platform
_platform
;
static
const
String
artifactName
=
'font-subset'
;
@override
List
<
List
<
String
>>
getBinaryDirs
()
{
// Currently only Linux supports both arm64 and x64.
final
String
arch
=
cache
.
getHostPlatformArchName
();
final
Map
<
String
,
List
<
String
>>
artifacts
=
<
String
,
List
<
String
>>
{
'macos'
:
<
String
>[
'darwin-x64'
,
'darwin-x64/
$artifactName
.zip'
],
'linux'
:
<
String
>[
'linux-
$arch
'
,
'linux-
$arch
/
$artifactName
.zip'
],
'windows'
:
<
String
>[
'windows-x64'
,
'windows-x64/
$artifactName
.zip'
],
};
if
(
cache
.
includeAllPlatforms
)
{
return
artifacts
.
values
.
toList
();
}
else
{
final
List
<
String
>
binaryDirs
=
artifacts
[
_platform
.
operatingSystem
];
if
(
binaryDirs
==
null
)
{
throwToolExit
(
'Unsupported operating system:
${_platform.operatingSystem}
'
);
}
return
<
List
<
String
>>[
binaryDirs
];
}
}
@override
List
<
String
>
getLicenseDirs
()
=>
const
<
String
>[];
@override
List
<
String
>
getPackageDirs
()
=>
const
<
String
>[];
}
/// Cached iOS/USB binary artifacts.
class
IosUsbArtifacts
extends
CachedArtifact
{
IosUsbArtifacts
(
String
name
,
Cache
cache
,
{
@required
Platform
platform
,
})
:
_platform
=
platform
,
super
(
name
,
cache
,
DevelopmentArtifact
.
universal
,
);
final
Platform
_platform
;
static
const
List
<
String
>
artifactNames
=
<
String
>[
'libimobiledevice'
,
'usbmuxd'
,
'libplist'
,
'openssl'
,
'ios-deploy'
,
];
// For unknown reasons, users are getting into bad states where libimobiledevice is
// downloaded but some executables are missing from the zip. The names here are
// used for additional download checks below, so we can re-download if they are
// missing.
static
const
Map
<
String
,
List
<
String
>>
_kExecutables
=
<
String
,
List
<
String
>>{
'libimobiledevice'
:
<
String
>[
'idevicescreenshot'
,
'idevicesyslog'
,
],
'usbmuxd'
:
<
String
>[
'iproxy'
,
],
};
@override
Map
<
String
,
String
>
get
environment
{
return
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
cache
.
getArtifactDirectory
(
name
).
path
,
};
}
@override
bool
isUpToDateInner
(
FileSystem
fileSystem
)
{
final
List
<
String
>
executables
=
_kExecutables
[
name
];
if
(
executables
==
null
)
{
return
true
;
}
for
(
final
String
executable
in
executables
)
{
if
(!
location
.
childFile
(
executable
).
existsSync
())
{
return
false
;
}
}
return
true
;
}
@override
Future
<
void
>
updateInner
(
ArtifactUpdater
artifactUpdater
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
,
)
async
{
if
(!
_platform
.
isMacOS
&&
!
ignorePlatformFiltering
)
{
return
;
}
if
(
location
.
existsSync
())
{
location
.
deleteSync
(
recursive:
true
);
}
await
artifactUpdater
.
downloadZipArchive
(
'Downloading
$name
...'
,
archiveUri
,
location
);
}
@visibleForTesting
Uri
get
archiveUri
=>
Uri
.
parse
(
'
${cache.storageBaseUrl}
/flutter_infra_release/ios-usb-dependencies
${cache.useUnsignedMacBinaries ? '/unsigned' : ''}
/
$name
/
$version
/
$name
.zip'
);
}
// TODO(jonahwilliams): upload debug desktop artifacts to host-debug and
// remove from existing host folder.
// https://github.com/flutter/flutter/issues/38935
const
List
<
List
<
String
>>
_windowsDesktopBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'windows-x64'
,
'windows-x64/windows-x64-flutter.zip'
],
<
String
>[
'windows-x64'
,
'windows-x64/flutter-cpp-client-wrapper.zip'
],
<
String
>[
'windows-x64-profile'
,
'windows-x64-profile/windows-x64-flutter.zip'
],
<
String
>[
'windows-x64-release'
,
'windows-x64-release/windows-x64-flutter.zip'
],
];
const
List
<
List
<
String
>>
_macOSDesktopBinaryDirs
=
<
List
<
String
>>[
<
String
>[
'darwin-x64'
,
'darwin-x64/FlutterMacOS.framework.zip'
],
<
String
>[
'darwin-x64-profile'
,
'darwin-x64-profile/FlutterMacOS.framework.zip'
],
<
String
>[
'darwin-x64-profile'
,
'darwin-x64-profile/artifacts.zip'
],
<
String
>[
'darwin-x64-release'
,
'darwin-x64-release/FlutterMacOS.framework.zip'
],
<
String
>[
'darwin-x64-release'
,
'darwin-x64-release/artifacts.zip'
],
];
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-x64-profile/darwin-x64'
,
'android-x64-profile/darwin-x64.zip'
],
<
String
>[
'android-x64-release/darwin-x64'
,
'android-x64-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-x64-profile/linux-x64'
,
'android-x64-profile/linux-x64.zip'
],
<
String
>[
'android-x64-release/linux-x64'
,
'android-x64-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-x64-profile/windows-x64'
,
'android-x64-profile/windows-x64.zip'
],
<
String
>[
'android-x64-release/windows-x64'
,
'android-x64-release/windows-x64.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
>>
_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-x64-profile'
,
'android-x64-profile/artifacts.zip'
],
<
String
>[
'android-x64-release'
,
'android-x64-release/artifacts.zip'
],
<
String
>[
'android-x86-jit-release'
,
'android-x86-jit-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/runner/flutter_command_runner.dart
View file @
26b9a015
...
@@ -22,12 +22,6 @@ import '../globals.dart' as globals;
...
@@ -22,12 +22,6 @@ import '../globals.dart' as globals;
import
'../tester/flutter_tester.dart'
;
import
'../tester/flutter_tester.dart'
;
import
'../web/web_device.dart'
;
import
'../web/web_device.dart'
;
const
String
kFlutterRootEnvironmentVariableName
=
'FLUTTER_ROOT'
;
// should point to //flutter/ (root of flutter/flutter repo)
const
String
kFlutterEngineEnvironmentVariableName
=
'FLUTTER_ENGINE'
;
// should point to //engine/src/ (root of flutter/engine repo)
const
String
kSnapshotFileName
=
'flutter_tools.snapshot'
;
// in //flutter/bin/cache/
const
String
kFlutterToolsScriptFileName
=
'flutter_tools.dart'
;
// in //flutter/packages/flutter_tools/bin/
const
String
kFlutterEnginePackageName
=
'sky_engine'
;
class
FlutterCommandRunner
extends
CommandRunner
<
void
>
{
class
FlutterCommandRunner
extends
CommandRunner
<
void
>
{
FlutterCommandRunner
({
bool
verboseHelp
=
false
})
:
super
(
FlutterCommandRunner
({
bool
verboseHelp
=
false
})
:
super
(
'flutter'
,
'flutter'
,
...
...
packages/flutter_tools/lib/src/runner/local_engine.dart
View file @
26b9a015
...
@@ -13,8 +13,8 @@ import '../base/file_system.dart';
...
@@ -13,8 +13,8 @@ import '../base/file_system.dart';
import
'../base/logger.dart'
;
import
'../base/logger.dart'
;
import
'../base/platform.dart'
;
import
'../base/platform.dart'
;
import
'../base/user_messages.dart'
hide
userMessages
;
import
'../base/user_messages.dart'
hide
userMessages
;
import
'../cache.dart'
;
import
'../dart/package_map.dart'
;
import
'../dart/package_map.dart'
;
import
'flutter_command_runner.dart'
;
/// A strategy for locating the out/ directory of a local engine build.
/// A strategy for locating the out/ directory of a local engine build.
///
///
...
...
packages/flutter_tools/test/general.shard/artifacts_test.dart
View file @
26b9a015
...
@@ -33,6 +33,7 @@ void main() {
...
@@ -33,6 +33,7 @@ void main() {
platform:
platform
,
platform:
platform
,
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
osUtils:
FakeOperatingSystemUtils
(),
osUtils:
FakeOperatingSystemUtils
(),
artifacts:
<
ArtifactSet
>[],
);
);
artifacts
=
CachedArtifacts
(
artifacts
=
CachedArtifacts
(
fileSystem:
fileSystem
,
fileSystem:
fileSystem
,
...
@@ -187,6 +188,7 @@ void main() {
...
@@ -187,6 +188,7 @@ void main() {
platform:
platform
,
platform:
platform
,
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
osUtils:
FakeOperatingSystemUtils
(),
osUtils:
FakeOperatingSystemUtils
(),
artifacts:
<
ArtifactSet
>[],
);
);
artifacts
=
LocalEngineArtifacts
(
artifacts
=
LocalEngineArtifacts
(
fileSystem
.
path
.
join
(
fileSystem
.
currentDirectory
.
path
,
'out'
,
'android_debug_unopt'
),
fileSystem
.
path
.
join
(
fileSystem
.
currentDirectory
.
path
,
'out'
,
'android_debug_unopt'
),
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
26b9a015
...
@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/base/os.dart';
...
@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/base/os.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/flutter_cache.dart'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:mockito/mockito.dart'
;
...
...
packages/flutter_tools/test/general.shard/project_test.dart
View file @
26b9a015
...
@@ -814,6 +814,7 @@ void _testInMemory(String description, Future<void> Function() testMethod) {
...
@@ -814,6 +814,7 @@ void _testInMemory(String description, Future<void> Function() testMethod) {
transfer
(
Cache
(
transfer
(
Cache
(
fileSystem:
globals
.
fs
,
fileSystem:
globals
.
fs
,
logger:
logger
,
logger:
logger
,
artifacts:
<
ArtifactSet
>[],
osUtils:
OperatingSystemUtils
(
osUtils:
OperatingSystemUtils
(
fileSystem:
globals
.
fs
,
fileSystem:
globals
.
fs
,
logger:
logger
,
logger:
logger
,
...
@@ -858,6 +859,7 @@ void _testInMemory(String description, Future<void> Function() testMethod) {
...
@@ -858,6 +859,7 @@ void _testInMemory(String description, Future<void> Function() testMethod) {
fileSystem:
testFileSystem
,
fileSystem:
testFileSystem
,
osUtils:
globals
.
os
,
osUtils:
globals
.
os
,
platform:
globals
.
platform
,
platform:
globals
.
platform
,
artifacts:
<
ArtifactSet
>[],
),
),
FlutterProjectFactory:
()
=>
FlutterProjectFactory
(
FlutterProjectFactory:
()
=>
FlutterProjectFactory
(
fileSystem:
testFileSystem
,
fileSystem:
testFileSystem
,
...
...
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