Skip to content

Swift: make C++ code generation more self-contained #9198

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

Merged
merged 3 commits into from
May 23, 2022

Conversation

redsun82
Copy link
Contributor

This is solving a papercut, where the C++ build was relying on the
local dbscheme file to be up-to-date, even if all the information for
building is actually in schema.yml. This made a pure C++ development
cycle with changes to schema.yml clumsy, as it required a further
dbscheme generation step.

Now for C++ the dbscheme is generated internally in the build files, and
thus a change in schema.yml is reflected immediately in the C++ build.

A swift/codegen step for checked in generated code (including the
dbscheme) is still required, but a developer can do it just before
running QL tests or committing, instead of during each C++
recompilation.

Some directory reorganization was also carried out, moving specific
generator modules to a new generators python package, and only leaving
the two drivers at the top level.

redsun82 added 2 commits May 17, 2022 16:31
This allows to avoid bypassing label type correcness in the extractor,
and allows to independently resolve TBD extractions, as with this
approach TBD nodes do have the correctly typed trap label. The TBD
status is now a predicate on the QL side.

This requires:
* a default visit using the correct type, which is achieved via macro
  metaprogramming in `VisitorBase.h`, following the way
  `swift::ASTVisitor` is programmed
* a mapping from labels to corresponding binding trap entries. The
  functor is defined in `TrapTagTraits.h` and instantiated in generated
  `TrapEntries.h`
* Binding trap entries for TBD unknown entities must not have any other
  field than the `id` (after all, we are supposed to not extract them
  yet). This is why all unextracted fields in `schema.yml` have been
  commented out, and will be uncommentend when visitors are added
This is solving a papercut, where the C++ build was relying on the
local dbscheme file to be up-to-date, even if all the information for
building is actually in `schema.yml`. This made a pure C++ development
cycle with changes to `schema.yml` clumsy, as it required a further
dbscheme generation step.

Now for C++ the dbscheme is generated internally in the build files, and
thus a change in `schema.yml` is reflected immediately in the C++ build.

A `swift/codegen` step for checked in generated code (including the
dbscheme) is still required, but a developer can do it just before
running QL tests or committing, instead of during each C++
recompilation.

Some directory reorganization was also carried out, moving specific
generator modules to a new `generators` python package, and only leaving
the two drivers at the top level.
@redsun82 redsun82 requested a review from AlexDenisov May 17, 2022 15:07
@redsun82 redsun82 requested review from a team as code owners May 17, 2022 15:07
@github-actions github-actions bot added the Swift label May 17, 2022
AlexDenisov
AlexDenisov previously approved these changes May 17, 2022
@redsun82 redsun82 force-pushed the redsun82/swift-tbd-rework branch 4 times, most recently from 83e1071 to da00bf9 Compare May 20, 2022 07:52
Base automatically changed from redsun82/swift-tbd-rework to main May 20, 2022 13:39
@redsun82 redsun82 merged commit 06a8cf6 into main May 23, 2022
@redsun82 redsun82 deleted the redsun82/swift-self-contained-cpp-code-gen branch May 23, 2022 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants