How execute external application as pre-build steps ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How execute external application as pre-build steps ?

8,287 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by plebi on Wed Apr 13 02:43:27 MST 2011
I'd like to execute external application before compilation  - automatically.
Always before compilation should be executed application (especialy python script). Now im using run->extrenal tool but it is not automatic action.

How to realize it ?
Thanx
0 Kudos
Reply
15 Replies

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Fri Nov 08 08:24:00 MST 2013
I suggest you read and learn how to invoke cmd.exe.

Hint: you don't want the /s option...
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dore on Fri Nov 08 08:19:57 MST 2013
I am getting the following at the end of the build:

make --no-print-directory post-build
Performing post-build steps
cmd /s "..\..\..\Tools\hexfile.cmd"
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

And I have the .cmd/bat file in the root folder (outside the folders of my application code) file I have the "arm-none-eabi-objcopy.exe", arm-none-eabi-size.exe and srec_cat.exe also in the same folder where the .bat file is present. I have my hex file also in the same folder (just copied from the debug folder of the compiled code)
And my .bat file contains srec_cat "AppCode.hex" -intel -o "AppCode1.hex" -intel command line.

Now I just want to invoke my .bat or .cmd file and generate the AppCode1.hex file as a result of the post compilation.
I am not able to see AppCode1.hex whereas if I double click on my batch file I am getting it.
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Fri Nov 08 07:25:41 MST 2013
What is the error that is reported.

My guess is that you do not have the correct number of ".."'s. The script is executed from the directory in which the build is happening - typically Debug or Release. So get get to the main project directory, you need to use "..\script" etc.
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dore on Fri Nov 08 07:17:38 MST 2013
Hi,

I have a .bat file which executes the arm-none-eabi-objcopy, arm-none-eabi-size and srec_cat commands to generate the hex file and bin file from .axf file and generates combined hex file from my boot code and application code. I have these commands in my .bat file. I have tried using cmd /s "..\..\..\Tools\hexfile.cmd" it doesnt work. I have tried multiple other methods too, but nothing helped me.
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by adrien.thurin on Fri Nov 01 01:35:20 MST 2013
I have tried cmd /c "..\script.cmd ${eclipse_home} ", and it works ! Thank you very much !

Even though the test script doesn't actually use the parameter, the whole script seems to not be executed at all with the cmd /C "..\script.bat" "${eclipse_home} " syntax. Very weird, but it works now and it's all that matters.

Thank you very much for your help !
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Oct 31 11:53:00 MST 2013
I think the problem is in the way you are invoking cmd.exe - and I cannot provide you with assistance for running Windows commands.

I can tell you that if you run
cmd /s "..\script.bat"

then the script is run.

For more information on running cmd.exe:
- run cmd /?
- take a look at these links
http://ss64.com/nt/cmd.html
http://stackoverflow.com/questions/12891383/correct-quoting-for-cmd-exe-for-multiple-arguments

[EDIT]
This post-build step works for me:
cmd /c "..\script.cmd ${eclipse_home} "

0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by adrien.thurin on Thu Oct 31 09:11:43 MST 2013
The exact post-build command is :
cmd /C "..\script.bat" "${eclipse_home} "; arm-none-eabi-size ${BuildArtifactFileName}; # arm-none-eabi-objcopy -O binary ${BuildArtifactFileName} ${BuildArtifactFileBaseName}.bin ; checksum -p ${TargetChip} -d ${BuildArtifactFileBaseName}.bin;


The output on the LPC console window is :
Performing post-build steps
cmd /C "..\script.bat" "C:\nxp\LPCXpresso_4.3.0_1023\lpcxpresso\ "; arm-none-eabi-size PWM.axf; # arm-none-eabi-objcopy -O binary PWM.axf PWM.bin ; checksum -p LPC1112FD_102 -d PWM.bin;
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

(adrient)C:\Users\adrient\Desktop\New folder (5)\S module\.debug>   text   data    bss    dec    hexfilename
   3104      4     72   3180    c6cPWM.axf
 


The test script is as described previously.

Part of the command seems to be interpreted, since a cmd prompt appears in LCP console window, but not the script.

0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Oct 31 08:55:39 MST 2013

Are you trying to add it to the end of the existing post-build steps? If so, please remember that
1. the ";" character separates individual command and
2. the "#" character is a comment. Anything after the first # is ignored.

From your description, my guess is that your command is being commented out.

If that does not explain your problem, please post EXACTLY the post-build step you are trying to run.
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by adrien.thurin on Thu Oct 31 08:01:34 MST 2013
I have tried both types of slash, but both of them behave exactly the same. I didn't get any error message. Either the system understands both types, or it doesn't read the "..\script.bat" part at all, I guess.

I have tried using the shell provided with LPC for the script, but I spent one full day trying and not getting anywhere. It seems like many standard linux shell commands are not available with LPC shell. Since I am quite beginner in scripting, I tried to do things that are standard and well documented. I have tried many things with linux shell commands, but most of them are not available the the LPC shell. After one day not getting anywhere, I gave up and went back to windows batch.

The most surprising to me is that I had to do a similar script for another project using a TI part. TI's Code Composer Studio is also based on eclipse, but it runs windows-type script perfectly smoothly.

I don't know if it matters, but I am running LPCXpresso version 4.3.0.
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Oct 31 07:20:23 MST 2013
I think that if you look in the console, you will see and error, something like this:
'..' is not recognized as an internal or external command, operable program or batch file.


This is because you have used the wrong sort of slash. As you are passing a parameter to cmd.exe, you need to pass the Windows backslash. i.e.
cmd /c "..\script.cmd"

BTW: Have you considered using shell commands instead of windows bath commands? shell is much more powerful, and is also portable across all platforms (Windows, Linux and Mac).
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by adrien.thurin on Thu Oct 31 03:30:08 MST 2013
Hi,

I am also trying to execute a script during past-build steps, but I can't get it to execute the script, even using the cmd /c command.

I use, as a test script :
@echo off
echo "Hello World"
echo "Hello World" > "..\LPC.txt"


And as a post-build command :
cmd /C "../script.bat"


The output in the LPC command is :
cmd /C "../script.bat"
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

(adrient)C:\MyWorkspace\MyProject\Debug>


The expected "Hello World" output doesn't appear in the LCP console, and the LPC.txt file is not created in the project folder. This shows that the script isn't executed at all.



0 Kudos
Reply

6,075 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by plebi on Thu Apr 14 01:49:18 MST 2011
thanx,
using cmd it works
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Apr 14 00:33:17 MST 2011
It does work, but
1. You haven't put ver.bat into a location that can be found. Make is run in the Debug (or Release) directory, so if ver.bat is in the root of your project, you will need to use ../ver.bat
2. I don't think you can execute a batch file directly from make. You will need to run it through the command shell. i.e. cmd/c ../ver.bat (you might need to experiment with the exact syntax - I haven't tried it)
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by plebi on Wed Apr 13 23:53:27 MST 2011
This method dont works. This is command for make as I see.
Example - run ver.bat command:

"make -j1 pre-build main-build
Performing ppre-build steps
ver.bat
[B]make: ver.bat: Command not found[/B]
make: [pre-build] Error 127 (ignored)"
0 Kudos
Reply

6,074 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed Apr 13 07:44:57 MST 2011
Did you look at:
Project Properties
  +-C/C++ Build
      +-Settings
         +-Build Steps
            +-Pre-build steps

?
0 Kudos
Reply