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
ab260bac
Unverified
Commit
ab260bac
authored
Oct 28, 2019
by
Jonah Williams
Committed by
GitHub
Oct 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor BuildMode into class, add jit_release configuration (#42476)
parent
84299aeb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
22 deletions
+88
-22
build_info.dart
packages/flutter_tools/lib/src/build_info.dart
+64
-21
dart.dart
...ages/flutter_tools/lib/src/build_system/targets/dart.dart
+0
-1
build_info_test.dart
...ges/flutter_tools/test/general.shard/build_info_test.dart
+24
-0
No files found.
packages/flutter_tools/lib/src/build_info.dart
View file @
ab260bac
...
...
@@ -113,35 +113,78 @@ class AndroidBuildInfo {
final
Iterable
<
AndroidArch
>
targetArchs
;
}
/// The type of build.
enum
BuildMode
{
debug
,
profile
,
release
,
}
/// A summary of the compilation strategy used for Dart.
class
BuildMode
{
const
BuildMode
.
_
(
this
.
name
);
factory
BuildMode
.
fromName
(
String
value
)
{
switch
(
value
)
{
case
'debug'
:
return
BuildMode
.
debug
;
case
'profile'
:
return
BuildMode
.
profile
;
case
'release'
:
return
BuildMode
.
release
;
case
'jit_release'
:
return
BuildMode
.
jitRelease
;
}
throw
ArgumentError
(
'
$value
is not a supported build mode'
);
}
const
List
<
String
>
_kBuildModes
=
<
String
>[
'debug'
,
'profile'
,
'release'
,
];
/// Built in JIT mode with no optimizations, enabled asserts, and an observatory.
static
const
BuildMode
debug
=
BuildMode
.
_
(
'debug'
);
/// Built in AOT mode with some optimizations and an observatory.
static
const
BuildMode
profile
=
BuildMode
.
_
(
'profile'
);
/// Built in AOT mode with all optimizations and no observatory.
static
const
BuildMode
release
=
BuildMode
.
_
(
'release'
);
/// Built in JIT mode with all optimizations and no observatory.
static
const
BuildMode
jitRelease
=
BuildMode
.
_
(
'jit_release'
);
static
const
List
<
BuildMode
>
values
=
<
BuildMode
>[
debug
,
profile
,
release
,
jitRelease
,
];
static
const
Set
<
BuildMode
>
releaseModes
=
<
BuildMode
>{
release
,
jitRelease
,
};
static
const
Set
<
BuildMode
>
jitModes
=
<
BuildMode
>{
debug
,
jitRelease
,
};
/// Whether this mode is considered release.
///
/// Useful for determining whether we should enable/disable asserts or
/// other development features.
bool
get
isRelease
=>
releaseModes
.
contains
(
this
);
/// Whether this mode is using the jit runtime.
bool
get
isJit
=>
jitModes
.
contains
(
this
);
/// Whether this mode is using the precompiled runtime.
bool
get
isPrecompiled
=>
!
isJit
;
/// The name for this build mode.
final
String
name
;
@override
String
toString
()
=>
name
;
}
/// Return the name for the build mode, or "any" if null.
String
getNameForBuildMode
(
BuildMode
buildMode
)
{
return
_kBuildModes
[
buildMode
.
index
]
;
return
buildMode
.
name
;
}
/// Returns the [BuildMode] for a particular `name`.
BuildMode
getBuildModeForName
(
String
name
)
{
switch
(
name
)
{
case
'debug'
:
return
BuildMode
.
debug
;
case
'profile'
:
return
BuildMode
.
profile
;
case
'release'
:
return
BuildMode
.
release
;
}
return
null
;
return
BuildMode
.
fromName
(
name
);
}
String
validatedBuildNumberForPlatform
(
TargetPlatform
targetPlatform
,
String
buildNumber
)
{
...
...
packages/flutter_tools/lib/src/build_system/targets/dart.dart
View file @
ab260bac
...
...
@@ -232,7 +232,6 @@ class KernelSnapshot extends Target {
}
}
/// Supports compiling a dart kernel file to an ELF binary.
abstract
class
AotElfBase
extends
Target
{
const
AotElfBase
();
...
...
packages/flutter_tools/test/general.shard/build_info_test.dart
View file @
ab260bac
...
...
@@ -53,5 +53,29 @@ void main() {
buildName
=
validatedBuildNameForPlatform
(
TargetPlatform
.
android_arm
,
'abc+-'
);
expect
(
buildName
,
'abc+-'
);
});
test
(
'build mode configuration is correct'
,
()
{
expect
(
BuildMode
.
debug
.
isRelease
,
false
);
expect
(
BuildMode
.
debug
.
isPrecompiled
,
false
);
expect
(
BuildMode
.
debug
.
isJit
,
true
);
expect
(
BuildMode
.
profile
.
isRelease
,
false
);
expect
(
BuildMode
.
profile
.
isPrecompiled
,
true
);
expect
(
BuildMode
.
profile
.
isJit
,
false
);
expect
(
BuildMode
.
release
.
isRelease
,
true
);
expect
(
BuildMode
.
release
.
isPrecompiled
,
true
);
expect
(
BuildMode
.
release
.
isJit
,
false
);
expect
(
BuildMode
.
jitRelease
.
isRelease
,
true
);
expect
(
BuildMode
.
jitRelease
.
isPrecompiled
,
false
);
expect
(
BuildMode
.
jitRelease
.
isJit
,
true
);
expect
(
BuildMode
.
fromName
(
'debug'
),
BuildMode
.
debug
);
expect
(
BuildMode
.
fromName
(
'profile'
),
BuildMode
.
profile
);
expect
(
BuildMode
.
fromName
(
'jit_release'
),
BuildMode
.
jitRelease
);
expect
(
BuildMode
.
fromName
(
'release'
),
BuildMode
.
release
);
expect
(()
=>
BuildMode
.
fromName
(
'foo'
),
throwsA
(
isInstanceOf
<
ArgumentError
>()));
});
});
}
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