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
00263c4f
Unverified
Commit
00263c4f
authored
May 26, 2021
by
Jenn Magder
Committed by
GitHub
May 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate build system build.dart to null safety (#83381)
parent
48a2bc8c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
62 deletions
+72
-62
build.dart
packages/flutter_tools/lib/src/base/build.dart
+32
-34
process.dart
packages/flutter_tools/lib/src/base/process.dart
+10
-8
android.dart
...s/flutter_tools/lib/src/build_system/targets/android.dart
+1
-1
common.dart
...es/flutter_tools/lib/src/build_system/targets/common.dart
+1
-1
ios.dart
packages/flutter_tools/lib/src/build_system/targets/ios.dart
+1
-1
macos.dart
...ges/flutter_tools/lib/src/build_system/targets/macos.dart
+1
-1
build_test.dart
...ges/flutter_tools/test/general.shard/base/build_test.dart
+8
-16
process_test.dart
...s/flutter_tools/test/general.shard/base/process_test.dart
+18
-0
No files found.
packages/flutter_tools/lib/src/base/build.dart
View file @
00263c4f
...
...
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'../artifacts.dart'
;
...
...
@@ -20,7 +17,7 @@ class SnapshotType {
SnapshotType
(
this
.
platform
,
this
.
mode
)
:
assert
(
mode
!=
null
);
final
TargetPlatform
platform
;
final
TargetPlatform
?
platform
;
final
BuildMode
mode
;
@override
...
...
@@ -30,9 +27,9 @@ class SnapshotType {
/// Interface to the gen_snapshot command-line tool.
class
GenSnapshot
{
GenSnapshot
({
@
required
Artifacts
artifacts
,
@
required
ProcessManager
processManager
,
@
required
Logger
logger
,
required
Artifacts
artifacts
,
required
ProcessManager
processManager
,
required
Logger
logger
,
})
:
_artifacts
=
artifacts
,
_processUtils
=
ProcessUtils
(
logger:
logger
,
processManager:
processManager
);
...
...
@@ -56,10 +53,11 @@ class GenSnapshot {
};
Future
<
int
>
run
({
@
required
SnapshotType
snapshotType
,
DarwinArch
darwinArch
,
required
SnapshotType
snapshotType
,
DarwinArch
?
darwinArch
,
Iterable
<
String
>
additionalArgs
=
const
<
String
>[],
})
{
assert
(
snapshotType
.
platform
!=
TargetPlatform
.
ios
||
darwinArch
!=
null
);
final
List
<
String
>
args
=
<
String
>[
...
additionalArgs
,
];
...
...
@@ -69,7 +67,7 @@ class GenSnapshot {
// iOS has a separate gen_snapshot for armv7 and arm64 in the same,
// directory. So we need to select the right one.
if
(
snapshotType
.
platform
==
TargetPlatform
.
ios
)
{
snapshotterPath
+=
'_'
+
getNameForDarwinArch
(
darwinArch
);
snapshotterPath
+=
'_'
+
getNameForDarwinArch
(
darwinArch
!
);
}
return
_processUtils
.
stream
(
...
...
@@ -82,11 +80,11 @@ class GenSnapshot {
class
AOTSnapshotter
{
AOTSnapshotter
({
this
.
reportTimings
=
false
,
@
required
Logger
logger
,
@
required
FileSystem
fileSystem
,
@
required
Xcode
xcode
,
@
required
ProcessManager
processManager
,
@
required
Artifacts
artifacts
,
required
Logger
logger
,
required
FileSystem
fileSystem
,
required
Xcode
xcode
,
required
ProcessManager
processManager
,
required
Artifacts
artifacts
,
})
:
_logger
=
logger
,
_fileSystem
=
fileSystem
,
_xcode
=
xcode
,
...
...
@@ -108,16 +106,16 @@ class AOTSnapshotter {
/// Builds an architecture-specific ahead-of-time compiled snapshot of the specified script.
Future
<
int
>
build
({
@
required
TargetPlatform
platform
,
@
required
BuildMode
buildMode
,
@
required
String
mainPath
,
@
required
String
outputPath
,
DarwinArch
darwinArch
,
String
sdkRoot
,
required
TargetPlatform
platform
,
required
BuildMode
buildMode
,
required
String
mainPath
,
required
String
outputPath
,
DarwinArch
?
darwinArch
,
String
?
sdkRoot
,
List
<
String
>
extraGenSnapshotOptions
=
const
<
String
>[],
@
required
bool
bitcode
,
@required
String
splitDebugInfo
,
@
required
bool
dartObfuscation
,
required
bool
bitcode
,
String
?
splitDebugInfo
,
required
bool
dartObfuscation
,
bool
quiet
=
false
,
})
async
{
assert
(
platform
!=
TargetPlatform
.
ios
||
darwinArch
!=
null
);
...
...
@@ -197,7 +195,7 @@ class AOTSnapshotter {
// Faster async/await
if
(
shouldSplitDebugInfo
)
...<
String
>[
'--dwarf-stack-traces'
,
'--save-debugging-info=
${_fileSystem.path.join(splitDebugInfo, debugFilename)}
'
'--save-debugging-info=
${_fileSystem.path.join(splitDebugInfo
!
, debugFilename)}
'
],
if
(
dartObfuscation
)
'--obfuscate'
,
...
...
@@ -220,7 +218,7 @@ class AOTSnapshotter {
// end-developer can link into their app.
if
(
platform
==
TargetPlatform
.
ios
||
platform
==
TargetPlatform
.
darwin
)
{
final
RunResult
result
=
await
_buildFramework
(
appleArch:
darwinArch
,
appleArch:
darwinArch
!
,
isIOS:
platform
==
TargetPlatform
.
ios
,
sdkRoot:
sdkRoot
,
assemblyPath:
assembly
,
...
...
@@ -238,13 +236,13 @@ class AOTSnapshotter {
/// Builds an iOS or macOS framework at [outputPath]/App.framework from the assembly
/// source at [assemblyPath].
Future
<
RunResult
>
_buildFramework
({
@
required
DarwinArch
appleArch
,
@
required
bool
isIOS
,
@required
String
sdkRoot
,
@
required
String
assemblyPath
,
@
required
String
outputPath
,
@
required
bool
bitcode
,
@
required
bool
quiet
required
DarwinArch
appleArch
,
required
bool
isIOS
,
String
?
sdkRoot
,
required
String
assemblyPath
,
required
String
outputPath
,
required
bool
bitcode
,
required
bool
quiet
})
async
{
final
String
targetArch
=
getNameForDarwinArch
(
appleArch
);
if
(!
quiet
)
{
...
...
@@ -262,7 +260,7 @@ class AOTSnapshotter {
const
String
embedBitcodeArg
=
'-fembed-bitcode'
;
final
String
assemblyO
=
_fileSystem
.
path
.
join
(
outputPath
,
'snapshot_assembly.o'
);
List
<
String
>
isysrootArgs
;
List
<
String
>
?
isysrootArgs
;
if
(
sdkRoot
!=
null
)
{
isysrootArgs
=
<
String
>[
'-isysroot'
,
sdkRoot
];
}
...
...
packages/flutter_tools/lib/src/base/process.dart
View file @
00263c4f
...
...
@@ -11,7 +11,7 @@ import 'common.dart';
import
'io.dart'
;
import
'logger.dart'
;
typedef
StringConverter
=
String
Function
(
String
string
);
typedef
StringConverter
=
String
?
Function
(
String
string
);
/// A function that will be run before the VM exits.
typedef
ShutdownHook
=
FutureOr
<
dynamic
>
Function
();
...
...
@@ -452,12 +452,13 @@ class _DefaultProcessUtils implements ProcessUtils {
.
transform
<
String
>(
const
LineSplitter
())
.
where
((
String
line
)
=>
filter
==
null
||
filter
.
hasMatch
(
line
))
.
listen
((
String
line
)
{
String
?
mappedLine
=
line
;
if
(
mapFunction
!=
null
)
{
l
ine
=
mapFunction
(
line
);
mappedL
ine
=
mapFunction
(
line
);
}
if
(
l
ine
!=
null
)
{
final
String
message
=
'
$prefix$
l
ine
'
;
if
(
stdoutErrorMatcher
?.
hasMatch
(
l
ine
)
==
true
)
{
if
(
mappedL
ine
!=
null
)
{
final
String
message
=
'
$prefix$
mappedL
ine
'
;
if
(
stdoutErrorMatcher
?.
hasMatch
(
mappedL
ine
)
==
true
)
{
_logger
.
printError
(
message
,
wrap:
false
);
}
else
if
(
trace
)
{
_logger
.
printTrace
(
message
);
...
...
@@ -471,11 +472,12 @@ class _DefaultProcessUtils implements ProcessUtils {
.
transform
<
String
>(
const
LineSplitter
())
.
where
((
String
line
)
=>
filter
==
null
||
filter
.
hasMatch
(
line
))
.
listen
((
String
line
)
{
String
?
mappedLine
=
line
;
if
(
mapFunction
!=
null
)
{
l
ine
=
mapFunction
(
line
);
mappedL
ine
=
mapFunction
(
line
);
}
if
(
l
ine
!=
null
)
{
_logger
.
printError
(
'
$prefix$
l
ine
'
,
wrap:
false
);
if
(
mappedL
ine
!=
null
)
{
_logger
.
printError
(
'
$prefix$
mappedL
ine
'
,
wrap:
false
);
}
});
...
...
packages/flutter_tools/lib/src/build_system/targets/android.dart
View file @
00263c4f
...
...
@@ -9,7 +9,7 @@ import '../../base/build.dart';
import
'../../base/deferred_component.dart'
;
import
'../../base/file_system.dart'
;
import
'../../build_info.dart'
;
import
'../../globals.dart'
as
globals
show
platform
,
printError
,
xcode
;
import
'../../globals
_null_migrated
.dart'
as
globals
show
platform
,
printError
,
xcode
;
import
'../../project.dart'
;
import
'../build_system.dart'
;
import
'../depfile.dart'
;
...
...
packages/flutter_tools/lib/src/build_system/targets/common.dart
View file @
00263c4f
...
...
@@ -12,7 +12,7 @@ import '../../base/file_system.dart';
import
'../../build_info.dart'
;
import
'../../compile.dart'
;
import
'../../dart/package_map.dart'
;
import
'../../globals.dart'
as
globals
show
xcode
;
import
'../../globals
_null_migrated
.dart'
as
globals
show
xcode
;
import
'../build_system.dart'
;
import
'../depfile.dart'
;
import
'../exceptions.dart'
;
...
...
packages/flutter_tools/lib/src/build_system/targets/ios.dart
View file @
00263c4f
...
...
@@ -12,7 +12,7 @@ import '../../base/common.dart';
import
'../../base/file_system.dart'
;
import
'../../base/io.dart'
;
import
'../../build_info.dart'
;
import
'../../globals.dart'
as
globals
show
xcode
;
import
'../../globals
_null_migrated
.dart'
as
globals
show
xcode
;
import
'../../macos/xcode.dart'
;
import
'../../project.dart'
;
import
'../build_system.dart'
;
...
...
packages/flutter_tools/lib/src/build_system/targets/macos.dart
View file @
00263c4f
...
...
@@ -10,7 +10,7 @@ import '../../base/file_system.dart';
import
'../../base/io.dart'
;
import
'../../base/process.dart'
;
import
'../../build_info.dart'
;
import
'../../globals.dart'
as
globals
show
xcode
;
import
'../../globals
_null_migrated
.dart'
as
globals
show
xcode
;
import
'../build_system.dart'
;
import
'../depfile.dart'
;
import
'../exceptions.dart'
;
...
...
packages/flutter_tools/test/general.shard/base/build_test.dart
View file @
00263c4f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/build.dart'
;
...
...
@@ -72,22 +70,16 @@ const List<String> kBitcodeClang = <String>[
void
main
(
)
{
group
(
'SnapshotType'
,
()
{
test
(
'throws, if build mode is null'
,
()
{
expect
(
()
=>
SnapshotType
(
TargetPlatform
.
android_x64
,
null
),
throwsA
(
anything
),
);
});
test
(
'does not throw, if target platform is null'
,
()
{
expect
(()
=>
SnapshotType
(
null
,
BuildMode
.
release
),
returnsNormally
);
});
});
group
(
'GenSnapshot'
,
()
{
GenSnapshot
genSnapshot
;
Artifacts
artifacts
;
FakeProcessManager
processManager
;
BufferLogger
logger
;
late
GenSnapshot
genSnapshot
;
late
Artifacts
artifacts
;
late
FakeProcessManager
processManager
;
late
BufferLogger
logger
;
setUp
(()
async
{
artifacts
=
Artifacts
.
test
();
...
...
@@ -179,10 +171,10 @@ void main() {
});
group
(
'AOTSnapshotter'
,
()
{
MemoryFileSystem
fileSystem
;
AOTSnapshotter
snapshotter
;
Artifacts
artifacts
;
FakeProcessManager
processManager
;
late
MemoryFileSystem
fileSystem
;
late
AOTSnapshotter
snapshotter
;
late
Artifacts
artifacts
;
late
FakeProcessManager
processManager
;
setUp
(()
async
{
fileSystem
=
MemoryFileSystem
.
test
();
...
...
packages/flutter_tools/test/general.shard/base/process_test.dart
View file @
00263c4f
...
...
@@ -83,6 +83,24 @@ void main() {
expect
(
logger
.
statusText
,
equals
(
'
${testString[0]}
\n
'
));
expect
(
logger
.
errorText
,
equals
(
'
${testString[0]}
\n
'
));
});
testWithoutContext
(
'Command output is filtered by mapFunction'
,
()
async
{
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'command'
],
stdout:
'match
\n
no match'
,
stderr:
'match
\n
no match'
,
));
await
processUtils
.
stream
(<
String
>[
'command'
],
mapFunction:
(
String
line
)
{
if
(
line
==
'match'
)
{
return
line
;
}
return
null
;
});
expect
(
logger
.
statusText
,
equals
(
'match
\n
'
));
expect
(
logger
.
errorText
,
equals
(
'match
\n
'
));
});
});
group
(
'run'
,
()
{
...
...
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