GN <-> Bazel conversion tool

1,647 views
Skip to first unread message

Stephen Lanham

unread,
Jan 18, 2017, 3:28:37 PM1/18/17
to Chromium-dev, ig...@chromium.org
All,

Does anyone know of a parsing script that could be used to generate Bazel files from GN? We (the Home team) have some code with a few dependencies on Chromium that we'd like to make into a standalone project. Our two best options at the moment seem to be to convert BUILD.gn files to Bazel and to set up a standalone GN project. Both options have costs - we would like to explore both. 

I welcome any thoughts or advice. Thanks!

-Stephen

Brett Wilson

unread,
Jan 18, 2017, 3:46:11 PM1/18/17
to sl...@chromium.org, Chromium-dev, ig...@chromium.org
I would use the flags to "gen" (see "gn help gen") to produce JSON output. This will give you some JSON in a standard format representing what GN has computed for each target. See tools/gn/json_project_writer.cc and desc_builder.cc for schema information.

You might also check out the --json-ide-script flag to GN when outputting JSON which can run a Python script as GN runs rather than focring you to do it manually in a second step.  I'm not aware of this being used in production so if it's not working it could just be broken. It shouldn't be hard to fix though.

Brett

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Stephen Lanham

unread,
Jan 18, 2017, 8:09:32 PM1/18/17
to Brett Wilson, Chromium-dev, ig...@chromium.org
Brett,

Thanks for the quick reply. This looks promising. I'll report back to the thread after playing around with it.

-Stephen

Henrik Kjellander

unread,
Jan 26, 2017, 5:22:00 PM1/26/17
to sl...@chromium.org, Brett Wilson, Chromium-dev, ig...@chromium.org
As you may already know, the WebRTC team is working on a GN->Bazel conversion tool (based on the JSON Brett mentioned). We've been busy tailoring it for our internal needs but we can surely share it with you offline waiting for it to be good enough to open source (which we plan to do).

Stewart Henderson

unread,
Jun 2, 2017, 2:55:45 PM6/2/17
to Chromium-dev, sl...@chromium.org, bre...@chromium.org, ig...@chromium.org
Any movement on this?  Just curious as I am dabbling with it as well.

Henrik Kjellander

unread,
Jun 15, 2017, 2:32:05 AM6/15/17
to henderson...@gmail.com, Chromium-dev, sl...@chromium.org, Brett Wilson, ig...@chromium.org, mbon...@chromium.org, char...@chromium.org, opr...@chromium.org, ehmal...@chromium.org
On Fri, Jun 2, 2017 at 8:55 PM, Stewart Henderson <henderson...@gmail.com> wrote:
Any movement on this?  Just curious as I am dabbling with it as well.

My team (WebRTC EngProd) is working on cutting out the last WebRTC-specific pieces from the gn2build tool we developed for our own needs. We've been making good progress and it's usable by other projects now. 
Unfortunately open sourcing the tool will require more work and is not our highest priority. I could promise open sourcing will happen during Q3, but not earlier than that.

---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/5f289e3f-b266-49f9-9242-a1def0b5eb44%40chromium.org.

Ion Lupascu

unread,
Aug 16, 2017, 5:35:11 PM8/16/17
to Chromium-dev, henderson...@gmail.com, sl...@chromium.org, bre...@chromium.org, ig...@chromium.org, mbon...@chromium.org, char...@chromium.org, opr...@chromium.org, ehmal...@chromium.org
What about BAZEL->GN? is any tools?

Dirk Pranke

unread,
Aug 16, 2017, 6:59:51 PM8/16/17
to ionlu...@gmail.com, Chromium-dev, Stewart Henderson, Stephen Lanham, Brett Wilson, ig...@chromium.org, mbon...@chromium.org, char...@chromium.org, opr...@chromium.org, ehmal...@chromium.org
I have not heard of any such tools.

-- Dirk

Andrew Grieve

unread,
Aug 16, 2017, 8:14:36 PM8/16/17
to Henrik Kjellander, henderson...@gmail.com, Chromium-dev, sl...@chromium.org, Brett Wilson, ig...@chromium.org, mbon...@chromium.org, char...@chromium.org, opr...@chromium.org, ehmal...@chromium.org
Wondering if you've tried out your converted BUILD files in https://ij.bazel.build/?

Jupp Müller

unread,
Mar 27, 2018, 2:03:49 PM3/27/18
to Chromium-dev, henderson...@gmail.com, sl...@chromium.org, bre...@chromium.org, ig...@chromium.org, mbon...@chromium.org, char...@chromium.org, opr...@chromium.org, ehmal...@chromium.org
Henrik,

On Wednesday, June 14, 2017 at 11:32:05 PM UTC-7, Henrik Kjellander wrote:

My team (WebRTC EngProd) is working on cutting out the last WebRTC-specific pieces from the gn2build tool we developed for our own needs. We've been making good progress and it's usable by other projects now. 
Unfortunately open sourcing the tool will require more work and is not our highest priority. I could promise open sourcing will happen during Q3, but not earlier than that.

is there any progress on this? If not, could you make the converted BUILD files for webrtc available somewhere?

Thanks!

Jupp 

Peter Boström

unread,
Mar 29, 2018, 1:16:15 PM3/29/18
to jup...@gmail.com, Chromium-dev, bre...@chromium.org, char...@chromium.org, ehmal...@chromium.org, henderson...@gmail.com, ig...@chromium.org, mbon...@chromium.org, opr...@chromium.org, sl...@chromium.org
Hi Jupp, I can't speak to the rest of the team's priorities as I'm not on it anymore but kjellander@ is not currently with Google anymore. For webrtc specifically you might have better reach with the discuss-webrtc googlegroup.

- Peter

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Patrik Höglund

unread,
Apr 3, 2018, 10:26:02 AM4/3/18
to pb...@chromium.org, jup...@gmail.com, Chromium-dev, bre...@chromium.org, char...@chromium.org, Edward Lesmes, henderson...@gmail.com, ig...@chromium.org, Mirko Bonadei, opr...@chromium.org, sl...@chromium.org
Hi! I'm Patrik from the WebRTC team.

While we would have liked to make the tool public at some point, we don't have the cycles for it now and we don't expect to have cycles in the forseeable future. We can't publish the BUILD files either because they contain confidential information. Sorry.

If it helps, our tool is a python script that runs gn desc, parses the json and generates BUILD files. It runs once per GN configuration (= platform) and then merges the BUILD files using select statements to encapsulate the differences.

/ P

Stephen Lanham

unread,
May 3, 2018, 6:32:31 PM5/3/18
to Patrik Höglund, Andres Medina, pb...@chromium.org, jup...@gmail.com, Chromium-dev, Brett Wilson, char...@chromium.org, Edward Lesmes, henderson...@gmail.com, ig...@chromium.org, Mirko Bonadei, opr...@chromium.org
+Andres
Reply all
Reply to author
Forward
0 new messages