2020-05-28 02:05 PM
So I've been messing with TouchGFX for a while now using the designer to construct the various GUI portions on my application. However I am now at a point that I need to add additional C++ classes to my project and I am having a hard time figuring out how to make them part of the TouchGFX project.
I have a STM32CubeIDE project named "Project" inside of which I have the "TouchGFX" folder that was generated when I configured the project for my target. I can successfully build and run my TouchGFX application on the target. Additionally I can also run the application using the simulator with out any issues.
I have added a new folder inside the "TouchGFX" folder called "additional" that contains a "src" and "include" folder for header and source files that I need to be included in the project (note the "src" and "include" folders also have sub folders in the to organize my files).
How can I make this "additional" folder and all its contents part of the project so they are compiled when I build the project for the target or the simulator and they show up correctly in the Visual Studio Solution Project?
If any one could help it would be much appreciated as I can't continue making progress on my application till this issue is resolved.
!!!!!!!!!!!!!!!!!EDIT UPDATE!!!!!!!!!!!!!!!!!
I have edited the ADDITIONAL_SOURCES and ADDITIONAL_INCLUDE_PATHS variables in the TouchGFX\simulator\gcc\Makefile... to read as follows but it still does not work... not sure what I'm doing wrong here...
temp_test_additional_path := ${application_path}/additional/src/
ADDITIONAL_SOURCES := $(call find, $(temp_test_additional_path),*.cpp)
ADDITIONAL_INCLUDE_PATHS := ${application_path}/additional/include/
!!!!!!!!!!!!!!!!!EDIT UPDATE!!!!!!!!!!!!!!!!!
Thanks,
2020-05-29 01:27 AM
Hello @JustAnotherGuy ,
If you look into the folder gcc, you will find the Makefile that is used for building the project. Look for the section where the c, c++ & h files to be included are defined. For e.g. search for "board_c_files".
Here you can either add to the existing list, your c/c++ files to be compiled or you can define your own variable & then list it to be compiled. If you've worked on open source compilers before then understanding this Makefile should be relatively easy ( there is no need to understand it fully, any ways. However, for academic purpose it makes sense to understand it. ).
Hope the above helps.
\Jagdish Bisawa
2020-05-29 07:34 AM
This does not appear to be how TouchGFX's make files are laid out.... None of the make files in the TouchGFX folder (of which there are two) appear to have the "board_c_files"
I suspect I would need to add something to either the:
TouchGFX\simulator\gcc\Makefile
TouchGFX\generated\simulator\gcc\Makefile
I have messed around with them a bit trying different things but I am still not sure what or how to add the "additional" folder and all its header and source files... nothing I have tried works
Regards
2020-05-30 08:00 AM
Hi @JustAnotherGuy ,
I had an impression that you were using a hardware such as the discovery board etc. & hence suggested to add to the Makefile under the gcc folder.
It seems you are using the simulator ( i.e. PC as the target ). In that case try making changes to the Makefile under TouchGFX\generated\simulator\gcc\Makefile, as understood by you correctly.
Look for the definition of include_paths source_paths. You may add your path to these variables & try.
/Jagdish Bisawa
2020-05-30 08:59 AM
My question relates to the both the target hardware and the simulator, see my edit above in my original post... Still don't have this working and I'm very disappointed that what is a trivial task in any other development environment is such a pain in the context of TouchGFX. I have not been y terribly impressed with the TouchGFX documentation either.
2020-05-31 12:50 AM
Hi @JustAnotherGuy ,
I have tried both - adding additional file names to the Makefile for a discovery board project & to the Makefile for a PC simulator project. In both cases it has worked for me. The only difference being that I use command line to make the project & you are making use of VS.
Add your additional 'include' folder name to the include_paths variable & additional 'src' folder name to the source_paths variable, in the Makefile found under TouchGFX\generated\simulator\gcc\.
There is no need to make any changes to the Makefile found in TouchGFX\simulator\gcc\.
/Jagdish Bisawa
2023-12-07 01:33 AM
Aren't the make files regenerated by TouchGFX? I tried modifying the make files but my changes keep being overwritten. I need a solution that allow include additional paths and files permanently to the project.
I develop the application using STM32CubeIDE for building the project for the target. It has it's own configuration for include directories and files. The problem is when I add a path there, it is not added to the TouchGFX Designer.
A good workaround would be just adding them somehow to the TouchGFX Designer configuration manually, but not having to fight with the tool overwriting my changes.
2024-04-09 08:29 AM
I have the same simple question.
How do I add my own folders and files to a TouchGFX project?
I don't want to use any of the folders already known by TouchGFX.
Thanks,
Dominic
2024-04-11 01:08 AM
It depends on your toolchain used for build the project. I think the most default one for TouchGFX project is TouchGFX Designer itself (simulator builds and even device builds) and STM32CubeIDE.
They have their own separate build configurations in various places.
First the easier one to configure, STM32CubeIDE:
You will find its include directories in project properties, just look at the picture:
As you can see, the paths there all start from "../../..". This is not a bug, the paths are relative to the project file directory. And the file is often not in a project's root directory. Just look at them and provide similar paths to your own project directories, the directories that contain include files.
You have separate configuration for assembler, C compiler and C++ compiler. As you use TouchGFX - you probably want to set your include directories both for C and C++.
Before you touch the include directories, be sure to target ALL CONFIGURATIONS:
Otherwise, you will have different include directories for debug and release builds. And it's not what most users want.
If you need specific C/C++ files compiled in your build - just include them in Project Explorer, either by linking files or linking a directory that contains the file.
I usually do it with drag & drop, because this gives a nice menu asking me whether I want to link individual files or do I want to link a folder. Those links are called virtual files or virtual folders. Technically they work similarly to Windows shortcuts, but they are usually created as relative to the main project file path. Every ".c" or ".cpp" file linked there will be compiled, unless you explicitly check not to compile it in the file properties tab.
Now the TouchGFX Designer itself. I usually don't use it to make device builds. It's too slow and clumsy for that, STM32CubeIDE is way more convenient. But I do use Designer's Simulator, because it's very fast way of testing the UI alone. The Simulator is just part of your code (UI) compiled for Windows. So - Designer has 2 build toolchains for compiling either the UI alone for Windows or the whole project for the target device. They have some common and some separate configuration files.
First you need to locate your TouchGFX project directory, usually named "TouchGFX". In 2 core MCU templates, it would be in CM7 directory. Inside it find `config/gcc` directory, that contains `app.mk` file.
In `app.mk` I usually add my own `cflags`, like this for example:
`user_cflags := -DUSE_BPP=16 -std=gnu++17 -Wno-unknown-pragmas`
Then I create my own file containing my custom configuration (additional files and folders) as `additional.mk` file:
# HMI TouchGFX extended Makefile configuration
#
# Include this file in Makefile with
# `include $(application_path)/config/gcc/additional.mk`
# before the line containing `export ADDITIONAL_SOURCES` of `TouchGFX/simulator/gcc/Makefile`
#
# Variables available:
# include_paths
# c_source_files
# cpp_source_files
ADDITIONAL_INCLUDE_PATHS := ../../Tools ../../HMI
ADDITIONAL_SOURCES := ../../Tools/TimeSpan.cpp
ADDITIONAL_LIBRARY_PATHS :=
ADDITIONAL_LIBRARIES :=
Then get back one directory, find the `simulator` directory, enter `gcc` subdirectory and open the `Makefile` file.
Place `include $(application_path)/config/gcc/additional.mk` just before the `export ADDITIONAL_SOURCES`..., look at how it looks in mine:
BTW, the paths in `additional.mk` files are separated with space. This should work, if it doesn't - try messing around with relative paths like "../.." or "../../.." - it's easy to make a mistake there.
That's it.
As for the other tools, look for makefiles. And be careful, because they are often generated, so they might get overwritten. TouchGFX usually doesn't overwrite the Simulator make file, but it might happen so you better back up your changes somewhere.
2024-04-16 06:38 AM
Thank you! I will give this a try, but I was under the impression that the make file would be regenerated by TouchGFX and would wipe out any changes to Makefile.
I don't like using CubeIDE (or any other Eclipse-based IDE) and just use VS Code to call make and use the Cortex-Debug extension. I wish TouchGFX supported the Makefile project type of CubeMX. In this type of CubeMX project you can actually add # USER CODE BEGIN and # USER CODE END comments to the make file to add custom project files.