Excluding from build specific directories from library


#1

I’m using a header-only library that includes a src directory with benchmarks and tests. I want the build process to ignore everything in the library’s src directory.

I can add a library.json file to the root directory of the library wherein I specify a source filter. Works great, but of course it’s manual and would have to be done by any project developer, because I don’t want to fork the lib maintain my own repo just to add the file. (And the library author is unlikely to accept a PR with PlatformIO specific file.)

I tried specifying a source filter in platformio.ini like -<../.piolibdeps/library_name/src> (and variants with ...src/*.cpp, ...src/*/*.cpp, ...src/subdir/*.cpp), but that didn’t work.

EDIT 20181123: src_filter works perfectly for this purpose. My test was bad. Also, Ivan’s alternative below works, too.

Should I be able to exclude library source files with a src_filter?


#2

How about to lib_ignore = MyLIb whole library and add relative include path to build_flags = -I .piolibdeps/library_name?


#3

That works. Thanks!

Also, src_filter works, too. I was putting the src_filter line in the wrong env, so needless to say it was having no effect.