Skip to content

BUILD file generation #789

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

Closed
alexeagle opened this issue Sep 5, 2017 · 14 comments
Closed

BUILD file generation #789

alexeagle opened this issue Sep 5, 2017 · 14 comments
Labels
Can Close? We will close this in 30 days if there is no further activity enhancement

Comments

@alexeagle
Copy link
Collaborator

Like https://github.com/bazelbuild/rules_go/tree/master/go/tools/gazelle

we should be able to generate/maintain BUILD files automatically from TypeScript sources.
We do this internally at google.

@dgoldstein0
Copy link

if this were open sourced, I would be interested in using it here at Dropbox.

@ashi009
Copy link
Contributor

ashi009 commented Jan 2, 2019

Any updates on this? Would love to contribute on this if there is a design doc shared publicly.

AFAIK, Gazelle is aiming to provide build file generation for other languages as well, and the implementation is almost language-agnostic already.

EDIT: gazelle 0.16 is now released with custom language support

@alexeagle
Copy link
Collaborator Author

ts_auto_deps is now released, which has very minimal support for BUILD file generation.
Will move this to rules_nodejs - @Globegitter has a gazelle-based TS BUILD file generator but I'd like to see this reconciled with the library code in ts_auto_deps (both are written in Go so it should be possible)

@alexeagle alexeagle transferred this issue from bazelbuild/rules_typescript May 24, 2019
@alexeagle alexeagle changed the title tazel: BUILD file generator BUILD file generation May 24, 2019
@Globegitter
Copy link

I actually just added basic ts_library support now to the build file generator, as well as for babel_library. It does not add any test rules yet for .spec.ts files but that would also not be too difficult. In any case, I agree reconciliation would be good. I wonder how the two generators differ and what the one is missing from the other. Probably good to set a little test project up at some point. Or I might even try to use the auto-generators on all the examples/tests in this repo. Might be a decent test scenario.

@codebreach
Copy link

It seems that ts_auto_deps was removed in bazelbuild/rules_typescript@09f0469

is there a story for this moving forward?

asking as we are trying to move a relatively large project (300K LOC across 3K+ components) to bazel and were wondering if there was a tool to generate the first pass of BUILD files.

@vpanta
Copy link
Contributor

vpanta commented May 20, 2020

As someone who recently left Google, I was just about to file a FR for taze to be open sourced XD
I was very sad to see we never got it out to the world :(

I guess this is the right place to add my "please may we get it", cause honestly taze made everything so simple...

@alexeagle
Copy link
Collaborator Author

Hi @vpanta welcome to xoogler status! Let me dump a bit of my current thinking on this.

There are a few partial attempts at this. I recently wrote a generator for ts_project and pkg_npm in https://github.com/stackb/bzl-configure. @mattem has made a bunch of progress on https://github.com/Evertz/bzlgen. @Globegitter mentions his tooling up the thread. I think we'll continue to have partial solutions contributed by lots of people without much coordination between them.

There are a bunch of ways you might want to setup your repo. taze was based on a single opinion and a single rule (ts_library). In the wild, one team might want to generate pkg_npm from every package.json while another team doesn't want to check in any package.json files. One team might use a variant of the toolchain with ts_project mixed with babel. I think we'll have increasing fragmentation of how you might want to generate BUILD files.

Finally, you have the polyglot story. You need tooling written in the same language, for example ts_project generation needs to use the typescript library (unlike taze, it asks TypeScript itself for what are the srcs in the project, so it can't be in pure Go). So I don't think there can be one tool either.

All of this leads me to think that we need a loose coupling and powerful meta-configuration facility, with possibly several tools coordinating work.

My current favorite loosely-considered proposal: Gazelle as the coordinator, with a plugin for typescript that spawns a nodejs subprocess to do the actual work. That subprocess has a generalized API for passing stdin/arguments and producing buildozer commands on stdout. In addition to running that tool under gazelle, you can also run it standalone with the @bazel/buildozer dependency to apply the edits itself. Then a separate competing coordinator that takes a richer DSL for configuration, allowing you to say "all the tsconfig.json files under this directory should be turned into ts_project using that tool, plus any foo.bar files should have my_custom_rule generated for them"

If you have any time to dig in, happy to think through this some more.

@mattem
Copy link
Collaborator

mattem commented May 21, 2020

I was having the same thoughts around using the plugins for Gazelle in bzlgen (Evertz/bzlgen#50) as there are specific typescript libraries and implementations that make it easier to resolve deps for TS, especially when generating for ng_module (or a variant that needs the angular assets).

I think with all of these tools, they are going to be very opinionated depending on where they originated (bzlgen expects Evertz' way of doing Angular folder layouts for example, and lacks support for ts_project). Having said that, I'm happy to drive it in the right direction for this, my eventual goal is for our internal version to go away and I just have to maintain one thing (might as well be the OSS one).

@purkhusid
Copy link
Contributor

Is it currently possible to create a Gazelle extension that is not purely Go? I was thinking about doing some buildfile generation but hit a wall when trying to figure out how I would let my gazelle extension call a node process that would take care of parsing the files.

@alexeagle
Copy link
Collaborator Author

With @achew22 and @mrmeku I started this "rosetta" plugin for gazelle that adapts the API to work with any subprocess
https://github.com/alexeagle/bazel-gazelle
The plan is to let you write gazelle plugins in any language.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for 90 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

@github-actions github-actions bot added the Can Close? We will close this in 30 days if there is no further activity label Dec 12, 2020
@alexeagle alexeagle removed the Can Close? We will close this in 30 days if there is no further activity label Dec 13, 2020
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for 90 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

@github-actions github-actions bot added the Can Close? We will close this in 30 days if there is no further activity label Mar 14, 2021
@github-actions
Copy link

This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?"

@andy-zhou
Copy link

What's the preferred way of making a build_cleaner like utility today? I noticed that @Globegitter's repo has been archived.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? We will close this in 30 days if there is no further activity enhancement
Projects
None yet
Development

No branches or pull requests

10 participants