Reputation: 129
What I want to find is the existence of some platform specific header file. For example, in source code there will be some #ifdef section like this.
#ifdef HAVE_XXX_H
//...do something
#else
//...do other thing
#endif
In Autoconf or Cmake, there exists dedicated macro or command for detecting platform specific header file or definition. So, I can easily set 'HAVE_XXX_H' as 1 or 0 according to the result of that macro.
Using bazel, how can I achieve this kind of thing?
Thanks.
Upvotes: 2
Views: 763
Reputation: 3270
If you are sure that the header is always present on a particular platform, use select()
as elaborated by László.
If you actually need to detect the header at the build time, you will have to implement a custom repository_rule that will query the system and will generate a workspace with a header defining the macro.
Upvotes: 2
Reputation: 4271
You can use select()
.
Example: select()
in cc_library.srcs
. You can do the same in cc_library.hdrs
.
Upvotes: 0