SpiNNakerManchester / SpiNNakerManchester.github.io

Organization Pages, Documentation and Issues
http://spinnakermanchester.github.io/
Apache License 2.0
12 stars 7 forks source link

make clean in live_packet_gather deletes the official source file #14

Closed nicolasgazeres closed 7 years ago

nicolasgazeres commented 7 years ago

Hi team, Calling make clean from the SpiNNFrontEndCommon-3.0.0\c_common\models\live_packet_gather directory causes the official live_packet_gather.c source file to be deleted from the source tree. I could trace it down to the $(OBJECT) argument to $(RM) in Makefile.SpiNNFrontEndCommon. I guess what is intended here is to remove live_packet_gather_build.c . Regards, Nicolas

rowleya commented 7 years ago

This doesn't happen on my build - $(OBJECTS) should contain live_packet_gather.o rather than live_packet_gather.c...

nicolasgazeres commented 7 years ago

Hi Andrew, (I run make from live_packet_gather, I don't know if I'm supposed to do that). In Makefile.SpiNNFrontEndCommon: $(OBJECTS) is assigned through $(OBJECTS)+=$(OBJS) $(OBJS) itself is assigned through OBJS := $(abspath $(SOURCES)) $(SOURCES) is assigned to live_packet_gather.c from live_packet_gather/Makefile Regards, Nicolas

nicolasgazeres commented 7 years ago

Hi Andrew, OK, I got it, the .c to .o substitution does not work on my system. I'll investigate that. Regards, Nicolas

rowleya commented 7 years ago

Yes, the rules being followed are:

OBJS := $(abspath $(SOURCES))
$(foreach dir, $(sort $(SOURCE_DIRS)), $(eval OBJS := $(OBJS:$(abspath $(dir))/%.c=$(BUILD_DIR)%.o)))
$(foreach dir, $(sort $(SOURCE_DIRS)), $(eval $(call define-build-code,$(dir))))
OBJECTS += $(OBJS)

It is the second line here that should do most of the .c to .o conversion - this will only work if one of the entries in $(SOURCE_DIRS) matches the $(abspath ...) of the source file. If this doesn't happen, you will get what you observe. This is a bit of a bug, since it might be better to error if a .c file ends up in $(OBJECTS). I will have a look and see if this sort of error is possible to detect.

rowleya commented 7 years ago

OK, I think this should do the detection:

ERROR_OBJS = $(filter %.c, $(OBJECTS))
ifneq ($(ERROR_OBJS), )
    $(error Objects $(ERROR_OBJS) are not contained within source directories $(SOURCE_DIRS))
endif 

This should come just after line 36 in Makefile.SpiNNFrontEndCommon (which reads OBJECTS += $(OBJS))

This should then detect any .c files in objects and error, rather than delete them!

nicolasgazeres commented 7 years ago

Indeed, the code above does spot when a .c file remains in the OBJECTS variable.

For my information, could you please give the output of command "find ." on your system when issued from the c_common\models\live_packet_gather directory (after a complete build) ? Thanks.

rowleya commented 7 years ago

After a build, "find ." results in the following: . ./build ./build/live_packet_gather ./build/live_packet_gather.elf ./build/live_packet_gather.txt ./live_packet_gather.c ./Makefile

Note that Make deletes a number of intermediate files.

alan-stokes commented 7 years ago

think this is solved in master. will close, but if it becomes apparent that its not fixed, please feel free to reopen in