IAR: Genrate Source files using a pre-build and then add source files to project - iar

I'm using nanopb in my project and I'm generating C files from protocol buffer files. I want to run nanopb every time the build runs. I figure the way to do this is to use the pre build actions in IAR however, I don't know how to add the sources that are generated to the project so that it will compile the generated files.
Typically I manually add files to the project by specifically adding them to the workspace. Is there a way I can add generated sources after they have been generated in the the pre-build action

Run pre-build once, to generate the source files. Then you can simply add those files to IAR project just like usual source files.
You can also add files manually. .ewp file is a XML file. Just add new file element:
<file>
<name>$PROJ_DIR$\relative\path\to\file.c</name>
</file>
Or
Create file which where you will include all generated files:
// non-generated_file.c
#include "generated/file_a.c"
#include "generated/file_b.c"

Related

A smarter clang-tidy run: only check changed files & other source files that include a changed header?

We use the run-clang-tidy script to check the whole component after a build like so:
run-clang-tidy-12 -p build -header-filter="(src|libraries)" src libraries
We would like to run this (by changing the parameters) only on the files that are changed and for all source files that include a changed header file. As we're using git, maybe together with gcc it can give use that list of files.
Thanks!

How to replace the source file with my own source file (from download or edit) in Xcode?

I'm using Xcode as an IDLE editor of C language. I downloaded an SDK package from a algorithm competition website and compiled it successfully on the terminal, but now I have a need to compile and run the source .cpp file(that inside the SDK packadge) directly by Xcode, so:
Is there a way to replace the CPP source file of command-line-tools project with the CPP source file that I specify the path of it?
Or is there a way to creat a new command-line-tools project from the specified path CPP source file?
I've now Solved this problem through the method one whitch says "Is there a way to replace the CPP source file of command-line-tools project with the CPP source file that I specify the path of it?", but still have no idea about method two.
Just creat a symbolink of CPP source file and right-click the project, add the alias to project. Because the "add" is copy in fact, instead of "import" or "open". Only by copying the alias can the purpose of modifying the source file be achieved.

How do I set up this visual studio (2015) custom build step (tool?). Basically I want a pre-preprocessor step that modifies header files (c++)

I want a run a build step that looks at a .h file, adds some code based on some external params, and hands the resulting file to the preprocessor.
I see the "Custom Build Step" in the project properties. It seems to need an output file. I just want to forward the results to the preprocessor.
It seems like the custom build step wants to do a 1-time process, not per-file or by file type.
The problem is that I don't know how to send my external executable the file currently being processed (eg, "HelloWorld.cpp"). $(InputName) and %(Filename) are blank and docs say it's deprecated. How do I send the filename to my external executable?
But even if I get that working, I don't want to set this per-file. I want all header files to go through this process.
Any ideas?
I've looked at:
https://msdn.microsoft.com/en-us/library/dd293663.aspx?f=255&MSPPError=-2147217396
https://msdn.microsoft.com/en-us/library/hefydhhy(v=vs.90).aspx
https://msdn.microsoft.com/en-us/library/ff770593(v=vs.140).aspx
working on a debug, x64 config on windows.
First of all, No, you cannot modify a file and pass along the results to the next stage (that I could see). I'd need some sort of Program Transformation System.
So I need an intermediate file. That file has to be added to the project, even if it gets overwritten by your code generator. I can associate c++ header files with a custom build tool, and they will all get called one-by-one in the stage of the build specified in the Custom Build Step. The custom build tool will modify the intermediate file(s), and all is well.
The VS 2015 name for the current file being processed is %(Filename). In older versions it has been $(ProjectName) and $(InputName).

Compiling C++Builder project on command line

Is there a way to compile a C++Builder project (a specific build configuration) from the command line?
Something like:
CommandToBuild ProjectNameToBuild BuildConfiguration ...
There are different ways for automating your builds in C++Builder (as of my experience, I'm speaking about old C++Builder versions like 5 and 6).
You can manually call compilers - bcc32.exe (also dcc32.exe, brcc32.exe and tasm32.exe if you have to compile Delphi units, resource files or assembly language lines of code in your sources) and linker - ilink32.exe.
In this case, you will need to manually provide the necessary input files, paths, and keys as arguments for each stage of compilation and linking.
All data necessary for compilation and linking is stored in project files and, hopefully there are special utilities, included in the C++Builder installation, which can automate this dirty work, provide necessary parameters to compilers and linker and run them. Their names are bpr2mak.exe and make.exe.
First you have to run bpr2mak.exe, passing your project *.bpr or *.bpk file as a parameter and then you will get a special *.mak file as output, which you can use to feed on make.exe, which finally will build your project.
Look at this simple cmd script:
#bpr2mak.exe YourProject.bpr
#ren YourProject.mak makefile
#make.exe
You can provide the real name of "YourProject.mak" as a parameter to make.exe, but the most straightforward way is to rename the *.mak file to "makefile", and then make.exe will find it.
To have different build options, you can do the following:
The first way: you can open your project in the IDE, edit options and save it with a different project name in the same folder (usually there are two project files for debug and release compile options). Then you can provide your building script with different *.bpr files. This way, it looks simple, because it doesn't involves scripting, but the user will have to manually maintain coherency of all project files if something changes (forms or units added and so on).
The second way is to make a script which edits the project file or make file. You will have to parse files, find compiler and linker related lines and put in the necessary keys. You can do it even in a cmd script, but surely a specialised scripting language like Python is preferable.
Use:
msbuild project.cbproj /p:config=[build configuration]
More specifics can be found in Building a Project Using an MSBuild Command.
A little detail not mentioned.
Suppose you have external dependencies and that the .dll file does not initially exist in your folder
You will need to include the external dependencies in the ILINK32.CFG file.
This file is usually in the folder
C:\Program Files (x86)\Borland\CBuilder6\Bin\ilink32.cfg
(consider your installation location)
In this file, place the note for your dependencies.
Example: A dependency for TeeChart, would look like this (consider the last parameter):
-L"C:\Program Files (x86)\Borland\CBuilder6\lib";"C:\Program Files (x86)\Borland\CBuilder6\lib\obj";"C:\Program Files (x86)\Borland\CBuilder6\lib\release";"C:\Program Files (x86)\Steema Software\TeeChart 805 for Builder 6\Builder6\Include\";"C:\Program Files (x86)\Steema Software\TeeChart 805 for Builder 6\Builder6\Lib\"
You will also need to include the -f command to compile.
In cmd, do:
//first generate the file.mak
1 - bpr2mak.exe MyProject.bpr
//then compile the .mak
2 - make.exe -f MyProject.mak
You can also generate a temporary mak file with another name, as the answer above says, directly with bpr2mak
bpr2mak.exe MyProject.bpr -oMyTempMak.mak

How to include net_rim_api_wlan_hotspot in my BB project?

I have a project that is going to create hotspot client, so it imports net.rim.device.api.wlan.hotspot.*
When the code runs it complains that it cannot find net_rim_api_wlan_hotspot. If I display the table-of-contents for the jar file, *\BlackBerry JDE 5.0.0\lib\net_rim_api.jar, the file class files are listed.
What steps am I missing to build the project correctly?