@@ -162,6 +162,7 @@ all: $(BIN)
162162.PHONY : context clean_context config oldconfig menuconfig nconfig qconfig gconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
163163.PHONY : pass1 pass1dep
164164.PHONY : pass2 pass2dep
165+ .PHONY : host_info checkpython3
165166
166167# Target used to copy include/nuttx/lib/math.h. If CONFIG_ARCH_MATH_H is
167168# defined, then there is an architecture specific math.h header file
@@ -618,6 +619,35 @@ bootloader:
618619clean_bootloader :
619620 $(Q ) $(MAKE ) -C $(ARCH_SRC ) clean_bootloader
620621
622+ checkpython3 :
623+ @if [ -z " $$ (which python3)" ]; then \
624+ echo " ERROR: python3 not found in PATH" ; \
625+ echo " Please install python3 or fix the PATH" ; \
626+ exit 1; \
627+ fi
628+
629+ # host_info target flags to get diagnostic info without building nxdiag application
630+
631+ SYSINFO_PARSE_FLAGS = "$(realpath $(TOPDIR ) ) "
632+ SYSINFO_PARSE_FLAGS += "-fsysinfo.h"
633+
634+ SYSINFO_FLAGS = "-c"
635+ SYSINFO_FLAGS += "-p"
636+ SYSINFO_FLAGS += -f \""$(shell echo '$(CFLAGS ) ' | sed 's/"/\\\\\\"/g') "\"
637+ SYSINFO_FLAGS += \""$(shell echo '$(CXXFLAGS ) ' | sed 's/"/\\\\\\"/g') "\"
638+ SYSINFO_FLAGS += \""$(shell echo '$(LDFLAGS ) ' | sed 's/"/\\\\\\"/g') "\"
639+ SYSINFO_FLAGS += "--target_info"
640+
641+ # host_info: Parse nxdiag example output file (sysinfo.h) and print
642+
643+ host_info : checkpython3
644+ @if [[ ! -f " sysinfo.h" ]]; then \
645+ echo " file sysinfo.h not exists" ; \
646+ python3 $(TOPDIR )$(DELIM ) tools$(DELIM ) host_info_dump.py $(SYSINFO_FLAGS ) \
647+ $(realpath $(TOPDIR ) ) > sysinfo.h; \
648+ fi
649+ @python3 $(TOPDIR )$(DELIM ) tools$(DELIM ) host_info_parse.py $(SYSINFO_PARSE_FLAGS )
650+
621651# pass1dep: Create pass1 build dependencies
622652# pass2dep: Create pass2 build dependencies
623653
@@ -801,6 +831,7 @@ endif
801831 $(call DELFILE, .config.orig)
802832 $(call DELFILE, .config.backup)
803833 $(call DELFILE, .gdbinit)
834+ $(call DELFILE, sysinfo.h)
804835
805836# Application housekeeping targets. The APPDIR variable refers to the user
806837# application directory. A sample apps/ directory is included with NuttX,
0 commit comments