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
897e3db4
Unverified
Commit
897e3db4
authored
Mar 23, 2023
by
Harry Terkelsen
Committed by
GitHub
Mar 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inject the gstatic CanvasKit CDN URL by default in `flutter build web` (#122772)
parent
cbdee525
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
1 deletion
+54
-1
build_web.dart
packages/flutter_tools/lib/src/commands/build_web.dart
+1
-0
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+1
-0
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+18
-0
build_web_test.dart
...er_tools/test/commands.shard/hermetic/build_web_test.dart
+34
-1
No files found.
packages/flutter_tools/lib/src/commands/build_web.dart
View file @
897e3db4
...
@@ -60,6 +60,7 @@ class BuildWebCommand extends BuildSubCommand {
...
@@ -60,6 +60,7 @@ class BuildWebCommand extends BuildSubCommand {
},
},
);
);
usesWebRendererOption
();
usesWebRendererOption
();
usesWebResourcesCdnFlag
();
//
//
// JavaScript compilation options
// JavaScript compilation options
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
897e3db4
...
@@ -38,6 +38,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
...
@@ -38,6 +38,7 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
usesDartDefineOption
();
usesDartDefineOption
();
usesFlavorOption
();
usesFlavorOption
();
usesWebRendererOption
();
usesWebRendererOption
();
usesWebResourcesCdnFlag
();
addNativeNullAssertions
(
hide:
!
verboseHelp
);
addNativeNullAssertions
(
hide:
!
verboseHelp
);
addBundleSkSLPathOption
(
hide:
!
verboseHelp
);
addBundleSkSLPathOption
(
hide:
!
verboseHelp
);
usesApplicationBinaryOption
();
usesApplicationBinaryOption
();
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
897e3db4
...
@@ -125,6 +125,7 @@ class FlutterOptions {
...
@@ -125,6 +125,7 @@ class FlutterOptions {
static
const
String
kUseApplicationBinary
=
'use-application-binary'
;
static
const
String
kUseApplicationBinary
=
'use-application-binary'
;
static
const
String
kWebBrowserFlag
=
'web-browser-flag'
;
static
const
String
kWebBrowserFlag
=
'web-browser-flag'
;
static
const
String
kWebRendererFlag
=
'web-renderer'
;
static
const
String
kWebRendererFlag
=
'web-renderer'
;
static
const
String
kWebResourcesCdnFlag
=
'web-resources-cdn'
;
}
}
/// flutter command categories for usage.
/// flutter command categories for usage.
...
@@ -668,6 +669,14 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -668,6 +669,14 @@ abstract class FlutterCommand extends Command<void> {
);
);
}
}
void
usesWebResourcesCdnFlag
()
{
// TODO(hterkelsen): Default to true once we have a smoke test.
argParser
.
addFlag
(
FlutterOptions
.
kWebResourcesCdnFlag
,
help:
'Use Web static resources hosted on a CDN.'
,
);
}
void
usesDeviceUserOption
()
{
void
usesDeviceUserOption
()
{
argParser
.
addOption
(
FlutterOptions
.
kDeviceUser
,
argParser
.
addOption
(
FlutterOptions
.
kDeviceUser
,
help:
'Identifier number for a user or work profile on Android only. Run "adb shell pm list users" for available identifiers.'
,
help:
'Identifier number for a user or work profile on Android only. Run "adb shell pm list users" for available identifiers.'
,
...
@@ -1207,6 +1216,15 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -1207,6 +1216,15 @@ abstract class FlutterCommand extends Command<void> {
dartDefines
=
updateDartDefines
(
dartDefines
,
webRenderer
);
dartDefines
=
updateDartDefines
(
dartDefines
,
webRenderer
);
}
}
if
(
argParser
.
options
.
containsKey
(
FlutterOptions
.
kWebResourcesCdnFlag
))
{
final
bool
hasLocalWebSdk
=
argParser
.
options
.
containsKey
(
'local-web-sdk'
)
&&
stringArg
(
'local-web-sdk'
)
!=
null
;
if
(
boolArg
(
FlutterOptions
.
kWebResourcesCdnFlag
)
&&
!
hasLocalWebSdk
)
{
if
(!
dartDefines
.
any
((
String
define
)
=>
define
.
startsWith
(
'FLUTTER_WEB_CANVASKIT_URL='
)))
{
dartDefines
.
add
(
'FLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/
${globals.flutterVersion.engineRevision}
/'
);
}
}
}
return
BuildInfo
(
buildMode
,
return
BuildInfo
(
buildMode
,
argParser
.
options
.
containsKey
(
'flavor'
)
argParser
.
options
.
containsKey
(
'flavor'
)
?
stringArg
(
'flavor'
)
?
stringArg
(
'flavor'
)
...
...
packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
View file @
897e3db4
...
@@ -112,7 +112,7 @@ void main() {
...
@@ -112,7 +112,7 @@ void main() {
);
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
setupFileSystemForEndToEndTest
(
fileSystem
);
setupFileSystemForEndToEndTest
(
fileSystem
);
await
runner
.
run
(<
String
>[
'build'
,
'web'
,
'--no-pub'
,
'--dart-define=foo=a'
,
'--dart2js-optimization=O3'
]);
await
runner
.
run
(<
String
>[
'build'
,
'web'
,
'--no-pub'
,
'--
no-web-resources-cdn'
,
'--
dart-define=foo=a'
,
'--dart2js-optimization=O3'
]);
final
Directory
buildDir
=
fileSystem
.
directory
(
fileSystem
.
path
.
join
(
'build'
,
'web'
));
final
Directory
buildDir
=
fileSystem
.
directory
(
fileSystem
.
path
.
join
(
'build'
,
'web'
));
...
@@ -164,6 +164,7 @@ void main() {
...
@@ -164,6 +164,7 @@ void main() {
'build'
,
'build'
,
'web'
,
'web'
,
'--no-pub'
,
'--no-pub'
,
'--no-web-resources-cdn'
,
'--output=
$newBuildDir
'
'--output=
$newBuildDir
'
]);
]);
...
@@ -251,6 +252,38 @@ void main() {
...
@@ -251,6 +252,38 @@ void main() {
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
BuildSystem:
()
=>
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
BuildSystem:
()
=>
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
});
});
testUsingContext
(
'Defaults to gstatic CanvasKit artifacts'
,
()
async
{
final
TestWebBuildCommand
buildCommand
=
TestWebBuildCommand
(
fileSystem:
fileSystem
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
setupFileSystemForEndToEndTest
(
fileSystem
);
await
runner
.
run
(<
String
>[
'build'
,
'web'
,
'--no-pub'
,
'--web-resources-cdn'
]);
final
BuildInfo
buildInfo
=
await
buildCommand
.
webCommand
.
getBuildInfo
(
forcedBuildMode:
BuildMode
.
debug
);
expect
(
buildInfo
.
dartDefines
,
contains
(
startsWith
(
'FLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/'
)));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
BuildSystem:
()
=>
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
});
testUsingContext
(
'Does not override custom CanvasKit URL'
,
()
async
{
final
TestWebBuildCommand
buildCommand
=
TestWebBuildCommand
(
fileSystem:
fileSystem
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
setupFileSystemForEndToEndTest
(
fileSystem
);
await
runner
.
run
(<
String
>[
'build'
,
'web'
,
'--no-pub'
,
'--web-resources-cdn'
,
'--dart-define=FLUTTER_WEB_CANVASKIT_URL=abcdefg'
]);
final
BuildInfo
buildInfo
=
await
buildCommand
.
webCommand
.
getBuildInfo
(
forcedBuildMode:
BuildMode
.
debug
);
expect
(
buildInfo
.
dartDefines
,
contains
(
'FLUTTER_WEB_CANVASKIT_URL=abcdefg'
));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
BuildSystem:
()
=>
TestBuildSystem
.
all
(
BuildResult
(
success:
true
)),
});
}
}
void
setupFileSystemForEndToEndTest
(
FileSystem
fileSystem
)
{
void
setupFileSystemForEndToEndTest
(
FileSystem
fileSystem
)
{
...
...
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