Skip to content

Commit 9968419

Browse files
dcharkesCommit Queue
authored and
Commit Queue
committed
[deps] Roll dart-lang/native
Manuall roll for dart-lang/native#964. TEST=pkg/dartdev/test/native_assets/ Change-Id: Ie1e762ed57971db105cc9d6d5fa21e9f99e76453 Cq-Include-Trybots: luci.dart.try:pkg-win-release-try,pkg-win-release-arm64-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-linux-release-try,pkg-linux-release-arm64-try,pkg-linux-debug-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352642 Reviewed-by: Moritz Sümmermann <[email protected]> Commit-Queue: Daco Harkes <[email protected]>
1 parent db76210 commit 9968419

File tree

3 files changed

+55
-18
lines changed

3 files changed

+55
-18
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ vars = {
162162
"material_color_utilities_rev": "799b6ba2f3f1c28c67cc7e0b4f18e0c7d7f3c03e",
163163
"mime_rev": "9a168712d6db610c3822617c132daea72d4fd2b5",
164164
"mockito_rev": "7d6632fd679f0f6aae32ee74038ba8cb6b64a607",
165-
"native_rev": "b1a0c2a211c2c85d9392b74abacef5eca7a62364", # mosum@ and dacoharkes@ are rolling breaking changes manually while the assets features are in experimental.
165+
"native_rev": "0901a3323022fdb59657cc2cb00ea5c80a8468a6", # mosum@ and dacoharkes@ are rolling breaking changes manually while the assets features are in experimental.
166166
"package_config_rev": "4a7042bb286cf0b41b26e87972bc28bda535f8b9",
167167
"path_rev": "a7b696071bd83d3ee0a0f1b57ac94d6b1f05cac4",
168168
"pool_rev": "782da82fedca4e5776e43ba321543ed2b20373b2",

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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ class BuildCommand extends DartdevCommand {
141141
stderr.write('Native assets build failed.');
142142
return 255;
143143
}
144-
final staticAssets = nativeAssets.whereLinkMode(LinkMode.static);
144+
final staticAssets =
145+
nativeAssets.where((e) => e.linkMode == LinkMode.static);
145146
if (staticAssets.isNotEmpty) {
146147
stderr.write(
147148
"""'dart build' does not yet support native artifacts packaged as ${LinkMode.static.name}.
@@ -154,42 +155,51 @@ Use linkMode as dynamic library instead.""");
154155
final tempDir = Directory.systemTemp.createTempSync();
155156
if (nativeAssets.isNotEmpty) {
156157
stdout.writeln('Copying native assets.');
157-
Asset targetLocation(Asset asset) {
158+
KernelAsset targetLocation(Asset asset) {
158159
final path = asset.path;
160+
final KernelAssetPath kernelAssetPath;
159161
switch (path) {
160162
case AssetSystemPath _:
163+
kernelAssetPath = KernelAssetSystemPath(path.uri);
161164
case AssetInExecutable _:
165+
kernelAssetPath = KernelAssetInExecutable();
162166
case AssetInProcess _:
163-
return asset;
167+
kernelAssetPath = KernelAssetInProcess();
164168
case AssetAbsolutePath _:
165-
return asset.copyWith(
166-
path: AssetRelativePath(
167-
Uri(
168-
path: path.uri.pathSegments.last,
169-
),
170-
),
169+
kernelAssetPath = KernelAssetRelativePath(
170+
Uri(path: path.uri.pathSegments.last),
171+
);
172+
default:
173+
throw Exception(
174+
'Unsupported asset path type ${path.runtimeType} in asset $asset',
171175
);
172176
}
173-
throw 'Unsupported asset path type ${path.runtimeType} in asset $asset';
177+
return KernelAsset(
178+
id: asset.id,
179+
target: target,
180+
path: kernelAssetPath,
181+
);
174182
}
175183

176184
final assetTargetLocations = {
177185
for (final asset in nativeAssets) asset: targetLocation(asset),
178186
};
179-
await Future.wait([
187+
final copiedFiles = await Future.wait([
180188
for (final assetMapping in assetTargetLocations.entries)
181-
if (assetMapping.key != assetMapping.value)
189+
if (assetMapping.value.path is KernelAssetRelativePath)
182190
File.fromUri((assetMapping.key.path as AssetAbsolutePath).uri).copy(
183191
outputUri
184192
.resolveUri(
185-
(assetMapping.value.path as AssetRelativePath).uri)
193+
(assetMapping.value.path as KernelAssetRelativePath)
194+
.uri)
186195
.toFilePath())
187196
]);
197+
stdout.writeln('Copied ${copiedFiles.length} native assets.');
188198

189199
tempUri = tempDir.uri;
190200
nativeAssetsDartUri = tempUri.resolve('native_assets.yaml');
191-
final assetsContent =
192-
assetTargetLocations.values.toList().toNativeAssetsFile();
201+
final assetsContent = KernelAssets(assetTargetLocations.values.toList())
202+
.toNativeAssetsFile();
193203
await Directory.fromUri(nativeAssetsDartUri.resolve('.')).create();
194204
await File(nativeAssetsDartUri.toFilePath()).writeAsString(assetsContent);
195205
}

pkg/dartdev/lib/src/native_assets.dart

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,44 @@ Future<(bool success, Uri? nativeAssetsYaml)> compileNativeAssetsJitYamlFile({
6464
if (!success) {
6565
return (false, null);
6666
}
67+
final kernelAssets = KernelAssets([
68+
for (final asset in assets) _targetLocation(asset),
69+
]);
6770

6871
final workingDirectory = Directory.current.uri;
6972
final assetsUri = workingDirectory.resolve('.dart_tool/native_assets.yaml');
7073
final nativeAssetsYaml = '''# Native assets mapping for host OS in JIT mode.
71-
# Generated by dartdev and package:native.
72-
${assets.toNativeAssetsFile()}''';
74+
# Generated by dartdev and package:native_assets_builder.
75+
${kernelAssets.toNativeAssetsFile()}''';
7376
final assetFile = File(assetsUri.toFilePath());
7477
await assetFile.writeAsString(nativeAssetsYaml);
7578
return (true, assetsUri);
7679
}
7780

81+
KernelAsset _targetLocation(Asset asset) {
82+
final path = asset.path;
83+
final KernelAssetPath kernelAssetPath;
84+
switch (path) {
85+
case AssetSystemPath _:
86+
kernelAssetPath = KernelAssetSystemPath(path.uri);
87+
case AssetInExecutable _:
88+
kernelAssetPath = KernelAssetInExecutable();
89+
case AssetInProcess _:
90+
kernelAssetPath = KernelAssetInProcess();
91+
case AssetAbsolutePath _:
92+
kernelAssetPath = KernelAssetAbsolutePath(path.uri);
93+
default:
94+
throw Exception(
95+
'Unsupported asset path type ${path.runtimeType} in asset $asset',
96+
);
97+
}
98+
return KernelAsset(
99+
id: asset.id,
100+
target: asset.target,
101+
path: kernelAssetPath,
102+
);
103+
}
104+
78105
Future<bool> warnOnNativeAssets() async {
79106
final workingDirectory = Directory.current.uri;
80107
if (!await File.fromUri(

0 commit comments

Comments
 (0)