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
Hide 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 {
...
@@ -446,6 +446,29 @@ class Cache {
return
overrideUrl
;
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
;
bool
_hasWarnedAboutStorageOverride
=
false
;
void
_maybeWarnAboutStorageOverride
(
String
overrideUrl
)
{
void
_maybeWarnAboutStorageOverride
(
String
overrideUrl
)
{
...
...
packages/flutter_tools/lib/src/flutter_cache.dart
View file @
a2a888ec
...
@@ -198,7 +198,7 @@ class FlutterWebSdk extends CachedArtifact {
...
@@ -198,7 +198,7 @@ class FlutterWebSdk extends CachedArtifact {
}
}
final
String
canvasKitVersion
=
cache
.
getVersionFor
(
'canvaskit'
)!;
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
(
return
artifactUpdater
.
downloadZipArchive
(
'Downloading CanvasKit...'
,
'Downloading CanvasKit...'
,
Uri
.
parse
(
canvasKitUrl
),
Uri
.
parse
(
canvasKitUrl
),
...
@@ -575,8 +575,6 @@ class GradleWrapper extends CachedArtifact {
...
@@ -575,8 +575,6 @@ class GradleWrapper extends CachedArtifact {
}
}
}
}
const
String
_cipdBaseUrl
=
'https://chrome-infra-packages.appspot.com/dl'
;
/// Common functionality for pulling Fuchsia SDKs.
/// Common functionality for pulling Fuchsia SDKs.
abstract
class
_FuchsiaSDKArtifacts
extends
CachedArtifact
{
abstract
class
_FuchsiaSDKArtifacts
extends
CachedArtifact
{
_FuchsiaSDKArtifacts
(
Cache
cache
,
String
platform
)
:
_FuchsiaSDKArtifacts
(
Cache
cache
,
String
platform
)
:
...
@@ -593,7 +591,7 @@ abstract class _FuchsiaSDKArtifacts extends CachedArtifact {
...
@@ -593,7 +591,7 @@ abstract class _FuchsiaSDKArtifacts extends CachedArtifact {
Directory
get
location
=>
cache
.
getArtifactDirectory
(
'fuchsia'
);
Directory
get
location
=>
cache
.
getArtifactDirectory
(
'fuchsia'
);
Future
<
void
>
_doUpdate
(
ArtifactUpdater
artifactUpdater
)
{
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...'
,
return
artifactUpdater
.
downloadZipArchive
(
'Downloading package fuchsia SDK...'
,
Uri
.
parse
(
url
),
location
);
Uri
.
parse
(
url
),
location
);
}
}
...
@@ -627,7 +625,7 @@ class FlutterRunnerSDKArtifacts extends CachedArtifact {
...
@@ -627,7 +625,7 @@ class FlutterRunnerSDKArtifacts extends CachedArtifact {
if
(!
_platform
.
isLinux
&&
!
_platform
.
isMacOS
)
{
if
(!
_platform
.
isLinux
&&
!
_platform
.
isMacOS
)
{
return
;
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
);
await
artifactUpdater
.
downloadZipArchive
(
'Downloading package flutter runner...'
,
Uri
.
parse
(
url
),
location
);
}
}
}
}
...
@@ -644,11 +642,13 @@ abstract class VersionedPackageResolver {
...
@@ -644,11 +642,13 @@ abstract class VersionedPackageResolver {
/// Resolves the CIPD archive URL for a given package and version.
/// Resolves the CIPD archive URL for a given package and version.
class
CipdArchiveResolver
extends
VersionedPackageResolver
{
class
CipdArchiveResolver
extends
VersionedPackageResolver
{
const
CipdArchiveResolver
();
const
CipdArchiveResolver
(
this
.
cache
);
final
Cache
cache
;
@override
@override
String
resolveUrl
(
String
packageName
,
String
version
)
{
String
resolveUrl
(
String
packageName
,
String
version
)
{
return
'
$
_cipdBaseUrl
/flutter/
$packageName
/+/git_revision:
$version
'
;
return
'
$
{cache.cipdBaseUrl}
/flutter/
$packageName
/+/git_revision:
$version
'
;
}
}
}
}
...
@@ -656,9 +656,10 @@ class CipdArchiveResolver extends VersionedPackageResolver {
...
@@ -656,9 +656,10 @@ class CipdArchiveResolver extends VersionedPackageResolver {
class
FlutterRunnerDebugSymbols
extends
CachedArtifact
{
class
FlutterRunnerDebugSymbols
extends
CachedArtifact
{
FlutterRunnerDebugSymbols
(
Cache
cache
,
{
FlutterRunnerDebugSymbols
(
Cache
cache
,
{
required
Platform
platform
,
required
Platform
platform
,
this
.
packageResolver
=
const
CipdArchiveResolver
()
,
VersionedPackageResolver
?
packageResolver
,
})
:
_platform
=
platform
,
})
:
_platform
=
platform
,
super
(
'flutter_runner_debug_symbols'
,
cache
,
DevelopmentArtifact
.
flutterRunner
);
packageResolver
=
packageResolver
??
CipdArchiveResolver
(
cache
),
super
(
'flutter_runner_debug_symbols'
,
cache
,
DevelopmentArtifact
.
flutterRunner
);
final
VersionedPackageResolver
packageResolver
;
final
VersionedPackageResolver
packageResolver
;
final
Platform
_platform
;
final
Platform
_platform
;
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
a2a888ec
...
@@ -730,14 +730,18 @@ void main() {
...
@@ -730,14 +730,18 @@ void main() {
testWithoutContext
(
'FlutterWebSdk fetches web artifacts and deletes previous directory contents'
,
()
async
{
testWithoutContext
(
'FlutterWebSdk fetches web artifacts and deletes previous directory contents'
,
()
async
{
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
File
canvasKitVersionFile
=
fileSystem
.
currentDirectory
final
Directory
internalDir
=
fileSystem
.
currentDirectory
.
childDirectory
(
'cache'
)
.
childDirectory
(
'cache'
)
.
childDirectory
(
'bin'
)
.
childDirectory
(
'bin'
)
.
childDirectory
(
'internal'
)
.
childDirectory
(
'internal'
)
;
.
childFile
(
'canvaskit.version'
);
final
File
canvasKitVersionFile
=
internalDir
.
childFile
(
'canvaskit.version'
);
canvasKitVersionFile
.
createSync
(
recursive:
true
);
canvasKitVersionFile
.
createSync
(
recursive:
true
);
canvasKitVersionFile
.
writeAsStringSync
(
'abcdefg'
);
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
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
fileSystem:
fileSystem
);
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
FakeArtifactUpdater
artifactUpdater
=
FakeArtifactUpdater
();
final
FakeArtifactUpdater
artifactUpdater
=
FakeArtifactUpdater
();
...
@@ -763,7 +767,7 @@ void main() {
...
@@ -763,7 +767,7 @@ void main() {
]);
]);
expect
(
downloads
,
<
String
>[
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'
,
'https://chrome-infra-packages.appspot.com/dl/flutter/web/canvaskit_bundle/+/abcdefg'
,
]);
]);
...
@@ -776,6 +780,51 @@ void main() {
...
@@ -776,6 +780,51 @@ void main() {
expect
(
webCacheDirectory
.
childFile
(
'bar'
),
isNot
(
exists
));
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
{
testWithoutContext
(
'FlutterWebSdk uses tryToDelete to handle directory edge cases'
,
()
async
{
final
FileExceptionHandler
handler
=
FileExceptionHandler
();
final
FileExceptionHandler
handler
=
FileExceptionHandler
();
final
MemoryFileSystem
fileSystem
=
MemoryFileSystem
.
test
(
opHandle:
handler
.
opHandle
);
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