Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into hotrestart
Browse files Browse the repository at this point in the history
  • Loading branch information
srujzs committed Jan 22, 2025
2 parents 393609a + 63894bb commit bcabca7
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dcm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg
echo 'deb [signed-by=/usr/share/keyrings/dcm.gpg arch=amd64] https://dcm.dev/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list
sudo apt-get update
sudo apt-get install dcm=1.16.2-1 # To avoid errors add `-1` (build number) to the version
sudo apt-get install dcm=1.26.0-1 # To avoid errors add `-1` (build number) to the version
sudo chmod +x /usr/bin/dcm
- name: Setup Dart SDK
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
Expand Down
2 changes: 2 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 24.3.3

- Added support for some debugging APIs with the DDC library bundle format. - [#2563](https://github.com/dart-lang/webdev/issues/2563)
- Update `DCM` version to `1.26.0-1`
- Add support for hot restart using the DDC library bundle format.

## 24.3.2
Expand Down
14 changes: 9 additions & 5 deletions dwds/lib/src/debugging/dart_runtime_debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ class DartRuntimeDebugger {
String _generateJsExpression(
String ddcExpression,
String libraryBundleExpression,
) {
return _useLibraryBundleExpression
? libraryBundleExpression
: ddcExpression;
}
) =>
_useLibraryBundleExpression ? libraryBundleExpression : ddcExpression;

/// Wraps a JS function call with SDK loader logic.
String _wrapWithSdkLoader(String args, String functionCall) {
Expand Down Expand Up @@ -199,4 +196,11 @@ class DartRuntimeDebugger {
),
);
}

String invokeExtensionJsExpression(String methodName, String encodedJson) {
return _generateJsExpression(
"${_loadStrategy.loadModuleSnippet}('dart_sdk').developer.invokeExtension('$methodName', JSON.stringify($encodedJson));",
"dartDevEmbedder.debugger.invokeExtension('$methodName', JSON.stringify($encodedJson));",
);
}
}
6 changes: 2 additions & 4 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,8 @@ class ChromeProxyService implements VmServiceInterface {
v is String ? v : jsonEncode(v),
),
);
final expression = '''
${globalToolConfiguration.loadStrategy.loadModuleSnippet}("dart_sdk").developer.invokeExtension(
"$method", JSON.stringify(${jsonEncode(stringArgs)}));
''';
final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
.invokeExtensionJsExpression(method, jsonEncode(stringArgs));
final result = await inspector.jsEvaluate(expression, awaitPromise: true);
final decodedResponse =
jsonDecode(result.value as String) as Map<String, dynamic>;
Expand Down
40 changes: 40 additions & 0 deletions dwds/test/chrome_proxy_service_amd_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

@TestOn('vm')
@Tags(['daily'])
@Timeout(Duration(minutes: 2))
library;

import 'package:dwds/expression_compiler.dart';
import 'package:test/test.dart';
import 'package:test_common/test_sdk_configuration.dart';

import 'common/chrome_proxy_service_common.dart';
import 'fixtures/context.dart';

void main() {
// Enable verbose logging for debugging.
final debug = false;
final canaryFeatures = false;
final moduleFormat = ModuleFormat.amd;
final compilationMode = CompilationMode.buildDaemon;

group('canary: $canaryFeatures |', () {
final provider = TestSdkConfigurationProvider(
verbose: debug,
canaryFeatures: canaryFeatures,
ddcModuleFormat: moduleFormat,
);
tearDownAll(provider.dispose);

runTests(
provider: provider,
moduleFormat: moduleFormat,
compilationMode: compilationMode,
canaryFeatures: canaryFeatures,
debug: debug,
);
});
}
40 changes: 40 additions & 0 deletions dwds/test/chrome_proxy_service_ddc_library_bundle_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

@TestOn('vm')
@Tags(['daily'])
@Timeout(Duration(minutes: 2))
library;

import 'package:dwds/expression_compiler.dart';
import 'package:test/test.dart';
import 'package:test_common/test_sdk_configuration.dart';

import 'common/chrome_proxy_service_common.dart';
import 'fixtures/context.dart';

void main() {
// Enable verbose logging for debugging.
final debug = false;
final canaryFeatures = true;
final moduleFormat = ModuleFormat.ddc;
final compilationMode = CompilationMode.frontendServer;

group('canary: $canaryFeatures |', () {
final provider = TestSdkConfigurationProvider(
verbose: debug,
canaryFeatures: canaryFeatures,
ddcModuleFormat: moduleFormat,
);
tearDownAll(provider.dispose);

runTests(
provider: provider,
moduleFormat: moduleFormat,
compilationMode: compilationMode,
canaryFeatures: canaryFeatures,
debug: debug,
);
});
}
Loading

0 comments on commit bcabca7

Please sign in to comment.