SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
Pre_Build.py File Reference

This script preprocesses source files for use with Log_t. More...

Go to the source code of this file.

Detailed Description

This script preprocesses source files for use with Log_t.

Author
IR
Version
0.1
Date
2020-11-11

This script works by first duplicating source files to the build folder.
Then it scans each file for calls to a Log function and modifies them as follows.
If the call has a string for LOG_TAG parameter, give that string a unique integer ID and replace it with that integer.
If the ID is not a string, leave the variable alone.
Replace the call's LOG_MSG string with a unique ID as well.
NOTE: The LOG_MSG parameter must always be an inline string.
LOG_TAGs and LOG_MSGs do not share IDs.
Eg.

Log(ID, "My Message"); -> Log(ID, 1);
Log("My Str ID", "My Message"); -> Log(1, 1);

Calls to Log functions also have the option to send a number with a third parameter.
Eg.

Log("My Str ID", "My Message", 56); -> Log(1, 1, 56);
Log(ID, "My Message", A_Num_Var); -> Log(ID, 1, A_Num_Var);

Declarations of LOG_TAG also have their strings replaced with a unique ID.
NOTE: Definition of LOG_TAGs must always be an inline string.
Eg.

LOG_TAG TAG = "Logging Tag"; -> LOG_TAG TAG = 2;

A special case has been made to also allocate and replace string that call the following macro

#define _LogPrebuildString(x)
Refer to Pre_Build.py.
Definition Log.h:20

Where x is the string, it will be given a unique ID and replaced with said ID as if it were being called by a Logging function. This is useful where one wishes to generate log functions using the C preprocessor. Note, however, if this script is not run the macro should still allow everything to compile normally, leaving the string untouched

Definition in file Pre_Build.py.