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
c584a5ea
Unverified
Commit
c584a5ea
authored
Dec 22, 2021
by
Jenn Magder
Committed by
GitHub
Dec 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate fuchsia_device to null safety (#95438)
parent
38cffc9c
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
137 deletions
+131
-137
fuchsia_build.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
+16
-17
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+90
-91
pkgctl.dart
packages/flutter_tools/lib/src/fuchsia/pkgctl.dart
+0
-2
session_control.dart
packages/flutter_tools/lib/src/fuchsia/session_control.dart
+0
-2
tiles_ctl.dart
packages/flutter_tools/lib/src/fuchsia/tiles_ctl.dart
+8
-8
fuchsia_device_test.dart
...tools/test/general.shard/fuchsia/fuchsia_device_test.dart
+17
-17
No files found.
packages/flutter_tools/lib/src/fuchsia/fuchsia_build.dart
View file @
c584a5ea
...
...
@@ -2,10 +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
'../artifacts.dart'
;
import
'../asset.dart'
;
import
'../base/common.dart'
;
...
...
@@ -45,12 +41,13 @@ Future<void> _validateCmxFile(FuchsiaProject fuchsiaProject) async {
// 3. Using these manifests, use the Fuchsia SDK 'pm' tool to create the
// Fuchsia package.
Future
<
void
>
buildFuchsia
({
@
required
FuchsiaProject
fuchsiaProject
,
@
required
TargetPlatform
targetPlatform
,
@required
String
target
,
// E.g., lib/main.dart
required
FuchsiaProject
fuchsiaProject
,
required
TargetPlatform
targetPlatform
,
String
?
target
,
// E.g., lib/main.dart
BuildInfo
buildInfo
=
BuildInfo
.
debug
,
String
runnerPackageSource
=
FuchsiaPackageServer
.
toolHost
,
})
async
{
final
String
targetPath
=
target
??=
'lib/main.dart'
;
await
_validateCmxFile
(
fuchsiaProject
);
final
Directory
outDir
=
globals
.
fs
.
directory
(
getFuchsiaBuildDirectory
());
if
(!
outDir
.
existsSync
())
{
...
...
@@ -58,18 +55,18 @@ Future<void> buildFuchsia({
}
await
_timedBuildStep
(
'fuchsia-kernel-compile'
,
()
=>
fuchsiaSdk
.
fuchsiaKernelCompiler
.
build
(
fuchsiaProject:
fuchsiaProject
,
target:
target
,
buildInfo:
buildInfo
));
()
=>
fuchsiaSdk
!
.
fuchsiaKernelCompiler
.
build
(
fuchsiaProject:
fuchsiaProject
,
target:
target
Path
,
buildInfo:
buildInfo
));
if
(
buildInfo
.
usesAot
)
{
await
_timedBuildStep
(
'fuchsia-gen-snapshot'
,
()
=>
_genSnapshot
(
fuchsiaProject
,
target
,
buildInfo
,
targetPlatform
));
()
=>
_genSnapshot
(
fuchsiaProject
,
target
Path
,
buildInfo
,
targetPlatform
));
}
await
_timedBuildStep
(
'fuchsia-build-assets'
,
()
=>
_buildAssets
(
fuchsiaProject
,
target
,
buildInfo
));
()
=>
_buildAssets
(
fuchsiaProject
,
target
Path
,
buildInfo
));
await
_timedBuildStep
(
'fuchsia-build-package'
,
()
=>
_buildPackage
(
fuchsiaProject
,
target
,
buildInfo
,
runnerPackageSource
));
()
=>
_buildPackage
(
fuchsiaProject
,
target
Path
,
buildInfo
,
runnerPackageSource
));
}
Future
<
void
>
_genSnapshot
(
...
...
@@ -84,7 +81,7 @@ Future<void> _genSnapshot(
final
String
elf
=
globals
.
fs
.
path
.
join
(
outDir
,
'elf.aotsnapshot'
);
final
String
genSnapshot
=
globals
.
artifacts
.
getArtifactPath
(
final
String
genSnapshot
=
globals
.
artifacts
!
.
getArtifactPath
(
Artifact
.
genSnapshot
,
platform:
targetPlatform
,
mode:
buildInfo
.
mode
,
...
...
@@ -118,7 +115,7 @@ Future<void> _buildAssets(
BuildInfo
buildInfo
,
)
async
{
final
String
assetDir
=
getAssetBuildDirectory
();
final
AssetBundle
assets
=
await
buildAssets
(
final
AssetBundle
?
assets
=
await
buildAssets
(
manifestPath:
fuchsiaProject
.
project
.
pubspecFile
.
path
,
packagesPath:
fuchsiaProject
.
project
.
packagesFile
.
path
,
assetDirPath:
assetDir
,
...
...
@@ -148,7 +145,7 @@ Future<void> _buildAssets(
}
void
_rewriteCmx
(
BuildMode
mode
,
String
runnerPackageSource
,
File
src
,
File
dst
)
{
final
Map
<
String
,
dynamic
>
cmx
=
castStringKeyedMap
(
json
.
decode
(
src
.
readAsStringSync
()))
;
final
Map
<
String
,
Object
?>
cmx
=
castStringKeyedMap
(
json
.
decode
(
src
.
readAsStringSync
()))
??
<
String
,
Object
?>{}
;
// If the app author has already specified the runner in the cmx file, then
// do not override it with something else.
if
(
cmx
.
containsKey
(
'runner'
))
{
...
...
@@ -171,7 +168,6 @@ void _rewriteCmx(BuildMode mode, String runnerPackageSource, File src, File dst)
break
;
default
:
throwToolExit
(
'Fuchsia does not support build mode "
$mode
"'
);
break
;
}
cmx
[
'runner'
]
=
'fuchsia-pkg://
$runnerPackageSource
/
$runner
#meta/
$runner
.cmx'
;
dst
.
writeAsStringSync
(
json
.
encode
(
cmx
));
...
...
@@ -218,7 +214,10 @@ Future<void> _buildPackage(
manifestFile
.
writeAsStringSync
(
'meta/package=
$pkgDir
/meta/package
\n
'
,
mode:
FileMode
.
append
);
final
FuchsiaPM
fuchsiaPM
=
fuchsiaSdk
.
fuchsiaPM
;
final
FuchsiaPM
?
fuchsiaPM
=
fuchsiaSdk
?.
fuchsiaPM
;
if
(
fuchsiaPM
==
null
)
{
return
;
}
if
(!
await
fuchsiaPM
.
init
(
pkgDir
,
appName
))
{
return
;
}
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
c584a5ea
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/fuchsia/pkgctl.dart
View file @
c584a5ea
...
...
@@ -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
'../base/process.dart'
;
import
'fuchsia_device.dart'
;
...
...
packages/flutter_tools/lib/src/fuchsia/session_control.dart
View file @
c584a5ea
...
...
@@ -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
'../base/process.dart'
;
import
'fuchsia_device.dart'
;
...
...
packages/flutter_tools/lib/src/fuchsia/tiles_ctl.dart
View file @
c584a5ea
...
...
@@ -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
'../base/process.dart'
;
import
'../globals.dart'
as
globals
;
...
...
@@ -23,7 +21,7 @@ class FuchsiaTilesCtl {
/// found.
static
Future
<
int
>
findAppKey
(
FuchsiaDevice
device
,
String
appName
)
async
{
final
FuchsiaTilesCtl
tilesCtl
=
fuchsiaDeviceTools
.
tilesCtl
;
final
Map
<
int
,
String
>
runningApps
=
await
tilesCtl
.
list
(
device
);
final
Map
<
int
,
String
>
?
runningApps
=
await
tilesCtl
.
list
(
device
);
if
(
runningApps
==
null
)
{
globals
.
printTrace
(
'tiles_ctl is not running'
);
return
-
1
;
...
...
@@ -39,7 +37,7 @@ class FuchsiaTilesCtl {
/// Ensures that tiles is running on the device.
static
Future
<
bool
>
ensureStarted
(
FuchsiaDevice
device
)
async
{
final
FuchsiaTilesCtl
tilesCtl
=
fuchsiaDeviceTools
.
tilesCtl
;
final
Map
<
int
,
String
>
runningApps
=
await
tilesCtl
.
list
(
device
);
final
Map
<
int
,
String
>
?
runningApps
=
await
tilesCtl
.
list
(
device
);
if
(
runningApps
==
null
)
{
return
tilesCtl
.
start
(
device
);
}
...
...
@@ -58,7 +56,7 @@ class FuchsiaTilesCtl {
///
/// Returns an empty mapping if tiles_ctl is running but no apps are running.
/// Returns null if tiles_ctl is not running.
Future
<
Map
<
int
,
String
>>
list
(
FuchsiaDevice
device
)
async
{
Future
<
Map
<
int
,
String
>
?
>
list
(
FuchsiaDevice
device
)
async
{
// Output of tiles_ctl list has the format:
// Found 1 tiles:
// Tile key 1 url fuchsia-pkg://fuchsia.com/stocks#meta/stocks.cmx ...
...
...
@@ -75,11 +73,13 @@ class FuchsiaTilesCtl {
for
(
final
String
line
in
result
.
stdout
.
split
(
'
\n
'
))
{
final
List
<
String
>
words
=
line
.
split
(
' '
);
if
(
words
.
isNotEmpty
&&
words
[
0
]
==
'Tile'
)
{
final
int
key
=
int
.
tryParse
(
words
[
2
]);
final
int
?
key
=
int
.
tryParse
(
words
[
2
]);
if
(
key
!=
null
)
{
final
String
url
=
words
[
4
];
tiles
[
key
]
=
url
;
}
}
}
return
tiles
;
}
...
...
packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
View file @
c584a5ea
...
...
@@ -91,7 +91,7 @@ void main() {
final
FakeFuchsiaWorkflow
fuchsiaWorkflow
=
FakeFuchsiaWorkflow
(
canListDevices:
false
);
final
FuchsiaDevices
fuchsiaDevices
=
FuchsiaDevices
(
platform:
FakePlatform
(),
fuchsiaSdk:
null
,
fuchsiaSdk:
FakeFuchsiaSdk
(
devices:
'ignored'
)
,
fuchsiaWorkflow:
fuchsiaWorkflow
,
logger:
BufferLogger
.
test
(),
);
...
...
@@ -154,7 +154,7 @@ void main() {
testUsingContext
(
'disposing device disposes the portForwarder'
,
()
async
{
final
FakePortForwarder
portForwarder
=
FakePortForwarder
();
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
device
.
portForwarder
=
portForwarder
;
await
device
.
dispose
();
...
...
@@ -162,7 +162,7 @@ void main() {
});
testWithoutContext
(
'default capabilities'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
memoryFileSystem
.
directory
(
'fuchsia'
).
createSync
(
recursive:
true
);
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
...
...
@@ -174,13 +174,13 @@ void main() {
});
test
(
'is ephemeral'
,
()
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
device
.
ephemeral
,
true
);
});
testWithoutContext
(
'supported for project'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
memoryFileSystem
.
directory
(
'fuchsia'
).
createSync
(
recursive:
true
);
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
...
...
@@ -189,7 +189,7 @@ void main() {
});
testWithoutContext
(
'not supported for project'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
memoryFileSystem
.
currentDirectory
);
memoryFileSystem
.
file
(
'pubspec.yaml'
).
createSync
();
...
...
@@ -197,7 +197,7 @@ void main() {
});
testUsingContext
(
'targetPlatform does not throw when sshConfig is missing'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_arm64
);
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -212,7 +212,7 @@ void main() {
stdout:
'aarch64'
,
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_arm64
);
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
...
@@ -226,7 +226,7 @@ void main() {
stdout:
'x86_64'
,
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
targetPlatform
,
TargetPlatform
.
fuchsia_x64
);
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
...
@@ -240,7 +240,7 @@ void main() {
stdout:
'fe80::8c6c:2fff:fe3d:c5e1%ethp0003 50666 fe80::5054:ff:fe63:5e7a%ethp0003 22'
,
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
,
name:
'device'
);
expect
(
await
device
.
hostAddress
,
'fe80::8c6c:2fff:fe3d:c5e1%25ethp0003'
);
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
...
@@ -254,7 +254,7 @@ void main() {
exitCode:
1
,
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
,
name:
'device'
);
await
expectLater
(()
=>
device
.
hostAddress
,
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
...
@@ -267,7 +267,7 @@ void main() {
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'id'
,
r'echo $SSH_CONNECTION'
],
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
,
name:
'device'
);
expect
(()
async
=>
device
.
hostAddress
,
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
...
...
@@ -289,7 +289,7 @@ void main() {
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'ssh'
,
'-F'
,
'/artifact'
,
'id'
,
'find /hub -name vmservice-port'
],
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
,
name:
'device'
);
await
expectLater
(
device
.
servicePorts
,
throwsToolExit
(
message:
'No Dart Observatories found. Are you running a debug build?'
));
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -766,7 +766,7 @@ void main() {
});
testUsingContext
(
'does not throw on non-existent ssh config'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -780,7 +780,7 @@ void main() {
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
stdout:
'version'
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia version'
));
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -794,7 +794,7 @@ void main() {
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
exitCode:
1
,
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -807,7 +807,7 @@ void main() {
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'ssh'
,
'-F'
,
'/ssh_config'
,
'123'
,
'cat /pkgfs/packages/build-info/0/data/version'
],
));
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
);
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'123'
,
name:
'device'
);
expect
(
await
device
.
sdkNameAndVersion
,
equals
(
'Fuchsia'
));
},
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