-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bazel fails if I #import <mylibrary/myheader.h> while XCode is fine with it. #306
Comments
Is the library a local library? Why are you using system include syntax to Cheers, On Tue, Jul 14, 2015 at 2:07 PM, Jorge Canizales notifications@github.com
|
It is a local library. The reason I was using angle brackets is I developed that code using Cocoapods to manage dependencies. Because the location on the file system of the library headers is an implementation detail of Cocoapods (which passes the appropriate flags to the compiler to find them), it serves no purpose to search them starting in the current directory. So it was I see the style guide calls for |
I'm running into the same issue as @jcanizales. Because we're moving from cocoapods, my coworkers and I are happy with the convention: system include ( It is an aesthetic thing, and it won't stop us from adopting Bazel (it's been great so far!), but I just wanted to say that this would definitely be nice for us! Since this is an older issue, is there any update on priority? Thanks! |
+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:
In short, move the source code into directory structure the same way that cocoapods did: copy and paste them into genfiles. i.e.
VFS can alias the 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 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. |
Any update on this? It seems there are a large number of cocoapods which do this type of style. I am in the process of importing these cocoapods and rewriting their BUILD files for our purposes. |
@lswith we are also doing this at Pinterest literally right now (porting our 40ish cocopods over). We ended up making a workspace rule called
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 By making each cocoapod a separate workspace rule you get 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 ***@***.***> wrote:
@lswith <https://github.com/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:
new_pod_repository(
name = "PINOperation",
url = "https://github.com/pinterest/PINOperation/archive/1.0.3.zip",
owner = ***@***.***",
strip_prefix = "PINOperation-1.0.3",
)
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
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA-K-yf_8naMmz4Wit1hEhkTMWKXx_Cpks5r2ju8gaJpZM4FYlDO>
.
|
@lswith We have plans to open-source in the near future but would like to finish our migration to stress test out the integration against the complexity of podspecs (subspecs, multiplatform attributes, external pod dependencies, etc) so we're confident it'll work well for others and have comprehensive documentation. We can also keep you in the loop before the OSS announcement if you'd like to beta test the integration (which would be great!). |
perfect. Please do! |
@bkase do you think you could give an example BUILD file for the FBSDKCoreKit cocoapod? I don't quite understand how the header files should be placed to allow for correct compilation by Bazel. |
@lswith this is what our script generates for FBSDKCoreKit (I'm working on this one now, currently working on Bolt -- a dep of this) so I'm not sure if this will exactly work yet.
You can see that it references
|
I like what you've done here! I was wondering how you handled the conditions for different OS' and how you put the files in the Public folder. I was wondering about the |
@lswith - We leverage |
I was wondering what configuration option you would use to differentiate between OS types? The main reason I ask this is because it looks like bazel is moving towards doing complete cross compilation and specifying which type of OS is done with the rule itself not with bazel flags. Take a look at the new apple rules to see what I mean: https://github.com/bazelbuild/rules_apple |
@lswith - We aren't on Bazel 0.5 yet so we haven't been able to adopt the new rules. We will likely have to tackle this soon though. |
Sorry I was wrong anyways. It appears they will be using platforms based on this thread: #350 |
Ping 🚀! Does anyone from the bazel team have a any suggestions on the original issue? |
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. Traditionally, the compiler has to parse a large string of `iquote` includes, and then search these directories for a given header. This is slow for many reasons. The protocol of HeaderMap is implemented within compilers. Please find the Lexer implementation in Clang. https://clang.llvm.org/doxygen/HeaderMapTypes_8h.html https://clang.llvm.org/doxygen/HeaderMap_8cpp_source.html Use case: I'm seeing a massive increase in build performance by using this. It dropped my times I'm using a HeaderMap for one directory with 1700 headers and a deep directory structure. Here is the clean build time: bazel-bin/Pinterest/iOS/App/PinterestDevelopment.ipa ____Elapsed time: 252.712s, Critical Path: 18.78s Build time before HeaderMap: bazel-bin/Pinterest/iOS/App/PinterestDevelopment.ipa ____Elapsed time: 373.588s, Critical Path: 18.86s Additionally, this solves the problem of having namespaced headers which is used in CocoaPods all over. With header maps, I can alias angle bracket includes directly to the files, which fixes: ( bazelbuild#306 ). This is easier to use in Bazel than `isystem` including a directory of symlinked headers. I haven't measured the performance speedups of that yet, but am excited to given my large number of external deps. Implementation: There is a rule which allows a user to create a HeaderMap directly. This allows me to customize HeaderMaps for CocoaPods and other parts of the source tree. The user writes a rule: header_map( name = "MyHeaderMap" map = { # Point Header.h at it's path "Header.h": "Path/To/Header.h" # Point Header.h at it's path and add a Namespace "Namespace/Header.h": "Path/To/Header.h" } ) And Bazel generates a Headermap, MyHeaderMap.hmap Internally, the rule writes out a binary representation that the lexer can interpret. The user includes a HeaderMap in `hdrs`. Please also find some useage examples in ClangHeaderMap.java. Why make it a native rule? - It is nice to use the data structures to create the headermap directly, and there is no way to do this in Skylark. Passing the arguments to a helper tool is cumbersome. - Eventually, I think Bazel could generate implicit headermaps without even having a rule ( similar to module maps ). This could be useful for some projects and some projects would still want to create custom ones. TODO: - Upstream unit tests ( The ClangHeaderMap has tests, but not yet integrated into Bazel ) - Add integration tests for the rule in general This is my first PR to the Bazel repo, so any suggestions or feedback is greatly appreciated!
I'm not sure if this issue has been resolved, but given the age and lack of activity, I'm going to assume it's no longer relevant. Please let me know otherwise and I'll reopen and retriage. |
- 3c7ec07fe0418446ffdb1a04c671a3810d74ae30 [cas] Add cas package (#300) by nodirg <56001730+nodirg@users.noreply.github.com> - 28fa42989a6c2d05cddb6b42494f34ef742c3de9 [cas] Implement file reading (#302) by nodirg <56001730+nodirg@users.noreply.github.com> - 69c6642c3a006636256c1d2e591899f07d4c74bf Simplify caching packages (#303) by nodirg <56001730+nodirg@users.noreply.github.com> - f7087af662fe5481f2e75abd652af46d9a376534 [cas] Implement presence check (#304) by nodirg <56001730+nodirg@users.noreply.github.com> - 847bca232f884b1e7ee059c64317a5140f11477e Simplify caching packages further (#306) by nodirg <56001730+nodirg@users.noreply.github.com> - 989513ef4a567a812f21b27f2a5d83f1a2145600 Rename singleflightcache.Cache (#310) by nodirg <56001730+nodirg@users.noreply.github.com> - 7eceb37537dec7c50e52d4f1af1a5d671c267144 [cas] Fix the build (#308) by nodirg <56001730+nodirg@users.noreply.github.com> - fd877b05ba2ed611f6d34e711da05917b729eff9 [cas] Add retries (#311) by nodirg <56001730+nodirg@users.noreply.github.com> - 5bc303584ef03ded33f03fa2976015e38da9c050 [cas] Add support for Symlinks. (#309) by nodirg <56001730+nodirg@users.noreply.github.com> - 4cfed65947cba54af1b2259d9e3facf7dd3007b9 [cas] Implement batch upload (#307) by nodirg <56001730+nodirg@users.noreply.github.com> - 144126c43e73aeeabdbeb8bc4ef0290fa7a91ba7 [cas] Move file IO semaphore to Client (#313) by nodirg <56001730+nodirg@users.noreply.github.com> - e1da041171a715b7bab3178acfe1cd774b9f5019 [cas] Reuse file read buffers (#317) by nodirg <56001730+nodirg@users.noreply.github.com> - e9184e44947661852a8887f3183e00c346208aaa [cas] Add UploadOptions (#314) by nodirg <56001730+nodirg@users.noreply.github.com> - e2bd6c8e2d6bc183ff059c688a604ba1ac18b840 [cas] Implement ServerCapabilities check (#315) by nodirg <56001730+nodirg@users.noreply.github.com> - b00d91e726265f23ad0a88730545831b8d5519ef [cas] Add RPCConfig (#318) by nodirg <56001730+nodirg@users.noreply.github.com> - 1c678dec65b62e49840419ab777c7b6ce65cfd76 [cas] Improve error messages (#321) by nodirg <56001730+nodirg@users.noreply.github.com> - ad8d2cfffe1f3728469a8dd5a7531b9157280ecd [cas] Limit FindMissingBlobs concurrency (#319) by nodirg <56001730+nodirg@users.noreply.github.com> - b1b54ee4d55b5d5bd71ca2df4353058515581697 [cas] Increase FindMissingBlobs concurrency to 256 (#323) by nodirg <56001730+nodirg@users.noreply.github.com> - b4a0e12d87c946ced360d723d743be1f57a47995 [cas] Move file IO buffering deeper (#322) by nodirg <56001730+nodirg@users.noreply.github.com> - abb14633e09633368f06d8e4fd28bd1553509061 [cas] Add filtering/callback (#316) by nodirg <56001730+nodirg@users.noreply.github.com> - 7447b28dd69e22848ee850936a1cdd28e2d0e20b Add Mtime to the file metadata cache. (#326) by ramymedhat <abdelaal@google.com> - 7182b476eb6260fae9ba2bd8995b97a7096e340c [cas] Implement streaming (#320) by nodirg <56001730+nodirg@users.noreply.github.com> - b0605647bbe2ff7d046a286c3023e7714376fb83 include file path in upload error (#327) by Takuto Ikuta <tikuta@google.com> - 3b602dd48f7f63a76cb1087a10355b3c668d583f [cas] Implement per-request timeouts in a stream (#325) by nodirg <56001730+nodirg@users.noreply.github.com> - 395c674af7a9cd696dfd1f2b4a950f6899ccb3a0 remove unused variables (#332) by Takuto Ikuta <tikuta@google.com> - 45f49a9529f755fb586fe2f8bf3e78b1eae39e81 [cas] Unembed cas.Client.ClientConfig. (#333) by nodirg <56001730+nodirg@users.noreply.github.com> - 2a9b29928abe867026e37833fa480ed16238df7a [cas] Rename UploadOptions.Callback to Prelude (#334) by nodirg <56001730+nodirg@users.noreply.github.com> - 80ea864b211ee3d87e14f4be0ca8d17e5917062c [cas] Read files once (#335) by nodirg <56001730+nodirg@users.noreply.github.com> - 0e577525a2dce2d0e7bddd80927c8901d28bf0fb [cas] PathExclude: use forward-slash-separated paths (#341) by nodirg <56001730+nodirg@users.noreply.github.com> - e155d015bcc4c9eb9978572422e3404f26220700 Add useful error message for uploading files. (#339) by bansalvinayak <vinayakbansal@google.com> - 3dfb518d390280a2ffef5a85ab1852a2a526a983 [cas] Rename UploadInput to PathSpec (#342) by nodirg <56001730+nodirg@users.noreply.github.com> - 752e4efb2631b45f5c27120f83d517cc2b2846d2 google/uuid -> pborman/uuid (#344) by Rubens Farias <rubensf@google.com> - d94f8a8ba888d384686a7cd74d8a9d0795ba4b6d Small tweaks to appease internal import checks. (#346) by Rubens Farias <rubensf@google.com> - f9d52cdef1c3aa8612d9c3ed7a0b65f96e55d870 Catch another pool check (#347) by Rubens Farias <rubensf@google.com> - ead1458eda2b7c756138429121a3e22bd5c9aa5a Preserving symlink or not can be configured from Command.... by Yoshisato Yanagisawa <yoshisato.yanagisawa@gmail.com> - f831c118b9c9e1dd3e857fbe43da7c992c91b20f make (*Chunker).Reset returns error (#348) by Takuto Ikuta <tikuta@google.com> - 1a7d2a4198fa0eb8515593b5259f495cdacf75ab [cas] Require PathSpec.Path to be absolute (#345) by nodirg <56001730+nodirg@users.noreply.github.com> - dd2d3976ed7c6482f361de7d24e24d5a8683c56c Upgrade zstdpool-syncpool for DecoderWrapper.Close bugfix... by Mostyn Bramley-Moore <mostyn@antipode.se> - 8544bdc0f3112900675a72decdb7a978cece0be7 [cas] Clean PathSpec.Path (#352) by nodirg <56001730+nodirg@users.noreply.github.com> - 882e3342509eb038dc04bf44581e5085c0320d16 [cas] Add UploadResult.Digest() (#340) by nodirg <56001730+nodirg@users.noreply.github.com> - 5d4d813411299a285f113cb541f2c5750746cdfa chunker: remove unused field from Chunker (#355) by Takuto Ikuta <tikuta@google.com> - a5af2d4316599a3fea87a459290e5f88a022a43c Add return value names in singleflightcache (#356) by nodirg <56001730+nodirg@users.noreply.github.com> - e7ea26b93b496d4d30e98390682faf6f69f84cb7 [cas] Fix joinFilePathsFast (#361) by nodirg <56001730+nodirg@users.noreply.github.com> - 5a8daf747858747b2bf6bdd59e7b07dedc17a244 [cas] Refactor code (#359) by nodirg <56001730+nodirg@users.noreply.github.com> - dd6c290b2ce791f3a3e56583a9632f7b538e8a05 [cas] Simplify UploadResult.Digest() signature (#362) by nodirg <56001730+nodirg@users.noreply.github.com> - 05222e7e8939959878a5798e51cf52e911feafaf Fix lint (#357) by nodirg <56001730+nodirg@users.noreply.github.com> - b2689fabc306d2cd20356f30b7f99eec445d9212 [cas] Refactor Digest() (#363) by nodirg <56001730+nodirg@users.noreply.github.com> - c672e5baca9280d181c7e2e87b3d9afd01650893 [cas] Add PathSpec.Allowlist (#360) by nodirg <56001730+nodirg@users.noreply.github.com> - f9e6595d5634ac4d4221ba6dca9f5c2e64114b3f add size check (#365) by Takuto Ikuta <tikuta@google.com> - 3d0cf1be08dd52d77204ad1be7e70fdd1e48c206 Revert "Add useful error message for uploading files. (#3... by Rubens Farias <rubensf@google.com> - 3ddc89f3e2b39308101060b3eeaa10a919cae13e "Wrap" gRPC error codes. (#367) by Rubens Farias <rubensf@google.com> - d965bf95d0af9d88d90e9723aee6b332dc3ef93e cas: fix deadlock (#368) by Takuto Ikuta <tikuta@google.com> - 3c4ce9170b6c5a5d64bcc4feecc5bcdf5dd1f101 allow to use streamBufSize larger than 32KiB (#369) by Takuto Ikuta <tikuta@google.com> - 21d6adc44e550f7aa5c4e9b3fedab838920a9632 use semaphore for large file upload (#370) by Takuto Ikuta <tikuta@google.com> - 1cec173a5bf76c02f435050d6fc9a02e1ccea637 update remote-apis (#371) by Takuto Ikuta <tikuta@google.com> - e96eb06339fb616167ee02535ab54d9c3a382232 add more log around upload (#372) by Takuto Ikuta <tikuta@google.com> - 3f34e744d83161ddcb602121b45b0b33185a36c5 Make glog import consistent. (#373) by Rubens Farias <rubensf@google.com> - 3db822c86088434a4d2d53ec2d3b889b9f8cf331 Remove typos (#374) by Rubens Farias <rubensf@google.com> PiperOrigin-RevId: 390319167
Bazel asks me to change
to
XCode is fine with
< >
though, so I'm bound to keep coding and later havebazel build
fail again.The text was updated successfully, but these errors were encountered: