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
3fd36200
Unverified
Commit
3fd36200
authored
Mar 08, 2019
by
Jonah Williams
Committed by
GitHub
Mar 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lazily download artifacts (III) (#27903)
parent
d4a441a0
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
924 additions
and
233 deletions
+924
-233
fuchsia_attach.dart
packages/flutter_tools/bin/fuchsia_attach.dart
+3
-0
xcode_backend.sh
packages/flutter_tools/bin/xcode_backend.sh
+6
-1
net.dart
packages/flutter_tools/lib/src/base/net.dart
+4
-3
cache.dart
packages/flutter_tools/lib/src/cache.dart
+612
-176
build_ios.dart
packages/flutter_tools/lib/src/commands/build_ios.dart
+8
-2
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+0
-2
ide_config.dart
packages/flutter_tools/lib/src/commands/ide_config.dart
+0
-2
precache.dart
packages/flutter_tools/lib/src/commands/precache.dart
+14
-7
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+62
-22
cache_test.dart
packages/flutter_tools/test/cache_test.dart
+209
-17
flutter_command_test.dart
packages/flutter_tools/test/runner/flutter_command_test.dart
+6
-1
No files found.
packages/flutter_tools/bin/fuchsia_attach.dart
View file @
3fd36200
...
@@ -134,4 +134,7 @@ class _FuchsiaAttachCommand extends AttachCommand {
...
@@ -134,4 +134,7 @@ class _FuchsiaAttachCommand extends AttachCommand {
Cache
.
flutterRoot
=
'
$originalWorkingDirectory
/third_party/dart-pkg/git/flutter'
;
Cache
.
flutterRoot
=
'
$originalWorkingDirectory
/third_party/dart-pkg/git/flutter'
;
return
super
.
runCommand
();
return
super
.
runCommand
();
}
}
@override
Future
<
void
>
updateCache
()
async
{}
}
}
packages/flutter_tools/bin/xcode_backend.sh
View file @
3fd36200
...
@@ -84,7 +84,6 @@ BuildApp() {
...
@@ -84,7 +84,6 @@ BuildApp() {
local
framework_path
=
"
${
FLUTTER_ROOT
}
/bin/cache/artifacts/engine/
${
artifact_variant
}
"
local
framework_path
=
"
${
FLUTTER_ROOT
}
/bin/cache/artifacts/engine/
${
artifact_variant
}
"
AssertExists
"
${
framework_path
}
"
AssertExists
"
${
project_path
}
"
AssertExists
"
${
project_path
}
"
local
derived_dir
=
"
${
SOURCE_ROOT
}
/Flutter"
local
derived_dir
=
"
${
SOURCE_ROOT
}
/Flutter"
...
@@ -123,6 +122,12 @@ BuildApp() {
...
@@ -123,6 +122,12 @@ BuildApp() {
flutter_podspec
=
"
${
FLUTTER_ENGINE
}
/out/
${
LOCAL_ENGINE
}
/Flutter.podspec"
flutter_podspec
=
"
${
FLUTTER_ENGINE
}
/out/
${
LOCAL_ENGINE
}
/Flutter.podspec"
fi
fi
# If the framework path does not exist, ensure that it is downloaded.
if
[[
!
-e
"
$1
"
]]
;
then
FLUTTER_ALREADY_LOCKED
=
"true"
RunCommand
"
${
FLUTTER_ROOT
}
/bin/flutter"
precache
--suppress-analytics
fi
if
[[
-e
"
${
project_path
}
/.ios"
]]
;
then
if
[[
-e
"
${
project_path
}
/.ios"
]]
;
then
RunCommand
rm
-rf
--
"
${
derived_dir
}
/engine"
RunCommand
rm
-rf
--
"
${
derived_dir
}
/engine"
mkdir
"
${
derived_dir
}
/engine"
mkdir
"
${
derived_dir
}
/engine"
...
...
packages/flutter_tools/lib/src/base/net.dart
View file @
3fd36200
...
@@ -37,7 +37,8 @@ Future<List<int>> _attempt(Uri url, { bool onlyHeaders = false }) async {
...
@@ -37,7 +37,8 @@ Future<List<int>> _attempt(Uri url, { bool onlyHeaders = false }) async {
printTrace
(
'Downloading:
$url
'
);
printTrace
(
'Downloading:
$url
'
);
HttpClient
httpClient
;
HttpClient
httpClient
;
if
(
context
[
HttpClientFactory
]
!=
null
)
{
if
(
context
[
HttpClientFactory
]
!=
null
)
{
httpClient
=
(
context
[
HttpClientFactory
]
as
HttpClientFactory
)();
// ignore: avoid_as
final
HttpClientFactory
httpClientFactory
=
context
[
HttpClientFactory
];
httpClient
=
httpClientFactory
();
}
else
{
}
else
{
httpClient
=
HttpClient
();
httpClient
=
HttpClient
();
}
}
...
@@ -64,9 +65,9 @@ Future<List<int>> _attempt(Uri url, { bool onlyHeaders = false }) async {
...
@@ -64,9 +65,9 @@ Future<List<int>> _attempt(Uri url, { bool onlyHeaders = false }) async {
// If we're making a HEAD request, we're only checking to see if the URL is
// If we're making a HEAD request, we're only checking to see if the URL is
// valid.
// valid.
if
(
onlyHeaders
)
{
if
(
onlyHeaders
)
{
return
(
response
.
statusCode
==
200
)
?
<
int
>[]
:
null
;
return
(
response
.
statusCode
==
HttpStatus
.
ok
)
?
<
int
>[]
:
null
;
}
}
if
(
response
.
statusCode
!=
200
)
{
if
(
response
.
statusCode
!=
HttpStatus
.
ok
)
{
if
(
response
.
statusCode
>
0
&&
response
.
statusCode
<
500
)
{
if
(
response
.
statusCode
>
0
&&
response
.
statusCode
<
500
)
{
throwToolExit
(
throwToolExit
(
'Download failed.
\n
'
'Download failed.
\n
'
...
...
packages/flutter_tools/lib/src/cache.dart
View file @
3fd36200
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/commands/build_ios.dart
View file @
3fd36200
...
@@ -49,9 +49,15 @@ class BuildIOSCommand extends BuildSubCommand {
...
@@ -49,9 +49,15 @@ class BuildIOSCommand extends BuildSubCommand {
final
String
description
=
'Build an iOS application bundle (Mac OS X host only).'
;
final
String
description
=
'Build an iOS application bundle (Mac OS X host only).'
;
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
void
>
validateCommand
()
async
{
final
bool
forSimulator
=
argResults
[
'simulator'
];
defaultBuildMode
=
forSimulator
?
BuildMode
.
debug
:
BuildMode
.
release
;
defaultBuildMode
=
forSimulator
?
BuildMode
.
debug
:
BuildMode
.
release
;
return
super
.
validateCommand
();
}
bool
get
forSimulator
=>
argResults
[
'simulator'
];
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
getCurrentHostPlatform
()
!=
HostPlatform
.
darwin_x64
)
if
(
getCurrentHostPlatform
()
!=
HostPlatform
.
darwin_x64
)
throwToolExit
(
'Building for iOS is only supported on the Mac.'
);
throwToolExit
(
'Building for iOS is only supported on the Mac.'
);
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
3fd36200
...
@@ -212,8 +212,6 @@ class CreateCommand extends FlutterCommand {
...
@@ -212,8 +212,6 @@ class CreateCommand extends FlutterCommand {
throwToolExit
(
'Neither the --flutter-root command line flag nor the FLUTTER_ROOT environment '
throwToolExit
(
'Neither the --flutter-root command line flag nor the FLUTTER_ROOT environment '
'variable was specified. Unable to find package:flutter.'
,
exitCode:
2
);
'variable was specified. Unable to find package:flutter.'
,
exitCode:
2
);
await
Cache
.
instance
.
updateAll
();
final
String
flutterRoot
=
fs
.
path
.
absolute
(
Cache
.
flutterRoot
);
final
String
flutterRoot
=
fs
.
path
.
absolute
(
Cache
.
flutterRoot
);
final
String
flutterPackagesDirectory
=
fs
.
path
.
join
(
flutterRoot
,
'packages'
);
final
String
flutterPackagesDirectory
=
fs
.
path
.
join
(
flutterRoot
,
'packages'
);
...
...
packages/flutter_tools/lib/src/commands/ide_config.dart
View file @
3fd36200
...
@@ -223,8 +223,6 @@ class IdeConfigCommand extends FlutterCommand {
...
@@ -223,8 +223,6 @@ class IdeConfigCommand extends FlutterCommand {
throwToolExit
(
'Currently, the only supported IDE is IntelliJ
\n
$usage
'
,
exitCode:
2
);
throwToolExit
(
'Currently, the only supported IDE is IntelliJ
\n
$usage
'
,
exitCode:
2
);
}
}
await
Cache
.
instance
.
updateAll
();
if
(
argResults
[
'update-templates'
])
{
if
(
argResults
[
'update-templates'
])
{
_handleTemplateUpdate
();
_handleTemplateUpdate
();
return
null
;
return
null
;
...
...
packages/flutter_tools/lib/src/commands/precache.dart
View file @
3fd36200
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'dart:async'
;
import
'../cache.dart'
;
import
'../globals.dart'
;
import
'../globals.dart'
;
import
'../runner/flutter_command.dart'
;
import
'../runner/flutter_command.dart'
;
...
@@ -11,6 +12,8 @@ class PrecacheCommand extends FlutterCommand {
...
@@ -11,6 +12,8 @@ class PrecacheCommand extends FlutterCommand {
PrecacheCommand
()
{
PrecacheCommand
()
{
argParser
.
addFlag
(
'all-platforms'
,
abbr:
'a'
,
negatable:
false
,
argParser
.
addFlag
(
'all-platforms'
,
abbr:
'a'
,
negatable:
false
,
help:
'Precache artifacts for all platforms.'
);
help:
'Precache artifacts for all platforms.'
);
argParser
.
addFlag
(
'force'
,
abbr:
'f'
,
negatable:
false
,
help:
'Force download of new cached artifacts'
);
}
}
@override
@override
...
@@ -24,14 +27,18 @@ class PrecacheCommand extends FlutterCommand {
...
@@ -24,14 +27,18 @@ class PrecacheCommand extends FlutterCommand {
@override
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
argResults
[
'all-platforms'
])
if
(
argResults
[
'all-platforms'
])
{
cache
.
includeAllPlatforms
=
true
;
cache
.
includeAllPlatforms
=
true
;
}
if
(
cache
.
isUpToDate
())
final
UpdateResult
result
=
cache
.
isUpToDate
(
skipUnknown:
false
);
if
(
result
.
isUpToDate
&&
!
result
.
clobber
&&
!
argResults
[
'force'
])
{
printStatus
(
'Already up-to-date.'
);
printStatus
(
'Already up-to-date.'
);
else
}
else
{
await
cache
.
updateAll
();
await
cache
.
updateAll
(
skipUnknown:
false
,
return
null
;
clobber:
argResults
[
'force'
]
||
result
.
clobber
,
);
}
return
const
FlutterCommandResult
(
ExitStatus
.
success
);
}
}
}
}
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
3fd36200
...
@@ -327,30 +327,43 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -327,30 +327,43 @@ abstract class FlutterCommand extends Command<void> {
}
}
BuildMode
getBuildMode
()
{
BuildMode
getBuildMode
()
{
final
List
<
bool
>
modeFlags
=
<
bool
>[
argResults
[
'debug'
],
argResults
[
'profile'
],
argResults
[
'release'
]];
bool
debug
;
if
(
modeFlags
.
where
((
bool
flag
)
=>
flag
).
length
>
1
)
bool
profile
;
bool
release
;
if
(
argParser
.
options
.
containsKey
(
'debug'
))
{
debug
=
argResults
[
'debug'
];
}
else
{
debug
=
_defaultBuildMode
==
BuildMode
.
debug
;
}
if
(
argParser
.
options
.
containsKey
(
'profile'
))
{
profile
=
argResults
[
'profile'
];
}
else
{
profile
=
_defaultBuildMode
==
BuildMode
.
profile
;
}
if
(
argParser
.
options
.
containsKey
(
'release'
))
{
release
=
argResults
[
'release'
];
}
else
{
release
=
_defaultBuildMode
==
BuildMode
.
release
;
}
if
(
debug
&&
profile
||
debug
&&
release
||
release
&&
profile
)
{
throw
UsageException
(
'Only one of --debug, --profile, or --release can be specified.'
,
null
);
throw
UsageException
(
'Only one of --debug, --profile, or --release can be specified.'
,
null
);
}
final
bool
dynamicFlag
=
argParser
.
options
.
containsKey
(
'dynamic'
)
final
bool
dynamicFlag
=
argParser
.
options
.
containsKey
(
'dynamic'
)
?
argResults
[
'dynamic'
]
?
argResults
[
'dynamic'
]
:
false
;
:
false
;
if
(
argResults
[
'debug'
]
)
{
if
(
debug
)
{
if
(
dynamicFlag
)
if
(
dynamicFlag
)
{
throw
ToolExit
(
'Error: --dynamic requires --release or --profile.'
);
throw
ToolExit
(
'Error: --dynamic requires --release or --profile.'
);
}
return
BuildMode
.
debug
;
return
BuildMode
.
debug
;
}
}
if
(
argResults
[
'profile'
])
if
(
profile
)
{
return
dynamicFlag
?
BuildMode
.
dynamicProfile
:
BuildMode
.
profile
;
return
dynamicFlag
?
BuildMode
.
dynamicProfile
:
BuildMode
.
profile
;
if
(
argResults
[
'release'
])
}
if
(
release
)
{
return
dynamicFlag
?
BuildMode
.
dynamicRelease
:
BuildMode
.
release
;
return
dynamicFlag
?
BuildMode
.
dynamicRelease
:
BuildMode
.
release
;
}
if
(
_defaultBuildMode
==
BuildMode
.
debug
&&
dynamicFlag
)
throw
ToolExit
(
'Error: --dynamic requires --release or --profile.'
);
if
(
_defaultBuildMode
==
BuildMode
.
release
&&
dynamicFlag
)
return
BuildMode
.
dynamicRelease
;
if
(
_defaultBuildMode
==
BuildMode
.
profile
&&
dynamicFlag
)
return
BuildMode
.
dynamicProfile
;
return
_defaultBuildMode
;
return
_defaultBuildMode
;
}
}
...
@@ -388,7 +401,7 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -388,7 +401,7 @@ abstract class FlutterCommand extends Command<void> {
'--patch-number (
${argResults['patch-number']}
) must be an int.'
,
null
);
'--patch-number (
${argResults['patch-number']}
) must be an int.'
,
null
);
}
}
String
extraFrontEndOptions
=
List
<
String
>
extraFrontEndOptions
=
argParser
.
options
.
containsKey
(
FlutterOptions
.
kExtraFrontEndOptions
)
argParser
.
options
.
containsKey
(
FlutterOptions
.
kExtraFrontEndOptions
)
?
argResults
[
FlutterOptions
.
kExtraFrontEndOptions
]
?
argResults
[
FlutterOptions
.
kExtraFrontEndOptions
]
:
null
;
:
null
;
...
@@ -397,9 +410,9 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -397,9 +410,9 @@ abstract class FlutterCommand extends Command<void> {
for
(
String
expFlag
in
argResults
[
FlutterOptions
.
kEnableExperiment
])
{
for
(
String
expFlag
in
argResults
[
FlutterOptions
.
kEnableExperiment
])
{
final
String
flag
=
'--enable-experiment='
+
expFlag
;
final
String
flag
=
'--enable-experiment='
+
expFlag
;
if
(
extraFrontEndOptions
!=
null
)
{
if
(
extraFrontEndOptions
!=
null
)
{
extraFrontEndOptions
+=
','
+
flag
;
extraFrontEndOptions
.
add
(
flag
)
;
}
else
{
}
else
{
extraFrontEndOptions
=
flag
;
extraFrontEndOptions
=
<
String
>[
flag
]
;
}
}
}
}
}
}
...
@@ -425,9 +438,9 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -425,9 +438,9 @@ abstract class FlutterCommand extends Command<void> {
baselineDir:
argParser
.
options
.
containsKey
(
'baseline-dir'
)
baselineDir:
argParser
.
options
.
containsKey
(
'baseline-dir'
)
?
argResults
[
'baseline-dir'
]
?
argResults
[
'baseline-dir'
]
:
null
,
:
null
,
extraFrontEndOptions:
extraFrontEndOptions
,
extraFrontEndOptions:
extraFrontEndOptions
?.
join
(
', '
)
,
extraGenSnapshotOptions:
argParser
.
options
.
containsKey
(
FlutterOptions
.
kExtraGenSnapshotOptions
)
extraGenSnapshotOptions:
argParser
.
options
.
containsKey
(
FlutterOptions
.
kExtraGenSnapshotOptions
)
?
argResults
[
FlutterOptions
.
kExtraGenSnapshotOptions
]
?
argResults
[
FlutterOptions
.
kExtraGenSnapshotOptions
]
?.
join
(
', '
)
:
null
,
:
null
,
buildSharedLibrary:
argParser
.
options
.
containsKey
(
'build-shared-library'
)
buildSharedLibrary:
argParser
.
options
.
containsKey
(
'build-shared-library'
)
?
argResults
[
'build-shared-library'
]
?
argResults
[
'build-shared-library'
]
...
@@ -517,6 +530,33 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -517,6 +530,33 @@ abstract class FlutterCommand extends Command<void> {
);
);
}
}
/// A hook called to populate the cache with a particular target platform
/// or build mode.
///
/// If a command requires specific artifacts, it is it's responsibility to
/// request them here.
Future
<
void
>
updateCache
()
async
{
// Download all artifacts unless told otherwise.
await
cache
.
updateAll
(
buildModes:
<
BuildMode
>[
BuildMode
.
debug
,
BuildMode
.
release
,
BuildMode
.
profile
,
BuildMode
.
dynamicProfile
,
BuildMode
.
dynamicRelease
,
],
targetPlatforms:
<
TargetPlatform
>[
TargetPlatform
.
android_arm
,
TargetPlatform
.
android_arm64
,
TargetPlatform
.
android_x64
,
TargetPlatform
.
android_x86
,
TargetPlatform
.
ios
,
],
clobber:
false
,
skipUnknown:
true
,
);
}
/// Perform validation then call [runCommand] to execute the command.
/// Perform validation then call [runCommand] to execute the command.
/// Return a [Future] that completes with an exit code
/// Return a [Future] that completes with an exit code
/// indicating whether execution was successful.
/// indicating whether execution was successful.
...
@@ -527,11 +567,11 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -527,11 +567,11 @@ abstract class FlutterCommand extends Command<void> {
@mustCallSuper
@mustCallSuper
Future
<
FlutterCommandResult
>
verifyThenRunCommand
(
String
commandPath
)
async
{
Future
<
FlutterCommandResult
>
verifyThenRunCommand
(
String
commandPath
)
async
{
await
validateCommand
();
await
validateCommand
();
// Populate the cache. We call this before pub get below so that the sky_engine
// 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.
// package is available in the flutter cache for pub to find.
if
(
shouldUpdateCache
)
if
(
shouldUpdateCache
)
{
await
cache
.
updateAll
();
await
updateCache
();
}
if
(
shouldRunPub
)
{
if
(
shouldRunPub
)
{
await
pubGet
(
context:
PubContext
.
getVerifyContext
(
name
));
await
pubGet
(
context:
PubContext
.
getVerifyContext
(
name
));
...
...
packages/flutter_tools/test/cache_test.dart
View file @
3fd36200
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/runner/flutter_command_test.dart
View file @
3fd36200
...
@@ -42,7 +42,12 @@ void main() {
...
@@ -42,7 +42,12 @@ void main() {
testUsingContext
(
'honors shouldUpdateCache true'
,
()
async
{
testUsingContext
(
'honors shouldUpdateCache true'
,
()
async
{
final
DummyFlutterCommand
flutterCommand
=
DummyFlutterCommand
(
shouldUpdateCache:
true
);
final
DummyFlutterCommand
flutterCommand
=
DummyFlutterCommand
(
shouldUpdateCache:
true
);
await
flutterCommand
.
run
();
await
flutterCommand
.
run
();
verify
(
cache
.
updateAll
()).
called
(
1
);
verify
(
cache
.
updateAll
(
buildModes:
anyNamed
(
'buildModes'
),
clobber:
anyNamed
(
'clobber'
),
skipUnknown:
anyNamed
(
'skipUnknown'
),
targetPlatforms:
anyNamed
(
'targetPlatforms'
)
)).
called
(
1
);
},
},
overrides:
<
Type
,
Generator
>{
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
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