Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a generate-all flag to emit all bindings #302

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

srujzs
Copy link
Contributor

@srujzs srujzs commented Sep 12, 2024

In the case where a user wants to use an experimental API
that we don't include in package:web, it is useful to have the
generator emit bindings still so they can copy it over instead
of having to write all of it themselves. This also allows us to
find problems in our tools with newer bindings before they
become standard.

  • Adds a generate-all flag to the tools and refactors code to
    incorporate it when determining whether to generate declarations.
  • Cleans up argument passing so we're always using package:args.
  • Adds a generate_all_and_analyze job to the Dart CI.

In the case where a user wants to use an experimental API
that we don't include in package:web, it is useful to have the
generator emit bindings still so they can copy it over instead
of having to write all of it themselves. This also allows us to
find problems in our tools with newer bindings before they
become standard.

- Adds a generate-all flag to the tools and refactors code to
incorporate it when determining whether to generate declarations.
- Cleans up argument passing so we're always using package:args.
- Adds a generate_all_and_analyze to the Dart CI.
@srujzs srujzs requested a review from sigmundch September 12, 2024 22:28
@srujzs
Copy link
Contributor Author

srujzs commented Sep 12, 2024

This came up a couple of times, but most recently in #287.

Copy link
Member

@sigmundch sigmundch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a small suggestion below

@@ -15,12 +15,18 @@ import 'filesystem_api.dart';
class BrowserCompatData {
static final Map<String, Set<BCDPropertyStatus>> _eventHandlers = {};

/// Whether to generate all the bindings regardless of property status.
static bool generateAll = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to see if we could get away without making this static and without too much refactoring, and it appears that maybe it's possible?

Seems we use this property in:

  • BCDItem subclasses's shouldGenerate getters: those however appear to be used within the context of a method that already checks for generateAll (isEventHandlerSupported and shouldGenerateInterface) so it may be safe to remove the use from these getters?
  • the methods where generateAll is used also have access to a translator, so they can fetch the value through it (e.g. _shouldGenerateMember can read it from Translator.instance!.browserCompatibilityData.generateAll?

Would that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! It took a little bit of refactoring, but making shouldGenerate a field allows this to work for the first bullet-point and the second bullet point works for translator.dart. isEventHandlerSupported doesn't need to check for generateAll since shouldGenerate handles that anyways.

web_generator/lib/src/bcd.dart Show resolved Hide resolved
@srujzs srujzs merged commit d8549a3 into dart-lang:main Sep 13, 2024
17 checks passed
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Sep 23, 2024
Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/8100ccf..526dbd5):
  526dbd55  2024-09-15  Sam Rawlins  Strip the enclosing package's lower-case name from a library's dir name (dart-lang/dartdoc#3883)
  98dd9dad  2024-09-13  Sam Rawlins  Add output-size info to the '--stats' flag on various tasks. (dart-lang/dartdoc#3879)
  090b05ba  2024-09-13  Sam Rawlins  Bump to 8.2.0 (dart-lang/dartdoc#3880)
  0a529762  2024-09-12  Sam Rawlins  Fix search which is not using canonical libraries as enclosing elements (dart-lang/dartdoc#3877)
  d4dff9a4  2024-09-12  Konstantin Scheglov  Stop using 'augmented' from the element model. (dart-lang/dartdoc#3878)
  d6b865f9  2024-09-11  Sam Rawlins  Support multiple partial calls from a single template (dart-lang/dartdoc#3873)
  25c9edf3  2024-09-10  Parker Lougheed  Standardize to newer SDK APIs (dart-lang/dartdoc#3872)
  b61de2f2  2024-09-10  Sam Rawlins  Clean up some sorting, naming, and doc nits (dart-lang/dartdoc#3876)
  55ce1164  2024-09-10  Sam Rawlins  Use latest language version for DartFormatter (dart-lang/dartdoc#3875)
  2a262818  2024-09-10  Sam Rawlins  Comply with analyzer 6.9.0 APIs (dart-lang/dartdoc#3874)
  ca98b898  2024-09-09  Sam Rawlins  Include extension members on the extended type's page (dart-lang/dartdoc#3863)

mockito (https://github.com/dart-lang/mockito/compare/d0fda0c..b66be81):
  b66be81  2024-09-13  Googler  Migration for analyzer APIs.

stack_trace (https://github.com/dart-lang/stack_trace/compare/090d3d1..5b82965):
  5b82965  2024-09-19  Ömer Sinan Ağacan  Relax URI matching in V8 Wasm frame regex (dart-lang/stack_trace#161)
  9b1ed4f  2024-09-19  Ömer Sinan Ağacan  Add support for parsing Wasm stack frames of Chrome (V8), Firefox, Safari (dart-lang/stack_trace#159)
  d38eee8  2024-09-17  Ömer Sinan Ağacan  Fix analysis issues (dart-lang/stack_trace#160)

test (https://github.com/dart-lang/test/compare/9a2d155..22835e2):
  22835e2e  2024-09-13  Nate Bosch  Add support for multiple full paths on macos (dart-lang/test#2276)

web (https://github.com/dart-lang/web/compare/933a37d..d8549a3):
  d8549a3  2024-09-13  Srujan Gaddam   Add a generate-all flag to emit all bindings (dart-lang/web#302)

Change-Id: Ib07e4c0eda9c8ea180ef989c7d9cf20c390457e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386260
Commit-Queue: Konstantin Shcheglov <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
FMorschel pushed a commit to FMorschel/sdk that referenced this pull request Sep 25, 2024
Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/8100ccf..526dbd5):
  526dbd55  2024-09-15  Sam Rawlins  Strip the enclosing package's lower-case name from a library's dir name (dart-lang/dartdoc#3883)
  98dd9dad  2024-09-13  Sam Rawlins  Add output-size info to the '--stats' flag on various tasks. (dart-lang/dartdoc#3879)
  090b05ba  2024-09-13  Sam Rawlins  Bump to 8.2.0 (dart-lang/dartdoc#3880)
  0a529762  2024-09-12  Sam Rawlins  Fix search which is not using canonical libraries as enclosing elements (dart-lang/dartdoc#3877)
  d4dff9a4  2024-09-12  Konstantin Scheglov  Stop using 'augmented' from the element model. (dart-lang/dartdoc#3878)
  d6b865f9  2024-09-11  Sam Rawlins  Support multiple partial calls from a single template (dart-lang/dartdoc#3873)
  25c9edf3  2024-09-10  Parker Lougheed  Standardize to newer SDK APIs (dart-lang/dartdoc#3872)
  b61de2f2  2024-09-10  Sam Rawlins  Clean up some sorting, naming, and doc nits (dart-lang/dartdoc#3876)
  55ce1164  2024-09-10  Sam Rawlins  Use latest language version for DartFormatter (dart-lang/dartdoc#3875)
  2a262818  2024-09-10  Sam Rawlins  Comply with analyzer 6.9.0 APIs (dart-lang/dartdoc#3874)
  ca98b898  2024-09-09  Sam Rawlins  Include extension members on the extended type's page (dart-lang/dartdoc#3863)

mockito (https://github.com/dart-lang/mockito/compare/d0fda0c..b66be81):
  b66be81  2024-09-13  Googler  Migration for analyzer APIs.

stack_trace (https://github.com/dart-lang/stack_trace/compare/090d3d1..5b82965):
  5b82965  2024-09-19  Ömer Sinan Ağacan  Relax URI matching in V8 Wasm frame regex (dart-lang/stack_trace#161)
  9b1ed4f  2024-09-19  Ömer Sinan Ağacan  Add support for parsing Wasm stack frames of Chrome (V8), Firefox, Safari (dart-lang/stack_trace#159)
  d38eee8  2024-09-17  Ömer Sinan Ağacan  Fix analysis issues (dart-lang/stack_trace#160)

test (https://github.com/dart-lang/test/compare/9a2d155..22835e2):
  22835e2e  2024-09-13  Nate Bosch  Add support for multiple full paths on macos (dart-lang/test#2276)

web (https://github.com/dart-lang/web/compare/933a37d..d8549a3):
  d8549a3  2024-09-13  Srujan Gaddam   Add a generate-all flag to emit all bindings (dart-lang/web#302)

Change-Id: Ib07e4c0eda9c8ea180ef989c7d9cf20c390457e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386260
Commit-Queue: Konstantin Shcheglov <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants