'IAR postbuild batch file call
I have a question with using IAR embedded workbench IDE ARM 7.60.2
I have a batch file that I run and it generates 2 files. When I click on this sample.bat, it works fine, thus I try to implement it in the postbuild option inside IAR: options -> build actions and type this:
cmd /c "directory....\sample.bat"
What ends up happening is that it runs however the files generated are incomplete and have wrong naming scheme.
A weird 'fix' to this issue was for me to copy the "cmd /c "directory....\sample.bat" line into a txt file and name it temp.bat, and now insert this into the postbuild command: cmd /c "directory....\temp.bat"
This seemed to generate the correct file names when called and worked the same way as manually running sample.bat
I have no clue why this works as I'm not sure if the issue is with IAR or with my .bat file itself.
Any input is greatly appreciated, thanks.
Solution 1:[1]
This is how I got IAR to run the post build step successfully for me
In IDE I enter: $PROJ_DIR$\src\postbuild.bat $PROJ_DIR$
Then in the bat file I write: %1\src\myExe.exe /i %1\fw.hex
This will run the batfile postbuild located in the subfolder src of my project file.
This bat file will then start myExe which also is located in same folder and then supply parameter /i and projectfolder follwed by \fw.hex
Solution 2:[2]
I have the exact same problem, particularly after getting a clean (freshly cloned) copy of the files with Git. My only solution is to do the unexplained fix from the original question:
- rename the existing batch file
- create a new batch file with the original name
- open both files in a text editor, copy the text from the original file to the new one
- save the new .bat file; close both files
- delete the old/renamed batch file
It could be a line ending issue, and (re-)saving the file with Windows line endings solves the problem. I noticed the file from the repository had "0x0a" line endings and my new copy has "0x0d 0x0a" endings.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anders Karlsson |
| Solution 2 | Salt |
