]> granicus.if.org Git - esp-idf/commitdiff
cmake: Add COMPONENT_SRCEXCLUDE option
authorAngus Gratton <angus@espressif.com>
Wed, 30 May 2018 07:55:44 +0000 (17:55 +1000)
committerAngus Gratton <gus@projectgus.com>
Thu, 31 May 2018 04:46:39 +0000 (14:46 +1000)
docs/en/api-guides/build-system.rst
tools/cmake/components.cmake

index f32cc9eb31174a07f08a94190f4564a03f08be77..01235fa08f26c0b9f6b60a9bd77848509c1f232e 100644 (file)
@@ -323,6 +323,7 @@ The following variables can be set inside ``component.mk`` to control the build
   ``*.c``, ``*.S``). Set this to specify a list of directories which contain source files.
 - ``COMPONENT_SRCS``: Paths to individual source files to compile. Setting this causes ``COMPONENT_SRCDIRS`` to be ignored. Setting this variable instead gives you finer grained control over which files are compiled.
   If you don't set ``COMPONENT_SRCDIRS`` or ``COMPONENT_SRCS``, your component won't compile a library but it may still add include paths for use when compiling other components or the source files listed in ``MAIN_SRCS``.
+- ``COMPONENT_SRCEXCLUDE``: Paths to source files to exclude from component. Can be set in conjunction with ``COMPONENT_SRCDIRS`` if there is a directory with a large number of source files to include in the component but one or more source files which should not be. Paths can be specified relative to the component directory or absolute.
 
 Controlling Component Compilation
 ---------------------------------
@@ -835,6 +836,7 @@ Some features are significantly different or removed in the CMake-based system.
 - ``COMPONENT_SUBMODULES``: No longer used, the build system will automatically enumerate all submodules in the ESP-IDF repo.
 - ``COMPONENT_EXTRA_INCLUDES``: Used to be an alternative to ``COMPONENT_PRIV_INCLUDEDIRS`` for absolute paths. Use ``COMPONENT_PRIV_INCLUDEDIRS`` for all cases now (can be relative or absolute).
 - ``COMPONENT_OBJS``: Previously, component sources could be specified as a list of object files. Now they can be specified as an list of source files via ``COMPONENT_SRCS``.
+- ``COMPONENT_OBJEXCLUDE``: Has been replaced with ``COMPONENT_SRCEXCLUDE``. Specify source files (as absolute paths or relative to component directory), instead.
 - ``COMPONENT_EXTRA_CLEAN``: Set property ``ADDITIONAL_MAKE_CLEAN_FILES`` instead but note :ref:`CMake has some restrictions around this functionality <ADDITIONAL_MAKE_CLEAN_FILES_note>`.
 - ``COMPONENT_OWNBUILDTARGET`` & ``COMPONENT_OWNCLEANTARGET``: Use CMake `ExternalProject`_ instead. See :ref:`component-build-full-override` for full details.
 - ``COMPONENT_CONFIG_ONLY``: Call ``register_config_only_component()`` instead. See `Configuration-Only Components`_.
index 506d8a06facea4355dd6f28722ac323215f83495..fc7c7f5ed5aa18193b6f50e8c07e802ae0d8f847 100644 (file)
@@ -20,6 +20,7 @@ function(register_component)
 
     spaces2list(COMPONENT_SRCDIRS)
     spaces2list(COMPONENT_ADD_INCLUDEDIRS)
+    spaces2list(COMPONENT_SRCEXCLUDE)
 
     # Add to COMPONENT_SRCS by globbing in COMPONENT_SRCDIRS
     if(NOT COMPONENT_SRCS)
@@ -39,6 +40,17 @@ function(register_component)
         endforeach()
     endif()
 
+    # Remove COMPONENT_SRCEXCLUDE matches
+    foreach(exclude ${COMPONENT_SRCEXCLUDE})
+        get_filename_component(exclude "${exclude}" ABSOLUTE ${component_dir})
+        foreach(src ${COMPONENT_SRCS})
+            get_filename_component(abs_src "${src}" ABSOLUTE ${component_dir})
+            if("${exclude}" STREQUAL "${abs_src}")  # compare as canonical paths
+                list(REMOVE_ITEM COMPONENT_SRCS src)
+            endif()
+        endforeach()
+    endforeach()
+
     # add as a PUBLIC library (if there are source files) or INTERFACE (if header only)
     if(COMPONENT_SRCS OR embed_binaries)
         add_library(${component} STATIC ${COMPONENT_SRCS})