Browse Source

cmake: Fix some bugs building mconf-idf from scratch

- Makefile didn't quite work with out-of-tree build unless there was already an in-tree build done.
- CMake needs to delete some of the in-tree build artifacts or they're used instead of the correct
 files.
Angus Gratton 6 years ago
parent
commit
6410f7a259
2 changed files with 13 additions and 4 deletions
  1. 11 4
      tools/cmake/kconfig.cmake
  2. 2 0
      tools/kconfig/Makefile

+ 11 - 4
tools/cmake/kconfig.cmake

@@ -39,23 +39,30 @@ function(__kconfig_init)
         # Use the existing Makefile to build mconf (out of tree) when needed
         # Use the existing Makefile to build mconf (out of tree) when needed
         #
         #
         set(MCONF ${CMAKE_BINARY_DIR}/kconfig_bin/mconf-idf)
         set(MCONF ${CMAKE_BINARY_DIR}/kconfig_bin/mconf-idf)
+        set(src_path ${idf_path}/tools/kconfig)
 
 
+        # note: we preemptively remove any build files from the src dir
+        # as we're building out of tree, but don't want build system to
+        # #include any from there that were previously build with/for make
         externalproject_add(mconf-idf
         externalproject_add(mconf-idf
-            SOURCE_DIR ${idf_path}/tools/kconfig
+            SOURCE_DIR ${src_path}
             CONFIGURE_COMMAND ""
             CONFIGURE_COMMAND ""
             BINARY_DIR "kconfig_bin"
             BINARY_DIR "kconfig_bin"
-            BUILD_COMMAND make -f ${idf_path}/tools/kconfig/Makefile mconf-idf
+            BUILD_COMMAND rm -f ${src_path}/zconf.lex.c ${src_path}/zconf.hash.c
+            COMMAND make -f ${src_path}/Makefile mconf-idf
             BUILD_BYPRODUCTS ${MCONF}
             BUILD_BYPRODUCTS ${MCONF}
             INSTALL_COMMAND ""
             INSTALL_COMMAND ""
             EXCLUDE_FROM_ALL 1
             EXCLUDE_FROM_ALL 1
             )
             )
 
 
-        file(GLOB mconf_srcfiles ${idf_path}/tools/kconfig/*.c)
+        file(GLOB mconf_srcfiles ${src_path}/*.c)
+        list(REMOVE_ITEM mconf_srcfiles "${src_path}/zconf.lex.c" "${src_path}/zconf.hash.c")
         externalproject_add_stepdependencies(mconf-idf build
         externalproject_add_stepdependencies(mconf-idf build
             ${mconf_srcfiles}
             ${mconf_srcfiles}
-            ${idf_path}/tools/kconfig/Makefile
+            ${src_path}/Makefile
             ${CMAKE_CURRENT_LIST_FILE})
             ${CMAKE_CURRENT_LIST_FILE})
         unset(mconf_srcfiles)
         unset(mconf_srcfiles)
+        unset(src_path)
 
 
         set(menuconfig_depends DEPENDS mconf-idf)
         set(menuconfig_depends DEPENDS mconf-idf)
     endif()
     endif()

+ 2 - 0
tools/kconfig/Makefile

@@ -167,6 +167,8 @@ check-lxdialog  := $(SRCDIR)/lxdialog/check-lxdialog.sh
 CFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
 CFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
                     -DLOCALE -MMD
                     -DLOCALE -MMD
 
 
+CFLAGS += -I "." -I "${SRCDIR}"
+
 %.o: $(SRCDIR)/%.c
 %.o: $(SRCDIR)/%.c
 	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
 	$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@