简体   繁体   中英

How to specify source files that shouldn't be compiled in Bazel?

I'm trying to wrap around Poco library. And it contains code like this:

#if defined(POCO_OS_FAMILY_UNIX)
#include "Path_UNIX.cpp"
#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
#if defined(_WIN32_WCE)
#include "Path_WINCE.cpp"
#else
#include "Path_WIN32U.cpp"
#endif
#elif defined(POCO_OS_FAMILY_WINDOWS)
#include "Path_WIN32.cpp"
#endif

But Bazel complains about Path_*.cpp files because I don't mention them in srcs section. What is a proper section to mention these files: they are private, sources, and shouldn't be compiled on their own?

My current workaround is to put them into data section, but it doesn't match conceptually.

Update:

actually data section doesn't work.

You want to use the hdrs attribute. Also if these files are required by dependent libraries you can add it to textual_hdrs .

https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library.textual_hdrs

If you need to hide these files from dependent rules you'll need to use a genrule (or patch command at the repository level) to copy the files to ah extension and modify the source file that includes the files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM