xuxin930 commented on code in PR #1979:
URL: https://github.com/apache/nuttx-apps/pull/1979#discussion_r1301483146


##########
Application.mk:
##########
@@ -93,6 +93,35 @@ ifneq ($(BUILD_MODULE),y)
   OBJS += $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ) $(MAINZIGOBJ)
 endif
 
+ifneq ($(PROGNAME),)
+  PROGOBJ := $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ)
+  ifneq ($(words $(PROGOBJ)), $(words $(PROGNAME)))
+    $(warning "program names $(PROGNAME) does not match mainsrcs $(PROGOBJ)")
+  endif
+  PROGLIST := $(addprefix $(BINDIR)$(DELIM),$(PROGNAME))
+  REGLIST := $(addprefix $(BUILTIN_REGISTRY)$(DELIM),$(addsuffix 
.bdat,$(PROGNAME)))
+
+  NLIST := $(shell seq 1 $(words $(PROGNAME)))
+  $(foreach IDX, $(NLIST), \
+    $(eval PROGKEY_$(word $(IDX),$(PROGOBJ)) := $(word $(IDX),$(PROGNAME))) \
+    $(eval ELFPROGKEY_$(word $(IDX),$(PROGLIST)) := $(word $(IDX),$(PROGOBJ))) 
\
+       $(eval REGAPPKEY_$(word $(IDX),$(REGLIST)) := $(word 
$(IDX),$(PROGNAME))) \
+       $(eval REGPRIORITYKEY_$(word $(IDX),$(REGLIST)) := \
+               $(if $(word $(IDX),$(PRIORITY)),$(word 
$(IDX),$(PRIORITY)),$(word $(words $(PRIORITY)),$(PRIORITY)))) \

Review Comment:
   > change `$(word $(words $(PRIORITY)),$(PRIORITY))` to `$(lastword 
$(PRIORITY))`
   
   Done✅
   and `UID`,`GID` and other variables that may not be initialized are also 
changed to `$(lastword)`.
   after testing, there will be no error like `$(word 0)`



##########
Application.mk:
##########
@@ -93,6 +93,35 @@ ifneq ($(BUILD_MODULE),y)
   OBJS += $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ) $(MAINZIGOBJ)
 endif
 
+ifneq ($(PROGNAME),)
+  PROGOBJ := $(MAINCOBJ) $(MAINCXXOBJ) $(MAINRUSTOBJ)
+  ifneq ($(words $(PROGOBJ)), $(words $(PROGNAME)))
+    $(warning "program names $(PROGNAME) does not match mainsrcs $(PROGOBJ)")
+  endif
+  PROGLIST := $(addprefix $(BINDIR)$(DELIM),$(PROGNAME))
+  REGLIST := $(addprefix $(BUILTIN_REGISTRY)$(DELIM),$(addsuffix 
.bdat,$(PROGNAME)))
+
+  NLIST := $(shell seq 1 $(words $(PROGNAME)))
+  $(foreach IDX, $(NLIST), \
+    $(eval PROGKEY_$(word $(IDX),$(PROGOBJ)) := $(word $(IDX),$(PROGNAME))) \
+    $(eval ELFPROGKEY_$(word $(IDX),$(PROGLIST)) := $(word $(IDX),$(PROGOBJ))) 
\
+       $(eval REGAPPKEY_$(word $(IDX),$(REGLIST)) := $(word 
$(IDX),$(PROGNAME))) \
+       $(eval REGPRIORITYKEY_$(word $(IDX),$(REGLIST)) := \
+               $(if $(word $(IDX),$(PRIORITY)),$(word 
$(IDX),$(PRIORITY)),$(word $(words $(PRIORITY)),$(PRIORITY)))) \

Review Comment:
   > change `$(word $(words $(PRIORITY)),$(PRIORITY))` to `$(lastword 
$(PRIORITY))`
   
   Done✅
   and `UID`,`GID` and other variables that may not be initialized are also 
changed to `$(lastword)`.
   after testing, there will be no error like `$(word 0)`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to