bazel: Bazel fails if I #import while XCode is fine with it.
Bazel asks me to change
#import <mylibrary/myheader.h>
to
#import "mylibrary/myheader.h"
XCode is fine with < >
though, so I’m bound to keep coding and later have bazel build
fail again.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 18 (7 by maintainers)
Commits related to this issue
- RFC: C++ HeaderMap rule Request for feedback on an implementation of C++ HeaderMaps in Bazel. A HeaderMap is a data structure that allows the compiler to lookup included headers in constant time. T... — committed to pinterest/bazel by jerrymarino 7 years ago
- Import bazelbuild/remote-apis-sdks from GitHub. - 3c7ec07fe0418446ffdb1a04c671a3810d74ae30 [cas] Add cas package (#300) by nodirg <56001730+nodirg@users.noreply.github.com> - 28fa42989a6c2d05cddb... — committed to bazelbuild/bazel by a-googler 3 years ago
@lswith we are also doing this at Pinterest literally right now (porting our 40ish cocopods over). We ended up making a workspace rule called
new_pod_repository
( https://bazel.build/versions/master/docs/be/workspace.html ). Example:During workspace loading we pull down the repo and then automatically convert the Podspec into a BUILD file using a Swift program. Then we can just refer to these as a dep like
@PINOperation//:PINOperation
By making each cocoapod a separate workspace rule you get
<>
imports that work in the same way (assuming you move the headers around in the same way that cocoapods does) + it also semantically to be a workspace makes sense as a workspace rule since we’re getting something from a third-party.The goal is to push as much as we can to our automated Podspec -> BUILD tool so it’s easy to add/upgrade/remove pods
This is exactly what I need!!! I would love if you open source this! It would be a lot of help. I’m happy to help contribute as well On Fri, 5 May 2017 at 6:58 am, Brandon Kase notifications@github.com wrote:
+1 - It’d be awesome if this worked out of the box, because a large subset of objc code uses angle bracket includes ( see www.cocoapods.com ) None the less, I think there are a few ways to overcome this issue:
pod install
:In short, move the source code into directory structure the same way that cocoapods did: copy and paste them into genfiles. i.e.
genfiles/SomeProject/SomeHeader.h
. Then, you can simply-isystem $(GENDIR)
and the angle brackets will resolve to the correct path. This may not work for all cases and have other complexities.VFS can alias the
<>
includes to their real location. Here is the RFC http://clang-developers.42468.n3.nabble.com/RFC-A-virtual-file-system-for-clang-td4037693.html .The drawback here, in my testing of this, the VFS needs an absolute path to the build directory: the per compilation bazel sandbox. I’m already compiling .o files with a shell script and passing them to
objc_library
, so it would be easy to generate a VFS overlay containing the absolute path of the sandbox.2a) Use VFS and disable the sandbox. This way, you wouldn’t need to have custom compiler invocations, and can generate a VFS overlay where the absolute path is the source directory.