Hi, I am using S32DS IDE for development.
Would it be possible to add preprocessor defined symbol using custom build steps with auto-generated makefile?
The value of defined symbol is not fixed.
I've tried to create makefile.defs, and add the following content in it. It seems not to work.
thanks in advance!
TOPREPROCESS_SRCS is declared in source.mk, which would be included in the auto-generated makefile
Solved! Go to Solution.
Hi,
thanks for the reply and discussion thread you provided
I give up adding git info in preprocessor defined symbol way.
I've followed the solution mentioned in the below image by first executing a script to get git info, then
writing it into the header file which would be included in the main.c in Pre-build steps.
After flashing binaries, it works!
thanks for providing solutions : )
Hi,
Could you help us elaborate more on this manner? We are not understanding the overall request.
We understand that you want to generate a preprocessor defined symbol, which can be done by looking into:
"Properties > C/C++ Build > Setting > Standard S32DS C Compiler > Preprocessor"
Of your project. In there, you can add new defined symbols for your project.
Please, let us know.
Hi,
Thanks for the reply.
I would like to write a script to get git commit hash first and make it a preprocessor defined symbol added to my code for identification.
The solution you provide works, but the commit hash varies for each commit. Therefore, the defined symbol might have to be modified manually for each commit.
Thanks in advance.
Hi,
There is the possibility of adding a "Preprocessor Macros File" to your project, in which you could add new macros. Below will be a picture of where to add this kind of file:
For our test, before trying to add the file, we created a new header file on the project by the name "MACROS.h" in which we have the following information:
#ifndef MACROS_H_
#define MACROS_H_
#define TEST 149
#endif /* MACROS_H_ */
We then added the "Preprocessor Macros File" as shown on the image above and created the #IF conditional on our project. Below the results:
If met:
If not met:
Please, let us know.
Hi,
Thanks for the reply.
I've follow the solution you provided to test it on one of NXP Uart example code, but it seems not to work on the project.
May I check the testing process with you?
process
1.create MACRO.h and add it to ${ProjDirPath}/ with the same content
2.add it to CDT_User_Setting_Entries
3.add #IF conditional in main.c
the #if block did being shaded if changing the compared value with TEST to 150
result
the warning messge was shown in the build log
flash binaries and monitor with uart terminal software
thanks in advance!
Hi,
Thanks for your feedback. It seems that as you are saying, the GUI shows as if the Macro has been detected, but at compilation it does not take it into account.
Digging further into this topic, seems that S32DS has a bug regarding this same topic. A thread below mentioning this:
Solved: Macros to access filename - NXP Community
I've tried with S32DS v3.5 (since it is the newer version) but I cannot get it working. We apologize.
On the above-mentioned thread, there is a possibility of adding the flag directly into the command line pattern, but we don't know if it is what you are looking for.
Please, let us know.
Hi,
thanks for the reply and discussion thread you provided
I give up adding git info in preprocessor defined symbol way.
I've followed the solution mentioned in the below image by first executing a script to get git info, then
writing it into the header file which would be included in the main.c in Pre-build steps.
After flashing binaries, it works!
thanks for providing solutions : )
Hi,
Thanks for your feedback. Good to know you found a workaround.
Please, let us know if there is anything else we can help you with.