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
ac7b3078
Commit
ac7b3078
authored
Jan 21, 2020
by
Jenn Magder
Committed by
Flutter GitHub Bot
Jan 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't pre-cache Android artifacts with --no-android flag (#49009)
parent
975bb08a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
8 deletions
+58
-8
precache.dart
packages/flutter_tools/lib/src/commands/precache.dart
+45
-4
precache_test.dart
...ter_tools/test/commands.shard/hermetic/precache_test.dart
+13
-4
No files found.
packages/flutter_tools/lib/src/commands/precache.dart
View file @
ac7b3078
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'../base/common.dart'
;
import
'../cache.dart'
;
import
'../features.dart'
;
import
'../globals.dart'
as
globals
;
...
...
@@ -57,6 +58,31 @@ class PrecacheCommand extends FlutterCommand {
@override
bool
get
shouldUpdateCache
=>
false
;
/// Some flags are umbrella names that expand to include multiple artifacts.
static
const
Map
<
String
,
List
<
String
>>
_expandedArtifacts
=
<
String
,
List
<
String
>>{
'android'
:
<
String
>[
'android_gen_snapshot'
,
'android_maven'
,
'android_internal_build'
,
]
};
@override
Future
<
void
>
validateCommand
()
{
_expandedArtifacts
.
forEach
((
String
umbrellaName
,
List
<
String
>
childArtifactNames
)
{
if
(!
argResults
.
arguments
.
contains
(
'--no-
$umbrellaName
'
))
{
return
;
}
for
(
final
String
childArtifactName
in
childArtifactNames
)
{
if
(
argResults
.
arguments
.
contains
(
'--
$childArtifactName
'
))
{
throwToolExit
(
'--
$childArtifactName
requires --
$umbrellaName
'
);
}
}
});
return
super
.
validateCommand
();
}
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
if
(
boolArg
(
'all-platforms'
))
{
...
...
@@ -74,11 +100,26 @@ class PrecacheCommand extends FlutterCommand {
if
(
artifact
.
feature
!=
null
&&
!
featureFlags
.
isEnabled
(
artifact
.
feature
))
{
continue
;
}
if
(
boolArg
(
artifact
.
name
))
{
bool
expandedArtifactProcessed
=
false
;
_expandedArtifacts
.
forEach
((
String
umbrellaName
,
List
<
String
>
childArtifactNames
)
{
if
(!
childArtifactNames
.
contains
(
artifact
.
name
))
{
return
;
}
expandedArtifactProcessed
=
true
;
// Expanded artifacts options are true by default.
// Explicitly ignore them if umbrella name is excluded.
// Example: --no-android [--android_gen_snapshot]
if
(!
boolArg
(
umbrellaName
))
{
return
;
}
// Example: --android [--android_gen_snapshot]
requiredArtifacts
.
add
(
artifact
);
}
// The `android` flag expands to android_gen_snapshot, android_maven, android_internal_build.
if
(
artifact
.
name
.
startsWith
(
'android_'
)
&&
boolArg
(
'android'
))
{
}
);
if
(
!
expandedArtifactProcessed
&&
boolArg
(
artifact
.
name
))
{
requiredArtifacts
.
add
(
artifact
);
}
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart
View file @
ac7b3078
...
...
@@ -44,8 +44,6 @@ void main() {
expect
(
artifacts
,
unorderedEquals
(<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
,
DevelopmentArtifact
.
web
,
DevelopmentArtifact
.
androidGenSnapshot
,
DevelopmentArtifact
.
androidMaven
,
}));
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
...
...
@@ -59,14 +57,25 @@ void main() {
expect
(
artifacts
,
unorderedEquals
(<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
,
DevelopmentArtifact
.
androidGenSnapshot
,
DevelopmentArtifact
.
androidMaven
,
}));
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
false
),
});
testUsingContext
(
'precache exits if requesting mismatched artifacts.'
,
()
async
{
final
PrecacheCommand
command
=
PrecacheCommand
();
applyMocksToCommand
(
command
);
expect
(
createTestCommandRunner
(
command
).
run
(
const
<
String
>[
'precache'
,
'--no-android'
,
'--android_gen_snapshot'
,
]),
throwsToolExit
(
message:
'--android_gen_snapshot requires --android'
));
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
cache
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
false
),
});
testUsingContext
(
'precache adds artifact flags to requested artifacts'
,
()
async
{
final
PrecacheCommand
command
=
PrecacheCommand
();
applyMocksToCommand
(
command
);
...
...
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