-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
58019: lang{,gen},bazel: generate more files within the sandbox r=irfansharif a=irfansharif Part of #57801. Generating these files within the sandbox was a bit tricky seeing as how the optgen language compiler uses itself to generate its AST expressions. This is a form of compiler bootstrapping [1], and needed some manual overrides to fit into how Bazel wants things to be. To this end, we define a second `go_library` target [2] that sources pre-generated `og.go` files that are already checked into the source tree. These files are then used to compile `langgen`, which is in turn used to generate newer revisions of those same generated files. All dependants of [3] will need to depend on the og.go files generated in the Bazel sandbox, which is achieved by [4]. Conversely, to instruct gazelle/Bazel to resolve langgen's import of [3] appropriately, we added a custom resolve directive. We'll eventually want to be able to implant the sandbox generated files back into the source tree. This will be necessary for IDEs, but also for a sane workflow for the engineers working on langgen. If they were only using Bazel today, langgen dependent builds would misbehave as we wouldn't be updating the checked-in og.go files used to build langgen itself (assuming any diffs there would result in different code/compilation behaviour). See #58018. ``` [1]: https://en.wikipedia.org/wiki/Bootstrapping_(compilers) [2]: //pkg/sql/opt/optgen/lang:bootstrap [3]: github.com/cockroachdb/cockroach/pkg/sql/opt/optgen/lang [4]: See the "gazelle:resolve" directive in the top-level BUILD.bazel file ``` Release note: None Co-authored-by: irfan sharif <[email protected]>
- Loading branch information
Showing
4 changed files
with
80 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters