Hermetic Builds with Bazel

1,065 views
Skip to first unread message

Aham Brahmasmi

unread,
Aug 23, 2018, 3:15:42 PM8/23/18
to flutt...@googlegroups.com
Hi Flutter Team,

1) Is Bazel supported as an option to build Flutter apps?

2) If not (OR yes, but Google internal), when can we expect external Bazel support for building Flutter apps?

I see that there is a recently opened issue (danke Matan) [1]. However, there does not seem to be any further activity. To put this in context, it was first raised in May 2017 [2], and the use case quoted in that mail is increasingly applicable. Reproducing the relevant bits:
"Our company uses bazel as our single build tool for a broad set of languages....Given the broad langauge support of bazel it makes flutter a somewhat less attractive option if we need to introduce another set of build tools outside bazel in order to use it."

The last bit has become extremely important within the last year with the move towards Monorepos. Just like Flutter, Bazel has gained strong momentum. Lack of hermetic builds are now dealbreakers.

I assume lack of Bazel support might be why this roadmap [3] does not have Flutter on it.

Regards,
ab

[1] - https://github.com/flutter/flutter/issues/19680
[2] - https://groups.google.com/forum/#!topic/flutter-dev/gOJZs9rAseg
[3] - https://github.com/google/startup-os/blob/master/docs/milestones.md

Aham Brahmasmi

unread,
Sep 26, 2018, 1:49:48 PM9/26/18
to flutt...@googlegroups.com
Hi Flutter Team,

Would appreciate the team sharing their thinking on this.

Regards,
ab


> Sent: Thursday, August 23, 2018 at 9:15 PM
> From: "Aham Brahmasmi" <aham.br...@gmx.com>
> To: flutt...@googlegroups.com
> Subject: Hermetic Builds with Bazel
> --
> You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Greg Spencer

unread,
Sep 26, 2018, 4:21:27 PM9/26/18
to aham.br...@gmx.com, Flutter Dev
Hi Aham,

No, as you've observed, Flutter does not yet support building with Bazel. We currently use Dart, pub, and the flutter tool to build things (forking off things like gradle and XCode to do it), and we use gn and ninja on the Flutter Engine code.

The main obstacle to adopting Bazel is that we don't want to add a dependency on Java to Flutter, and we don't want to maintain more than one build system for Flutter (well, two: one for Framework and one for Engine).  Also, in order to make it most useful and efficient to build with Bazel, the Dart team would need to add some way to translate from pubspec.yaml dependencies to Bazel dependencies: there is no natural mapping from a dart file/library/package/module to a Bazel module.

Bazel is an excellent product, and it would definitely be on the short list of build systems we would consider if we switched, but it's not on our pre-1.0 priorities to support it.

I hope that helps.

-Greg.

Aham Brahmasmi

unread,
Sep 28, 2018, 3:36:40 AM9/28/18
to Greg Spencer, Flutter Dev
Hi Greg,

Thank you for your response.

I understand and appreciate the hesitation in adding Java as a dependency. I myself am not comfortable with Bazel's decision to opt for Java, but understand it is driven by legacy (Blaze) reasons. In my completely layman opinion, Go could have been considered - easy to deploy a single self-contained binary. And with Java's rapid version iteration becoming the norm, I think we are in a world of hurt.

Having said that,

1) Are we sure that there is no Flutter support for Bazel, even Google-internal? I ask this because a rudimentary web search with "Flutter Bazel" throws up mentions like the following:
i) "for non-Bazel projects, don't show the Flutter Bazel launch type" at https://news.dartlang.org/2018/01/flutter-plugin-v21-now-available.html
ii) "fix for a file watching related NPE on build systems using Bazel", "simplify how we recognize Flutter projects when using Bazel", "update FlutterViewCondition to be bazel project aware" and others at https://github.com/flutter/flutter-intellij/blob/master/resources/META-INF/plugin.xml

2) What would be your suggestions for hermetic Flutter builds inside a monorepo without using Bazel? In fact, any guidance around hermetic Flutter builds within a monorepo with Angular{Dart}/Protobufs/gRPC/Go would be much appreciated.

Regards,
ab

Todd Volkert

unread,
Sep 28, 2018, 10:30:37 AM9/28/18
to aham.br...@gmx.com, Greg Spencer, flutt...@googlegroups.com
Hi Aham,

Thanks for your thoughtful questions -- my answers are below.

1) Google does use Bazel rules to build Flutter apps internally, but open sourcing those rules would require significant effort, so it's not currently on our roadmap.
2) That's tough to say - it really depends on your setup.  I imagine any solution would require building a shim layer on top of flutter_tools whereby you call runInContext() directly and override some of the default injected values (to keep the tool from downloading packages using pub, etc.).

Cheers,
-T

Aham Brahmasmi

unread,
Sep 28, 2018, 12:18:54 PM9/28/18
to Todd Volkert, Greg Spencer, flutt...@googlegroups.com
Hi Todd,

Thank you for your helpful response.

Would it be fair to expect open sourcing Bazel rules to be on the post-1.0 roadmap?

Regards,
ab

Todd Volkert

unread,
Sep 28, 2018, 1:17:48 PM9/28/18
to aham.br...@gmx.com, Greg Spencer, flutt...@googlegroups.com
I'd say it's in our stretch goals but not on any particular roadmap.

Hope that helps,
-T

Gregg Reynolds

unread,
Sep 29, 2018, 2:08:00 PM9/29/18
to Todd Volkert, aham.br...@gmx.com, Greg Spencer, flutt...@googlegroups.com


On Fri, Sep 28, 2018, 9:30 AM 'Todd Volkert' via Flutter Dev <flutt...@googlegroups.com> wrote:
Hi Aham,

Thanks for your thoughtful questions -- my answers are below.

1) Google does use Bazel rules to build Flutter apps internally, but open sourcing those rules would require significant effort, so it's not currently on our roadmap.

How complex are those rules? Would it be foolish to think about a community-based effort to do this?

Fwiw I've got an embedded c lib built with bazel, which is relatively small but also relatively complex - code on Mac, Linux or windows, and cross compile to raspberry pi or whatever. To use it with flutter I have to maintain two build systems- not terribly hard but annoying.  Would be great to do it all in Bazel, and I've toyed with writing Bazel rules for flutter, but I'm not sure how much pain I would be in for, for how long.  What do you think?

Gregg

Todd Volkert

unread,
Oct 2, 2018, 11:36:30 AM10/2/18
to d...@mobileink.com, aham.br...@gmx.com, Greg Spencer, flutt...@googlegroups.com
They're moderately complex, but the bigger issue is that they're intertwined with assumptions about the internal structure of Google's source repository.
Reply all
Reply to author
Forward
0 new messages