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
a2a888ec
Unverified
Commit
a2a888ec
authored
Nov 24, 2021
by
Yegor
Committed by
GitHub
Nov 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make CIPD url customizable using FLUTTER_STORAGE_BASE_URL (#94137)
parent
30b6b9e7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
13 deletions
+86
-13
cache.dart
packages/flutter_tools/lib/src/cache.dart
+23
-0
flutter_cache.dart
packages/flutter_tools/lib/src/flutter_cache.dart
+10
-9
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+53
-4
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
a2a888ec
...
...
@@ -446,6 +446,29 @@ class Cache {
return
overrideUrl
;
}
String
get
cipdBaseUrl
{
final
String
?
overrideUrl
=
_platform
.
environment
[
'FLUTTER_STORAGE_BASE_URL'
];
if
(
overrideUrl
==
null
)
{
return
'https://chrome-infra-packages.appspot.com/dl'
;
}
final
Uri
original
;
try
{
original
=
Uri
.
parse
(
overrideUrl
);
}
on
FormatException
catch
(
err
)
{
throwToolExit
(
'"FLUTTER_STORAGE_BASE_URL" contains an invalid URI:
\n
$err
'
);
}
final
String
cipdOverride
=
original
.
replace
(
pathSegments:
<
String
>[
...
original
.
pathSegments
,
'flutter_infra_release'
,
'cipd'
,
],
).
toString
();
return
cipdOverride
;
}
bool
_hasWarnedAboutStorageOverride
=
false
;
void
_maybeWarnAboutStorageOverride
(
String
overrideUrl
)
{
...
...
packages/flutter_tools/lib/src/flutter_cache.dart
View file @
a2a888ec
...
...
@@ -198,7 +198,7 @@ class FlutterWebSdk extends CachedArtifact {
}
final
String
canvasKitVersion
=
cache
.
getVersionFor
(
'canvaskit'
)!;
final
String
canvasKitUrl
=
'
$
_cipdBaseUrl
/flutter/web/canvaskit_bundle/+/
$canvasKitVersion
'
;
final
String
canvasKitUrl
=
'
$
{cache.cipdBaseUrl}
/flutter/web/canvaskit_bundle/+/
$canvasKitVersion
'
;
return
artifactUpdater
.
downloadZipArchive
(
'Downloading CanvasKit...'
,
Uri
.
parse
(
canvasKitUrl
),
...
...
@@ -575,8 +575,6 @@ class GradleWrapper extends CachedArtifact {
}
}
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
)
:
...
...
@@ -593,7 +591,7 @@ abstract class _FuchsiaSDKArtifacts extends CachedArtifact {
Directory
get
location
=>
cache
.
getArtifactDirectory
(
'fuchsia'
);
Future
<
void
>
_doUpdate
(
ArtifactUpdater
artifactUpdater
)
{
final
String
url
=
'
$
_cipdBaseUrl
/
$_path
/+/
$version
'
;
final
String
url
=
'
$
{cache.cipdBaseUrl}
/
$_path
/+/
$version
'
;
return
artifactUpdater
.
downloadZipArchive
(
'Downloading package fuchsia SDK...'
,
Uri
.
parse
(
url
),
location
);
}
...
...
@@ -627,7 +625,7 @@ class FlutterRunnerSDKArtifacts extends CachedArtifact {
if
(!
_platform
.
isLinux
&&
!
_platform
.
isMacOS
)
{
return
;
}
final
String
url
=
'
$
_cipdBaseUrl
/flutter/fuchsia/+/git_revision:
$version
'
;
final
String
url
=
'
$
{cache.cipdBaseUrl}
/flutter/fuchsia/+/git_revision:
$version
'
;
await
artifactUpdater
.
downloadZipArchive
(
'Downloading package flutter runner...'
,
Uri
.
parse
(
url
),
location
);
}
}
...
...
@@ -644,11 +642,13 @@ abstract class VersionedPackageResolver {
/// Resolves the CIPD archive URL for a given package and version.
class
CipdArchiveResolver
extends
VersionedPackageResolver
{
const
CipdArchiveResolver
();
const
CipdArchiveResolver
(
this
.
cache
);
final
Cache
cache
;
@override
String
resolveUrl
(
String
packageName
,
String
version
)
{
return
'
$
_cipdBaseUrl
/flutter/
$packageName
/+/git_revision:
$version
'
;
return
'
$
{cache.cipdBaseUrl}
/flutter/
$packageName
/+/git_revision:
$version
'
;
}
}
...
...
@@ -656,8 +656,9 @@ class CipdArchiveResolver extends VersionedPackageResolver {
class
FlutterRunnerDebugSymbols
extends
CachedArtifact
{
FlutterRunnerDebugSymbols
(
Cache
cache
,
{
required
Platform
platform
,
this
.
packageResolver
=
const
CipdArchiveResolver
()
,
VersionedPackageResolver
?
packageResolver
,
})
:
_platform
=
platform
,
packageResolver
=
packageResolver
??
CipdArchiveResolver
(
cache
),
super
(
'flutter_runner_debug_symbols'
,
cache
,
DevelopmentArtifact
.
flutterRunner
);
final
VersionedPackageResolver
packageResolver
;
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
a2a888ec
...
...
@@ -730,14 +730,18 @@ void main() {
testWithoutContext
(
'FlutterWebSdk fetches web artifacts and deletes previous directory contents'
,
()
async
{
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
File
canvasKitVersionFile
=
fileSystem
.
currentDirectory
final
Directory
internalDir
=
fileSystem
.
currentDirectory
.
childDirectory
(
'cache'
)
.
childDirectory
(
'bin'
)
.
childDirectory
(
'internal'
)
.
childFile
(
'canvaskit.version'
);
.
childDirectory
(
'internal'
)
;
final
File
canvasKitVersionFile
=
internalDir
.
childFile
(
'canvaskit.version'
);
canvasKitVersionFile
.
createSync
(
recursive:
true
);
canvasKitVersionFile
.
writeAsStringSync
(
'abcdefg'
);
final
File
engineVersionFile
=
internalDir
.
childFile
(
'engine.version'
);
engineVersionFile
.
createSync
(
recursive:
true
);
engineVersionFile
.
writeAsStringSync
(
'hijklmnop'
);
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
fileSystem:
fileSystem
);
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
FakeArtifactUpdater
artifactUpdater
=
FakeArtifactUpdater
();
...
...
@@ -763,7 +767,7 @@ void main() {
]);
expect
(
downloads
,
<
String
>[
'https://storage.googleapis.com/flutter_infra_release/flutter/
null
/flutter-web-sdk-linux-x64.zip'
,
'https://storage.googleapis.com/flutter_infra_release/flutter/
hijklmnop
/flutter-web-sdk-linux-x64.zip'
,
'https://chrome-infra-packages.appspot.com/dl/flutter/web/canvaskit_bundle/+/abcdefg'
,
]);
...
...
@@ -776,6 +780,51 @@ void main() {
expect
(
webCacheDirectory
.
childFile
(
'bar'
),
isNot
(
exists
));
});
testWithoutContext
(
'FlutterWebSdk CanvasKit URL can be overridden via FLUTTER_STORAGE_BASE_URL'
,
()
async
{
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Directory
internalDir
=
fileSystem
.
currentDirectory
.
childDirectory
(
'cache'
)
.
childDirectory
(
'bin'
)
.
childDirectory
(
'internal'
);
final
File
canvasKitVersionFile
=
internalDir
.
childFile
(
'canvaskit.version'
);
canvasKitVersionFile
.
createSync
(
recursive:
true
);
canvasKitVersionFile
.
writeAsStringSync
(
'abcdefg'
);
final
File
engineVersionFile
=
internalDir
.
childFile
(
'engine.version'
);
engineVersionFile
.
createSync
(
recursive:
true
);
engineVersionFile
.
writeAsStringSync
(
'hijklmnop'
);
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
fileSystem:
fileSystem
,
platform:
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_STORAGE_BASE_URL'
:
'https://flutter.storage.com/override'
},
),
);
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
FakeArtifactUpdater
artifactUpdater
=
FakeArtifactUpdater
();
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
());
final
List
<
String
>
downloads
=
<
String
>[];
final
List
<
String
>
locations
=
<
String
>[];
artifactUpdater
.
onDownloadZipArchive
=
(
String
message
,
Uri
uri
,
Directory
location
)
{
downloads
.
add
(
uri
.
toString
());
locations
.
add
(
location
.
path
);
location
.
createSync
(
recursive:
true
);
location
.
childFile
(
'foo'
).
createSync
();
};
webCacheDirectory
.
childFile
(
'bar'
).
createSync
(
recursive:
true
);
await
webSdk
.
updateInner
(
artifactUpdater
,
fileSystem
,
FakeOperatingSystemUtils
());
expect
(
downloads
,
<
String
>[
'https://flutter.storage.com/override/flutter_infra_release/flutter/hijklmnop/flutter-web-sdk-linux-x64.zip'
,
'https://flutter.storage.com/override/flutter_infra_release/cipd/flutter/web/canvaskit_bundle/+/abcdefg'
]);
});
testWithoutContext
(
'FlutterWebSdk uses tryToDelete to handle directory edge cases'
,
()
async
{
final
FileExceptionHandler
handler
=
FileExceptionHandler
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
(
opHandle:
handler
.
opHandle
);
...
...
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