Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/Unix.mk: Add debug_info target to print nxdiag output #15304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tools/Unix.mk
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ all: $(BIN)
.PHONY: context clean_context config oldconfig menuconfig nconfig qconfig gconfig export subdir_clean clean subdir_distclean distclean apps_clean apps_distclean
.PHONY: pass1 pass1dep
.PHONY: pass2 pass2dep
.PHONY: debug_info checkpython3

# Target used to copy include/nuttx/lib/math.h. If CONFIG_ARCH_MATH_H is
# defined, then there is an architecture specific math.h header file
Expand Down Expand Up @@ -618,6 +619,40 @@ bootloader:
clean_bootloader:
$(Q) $(MAKE) -C $(ARCH_SRC) clean_bootloader

checkpython3:
@if [ -z "$$(which python3)" ]; then \
echo "ERROR: python3 not found in PATH"; \
echo " Please install python3 or fix the PATH"; \
exit 1; \
fi

# debug_info target flags to get diagnostic info without building nxdiag application

SYSINFO_PARSE_FLAGS = "$(realpath $(TOPDIR))"
SYSINFO_PARSE_FLAGS += "-fsysinfo.h"

SYSINFO_FLAGS = "-c"
SYSINFO_FLAGS += "-p"
SYSINFO_FLAGS += -f \""$(shell echo '$(CFLAGS)' | sed 's/"/\\\\\\"/g')"\"
SYSINFO_FLAGS += \""$(shell echo '$(CXXFLAGS)' | sed 's/"/\\\\\\"/g')"\"
SYSINFO_FLAGS += \""$(shell echo '$(LDFLAGS)' | sed 's/"/\\\\\\"/g')"\"

ifneq ($(findstring esp,$(CONFIG_ARCH_CHIP)),)
ARCH_ESP_HALDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)chip$(DELIM)esp-hal-3rdparty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but parse_sysinfo.py doesn't use many of these options

Copy link
Contributor Author

@eren-terzioglu eren-terzioglu Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, parse_sysinfo.py uses SYSINFO_PARSE_FLAGS flags. Others are (SYSINFO_FLAGS) for host_sysinfo.py which are taken from nxdiag example.

If you are asking does parse_sysinfo.py prints every information, it does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, should we just keep the flag required by parse_sysinfo.py, but move the host_sysinfo.py's options to apps/system/nxdiag.
BTW, host_sysinfo.py should be still keep in apps/system/nxdiag too.

Copy link
Contributor Author

@eren-terzioglu eren-terzioglu Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move host_sysinfo.py to its original place and then put related flags in apps/system/nxdiag/makefile but in the end, we will revert it into first version of this PR(mostly). Final decision is up to you. Important point is, if we move it we will call something in appsdir from nuttx (here/ tools/Unix.mk). Let me create an example to show it better:

# tools/Unix.mk
FLAGS = $(APPDIR)/system/nxdiag/sysinfo.h
FLAGS += ...
debug_info: checkpython3
ifneq ($(APPDIR),)
	$(Q) $(MAKE) -C $(APPDIR) debug_info
endif
python3 tools/parse_sysinfo.py FLAGS

# apps/Makefile:
debug_info:
$(Q) $(MAKE) -C $(APPDIR)/system/nxdiag debug_info

# apps/system/nxdiag/Makefile:
FLAGS = ...
debug_info: checkpython3
python3 $(APPDIR)/tools/host_sysinfo.py FLAGS> sysinfo.h

You might ask why we need to add a target on apps/Makefile. If we don't add it, make debug_info command gives some errors due to missing some configurations.

SYSINFO_FLAGS += --espressif "$(TOPDIR)" "$(ARCH_ESP_HALDIR)"
SYSINFO_FLAGS += "--espressif_chip"
endif

# debug_info: Parse nxdiag example output file (sysinfo.h) and print

debug_info: checkpython3
@if [[ ! -f "sysinfo.h" ]]; then \
echo "file sysinfo.h not exists"; \
python3 $(TOPDIR)$(DELIM)tools$(DELIM)host_sysinfo.py $(SYSINFO_FLAGS) \
$(realpath $(TOPDIR)) > sysinfo.h; \
fi
@python3 $(TOPDIR)$(DELIM)tools$(DELIM)parse_sysinfo.py $(SYSINFO_PARSE_FLAGS)

# pass1dep: Create pass1 build dependencies
# pass2dep: Create pass2 build dependencies

Expand Down
Loading
Loading