cancel
Showing results for 
Search instead for 
Did you mean: 

How to add additional c source file to TouchGFX project ?

JLakn
Associate II

Hey, my question is how to add additional c source files to TouchGFX project so I can build project in TouchGFX Designer?

I know I have to edit Makefile . I already tried it but with no success.

Here is the code of my makefile:

# Helper macros to convert spaces into question marks and back again
e := 
sp := $(e) $(e)
qs = $(subst ?,$(sp),$1)
sq = $(subst $(sp),?,$1)
 
# Get name of this Makefile (avoid getting word 0 and a starting space)
makefile_name := $(wordlist 1,1000,$(MAKEFILE_LIST))
 
# Get path of this Makefile
makefile_path := $(call qs,$(dir $(call sq,$(abspath $(call sq,$(makefile_name))))))
 
# Get path where the Application is
application_path := $(call qs,$(abspath $(call sq,$(makefile_path)../..)))
 
.PHONY: clean assets all
 
ifneq ($(words $(makefile_path))$(words $(MAKEFILE_LIST)),11)
all clean assets:
$(error Spaces not allowed in path)
else
 
project_path := $(call qs,$(abspath $(call sq,$(makefile_path)../../..)))
core_path := $(project_path)/Core/Inc
core_src := $(project_path)/Core/Src
 
 
ADDITIONAL_SOURCES :=$(core_src)
ADDITIONAL_INCLUDE_PATHS :=$(core_path)
ADDITIONAL_LIBRARY_PATHS := 
ADDITIONAL_LIBRARIES :=
export ADDITIONAL_SOURCES ADDITIONAL_INCLUDE_PATHS ADDITIONAL_LIBRARY_PATHS ADDITIONAL_LIBRARIES 
 
all: $(filter assets,$(MAKECMDGOALS))
all assets: $(filter clean,$(MAKECMDGOALS))
all clean assets:
	@$(MAKE) -r -f generated/simulator/gcc/Makefile -s $(MFLAGS) $@ -C "$(application_path)"
endif

12 REPLIES 12

Thank you @Alexandre RENOUX​ now it's working. As you said each source needs to be explicitly indicated.

I have a similar need, except it would be far too unwieldy to list all the additional source code files. Does the makefile support wildcards? If not, what should I do? 

Pavel A.
Evangelist III

Of course, the make has a function for expanding wildcards.

https://www.gnu.org/software/make/manual/html_node/Wildcard-Function.html