RFC: Add Bazel build configurations for Apollo iOS#1309
RFC: Add Bazel build configurations for Apollo iOS#1309liuliu wants to merge 1 commit intoapollographql:mainfrom
Conversation
I plan to add some Bazel support for Apollo iOS, including runtime BUILD
files and some bzl macros that can download schema and generate code
from the schema.
Before that, this PR added relevant BUILD configuration to build Apollo
/ ApolloCore / ApolloWebSocket / ApolloSQLite.
I am not sure what SwiftScripts do, and whether these will work as
expected, since Bazel sandbox the binary therefore the path finding
logic will be incorrect.
For the codegen part, I need to figure out a few things:
1. It seems OK to wrap the node / run with sh_binary, with additional
shell scripts (run-bundled-codegen.sh messes with Bazel sandbox and
I am not happy to just wrap that, mainly because it won't be
properly cached (the downloaded tar.gz file)).
2. I need to use http_archive most likely for the apollo cli tools (in
node.js). However, the current link doesn't end with tar.gz, which
Bazel doesn't like.
Hence, this PR upstreams some conservative changes. Please let me know
what you maintainers think.
The broad picture is to make integration with Bazel based iOS project
easier, and uses Bazel's cache for schema download, code generation etc.
|
@liuliu: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
|
|
|
Interesting! I do have serious concerns about upstreaming this, though:
Personally, I'm super-reluctant to upstream this given the additional maintenance overhead vs. the considerably smaller number of users who use Bazel vs other package managers + the normal Xcode build system. To be honest, I've also generally found that people who have a project big enough to make switching to the Bazel build system worth it generally are at very, very large companies. These projects therefore have access to very talented build engineers who a) can absolutely do this work themselves and b) want to do it Very Specifically Their Way, which having a default setup would likely interfere with. Given all that, do you want to continue with this PR? |
|
@designatednerd, that's a very reasonable reasoning! I am putting up the PR to get feedback on:
The main motivation is to exploit buck cache for ApolloCLI outputs (schema downloading / code gen). It seems that:
There are still some questions I need some answers:
We can certainly just revisit this once Bazel acquired bigger mind-share. It won't impede my work, I will simply maintain it in a fork. Thanks! |
That's correct, it only depends on
So the Codegen lib is doing two things:
Basically ideally we'll be able to jettison JS entirely, but it's going to be a while before we can do that. |
|
Thanks! That makes a lot of sense. I initially started because the Codegen part build (with Bazel) is fairly involved. If it was written in Swift, ideally, I would like to have Bazel build the codegen binary and then use the codegen binary for Bazel macro to do the codegen. Right now with the node.js codegen, I can either wrap the whole thing as a shell (it is not ideal to wrap a Swift binary as shell), and use that for codegen or just use node.js wrapper in Bazel to build. Otherwise, the runtime part is fairly straightforward to maintain as a fork. I will follow the project and the issue in case the Swift codegen start to move again and I need to do the fairly involved work again. |
|
The Swift wrapper portion of codegen automatically downloads and executes the necessary JS stuff, without the need for any nonsense with Node directly. I'm not sure how well this will work with sandboxing, buy because the zip file it downloads includes all of node and all dependencies, it might help. Please check out the Swift Scripting docs for more details. |
|
Thought about it over the weekend, but I'm sticking with my original though about not supporting Bazel officially, for the reasons I've already outlined. I'm going to go ahead and close this PR since I have no intention of merging it. - if you want to discuss Bazel support further, our Spectrum Chat is a great place for discussion at this time. Thank you for your efforts though! |
I plan to add some Bazel support for Apollo iOS, including runtime BUILD
files and some bzl macros that can download schema and generate code
from the schema.
Before that, this PR added relevant BUILD configuration to build Apollo
/ ApolloCore / ApolloWebSocket / ApolloSQLite.
I am not sure what SwiftScripts do, and whether these will work as
expected, since Bazel sandbox the binary therefore the path finding
logic will be incorrect.
For the codegen part, I need to figure out a few things:
It seems OK to wrap the node / run with sh_binary, with additional
shell scripts (run-bundled-codegen.sh messes with Bazel sandbox and
I am not happy to just wrap that, mainly because it won't be
properly cached (the downloaded tar.gz file)).
I need to use http_archive most likely for the apollo cli tools (in
node.js). However, the current link doesn't end with tar.gz, which
Bazel doesn't like.
Hence, this PR upstreams some conservative changes. Please let me know
what you maintainers think.
The broad picture is to make integration with Bazel based iOS project
easier, and uses Bazel's cache for schema download, code generation etc.