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
17ec3b1d
Unverified
Commit
17ec3b1d
authored
Nov 01, 2022
by
Elias Yishak
Committed by
GitHub
Nov 01, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Introducing arg option for specifying the output directory for web (#113076)
parent
61deaef5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
9 deletions
+70
-9
build_aar.dart
packages/flutter_tools/lib/src/commands/build_aar.dart
+3
-7
build_web.dart
packages/flutter_tools/lib/src/commands/build_web.dart
+7
-0
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+13
-0
compile.dart
packages/flutter_tools/lib/src/web/compile.dart
+4
-1
build_web_test.dart
...er_tools/test/commands.shard/hermetic/build_web_test.dart
+43
-1
No files found.
packages/flutter_tools/lib/src/commands/build_aar.dart
View file @
17ec3b1d
...
...
@@ -37,6 +37,7 @@ class BuildAarCommand extends BuildSubCommand {
addTreeShakeIconsFlag
();
usesFlavorOption
();
usesBuildNumberOption
();
usesOutputDir
();
usesPubOption
();
addSplitDebugInfoOption
();
addDartObfuscationOption
();
...
...
@@ -47,16 +48,11 @@ class BuildAarCommand extends BuildSubCommand {
addEnableExperimentation
(
hide:
!
verboseHelp
);
addAndroidSpecificBuildOptions
(
hide:
!
verboseHelp
);
argParser
.
.
addMultiOption
(
.
addMultiOption
(
'target-platform'
,
defaultsTo:
<
String
>[
'android-arm'
,
'android-arm64'
,
'android-x64'
],
allowed:
<
String
>[
'android-arm'
,
'android-arm64'
,
'android-x86'
,
'android-x64'
],
help:
'The target platform for which the project is compiled.'
,
)
..
addOption
(
'output-dir'
,
help:
'The absolute path to the directory where the repository is generated. '
'By default, this is "<current-directory>android/build".'
,
);
}
...
...
@@ -142,7 +138,7 @@ class BuildAarCommand extends BuildSubCommand {
project:
_getProject
(),
target:
targetFile
.
path
,
androidBuildInfo:
androidBuildInfo
,
outputDirectoryPath:
stringArg
Deprecated
(
'output-dir
'
),
outputDirectoryPath:
stringArg
(
'output
'
),
buildNumber:
buildNumber
,
);
return
FlutterCommandResult
.
success
();
...
...
packages/flutter_tools/lib/src/commands/build_web.dart
View file @
17ec3b1d
...
...
@@ -19,6 +19,7 @@ class BuildWebCommand extends BuildSubCommand {
})
:
super
(
verboseHelp:
verboseHelp
)
{
addTreeShakeIconsFlag
(
enabledByDefault:
false
);
usesTargetOption
();
usesOutputDir
();
usesPubOption
();
usesBuildNumberOption
();
usesBuildNameOption
();
...
...
@@ -113,6 +114,11 @@ class BuildWebCommand extends BuildSubCommand {
r'Please add `<base href="$FLUTTER_BASE_HREF">` to web/index.html'
);
}
// Currently supporting options [output-dir] and [output] as
// valid approaches for setting output directory of build artifacts
final
String
?
outputDirectoryPath
=
stringArg
(
'output'
);
displayNullSafetyMode
(
buildInfo
);
await
buildWeb
(
flutterProject
,
...
...
@@ -124,6 +130,7 @@ class BuildWebCommand extends BuildSubCommand {
boolArgDeprecated
(
'native-null-assertions'
),
baseHref
,
stringArgDeprecated
(
'dart2js-optimization'
),
outputDirectoryPath:
outputDirectoryPath
,
);
return
FlutterCommandResult
.
success
();
}
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
17ec3b1d
...
...
@@ -392,6 +392,19 @@ abstract class FlutterCommand extends Command<void> {
_usesPortOption
=
true
;
}
/// Add option values for output directory of artifacts
void
usesOutputDir
()
{
// TODO(eliasyishak): this feature has been added to [BuildWebCommand] and
// [BuildAarCommand]
argParser
.
addOption
(
'output'
,
abbr:
'o'
,
aliases:
<
String
>[
'output-dir'
],
help:
'The absolute path to the directory where the repository is generated. '
'By default, this is <current-directory>/build/<target-platform>.
\n
'
'Currently supported for subcommands: aar, web.'
);
}
void
addDevToolsOptions
({
required
bool
verboseHelp
})
{
argParser
.
addFlag
(
kEnableDevTools
,
...
...
packages/flutter_tools/lib/src/web/compile.dart
View file @
17ec3b1d
...
...
@@ -28,10 +28,13 @@ Future<void> buildWeb(
bool
nativeNullAssertions
,
String
?
baseHref
,
String
?
dart2jsOptimization
,
{
String
?
outputDirectoryPath
}
)
async
{
final
bool
hasWebPlugins
=
(
await
findPlugins
(
flutterProject
))
.
any
((
Plugin
p
)
=>
p
.
platforms
.
containsKey
(
WebPlugin
.
kConfigKey
));
final
Directory
outputDirectory
=
globals
.
fs
.
directory
(
getWebBuildDirectory
());
final
Directory
outputDirectory
=
outputDirectoryPath
==
null
?
globals
.
fs
.
directory
(
getWebBuildDirectory
())
:
globals
.
fs
.
directory
(
outputDirectoryPath
);
outputDirectory
.
createSync
(
recursive:
true
);
// The migrators to apply to a Web project.
...
...
packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
View file @
17ec3b1d
...
...
@@ -84,7 +84,7 @@ void main() {
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
testUsingContext
(
'
Builds a web bundle - end to end
'
,
()
async
{
testUsingContext
(
'
Setup for a web build with default output directory
'
,
()
async
{
final
BuildCommand
buildCommand
=
BuildCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
setupFileSystemForEndToEndTest
(
fileSystem
);
...
...
@@ -116,6 +116,48 @@ void main() {
}),
});
testUsingContext
(
'Setup for a web build with a user specified output directory'
,
()
async
{
final
BuildCommand
buildCommand
=
BuildCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
setupFileSystemForEndToEndTest
(
fileSystem
);
const
String
newBuildDir
=
'new_dir'
;
final
Directory
buildDir
=
fileSystem
.
directory
(
fileSystem
.
path
.
join
(
newBuildDir
));
expect
(
buildDir
.
existsSync
(),
false
);
await
runner
.
run
(<
String
>[
'build'
,
'web'
,
'--no-pub'
,
'--output=
$newBuildDir
'
]);
expect
(
buildDir
.
existsSync
(),
true
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
BuildSystem:
()
=>
TestBuildSystem
.
all
(
BuildResult
(
success:
true
),
(
Target
target
,
Environment
environment
)
{
expect
(
environment
.
defines
,
<
String
,
String
>{
'TargetFile'
:
'lib/main.dart'
,
'HasWebPlugins'
:
'true'
,
'cspMode'
:
'false'
,
'SourceMaps'
:
'false'
,
'NativeNullAssertions'
:
'true'
,
'ServiceWorkerStrategy'
:
'offline-first'
,
'BuildMode'
:
'release'
,
'DartDefines'
:
'RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=='
,
'DartObfuscation'
:
'false'
,
'TrackWidgetCreation'
:
'false'
,
'TreeShakeIcons'
:
'false'
,
});
}),
});
testUsingContext
(
'hidden if feature flag is not enabled'
,
()
async
{
expect
(
BuildWebCommand
(
verboseHelp:
false
).
hidden
,
true
);
},
overrides:
<
Type
,
Generator
>{
...
...
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