Flex compilation using mxmlc in a for loop in a windows batch script

Basically, what I have tried to do is using a Jenkins job to run on a windows machine, run over a few modules folders, get the mxml files under them and compile using mxmlc (flex compiler).

It worked very well but there was a problem when I have tried to catch the exit code of the compilation status.

The errorlevel parameter will have the correct value only outside of the for loop. Inside the for loop it'll always be equal to zero. This will not help me because in the end of the loop, it'll only hold the exit code of the last iteration.

To solve this I did the following:




setlocal enabledelayedexpansion

for %%x in (%Modules::= %) do (
  mxmlc src\Modules\%%x.mxml -source-path=src -load-config+=Build\Build-Config.xml -output=%deploymentDir%\App\Flex\Modules\%%x.swf
  IF !ERRORLEVEL! NEQ 0 exit 1
)

 

 

The above syntax disables the global parameters and makes them local. That way, the ERROLEVEL with the '!' in the beginning and end of it will have the right value in each iteration and therefore will fail if one of the compilations fails.

 

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com