You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/01/04 18:03:17 UTC

[incubator-nuttx] branch master updated: Improve dirlinks dependencies for Makefile.win

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 57a19de  Improve dirlinks dependencies for Makefile.win
57a19de is described below

commit 57a19de451738c7512c1ed3df619f820764a1ff7
Author: Alan Rosenthal <al...@google.com>
AuthorDate: Tue Jan 4 10:46:26 2022 -0500

    Improve dirlinks dependencies for Makefile.win
    
    This PR improved dirlinks dependencies for Makefile.unix: https://github.com/apache/incubator-nuttx/pull/5069
    
    This PR copies the changes into Makefile.win
---
 tools/Makefile.win | 160 +++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 118 insertions(+), 42 deletions(-)

diff --git a/tools/Makefile.win b/tools/Makefile.win
index 3f16f5d..7726f61 100644
--- a/tools/Makefile.win
+++ b/tools/Makefile.win
@@ -131,7 +131,7 @@ endif
 BIN = nuttx$(EXEEXT)
 
 all: $(BIN)
-.PHONY: dirlinks context clean_context config oldconfig menuconfig nconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
+.PHONY: context clean_context config oldconfig menuconfig nconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
 .PHONY: pass1 pass1dep
 .PHONY: pass2 pass2dep
 
@@ -233,7 +233,7 @@ include\nuttx\config.h: $(TOPDIR)\.config tools\mkconfig$(HOSTEXEEXT)
 tools\mkdeps$(HOSTEXEEXT):
 	$(Q) $(MAKE) -C tools -f Makefile.host mkdeps$(HOSTEXEEXT)
 
-# dirlinks, and helpers
+# .dirlinks, and helpers
 #
 # Directories links.  Most of establishing the NuttX configuration involves
 # setting up symbolic links with 'generic' directory names to specific,
@@ -242,71 +242,147 @@ tools\mkdeps$(HOSTEXEEXT):
 # Link the arch\<arch-name>\include directory to include\arch
 
 include\arch:
-	@echo LN: include\arch to $(ARCH_DIR)\include
-	$(Q) $(DIRLINK) $(TOPDIR)\$(ARCH_DIR)\include include\arch
-	$(Q) touch $@
+	@echo "LN: $@ to $(ARCH_DIR)\include"
+	$(Q) $(DIRLINK) $(TOPDIR)\$(ARCH_DIR)\include $@
 
 # Link the boards\<arch>\<chip>\<board>\include directory to include\arch\board
 
-include\arch\board: include\arch
-	@echo LN: include\arch\board to $(BOARD_DIR)\include
-	$(Q) $(DIRLINK) $(BOARD_DIR)\include include\arch\board
-	$(Q) touch $@
+include\arch\board: | include\arch
+	@echo "LN: $@ to $(BOARD_DIR)\include"
+	$(Q) $(DIRLINK) $(BOARD_DIR)\include $@
 
-ifneq ($(BOARD_COMMON_DIR),)
 # Link the boards\<arch>\<chip>\common dir to arch\<arch-name>\src\board
 # Link the boards\<arch>\<chip>\<board>\src dir to arch\<arch-name>\src\board\board
 
-$(ARCH_SRC)\board:
-	@echo "LN: $(ARCH_SRC)\board to $(BOARD_COMMON_DIR)"
-	$(Q) $(DIRLINK) $(BOARD_COMMON_DIR) $(ARCH_SRC)\board
-	@echo "LN: $(ARCH_SRC)\board\board to $(BOARD_DIR)\src"
-	$(Q) $(DIRLINK) $(BOARD_DIR)\src $(ARCH_SRC)\board\board
-	$(Q) touch $@
+ifneq ($(BOARD_COMMON_DIR),)
+ARCH_SRC_BOARD_SYMLINK=$(BOARD_COMMON_DIR)
+ARCH_SRC_BOARD_BOARD_SYMLINK=$(BOARD_DIR)\src
 else
-# Link the boards\<arch>\<chip>\<board>\src dir to arch\<arch-name>\src\board
+ARCH_SRC_BOARD_SYMLINK=$(BOARD_DIR)\src
+endif
 
+ifneq ($(ARCH_SRC_BOARD_SYMLINK),)
 $(ARCH_SRC)\board:
-	@echo LN: $(ARCH_SRC)\board to $(BOARD_DIR)\src
-	$(Q) $(DIRLINK) $(BOARD_DIR)\src $(ARCH_SRC)\board
-	$(Q) touch $@
+	@echo "LN: $@ to $(ARCH_SRC_BOARD_SYMLINK)"
+	$(Q) $(DIRLINK) $(ARCH_SRC_BOARD_SYMLINK) $@
+endif
+
+ifneq ($(ARCH_SRC_BOARD_BOARD_SYMLINK),)
+$(ARCH_SRC)\board\board: | $(ARCH_SRC)\board
+	@echo "LN: $@ to $(ARCH_SRC_BOARD_BOARD_SYMLINK)"
+	$(Q) $(DIRLINK) $(ARCH_SRC_BOARD_BOARD_SYMLINK) $@
 endif
 
 # Link the boards\<arch>\<chip>\drivers dir to drivers\platform
 
 drivers\platform:
-	@echo LN: $(TOPDIR)\drivers\platform to $(BOARD_DRIVERS_DIR)
-	$(Q) $(DIRLINK) $(BOARD_DRIVERS_DIR) $(TOPDIR)\drivers\platform
-	$(Q) touch $@
+	@echo "LN: $@ to $(BOARD_DRIVERS_DIR)"
+	$(Q) $(DIRLINK) $(BOARD_DRIVERS_DIR) $@
 
 # Link arch\<arch-name>\src\<chip-name> to arch\<arch-name>\src\chip
 
-$(ARCH_SRC)\chip:
 ifeq ($(CONFIG_ARCH_CHIP_CUSTOM),y)
-	@echo LN: $(ARCH_SRC)\chip to $(CHIP_DIR)
-	$(Q) $(DIRLINK) $(CHIP_DIR) $(ARCH_SRC)\chip
+ARCH_SRC_CHIP_SYMLINK_DIR=$(CHIP_DIR)
 else ifneq ($(CONFIG_ARCH_CHIP),)
-	@echo LN: $(ARCH_SRC)\chip to $(ARCH_SRC)\$(CONFIG_ARCH_CHIP)
-	$(Q) $(DIRLINK) $(TOPDIR)\$(ARCH_SRC)\$(CONFIG_ARCH_CHIP) $(ARCH_SRC)\chip
+ARCH_SRC_CHIP_SYMLINK_DIR=$(TOPDIR)\$(ARCH_SRC)\$(CONFIG_ARCH_CHIP)
+endif
+
+ifneq ($(ARCH_SRC_CHIP_SYMLINK_DIR),)
+$(ARCH_SRC)\chip:
+	@echo "LN: $@ to $(ARCH_SRC_CHIP_SYMLINK_DIR)"
+	$(Q) $(DIRLINK) $(ARCH_SRC_CHIP_SYMLINK_DIR) $@
 endif
-	$(Q) cp -f $(CHIP_KCONFIG) $(TOPDIR)\arch\dummy\Kconfig
-	$(Q) touch $@
 
-# Link arch\<arch-name>\include\<chip-name> to arch\<arch-name>\include\chip
+# Link arch\<arch-name>\include\<chip-name> to include\arch\chip
 
-include\arch\chip: include\arch
 ifeq ($(CONFIG_ARCH_CHIP_CUSTOM),y)
-	@echo LN: include\arch\chip to $(CHIP_DIR)\include
-	$(Q) $(DIRLINK) $(CHIP_DIR)\include include\arch\chip
+INCLUDE_ARCH_CHIP_SYMLINK_DIR=$(CHIP_DIR)\include
 else ifneq ($(CONFIG_ARCH_CHIP),)
-	@echo LN: include\arch\chip to $(ARCH_INC)\$(CONFIG_ARCH_CHIP)
-	$(Q) $(DIRLINK) $(TOPDIR)\$(ARCH_INC)\$(CONFIG_ARCH_CHIP) include\arch\chip
+INCLUDE_ARCH_CHIP_SYMLINK_DIR=$(TOPDIR)\$(ARCH_INC)\$(CONFIG_ARCH_CHIP)
+endif
+
+ifneq ($(INCLUDE_ARCH_CHIP_SYMLINK_DIR),)
+include\arch\chip:
+	@echo "LN: $@ to $(INCLUDE_ARCH_CHIP_SYMLINK_DIR)"
+	$(DIRLINK) $(INCLUDE_ARCH_CHIP_SYMLINK_DIR) $@
+endif
+
+# Copy $(CHIP_KCONFIG) to arch\dummy\Kconfig
+
+arch\dummy\Kconfig:
+	@echo "CP: $@ to $(CHIP_KCONFIG)"
+	$(Q) cp -f $(CHIP_KCONFIG) $@
+
+DIRLINKS_SYMLINK = \
+  include\arch \
+  include\arch\board \
+  drivers\platform \
+
+DIRLINKS_FILE = \
+  arch\dummy\Kconfig \
+
+ifneq ($(INCLUDE_ARCH_CHIP_SYMLINK_DIR),)
+DIRLINKS_SYMLINK += include\arch\chip
 endif
+
+ifneq ($(ARCH_SRC_CHIP_SYMLINK_DIR),)
+DIRLINKS_SYMLINK += $(ARCH_SRC)\chip
+endif
+
+ifneq ($(ARCH_SRC_BOARD_SYMLINK),)
+DIRLINKS_SYMLINK += $(ARCH_SRC)\board
+endif
+
+ifneq ($(ARCH_SRC_BOARD_BOARD_SYMLINK),)
+DIRLINKS_SYMLINK += $(ARCH_SRC)\board\board
+endif
+
+DIRLINKS_EXTERNAL_DIRS = boards
+
+ifneq ($(APPDIR),)
+DIRLINKS_EXTERNAL_DIRS += $(APPDIR)
+endif
+
+# Generate a pattern to build $(DIRLINKS_EXTERNAL_DIRS)
+DIRLINKS_EXTERNAL_DEP = $(patsubst %,%\.dirlinks,$(DIRLINKS_EXTERNAL_DIRS))
+DIRLINKS_FILE += $(DIRLINKS_EXTERNAL_DEP)
+
+.dirlinks: $(DIRLINKS_FILE) | $(DIRLINKS_SYMLINK)
+	touch $@
+
+# Pattern rule for $(DIRLINKS_EXTERNAL_DEP)
+
+%\.dirlinks:
+	$(Q) $(MAKE) -C $(patsubst %\.dirlinks,%,$@) dirlinks
 	$(Q) touch $@
 
-dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(ARCH_SRC)\chip drivers\platform
-	$(Q) $(MAKE) -C boards dirlinks
-	$(Q) $(MAKE) -C $(CONFIG_APPS_DIR) dirlinks
+
+# clean_dirlinks
+#
+# This is part of the distclean target. It removes all symbolic links created by the dirlink target.
+
+# The symlink subfolders need to be removed before the parent symlinks
+
+.PHONY: clean_dirlinks
+clean_dirlinks:
+	$(Q) $(call DELFILE, $(DIRLINKS_FILE))
+	$(Q) $(call DELFILE, .dirlinks)
+	$(Q) $(DIRUNLINK) drivers\platform
+ifneq ($(INCLUDE_ARCH_CHIP_SYMLINK_DIR),)
+	$(Q) $(DIRUNLINK) include\arch\chip
+endif
+	$(Q) $(DIRUNLINK) include\arch\board
+	$(Q) $(DIRUNLINK) include\arch
+ifneq ($(ARCH_SRC_BOARD_BOARD_SYMLINK),)
+	$(Q) $(DIRUNLINK) $(ARCH_SRC)\board\board
+endif
+ifneq ($(ARCH_SRC_BOARD_SYMLINK),)
+	$(Q) $(DIRUNLINK) $(ARCH_SRC)\board
+endif
+ifneq ($(ARCH_SRC_CHIP_SYMLINK_DIR),)
+	$(Q) $(DIRUNLINK) $(ARCH_SRC)\chip
+endif
+
 
 # context
 #
@@ -319,7 +395,7 @@ dirlinks: include\arch include\arch\board include\arch\chip $(ARCH_SRC)\board $(
 
 CONTEXTDIRS_DEPS = $(patsubst %,%\.context,$(CONTEXTDIRS))
 
-context: include\nuttx\config.h include\nuttx\version.h $(CONTEXTDIRS_DEPS) dirlinks | staging
+context: include\nuttx\config.h include\nuttx\version.h $(CONTEXTDIRS_DEPS) .dirlinks | staging
 
 ifeq ($(NEED_MATH_H),y)
 context: include\math.h
@@ -342,7 +418,7 @@ staging:
 
 # Pattern rule for $(CONTEXTDIRS_DEPS)
 
-%.context: include\nuttx\config.h dirlinks
+%.context: include\nuttx\config.h .dirlinks
 	$(Q) $(MAKE) -C $(patsubst %.context,%,$@) TOPDIR="$(TOPDIR)" context
 	$(Q) touch $@
 
@@ -602,7 +678,7 @@ endif
 # apps_distclean: Perform the distclean operation only in the user application
 #                 directory.
 
-apps_preconfig: dirlinks
+apps_preconfig: .dirlinks
 ifneq ($(APPDIR),)
 	$(Q) $(MAKE) -C "$(APPDIR)" preconfig
 endif