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/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 776136a11 Fix various error in Windows native build
776136a11 is described below

commit 776136a113e049031d93810010aabb36595e5c17
Author: zouboan <[email protected]>
AuthorDate: Fri Nov 11 01:24:10 2022 +0800

    Fix various error in Windows native build
---
 Application.mk    |  3 ++-
 Directory.mk      | 12 ++++++++----
 Make.defs         | 37 +++++++++++++++++++++----------------
 Makefile          | 24 +++++++++++++++++++-----
 builtin/Makefile  |  4 ++++
 platform/Makefile |  2 +-
 6 files changed, 55 insertions(+), 27 deletions(-)

diff --git a/Application.mk b/Application.mk
index 9c631c027..3541dd100 100644
--- a/Application.mk
+++ b/Application.mk
@@ -62,7 +62,8 @@ ifeq ($(BUILD_MODULE),y)
 endif
 
 SUFFIX = $(subst $(DELIM),.,$(CWD))
-PROGNAME := $(shell echo $(PROGNAME))
+
+PROGNAME := $(subst ",,$(PROGNAME))
 
 # Object files
 
diff --git a/Directory.mk b/Directory.mk
index 0b3ed7dee..e2f7069d4 100644
--- a/Directory.mk
+++ b/Directory.mk
@@ -22,11 +22,15 @@ include $(APPDIR)/Make.defs
 
 # Sub-directories that have been built or configured.
 
-SUBDIRS       := $(dir $(wildcard *$(DELIM)Makefile))
-CONFIGSUBDIRS := $(filter-out $(dir $(wildcard *$(DELIM)Kconfig)),$(SUBDIRS))
-CLEANSUBDIRS  += $(dir $(wildcard *$(DELIM).depend))
-CLEANSUBDIRS  += $(dir $(wildcard *$(DELIM).kconfig))
+SUBDIRS       := $(dir $(wildcard */Makefile))
+CONFIGSUBDIRS := $(filter-out $(dir $(wildcard */Kconfig)),$(SUBDIRS))
+CLEANSUBDIRS  += $(dir $(wildcard */.depend))
+CLEANSUBDIRS  += $(dir $(wildcard */.kconfig))
 CLEANSUBDIRS  := $(sort $(CLEANSUBDIRS))
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
+       CONFIGSUBDIRS  := $(subst /,\,$(CONFIGSUBDIRS))
+       CLEANSUBDIRS  := $(subst /,\,$(CLEANSUBDIRS))
+endif
 
 all: nothing
 
diff --git a/Make.defs b/Make.defs
index 3bef69a57..f1f66f4c4 100644
--- a/Make.defs
+++ b/Make.defs
@@ -21,27 +21,22 @@
 TOPDIR ?= $(APPDIR)/import
 include $(TOPDIR)/Make.defs
 
-# The GNU make CURDIR will always be a POSIX-like path with forward slashes
-# as path segment separators.  This is fine for the above inclusions but
-# will cause problems later for the native build.  If we know that this is
-# a native build, then we need to fix up the APPDIR path for subsequent
-# use
-
-ifeq ($(CONFIG_WINDOWS_NATIVE),y)
-APPDIR := ${shell echo %CD%}
-endif
-
 # Application Directories
 
 # BUILDIRS is the list of top-level directories containing Make.defs files
 # CLEANDIRS is the list of all top-level directories containing Makefiles.
 #   It is used only for cleaning.
 
-BUILDIRS   := $(dir $(wildcard $(APPDIR)$(DELIM)*$(DELIM)Make.defs))
-BUILDIRS   := $(filter-out $(APPDIR)$(DELIM)import$(DELIM),$(BUILDIRS))
-CONFIGDIRS := $(filter-out $(APPDIR)$(DELIM)builtin$(DELIM),$(BUILDIRS))
-CONFIGDIRS := $(filter-out $(dir $(wildcard 
$(APPDIR)$(DELIM)*$(DELIM)Kconfig)),$(CONFIGDIRS))
-CLEANDIRS  := $(dir $(wildcard $(APPDIR)$(DELIM)*$(DELIM)Makefile))
+BUILDIRS   := $(dir $(wildcard $(APPDIR)/*/Make.defs))
+BUILDIRS   := $(filter-out $(APPDIR)/import/,$(BUILDIRS))
+CONFIGDIRS := $(filter-out $(APPDIR)/builtin/,$(BUILDIRS))
+CONFIGDIRS := $(filter-out $(dir $(wildcard 
$(APPDIR)/*/Kconfig)),$(CONFIGDIRS))
+CLEANDIRS  := $(dir $(wildcard $(APPDIR)/*/Makefile))
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
+       BUILDIRS  := $(subst /,\,$(BUILDIRS))
+       CONFIGDIRS  := $(subst /,\,$(CONFIGDIRS))
+       CLEANDIRS  := $(subst /,\,$(CLEANDIRS))
+endif
 
 # CONFIGURED_APPS is the application directories that should be built in
 #   the current configuration.
@@ -85,14 +80,24 @@ endif
 BUILTIN_REGISTRY = $(APPDIR)$(DELIM)builtin$(DELIM)registry
 DEPCONFIG = $(TOPDIR)$(DELIM).config
 
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
 define REGISTER
        $(Q) echo Register: $1
-       $(Q) echo { \"$1\", $2, $3, $4 }, > "$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
+       $(Q) echo { "$(subst ",,$(1))", $2, $3, $(subst ",,$(4)) }, > 
"$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
+       $(Q) echo int $(subst ",,$(4))(int argc, char *argv[]); > 
"$(BUILTIN_REGISTRY)$(DELIM)$1.pdat"
+
+       $(Q) touch $(BUILTIN_REGISTRY)$(DELIM).updated"
+endef
+else
+define REGISTER
+       $(Q) echo "Register: $1"
+       $(Q) echo "{ \"$1\", $2, $3, $4 }," > 
"$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
        $(Q) if [ ! -z $4 ]; then \
                echo "int $4(int argc, char *argv[]);" > 
"$(BUILTIN_REGISTRY)$(DELIM)$1.pdat"; \
             fi;
        $(Q) touch "$(BUILTIN_REGISTRY)$(DELIM).updated"
 endef
+endif
 
 # Standard include path
 
diff --git a/Makefile b/Makefile
index 6344a513c..1e432a99b 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,16 @@
 export APPDIR = $(CURDIR)
 include $(APPDIR)/Make.defs
 
+# The GNU make CURDIR will always be a POSIX-like path with forward slashes
+# as path segment separators.  This is fine for the above inclusions but
+# will cause problems later for the native build.  If we know that this is
+# a native build, then we need to fix up the APPDIR path for subsequent
+# use
+
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
+export APPDIR = $(subst /,\,$(CURDIR))
+endif
+
 # Symbol table for loadable apps.
 
 SYMTABSRC = symtab_apps.c
@@ -83,11 +93,15 @@ else
 # symbol table is required.
 
 ifeq ($(CONFIG_BUILD_LOADABLE),)
-
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
+$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
+       $(Q) for %%G in ($(CONFIGURED_APPS)) do ( $(MAKE) -C %%G archive )
+else
 $(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
        $(Q) for app in ${CONFIGURED_APPS}; do \
                $(MAKE) -C "$${app}" archive ; \
        done
+endif
 
 else
 
@@ -189,10 +203,10 @@ clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean)
 
 distclean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_distclean)
 ifeq ($(CONFIG_WINDOWS_NATIVE),y)
-       $(Q) (if exist  external ( \
-               echo ********************************************************" \
-               echo * The external directory/link must be removed manually *" \
-               echo ********************************************************" \
+       $(Q) ( if exist  external \
+               echo "********************************************************" 
\
+               echo "* The external directory/link must be removed manually *" 
\
+               echo "********************************************************" 
\
        )
 else
        $(Q) (if [ -e external ]; then \
diff --git a/builtin/Makefile b/builtin/Makefile
index eaefd7748..ce1205ff3 100644
--- a/builtin/Makefile
+++ b/builtin/Makefile
@@ -28,6 +28,10 @@ CSRCS = builtin_list.c exec_builtin.c
 
 PDATLIST = $(strip $(call RWILDCARD, registry, *.pdat))
 BDATLIST = $(strip $(call RWILDCARD, registry, *.bdat))
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
+       PDATLIST  := $(subst /,\,$(PDATLIST))
+       BDATLIST  := $(subst /,\,$(BDATLIST))
+endif
 
 builtin_list.c: builtin_list.h builtin_proto.h
 
diff --git a/platform/Makefile b/platform/Makefile
index faf0a19db..8260ad92c 100644
--- a/platform/Makefile
+++ b/platform/Makefile
@@ -25,7 +25,7 @@ CONFIG_ARCH_BOARD ?= dummy
 # Directories
 
 PLATFORMDIR = board
-DUMMYDIR    = $(APPDIR)/platform/dummy
+DUMMYDIR    = $(APPDIR)$(DELIM)platform$(DELIM)dummy
 
 ifeq ($(CONFIG_ARCH_BOARD_CUSTOM),y)
   LINKDIR   = $(DUMMYDIR)

Reply via email to