Version control of Matlab Coder generated files
3 views (last 30 days)
Show older comments
I am using Matlab Coder to generate c++ files. I use git to version control the Matlab project.
Now, I want to somehow "tag" the generated files with the current git version of the Matlab repository. Im thinking of two solutions (both would work for me):
1) In the output folder, generate a .txt file with git information (I already have an .m-function that gets the necessary git-information)
2) Auto-generated comments in each generated cpp-file that displays the git information.
If someone knows of a different/better solution, thats even better.
0 Comments
Answers (1)
Namnendra
on 6 Sep 2023
Hi Øystein,
I understand that you want to "tag" the generated files with the current git version of the MATLAB repository when using MATLAB Coder. You can do so by implementing either of the following solutions:
1) Generating a .txt file with git information:
- Create a MATLAB script or function that retrieves the necessary git information using the existing .m-function you mentioned.
- After generating the C++ files using MATLAB Coder, call this script or function to obtain the git information.
- Write the git information to a .txt file in the output folder using MATLAB's file I/O functions, such as 'fprintf' or 'writematrix'. Kindly refer these links to know more:-
2) Auto-generated comments in each generated C++ file:
- Modify the MATLAB Coder template or code generation configuration to include an auto-generated comment at the top of each generated C++ file. Kindly refer this link to know more :- https://in.mathworks.com/help/ecoder/ref/coder.matlabcodetemplate-class.html
- In this comment, include the relevant git information obtained using the .m-function.
- You can use MATLAB's string manipulation functions, such as 'sprintf', to construct the comment string and insert the git information. Kindly refer this link to know more :- https://in.mathworks.com/help/matlab/ref/sprintf.html
Both solutions have their advantages and can be implemented based on your preference and requirements. The first solution provides a separate file with git information, while the second solution embeds the information directly into the generated files.
I hope the above information helps you.
Thank you,
Namnendra Gupta
0 Comments
See Also
Categories
Find more on Source Control Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!