Skip to content

Commit 27ba2f2

Browse files
authored
[native assets] Roll dependencies (#160672)
This PR rolls in a number of breaking changes from dart-lang/native: * `BuildMode` is no longer part of the protocol, so Flutter no longer passes it in. * This means all code dealing with the name conflict between `native_assets_cli.BuildMode` and `flutter_tools.BuildMode` has been cleaned up. * Also, the logs no longer mention the build mode. * The tests still exercise both modes, because linking only happens in release mode. * `OS` is no longer part of the main protocol, but of the "code" "protocol extension". * The code now aligns more with `OS?` being nullable in a bunch of places, since it is nullable if there's no code assets. * The OS-specific config is nested in an object per OS. * `CCompilerConfig`s fields are non-nullable now. * So instead of passing an object with nullable fields around, a null instead of the object is returned in various places. * `FileSystem` is now passed in to the native assets builder. This PR contains no feature changes. This PR will need to be followed up by restricting what environment variables are passed in (similar to dart-lang/native#1764), I will do this in a follow up PR. Tests: * All existing features should be covered by existing tests.
1 parent d9b7e56 commit 27ba2f2

File tree

24 files changed

+258
-277
lines changed

24 files changed

+258
-277
lines changed

dev/integration_tests/link_hook/hook/build.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:native_toolchain_c/native_toolchain_c.dart';
99

1010
void main(List<String> args) async {
1111
await build(args, (BuildConfig config, BuildOutputBuilder output) async {
12-
if (!config.supportedAssetTypes.contains(CodeAsset.type)) {
12+
if (!config.buildAssetTypes.contains(CodeAsset.type)) {
1313
return;
1414
}
1515

dev/integration_tests/link_hook/hook/link.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:native_assets_cli/code_assets.dart';
66

77
void main(List<String> args) async {
88
await link(args, (LinkConfig config, LinkOutputBuilder output) async {
9-
if (!config.supportedAssetTypes.contains(CodeAsset.type)) {
9+
if (!config.buildAssetTypes.contains(CodeAsset.type)) {
1010
return;
1111
}
1212
final CodeAsset asset = config.codeAssets.single;
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
11
name: link_hook
2-
description: "A new Dart FFI package project."
2+
description: 'A new Dart FFI package project.'
33
version: 0.0.1
44

55
environment:
66
sdk: ^3.7.0-0
77

88
dependencies:
99
logging: 1.3.0
10-
native_assets_cli: 0.9.0
11-
native_toolchain_c: 0.6.0
10+
native_assets_cli: 0.10.0
11+
native_toolchain_c: 0.7.0
12+
13+
async: 2.12.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
14+
collection: 1.19.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
15+
crypto: 3.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
16+
file: 7.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
17+
glob: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
18+
meta: 1.15.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
19+
path: 1.9.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
20+
pub_semver: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
21+
source_span: 1.10.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
22+
string_scanner: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
23+
term_glyph: 1.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
24+
typed_data: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
25+
yaml: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
26+
27+
dev_dependencies:
28+
ffi: 2.1.3
29+
ffigen: 16.0.0
30+
flutter_lints: 5.0.0
31+
test: 1.25.14
1232

1333
_fe_analyzer_shared: 76.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
1434
analyzer: 6.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
1535
args: 2.6.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
16-
async: 2.12.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
1736
boolean_selector: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
18-
collection: 1.19.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
37+
cli_util: 0.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
1938
convert: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
2039
coverage: 1.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
21-
crypto: 3.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
22-
file: 7.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
40+
dart_style: 2.3.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
2341
frontend_server_client: 4.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
24-
glob: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
2542
http_multi_server: 3.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
2643
http_parser: 4.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
2744
io: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
2845
js: 0.7.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
46+
lints: 5.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
2947
matcher: 0.12.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
30-
meta: 1.15.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3148
mime: 1.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3249
node_preamble: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3350
package_config: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
34-
path: 1.9.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3551
pool: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
36-
pub_semver: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
52+
quiver: 3.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3753
shelf: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3854
shelf_packages_handler: 3.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3955
shelf_static: 1.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4056
shelf_web_socket: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4157
source_map_stack_trace: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4258
source_maps: 0.10.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
43-
source_span: 1.10.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4459
stack_trace: 1.12.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4560
stream_channel: 2.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
46-
string_scanner: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
47-
term_glyph: 1.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4861
test_api: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
4962
test_core: 0.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
50-
typed_data: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
5163
vm_service: 14.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
5264
watcher: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
5365
web: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
5466
web_socket: 0.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
5567
web_socket_channel: 3.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
5668
webkit_inspection_protocol: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
57-
yaml: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
58-
59-
dev_dependencies:
60-
ffi: 2.1.3
61-
ffigen: 16.0.0
62-
flutter_lints: 5.0.0
63-
test: 1.25.14
64-
65-
cli_util: 0.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
66-
dart_style: 2.3.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
67-
lints: 5.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
68-
quiver: 3.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
6969
yaml_edit: 2.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
7070

71-
# PUBSPEC CHECKSUM: 3044
71+
# PUBSPEC CHECKSUM: 016c

packages/flutter_tools/lib/src/isolated/native_assets/android/native_assets.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import '../../../android/android_sdk.dart';
99
import '../../../android/gradle_utils.dart';
1010
import '../../../base/common.dart';
1111
import '../../../base/file_system.dart';
12-
import '../../../build_info.dart' hide BuildMode;
12+
import '../../../build_info.dart';
1313

1414
int targetAndroidNdkApi(Map<String, String> environmentDefines) {
1515
return int.parse(environmentDefines[kMinSdkVersion] ?? minSdkVersion);
@@ -105,14 +105,17 @@ Future<CCompilerConfig> cCompilerConfigAndroid() async {
105105
if (androidSdk == null) {
106106
throwToolExit('Android SDK could not be found.');
107107
}
108-
final CCompilerConfig result = CCompilerConfig(
109-
compiler: _toOptionalFileUri(androidSdk.getNdkClangPath()),
110-
archiver: _toOptionalFileUri(androidSdk.getNdkArPath()),
111-
linker: _toOptionalFileUri(androidSdk.getNdkLdPath()),
112-
);
113-
if (result.compiler == null || result.archiver == null || result.linker == null) {
108+
final Uri? compiler = _toOptionalFileUri(androidSdk.getNdkClangPath());
109+
final Uri? archiver = _toOptionalFileUri(androidSdk.getNdkArPath());
110+
final Uri? linker = _toOptionalFileUri(androidSdk.getNdkLdPath());
111+
if (compiler == null || archiver == null || linker == null) {
114112
throwToolExit('Android NDK Clang could not be found.');
115113
}
114+
final CCompilerConfig result = CCompilerConfig(
115+
compiler: compiler,
116+
archiver: archiver,
117+
linker: linker,
118+
);
116119
return result;
117120
}
118121

packages/flutter_tools/lib/src/isolated/native_assets/ios/native_assets.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import 'package:native_assets_builder/native_assets_builder.dart';
66
import 'package:native_assets_cli/code_assets_builder.dart';
77

88
import '../../../base/file_system.dart';
9-
import '../../../build_info.dart' hide BuildMode;
10-
import '../../../build_info.dart' as build_info;
9+
import '../../../build_info.dart';
1110
import '../macos/native_assets_host.dart';
1211

1312
// TODO(dcharkes): Fetch minimum iOS version from somewhere. https://github.com/flutter/flutter/issues/145104
@@ -100,7 +99,7 @@ Future<void> copyNativeCodeAssetsIOS(
10099
Uri buildUri,
101100
Map<KernelAssetPath, List<CodeAsset>> assetTargetLocations,
102101
String? codesignIdentity,
103-
build_info.BuildMode buildMode,
102+
BuildMode buildMode,
104103
FileSystem fileSystem,
105104
) async {
106105
assert(assetTargetLocations.isNotEmpty);

packages/flutter_tools/lib/src/isolated/native_assets/linux/native_assets.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ Future<CCompilerConfig> cCompilerConfigLinux() async {
3737
}
3838
binaryPaths[binary] = binaryFile.uri;
3939
}
40-
return CCompilerConfig(
41-
archiver: binaryPaths[kArBinary],
42-
compiler: binaryPaths[kClangBinary],
43-
linker: binaryPaths[kLdBinary],
44-
);
40+
final Uri? archiver = binaryPaths[kArBinary];
41+
final Uri? compiler = binaryPaths[kClangBinary];
42+
final Uri? linker = binaryPaths[kLdBinary];
43+
if (archiver == null || compiler == null || linker == null) {
44+
throwToolExit('Clang could not be found.');
45+
}
46+
return CCompilerConfig(archiver: archiver, compiler: compiler, linker: linker);
4547
}

packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import 'package:native_assets_builder/native_assets_builder.dart';
66
import 'package:native_assets_cli/code_assets_builder.dart';
77

88
import '../../../base/file_system.dart';
9-
import '../../../build_info.dart' hide BuildMode;
10-
import '../../../build_info.dart' as build_info;
9+
import '../../../build_info.dart';
1110
import 'native_assets_host.dart';
1211

1312
// TODO(dcharkes): Fetch minimum MacOS version from somewhere. https://github.com/flutter/flutter/issues/145104
@@ -116,7 +115,7 @@ Future<void> copyNativeCodeAssetsMacOS(
116115
Uri buildUri,
117116
Map<KernelAssetPath, List<CodeAsset>> assetTargetLocations,
118117
String? codesignIdentity,
119-
build_info.BuildMode buildMode,
118+
BuildMode buildMode,
120119
FileSystem fileSystem,
121120
) async {
122121
assert(assetTargetLocations.isNotEmpty);
@@ -204,7 +203,7 @@ Future<void> copyNativeCodeAssetsMacOSFlutterTester(
204203
Uri buildUri,
205204
Map<KernelAssetPath, List<CodeAsset>> assetTargetLocations,
206205
String? codesignIdentity,
207-
build_info.BuildMode buildMode,
206+
BuildMode buildMode,
208207
FileSystem fileSystem,
209208
) async {
210209
assert(assetTargetLocations.isNotEmpty);

packages/flutter_tools/lib/src/isolated/native_assets/macos/native_assets_host.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:native_assets_cli/code_assets_builder.dart';
99
import '../../../base/common.dart';
1010
import '../../../base/file_system.dart';
1111
import '../../../base/io.dart';
12-
import '../../../build_info.dart' as build_info;
12+
import '../../../build_info.dart';
1313
import '../../../convert.dart';
1414
import '../../../globals.dart' as globals;
1515

@@ -136,7 +136,7 @@ Future<Set<String>> getInstallNamesDylib(File dylibFile) async {
136136

137137
Future<void> codesignDylib(
138138
String? codesignIdentity,
139-
build_info.BuildMode buildMode,
139+
BuildMode buildMode,
140140
FileSystemEntity target,
141141
) async {
142142
if (codesignIdentity == null || codesignIdentity.isEmpty) {
@@ -147,7 +147,7 @@ Future<void> codesignDylib(
147147
'--force',
148148
'--sign',
149149
codesignIdentity,
150-
if (buildMode != build_info.BuildMode.release) ...<String>[
150+
if (buildMode != BuildMode.release) ...<String>[
151151
// Mimic Xcode's timestamp codesigning behavior on non-release binaries.
152152
'--timestamp=none',
153153
],

0 commit comments

Comments
 (0)