Skip to content

Commit

Permalink
Version 3.6.0-308.0.dev
Browse files Browse the repository at this point in the history
Merge c4a77dc into dev
  • Loading branch information
Dart CI committed Oct 1, 2024
2 parents 0e8b99c + c4a77dc commit 345a9d8
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 101 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ vars = {
"matcher_rev": "d6d573d0f8d65b36550ce62aad3ce6b5e987b642",
"material_color_utilities_rev": "799b6ba2f3f1c28c67cc7e0b4f18e0c7d7f3c03e",
"mockito_rev": "b66be81e38e1ac76d12ee2fe4f93757a40bbb7ba",
"native_rev": "67a258ce5a365f13180978637be0f10996cced43", # dart-native-interop-team@ is rolling breaking changes manually while the assets features are in experimental.
"native_rev": "d144f81442894f669108699517d4f4a3f7a529f8", # dart-native-interop-team@ is rolling breaking changes manually while the assets features are in experimental.
"package_config_rev": "76934c2ca25922ec72909bbff7dfbddaf0d02bd9",
"path_rev": "e969f42ed112dd702a9453beb9df6c12ae2d3805",
"pool_rev": "924fb04353cec915d927f9f1aed88e2eda92b98a",
Expand Down
47 changes: 23 additions & 24 deletions pkg/dartdev/lib/src/commands/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'package:dartdev/src/utils.dart';
import 'package:front_end/src/api_prototype/compiler_options.dart'
show Verbosity;
import 'package:native_assets_builder/native_assets_builder.dart';
import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';
import 'package:path/path.dart' as path;
import 'package:vm/target_os.dart'; // For possible --target-os values.
Expand Down Expand Up @@ -145,11 +144,11 @@ class BuildCommand extends DartdevCommand {
final buildResult = await nativeAssetsBuildRunner.build(
workingDirectory: workingDirectory,
target: target,
linkModePreference: LinkModePreferenceImpl.dynamic,
buildMode: BuildModeImpl.release,
linkModePreference: LinkModePreference.dynamic,
buildMode: BuildMode.release,
includeParentEnvironment: true,
supportedAssetTypes: [
NativeCodeAsset.type,
CodeAsset.type,
],
targetMacOSVersion: targetMacOSVersion,
linkingEnabled: true,
Expand Down Expand Up @@ -190,13 +189,13 @@ class BuildCommand extends DartdevCommand {
recordUseEnabled ? Uri.file(recordedUsagesPath!) : null,
workingDirectory: workingDirectory,
target: target,
linkModePreference: LinkModePreferenceImpl.dynamic,
buildMode: BuildModeImpl.release,
linkModePreference: LinkModePreference.dynamic,
buildMode: BuildMode.release,
includeParentEnvironment: true,
buildResult: buildResult,
targetMacOSVersion: targetMacOSVersion,
supportedAssetTypes: [
NativeCodeAsset.type,
CodeAsset.type,
],
);

Expand All @@ -209,11 +208,11 @@ class BuildCommand extends DartdevCommand {
Uri? assetsDartUri;
final allAssets = [...buildResult.assets, ...linkResult.assets];
final staticAssets = allAssets
.whereType<NativeCodeAssetImpl>()
.where((e) => e.linkMode == StaticLinkingImpl());
.whereType<CodeAsset>()
.where((e) => e.linkMode == StaticLinking());
if (staticAssets.isNotEmpty) {
stderr.write(
"""'dart build' does not yet support NativeCodeAssets with static linking.
"""'dart build' does not yet support CodeAssets with static linking.
Use linkMode as dynamic library instead.""");
return 255;
}
Expand Down Expand Up @@ -247,8 +246,8 @@ Use linkMode as dynamic library instead.""");
return 0;
}

List<({AssetImpl asset, KernelAsset target})> _targetMapping(
Iterable<AssetImpl> assets,
List<({Asset asset, KernelAsset target})> _targetMapping(
Iterable<Asset> assets,
Target target,
) {
return [
Expand All @@ -258,7 +257,7 @@ Use linkMode as dynamic library instead.""");
}

void _copyAssets(
List<({AssetImpl asset, KernelAsset target})> assetTargetLocations,
List<({Asset asset, KernelAsset target})> assetTargetLocations,
Uri output,
) {
for (final (asset: asset, target: target) in assetTargetLocations) {
Expand Down Expand Up @@ -303,33 +302,33 @@ extension on Uri {
}
}

extension on AssetImpl {
extension on Asset {
KernelAsset targetLocation(Target target) {
return switch (this) {
NativeCodeAssetImpl nativeAsset => nativeAsset.targetLocation(target),
DataAssetImpl dataAsset => dataAsset.targetLocation(target),
AssetImpl() => throw UnimplementedError(),
CodeAsset nativeAsset => nativeAsset.targetLocation(target),
DataAsset dataAsset => dataAsset.targetLocation(target),
Asset() => throw UnimplementedError(),
};
}
}

extension on NativeCodeAssetImpl {
extension on CodeAsset {
KernelAsset targetLocation(Target target) {
final KernelAssetPath kernelAssetPath;
switch (linkMode) {
case DynamicLoadingSystemImpl dynamicLoading:
case DynamicLoadingSystem dynamicLoading:
kernelAssetPath = KernelAssetSystemPath(dynamicLoading.uri);
case LookupInExecutableImpl _:
case LookupInExecutable _:
kernelAssetPath = KernelAssetInExecutable();
case LookupInProcessImpl _:
case LookupInProcess _:
kernelAssetPath = KernelAssetInProcess();
case DynamicLoadingBundledImpl _:
case DynamicLoadingBundled _:
kernelAssetPath = KernelAssetRelativePath(
Uri(path: path.join(_libOutputDirectory, file!.pathSegments.last)),
);
default:
throw Exception(
'Unsupported NativeCodeAsset linkMode ${linkMode.runtimeType} in asset $this',
'Unsupported CodeAsset linkMode ${linkMode.runtimeType} in asset $this',
);
}
return KernelAsset(
Expand All @@ -340,7 +339,7 @@ extension on NativeCodeAssetImpl {
}
}

extension on DataAssetImpl {
extension on DataAsset {
KernelAsset targetLocation(Target target) {
return KernelAsset(
id: id,
Expand Down
32 changes: 15 additions & 17 deletions pkg/dartdev/lib/src/native_assets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:dartdev/src/sdk.dart';
import 'package:dartdev/src/utils.dart';
import 'package:logging/logging.dart';
import 'package:native_assets_builder/native_assets_builder.dart';
import 'package:native_assets_cli/native_assets_cli.dart';
import 'package:native_assets_cli/native_assets_cli_internal.dart';

import 'core.dart';
Expand All @@ -18,7 +17,7 @@ import 'core.dart';
///
/// If provided, only native assets of all transitive dependencies of
/// [runPackageName] are built.
Future<(bool success, List<AssetImpl> assets)> compileNativeAssetsJit({
Future<(bool success, List<Asset> assets)> compileNativeAssetsJit({
required bool verbose,
String? runPackageName,
}) async {
Expand All @@ -33,10 +32,10 @@ Future<(bool success, List<AssetImpl> assets)> compileNativeAssetsJit({
// `getExecutableForCommand` later.
final result = await Process.run(sdk.dart, ['pub', 'get']);
if (result.exitCode != 0) {
return (true, <AssetImpl>[]);
return (true, <Asset>[]);
}
} else {
return (true, <AssetImpl>[]);
return (true, <Asset>[]);
}
}
final nativeAssetsBuildRunner = NativeAssetsBuildRunner(
Expand All @@ -52,13 +51,13 @@ Future<(bool success, List<AssetImpl> assets)> compileNativeAssetsJit({
// When running in JIT mode, only the host OS needs to be build.
target: target,
// When running in JIT mode, only dynamic libraries are supported.
linkModePreference: LinkModePreferenceImpl.dynamic,
linkModePreference: LinkModePreference.dynamic,
// Dart has no concept of release vs debug, default to release.
buildMode: BuildModeImpl.release,
buildMode: BuildMode.release,
includeParentEnvironment: true,
runPackageName: runPackageName,
supportedAssetTypes: [
NativeCodeAsset.type,
CodeAsset.type,
],
targetMacOSVersion: targetMacOSVersion,
linkingEnabled: false,
Expand Down Expand Up @@ -90,11 +89,10 @@ Future<(bool success, Uri? nativeAssetsYaml)> compileNativeAssetsJitYamlFile({
}
final kernelAssets = KernelAssets([
...[
for (final asset in assets.whereType<NativeCodeAssetImpl>())
_targetLocation(asset),
for (final asset in assets.whereType<CodeAsset>()) _targetLocation(asset),
],
...[
for (final asset in assets.whereType<DataAssetImpl>())
for (final asset in assets.whereType<DataAsset>())
_dataTargetLocation(asset),
]
]);
Expand All @@ -109,21 +107,21 @@ ${kernelAssets.toNativeAssetsFile()}''';
return (true, assetsUri);
}

KernelAsset _targetLocation(NativeCodeAssetImpl asset) {
KernelAsset _targetLocation(CodeAsset asset) {
final linkMode = asset.linkMode;
final KernelAssetPath kernelAssetPath;
switch (linkMode) {
case DynamicLoadingSystemImpl _:
case DynamicLoadingSystem _:
kernelAssetPath = KernelAssetSystemPath(linkMode.uri);
case LookupInExecutableImpl _:
case LookupInExecutable _:
kernelAssetPath = KernelAssetInExecutable();
case LookupInProcessImpl _:
case LookupInProcess _:
kernelAssetPath = KernelAssetInProcess();
case DynamicLoadingBundledImpl _:
case DynamicLoadingBundled _:
kernelAssetPath = KernelAssetAbsolutePath(asset.file!);
default:
throw Exception(
'Unsupported NativeCodeAsset linkMode ${linkMode.runtimeType} in asset $asset',
'Unsupported CodeAsset linkMode ${linkMode.runtimeType} in asset $asset',
);
}
return KernelAsset(
Expand All @@ -133,7 +131,7 @@ KernelAsset _targetLocation(NativeCodeAssetImpl asset) {
);
}

KernelAsset _dataTargetLocation(DataAssetImpl asset) {
KernelAsset _dataTargetLocation(DataAsset asset) {
return KernelAsset(
id: asset.id,
target: Target.current,
Expand Down
9 changes: 4 additions & 5 deletions pkg/dartdev/test/native_assets/build_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ void main(List<String> args) {
final directory =
Directory.fromUri(dartAppUri.resolve('bin/add_asset_link'));
expect(directory.existsSync(), true);
final dylib =
OSImpl.current.libraryFileName('add', DynamicLoadingBundledImpl());
final dylib = OS.current.libraryFileName('add', DynamicLoadingBundled());
expect(
File.fromUri(directory.uri.resolve('lib/$dylib')).existsSync(),
true,
Expand Down Expand Up @@ -241,9 +240,9 @@ void main(List<String> args) {
() async {
await recordUseTest('drop_dylib_recording', (dartAppUri) async {
final addLib =
OSImpl.current.libraryFileName('add', DynamicLoadingBundledImpl());
final mulitplyLib = OSImpl.current
.libraryFileName('multiply', DynamicLoadingBundledImpl());
OS.current.libraryFileName('add', DynamicLoadingBundled());
final mulitplyLib =
OS.current.libraryFileName('multiply', DynamicLoadingBundled());
// Now try using the add symbol only, so the multiply library is
// tree-shaken.

Expand Down
38 changes: 18 additions & 20 deletions pkg/dartdev/test/native_assets/test_environment_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,35 @@

import 'dart:io';

import 'package:native_assets_cli/native_assets_cli_internal.dart'
show CCompilerConfigImpl;
import 'package:test/test.dart';

void main() async {
// Test pkg/test_runner/lib/src/configuration.dart
test('test environment', () async {
printOnFailure(Platform.environment.toString());

String unparseKey(String key) =>
'DART_HOOK_TESTING_${key.replaceAll('.', '__').toUpperCase()}';

final arKey = unparseKey(CCompilerConfigImpl.arConfigKeyFull);
final ccKey = unparseKey(CCompilerConfigImpl.ccConfigKeyFull);
final ldKey = unparseKey(CCompilerConfigImpl.ldConfigKeyFull);
final envScriptKey = unparseKey(CCompilerConfigImpl.envScriptConfigKeyFull);
final envScriptArgsKey =
unparseKey(CCompilerConfigImpl.envScriptArgsConfigKeyFull);
final ar = Platform.environment['DART_HOOK_TESTING_C_COMPILER__AR'];
final cc = Platform.environment['DART_HOOK_TESTING_C_COMPILER__CC'];
final ld = Platform.environment['DART_HOOK_TESTING_C_COMPILER__LD'];
final envScript =
Platform.environment['DART_HOOK_TESTING_C_COMPILER__ENV_SCRIPT'];
final envScriptArgs = Platform
.environment['DART_HOOK_TESTING_C_COMPILER__ENV_SCRIPT_ARGUMENTS']
?.split(' ');

if (Platform.isLinux || Platform.isWindows) {
expect(Platform.environment[arKey], isNotEmpty);
expect(await File(Platform.environment[arKey]!).exists(), true);
expect(Platform.environment[ccKey], isNotEmpty);
expect(await File(Platform.environment[ccKey]!).exists(), true);
expect(Platform.environment[ldKey], isNotEmpty);
expect(await File(Platform.environment[ldKey]!).exists(), true);
expect(ar, isNotNull);
expect(await File(ar!).exists(), true);
expect(cc, isNotNull);
expect(await File(cc!).exists(), true);
expect(ld, isNotNull);
expect(await File(ld!).exists(), true);
}
if (Platform.isWindows) {
expect(Platform.environment[envScriptKey], isNotEmpty);
expect(await File(Platform.environment[envScriptKey]!).exists(), true);
expect(Platform.environment[envScriptArgsKey], isNotEmpty);
expect(envScript, isNotNull);
expect(await File(envScript!).exists(), true);
expect(envScriptArgs, isNotNull);
expect(envScriptArgs!, isNotEmpty);
}
});
}
4 changes: 3 additions & 1 deletion pkg/dds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 5.0.0
# 5.0.0-wip
- Updated the `devtools_shared` dependency to version `^11.0.0`.
- Made `runDartDevelopmentServiceFromCLI` pass the specified bind address
directly into `startDartDevelopmentService` without resolving the address.

# 4.2.7
- Added a new constant `RpcErrorCodes.kConnectionDisposed = -32010` for requests
Expand Down
25 changes: 12 additions & 13 deletions pkg/dds/lib/src/dds_cli_entrypoint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,18 @@ ${argParser.usage}
argResults[DartDevelopmentServiceOptions.vmServiceUriOption],
);

// Prefer IPv4 addresses if we can't determine the address type from the
// VM service host.
final preferredProtocolType =
InternetAddress.tryParse(remoteVmServiceUri.host)?.type ??
InternetAddressType.IPv4;

// Resolve the address which is potentially provided by the user.
late InternetAddress address;
// Ensure that the bind address, which is potentially provided by the user,
// can be resolved at all, and check whether it can be resolved to an IPv4
// address.
bool doesBindAddressResolveToIpv4Address = false;
final bindAddress =
argResults[DartDevelopmentServiceOptions.bindAddressOption];
try {
final addresses = await InternetAddress.lookup(bindAddress);
for (int i = 0; i < addresses.length; i++) {
address = addresses[i];
if (address.type == preferredProtocolType) break;
for (final address in addresses) {
if (address.type == InternetAddressType.IPv4) {
doesBindAddressResolveToIpv4Address = true;
}
}
} on SocketException catch (e, st) {
writeErrorResponse('Invalid bind address: $bindAddress', st);
Expand All @@ -86,7 +83,7 @@ ${argParser.usage}
}
final serviceUri = Uri(
scheme: 'http',
host: address.address,
host: bindAddress,
port: port,
);
final disableServiceAuthCodes =
Expand Down Expand Up @@ -118,7 +115,9 @@ ${argParser.usage}
remoteVmServiceUri,
serviceUri: serviceUri,
enableAuthCodes: !disableServiceAuthCodes,
ipv6: address.type == InternetAddressType.IPv6,
// Only use IPv6 to serve DDS if the bind address cannot be resolved to an
// IPv4 address.
ipv6: !doesBindAddressResolveToIpv4Address,
devToolsConfiguration: serveDevTools && devToolsBuildDirectory != null
? DevToolsConfiguration(
enable: serveDevTools,
Expand Down
Loading

0 comments on commit 345a9d8

Please sign in to comment.