PROJECT_EXCLUSIONS error (single files) and a fix

For OF v0.9.3/Android, using Eclipse to build projects (I’m running under OS X 10.10.5):

I wanted to exclude a single source file from one of my src directories, and I discovered that setting

    PROJECT_EXCLUSIONS = $(OF_ROOT)/src/thefile.cpp

in the project “config.make” file did not work. In the main “config.project.mk” in the OF/libs/openFrameworksCompiled/project/makefileCommon dir, the PROJECT_EXCLUSIONS are used to find directories to exclude, but not particular files (line 287 of my “config.project.mk” file):

    OF_PROJECT_SOURCE_PATHS = $(filter-out $(OF_PROJECT_EXCLUSIONS),$(ALL_OF_PROJECT_SOURCE_PATHS))

The problem is that OF then gathers all source files from the unexcluded directories, without checking to see if any individual files have been listed as a PROJECT_EXCLUSION (line 297 of my “config.project.mk” file):

    # find all sources inside the project's source directory (recursively) # grep -v "/\.[^\.]" will exclude all .hidden folders and files OF_PROJECT_SOURCE_FILES = $(shell $(FIND) $(OF_PROJECT_SOURCE_PATHS) -maxdepth 1 -name "*.mm" -or -name "*.m" -or -name "*.cpp" -or -name "*.c" -or -name "*.cc" -or -name "*.cxx" -or -name "*.S" | grep -v "/\.[^\.]")

If I change the OF_PROJECT_SOURCE_FILES to a temporary var name (make doesn’t like recursive assignments it seems) and add a filter after it constructs the list of sources:

    T_OF_PROJECT_SOURCE_FILES = $(shell $(FIND) $(OF_PROJECT_SOURCE_PATHS) -maxdepth 1 -name "*.mm" -or -name "*.m" -or -name "*.cpp" -or -name "*.c" -or -name "*.cc" -or -name "*.cxx" -or -name "*.S" | grep -v "/\.[^\.]") OF_PROJECT_SOURCE_FILES = $(filter-out $(OF_PROJECT_EXCLUSIONS),$(T_OF_PROJECT_SOURCE_FILES))

it will happily exclude any individual source file listed in the project config.make PROJECT_EXCLUSIONS.


I’m not sure where to report this if it seems like something that people would want to add to OF. And there may be a better way to do this!

brad

you can send a pull request in github: https://github.com/openframeworks/openFrameworks or if you are not sure how to send a PR you can just open an issue there

This should be probably fixed for ADDON_INCLUDES_EXCLUDE and ADDON_SOURCES_EXCLUDE aswell. I remember having problems with addon excludes in the past.