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
42bd5f2b
Unverified
Commit
42bd5f2b
authored
Jan 26, 2023
by
Harry Terkelsen
Committed by
GitHub
Jan 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Download platform-agnostic Flutter Web SDK in the flutter_tool (#118654)
parent
1b779b65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
88 deletions
+9
-88
flutter_cache.dart
packages/flutter_tools/lib/src/flutter_cache.dart
+4
-30
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+5
-58
No files found.
packages/flutter_tools/lib/src/flutter_cache.dart
View file @
42bd5f2b
...
...
@@ -37,7 +37,7 @@ class FlutterCache extends Cache {
registerArtifact
(
AndroidGenSnapshotArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
AndroidInternalBuildArtifacts
(
this
));
registerArtifact
(
IOSEngineArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
FlutterWebSdk
(
this
,
platform:
platform
));
registerArtifact
(
FlutterWebSdk
(
this
));
registerArtifact
(
FlutterSdk
(
this
,
platform:
platform
));
registerArtifact
(
WindowsEngineArtifacts
(
this
,
platform:
platform
));
registerArtifact
(
MacOSEngineArtifacts
(
this
,
platform:
platform
));
...
...
@@ -158,16 +158,13 @@ class MaterialFonts extends CachedArtifact {
///
/// 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
(
FlutterWebSdk
(
Cache
cache
)
:
super
(
'flutter_web_sdk'
,
cache
,
DevelopmentArtifact
.
web
,
);
final
Platform
_platform
;
@override
Directory
get
location
=>
cache
.
getWebSdkDirectory
();
...
...
@@ -180,15 +177,7 @@ class FlutterWebSdk extends CachedArtifact {
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'
);
final
Uri
url
=
Uri
.
parse
(
'
${cache.storageBaseUrl}
/flutter_infra_release/flutter/
$version
/flutter-web-sdk.zip'
);
ErrorHandlingFileSystem
.
deleteIfExists
(
location
,
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.
...
...
@@ -205,21 +194,6 @@ class FlutterWebSdk extends CachedArtifact {
entity
.
copySync
(
newPath
);
}
}
// If the flutter_web_sdk folder doesn't already contain CanvasKit, then
// download it from CIPD.
// TODO(hterkelsen): This whole section can be removed when we are always building
// CanvasKit as part of flutter_web_sdk. See https://github.com/flutter/flutter/issues/113073
final
File
expectedCanvasKitFile
=
fileSystem
.
file
(
fileSystem
.
path
.
join
(
location
.
path
,
'canvaskit'
,
'canvaskit.wasm'
));
if
(!
expectedCanvasKitFile
.
existsSync
())
{
final
String
canvasKitVersion
=
cache
.
getVersionFor
(
'canvaskit'
)!;
final
String
canvasKitUrl
=
'
${cache.cipdBaseUrl}
/flutter/web/canvaskit_bundle/+/
$canvasKitVersion
'
;
return
artifactUpdater
.
downloadZipArchive
(
'Downloading CanvasKit...'
,
Uri
.
parse
(
canvasKitUrl
),
location
,
);
}
}
}
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
42bd5f2b
...
...
@@ -760,7 +760,7 @@ void main() {
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
fileSystem:
fileSystem
);
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
FakeArtifactUpdater
artifactUpdater
=
FakeArtifactUpdater
();
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
()
);
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
);
final
List
<
String
>
messages
=
<
String
>[];
final
List
<
String
>
downloads
=
<
String
>[];
...
...
@@ -778,17 +778,14 @@ void main() {
expect
(
messages
,
<
String
>[
'Downloading Web SDK...'
,
'Downloading CanvasKit...'
,
]);
expect
(
downloads
,
<
String
>[
'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://storage.googleapis.com/flutter_infra_release/flutter/hijklmnop/flutter-web-sdk.zip'
,
]);
expect
(
locations
,
<
String
>[
'cache/bin/cache/flutter_web_sdk'
,
'cache/bin/cache/flutter_web_sdk'
,
]);
expect
(
webCacheDirectory
.
childFile
(
'foo'
),
exists
);
...
...
@@ -820,7 +817,7 @@ void main() {
);
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
FakeArtifactUpdater
artifactUpdater
=
FakeArtifactUpdater
();
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
()
);
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
);
final
List
<
String
>
downloads
=
<
String
>[];
final
List
<
String
>
locations
=
<
String
>[];
...
...
@@ -835,57 +832,7 @@ void main() {
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 does not download CanvasKit if it is already in flutter_web_sdk'
,
()
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
);
final
FakeArtifactUpdater
artifactUpdater
=
FakeArtifactUpdater
();
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
());
final
List
<
String
>
messages
=
<
String
>[];
final
List
<
String
>
downloads
=
<
String
>[];
final
List
<
String
>
locations
=
<
String
>[];
artifactUpdater
.
onDownloadZipArchive
=
(
String
message
,
Uri
uri
,
Directory
location
)
{
messages
.
add
(
message
);
downloads
.
add
(
uri
.
toString
());
locations
.
add
(
location
.
path
);
location
.
createSync
(
recursive:
true
);
location
.
childDirectory
(
'canvaskit'
).
createSync
();
location
.
childDirectory
(
'canvaskit'
).
childFile
(
'canvaskit.js'
).
createSync
();
location
.
childDirectory
(
'canvaskit'
).
childFile
(
'canvaskit.wasm'
).
createSync
();
location
.
childDirectory
(
'canvaskit'
).
childDirectory
(
'profiling'
).
createSync
();
location
.
childDirectory
(
'canvaskit'
).
childDirectory
(
'profiling'
).
childFile
(
'canvaskit.js'
).
createSync
();
location
.
childDirectory
(
'canvaskit'
).
childDirectory
(
'profiling'
).
childFile
(
'canvaskit.wasm'
).
createSync
();
};
await
webSdk
.
updateInner
(
artifactUpdater
,
fileSystem
,
FakeOperatingSystemUtils
());
expect
(
messages
,
<
String
>[
'Downloading Web SDK...'
,
]);
expect
(
downloads
,
<
String
>[
'https://storage.googleapis.com/flutter_infra_release/flutter/hijklmnop/flutter-web-sdk-linux-x64.zip'
,
]);
expect
(
locations
,
<
String
>[
'cache/bin/cache/flutter_web_sdk'
,
'https://flutter.storage.com/override/flutter_infra_release/flutter/hijklmnop/flutter-web-sdk.zip'
,
]);
});
...
...
@@ -895,7 +842,7 @@ void main() {
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
fileSystem:
fileSystem
);
final
Directory
webCacheDirectory
=
cache
.
getWebSdkDirectory
();
final
FakeArtifactUpdater
artifactUpdater
=
FakeArtifactUpdater
();
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
,
platform:
FakePlatform
()
);
final
FlutterWebSdk
webSdk
=
FlutterWebSdk
(
cache
);
artifactUpdater
.
onDownloadZipArchive
=
(
String
message
,
Uri
uri
,
Directory
location
)
{
location
.
createSync
(
recursive:
true
);
...
...
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