Skip to content

Commit 6270a46

Browse files
dcharkesCommit Queue
authored and
Commit Queue
committed
[deps] Roll package:native_assets_builder
Manual roll of dart-lang/native#946. Change-Id: I6d4fd28f4174307024526dd73ff29b63e570bfd7 Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-win-release-try,pkg-mac-release-try,pkg-win-release-arm64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357623 Reviewed-by: Moritz Sümmermann <[email protected]> Commit-Queue: Daco Harkes <[email protected]>
1 parent 081cff0 commit 6270a46

File tree

5 files changed

+56
-46
lines changed

5 files changed

+56
-46
lines changed

DEPS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ vars = {
163163
"material_color_utilities_rev": "799b6ba2f3f1c28c67cc7e0b4f18e0c7d7f3c03e",
164164
"mime_rev": "9a168712d6db610c3822617c132daea72d4fd2b5",
165165
"mockito_rev": "3ef744f8749864f2a036eba60c4203cc8f638949",
166-
"native_rev": "0901a3323022fdb59657cc2cb00ea5c80a8468a6", # mosum@ and dacoharkes@ are rolling breaking changes manually while the assets features are in experimental.
166+
"native_rev": "4fc6a333badace5d569bde4496462cc237dc3363", # mosum@ and dacoharkes@ are rolling breaking changes manually while the assets features are in experimental.
167167
"package_config_rev": "3d90e6955ef19b7ce4f1b742a06a20ed4260700a",
168168
"path_rev": "a7b696071bd83d3ee0a0f1b57ac94d6b1f05cac4",
169169
"pool_rev": "c118f69d8a6441a8453bf7d455fd7c79d3ee1497",
@@ -185,7 +185,7 @@ vars = {
185185
"test_descriptor_rev": "35f97afacb2b7fe627f6ed0bede722fd48980848",
186186
"test_process_rev": "7fe39afbb6c444f256c1ec0eef008edebcd44644",
187187
"test_reflective_loader_rev": "9862703a3d14848376c8efde271c88022fba91eb",
188-
"tools_rev": "fca993e4f287e8080f2a8d91dbfbace8b6a8a0bc",
188+
"tools_rev": "378790dd8cdaecd8cb48283de445f7cf80419cc0",
189189
"typed_data_rev": "375efaa02a13dad0785cfbd9bdcb9f09aa8ef529",
190190
"usage_rev": "67ecd7d1328347ec15cbf8d8a46918df75a66af8",
191191
"vector_math_rev": "7e705f734e94917e9a5347578e6e496f8db38ac6",

pkg/bisect_dart/lib/src/run_bisection.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ Future<void> runMain(List<String> args) async {
1515
print(BisectionConfig.helpMessage());
1616
return;
1717
}
18-
final config = BisectionConfig.fromConfig(await Config.fromArgs(args: args));
18+
final config = BisectionConfig.fromConfig(
19+
await Config.fromArguments(arguments: args),
20+
);
1921
await runBisection(config);
2022
}
2123

pkg/dartdev/lib/src/commands/build.dart

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:dartdev/src/sdk.dart';
1212
import 'package:front_end/src/api_prototype/compiler_options.dart'
1313
show Verbosity;
1414
import 'package:native_assets_builder/native_assets_builder.dart';
15+
import 'package:native_assets_cli/native_assets_cli.dart';
1516
import 'package:native_assets_cli/native_assets_cli_internal.dart';
1617
import 'package:path/path.dart' as path;
1718
import 'package:vm/target_os.dart'; // For possible --target-os values.
@@ -132,20 +133,24 @@ class BuildCommand extends DartdevCommand {
132133
).build(
133134
workingDirectory: workingDirectory,
134135
target: target,
135-
linkModePreference: LinkModePreference.dynamic,
136-
buildMode: BuildMode.release,
136+
linkModePreference: LinkModePreferenceImpl.dynamic,
137+
buildMode: BuildModeImpl.release,
137138
includeParentEnvironment: true,
139+
supportedAssetTypes: [
140+
NativeCodeAsset.type,
141+
],
138142
);
139-
final nativeAssets = buildResult.assets;
140143
if (!buildResult.success) {
141144
stderr.write('Native assets build failed.');
142145
return 255;
143146
}
147+
final assets = buildResult.assets;
148+
final nativeAssets = assets.whereType<NativeCodeAssetImpl>();
144149
final staticAssets =
145-
nativeAssets.where((e) => e.linkMode == LinkMode.static);
150+
nativeAssets.where((e) => e.linkMode == StaticLinkingImpl());
146151
if (staticAssets.isNotEmpty) {
147152
stderr.write(
148-
"""'dart build' does not yet support native artifacts packaged as ${LinkMode.static.name}.
153+
"""'dart build' does not yet support NativeCodeAssets with static linking.
149154
Use linkMode as dynamic library instead.""");
150155
return 255;
151156
}
@@ -155,23 +160,23 @@ Use linkMode as dynamic library instead.""");
155160
final tempDir = Directory.systemTemp.createTempSync();
156161
if (nativeAssets.isNotEmpty) {
157162
stdout.writeln('Copying native assets.');
158-
KernelAsset targetLocation(Asset asset) {
159-
final path = asset.path;
163+
KernelAsset targetLocation(NativeCodeAssetImpl asset) {
164+
final linkMode = asset.linkMode;
160165
final KernelAssetPath kernelAssetPath;
161-
switch (path) {
162-
case AssetSystemPath _:
163-
kernelAssetPath = KernelAssetSystemPath(path.uri);
164-
case AssetInExecutable _:
166+
switch (linkMode) {
167+
case DynamicLoadingSystemImpl _:
168+
kernelAssetPath = KernelAssetSystemPath(linkMode.uri);
169+
case LookupInExecutableImpl _:
165170
kernelAssetPath = KernelAssetInExecutable();
166-
case AssetInProcess _:
171+
case LookupInProcessImpl _:
167172
kernelAssetPath = KernelAssetInProcess();
168-
case AssetAbsolutePath _:
173+
case DynamicLoadingBundledImpl _:
169174
kernelAssetPath = KernelAssetRelativePath(
170-
Uri(path: path.uri.pathSegments.last),
175+
Uri(path: asset.file!.pathSegments.last),
171176
);
172177
default:
173178
throw Exception(
174-
'Unsupported asset path type ${path.runtimeType} in asset $asset',
179+
'Unsupported NativeCodeAsset linkMode ${linkMode.runtimeType} in asset $asset',
175180
);
176181
}
177182
return KernelAsset(
@@ -187,12 +192,10 @@ Use linkMode as dynamic library instead.""");
187192
final copiedFiles = await Future.wait([
188193
for (final assetMapping in assetTargetLocations.entries)
189194
if (assetMapping.value.path is KernelAssetRelativePath)
190-
File.fromUri((assetMapping.key.path as AssetAbsolutePath).uri).copy(
191-
outputUri
192-
.resolveUri(
193-
(assetMapping.value.path as KernelAssetRelativePath)
194-
.uri)
195-
.toFilePath())
195+
File.fromUri(assetMapping.key.file!).copy(outputUri
196+
.resolveUri(
197+
(assetMapping.value.path as KernelAssetRelativePath).uri)
198+
.toFilePath())
196199
]);
197200
stdout.writeln('Copied ${copiedFiles.length} native assets.');
198201

pkg/dartdev/lib/src/native_assets.dart

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'dart:io';
88
import 'package:dartdev/src/sdk.dart';
99
import 'package:logging/logging.dart';
1010
import 'package:native_assets_builder/native_assets_builder.dart';
11+
import 'package:native_assets_cli/native_assets_cli.dart';
1112
import 'package:native_assets_cli/native_assets_cli_internal.dart';
1213

1314
import 'core.dart';
@@ -16,7 +17,7 @@ import 'core.dart';
1617
///
1718
/// If provided, only native assets of all transitive dependencies of
1819
/// [runPackageName] are built.
19-
Future<(bool success, List<Asset> assets)> compileNativeAssetsJit({
20+
Future<(bool success, List<AssetImpl> assets)> compileNativeAssetsJit({
2021
required bool verbose,
2122
String? runPackageName,
2223
}) async {
@@ -26,7 +27,7 @@ Future<(bool success, List<Asset> assets)> compileNativeAssetsJit({
2627
if (!await File.fromUri(
2728
workingDirectory.resolve('.dart_tool/package_config.json'))
2829
.exists()) {
29-
return (true, <Asset>[]);
30+
return (true, <AssetImpl>[]);
3031
}
3132
final buildResult = await NativeAssetsBuildRunner(
3233
// This always runs in JIT mode.
@@ -37,11 +38,14 @@ Future<(bool success, List<Asset> assets)> compileNativeAssetsJit({
3738
// When running in JIT mode, only the host OS needs to be build.
3839
target: Target.current,
3940
// When running in JIT mode, only dynamic libraries are supported.
40-
linkModePreference: LinkModePreference.dynamic,
41+
linkModePreference: LinkModePreferenceImpl.dynamic,
4142
// Dart has no concept of release vs debug, default to release.
42-
buildMode: BuildMode.release,
43+
buildMode: BuildModeImpl.release,
4344
includeParentEnvironment: true,
4445
runPackageName: runPackageName,
46+
supportedAssetTypes: [
47+
NativeCodeAsset.type,
48+
],
4549
);
4650
return (buildResult.success, buildResult.assets);
4751
}
@@ -65,7 +69,8 @@ Future<(bool success, Uri? nativeAssetsYaml)> compileNativeAssetsJitYamlFile({
6569
return (false, null);
6670
}
6771
final kernelAssets = KernelAssets([
68-
for (final asset in assets) _targetLocation(asset),
72+
for (final asset in assets.whereType<NativeCodeAssetImpl>())
73+
_targetLocation(asset),
6974
]);
7075

7176
final workingDirectory = Directory.current.uri;
@@ -78,26 +83,26 @@ ${kernelAssets.toNativeAssetsFile()}''';
7883
return (true, assetsUri);
7984
}
8085

81-
KernelAsset _targetLocation(Asset asset) {
82-
final path = asset.path;
86+
KernelAsset _targetLocation(NativeCodeAssetImpl asset) {
87+
final linkMode = asset.linkMode;
8388
final KernelAssetPath kernelAssetPath;
84-
switch (path) {
85-
case AssetSystemPath _:
86-
kernelAssetPath = KernelAssetSystemPath(path.uri);
87-
case AssetInExecutable _:
89+
switch (linkMode) {
90+
case DynamicLoadingSystemImpl _:
91+
kernelAssetPath = KernelAssetSystemPath(linkMode.uri);
92+
case LookupInExecutableImpl _:
8893
kernelAssetPath = KernelAssetInExecutable();
89-
case AssetInProcess _:
94+
case LookupInProcessImpl _:
9095
kernelAssetPath = KernelAssetInProcess();
91-
case AssetAbsolutePath _:
92-
kernelAssetPath = KernelAssetAbsolutePath(path.uri);
96+
case DynamicLoadingBundledImpl _:
97+
kernelAssetPath = KernelAssetAbsolutePath(asset.file!);
9398
default:
9499
throw Exception(
95-
'Unsupported asset path type ${path.runtimeType} in asset $asset',
100+
'Unsupported NativeCodeAsset linkMode ${linkMode.runtimeType} in asset $asset',
96101
);
97102
}
98103
return KernelAsset(
99104
id: asset.id,
100-
target: asset.target,
105+
target: Target.fromArchitectureAndOS(asset.architecture!, asset.os),
101106
path: kernelAssetPath,
102107
);
103108
}

pkg/test_runner/lib/src/configuration.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:ffi';
88
import 'dart:io';
99

1010
import 'package:native_assets_cli/native_assets_cli_internal.dart'
11-
show CCompilerConfig;
11+
show CCompilerConfigImpl;
1212
import 'package:smith/configuration.dart';
1313
import 'package:smith/smith.dart';
1414

@@ -285,12 +285,12 @@ class TestConfiguration {
285285

286286
late final Map<String, String> nativeCompilerEnvironmentVariables = () {
287287
String unparseKey(String key) => key.replaceAll('.', '__').toUpperCase();
288-
final arKey = unparseKey(CCompilerConfig.arConfigKeyFull);
289-
final ccKey = unparseKey(CCompilerConfig.ccConfigKeyFull);
290-
final ldKey = unparseKey(CCompilerConfig.ldConfigKeyFull);
291-
final envScriptKey = unparseKey(CCompilerConfig.envScriptConfigKeyFull);
288+
final arKey = unparseKey(CCompilerConfigImpl.arConfigKeyFull);
289+
final ccKey = unparseKey(CCompilerConfigImpl.ccConfigKeyFull);
290+
final ldKey = unparseKey(CCompilerConfigImpl.ldConfigKeyFull);
291+
final envScriptKey = unparseKey(CCompilerConfigImpl.envScriptConfigKeyFull);
292292
final envScriptArgsKey =
293-
unparseKey(CCompilerConfig.envScriptArgsConfigKeyFull);
293+
unparseKey(CCompilerConfigImpl.envScriptArgsConfigKeyFull);
294294

295295
if (Platform.isWindows) {
296296
// Use MSVC from Depot Tools instead. When using clang from DEPS, we still

0 commit comments

Comments
 (0)