Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28477 Discussions

Executing a BAT file as a Post-Build Event

Smith__Neill
Beginner
1,278 Views
I am running the 11.1.070 and 10.1.034 compilers under the Visual Studio 2008 shell installed with the 11.1 complier. VS08 with the compilers are installed under a Windows 7 virtual machine (VM) on a Mac.

I would like to execute a BAT file (or some other script) as a post-build event that will copy the new Exe file from the VM to a shared folder on the Mac side. I want the destination of the copy process to depend on which compiler has been set before the build and the type of build configuration (Debug or Release). Is there any way to do this?

If it weren't for the need to pick the destination based on the compiler version, I could make the location of the final Exe file depend on the configuration with the properties set in the VFPROG file. However, in a reply to an earlier post (How to have 3 compilers under Visual Studio 2005, April 22, 20011) Steve said that there was no way to select the complier from the configuration file, so I can't have four configurations (like Debug_10, Debug_11, Release_10 and Release_11) that would specify the compiler and location of output files.

Thanks,

Neill
0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,278 Views
You might be able to compare the value of the IfortInstallDir environment variable, which is defined by the VS integration and will change based on the compiler version used. Use IF tests to compare this to a string. You can also test the value of "ConfigurationName".

I've had success putting a series of IF tests in a build event, haven't tried a .BAT file.
0 Kudos
Smith__Neill
Beginner
1,278 Views
Thanks for the quick reply Steve. How do I access the environment variable IfortInstallDir? I don't see it listed under the system environment variables from Control Panel. I do see three IVF-related environment variables, IFORT_COMPILER10, IFORT_COMPILER11 and INTEL_LICENSE_FILE, but these just tell me what IVF compilers are installed, not the one that I currently have selected inside of VS08.

Thanks,

Neill
0 Kudos
Steven_L_Intel1
Employee
1,278 Views
These are not system variables - they are defined only in the processes spawned as part of a build.

Just add a "SET" command as a build event and you'll see all the defined variables listed.

As an example, here's something from one of the Intel C++ samples as a post-build event. You'll get the idea:

[plain]if "$(icIDEInstallDir)" == "$(icInstallDir)CompilerVS IntegrationC++VS2008" copy /y "$(INTEL_DEF_IA32_INSTALL_DIR)TBBia32vc9bintbb_debug.dll" "$(OutDir)"
if "$(icIDEInstallDir)" == "$(icInstallDir)CompilerVS IntegrationC++VS2005" copy /y "$(INTEL_DEF_IA32_INSTALL_DIR)TBBia32vc8bintbb_debug.dll" "$(OutDir)"
if "$(icIDEInstallDir)" == "$(icInstallDir)CompilerVS IntegrationC++VSNet2003" copy /y "$(INTEL_DEF_IA32_INSTALL_DIR)TBBia32vc7.1bintbb_debug.dll" "$(OutDir)"
if "$(icIDEInstallDir)" == "$(icInstallDir)CompilerVS IntegrationC++VS2008" copy /y "$(INTEL_DEF_IA32_INSTALL_DIR)TBBia32vc9bintbbmalloc_debug.dll" "$(OutDir)"
if "$(icIDEInstallDir)" == "$(icInstallDir)CompilerVS IntegrationC++VS2005" copy /y "$(INTEL_DEF_IA32_INSTALL_DIR)TBBia32vc8bintbbmalloc_debug.dll" "$(OutDir)"
if "$(icIDEInstallDir)" == "$(icInstallDir)CompilerVS IntegrationC++VSNet2003" copy /y "$(INTEL_DEF_IA32_INSTALL_DIR)TBBia32vc7.1bintbbmalloc_debug.dll" "$(OutDir)"[/plain]
0 Kudos
Smith__Neill
Beginner
1,278 Views
Steve,

First a simple question before getting back to the main point of this thread. How do I get VS08's Help function to search the Intel Fortran help files? I tried searching for IFortInstallDir in Help and got no hits. When I expanded the Language drop box under Help it didn't even list Fortran as one of the languages. I then tried searching for help on several Fortran keywords with no luck. What the heck am I doing wrong?

Now for the main question. I added the SET command as a post-build event and the IFortInstallDir environment variable was not listed (I also tried it as a pre-build event and got the same results). What I got was as follows:

------ Rebuild All started: Project: fmvplot2_exe, Configuration: Debug Win32 ------
Deleting intermediate files and output files for project 'fmvplot2_exe', configuration 'Debug|Win32'.
Compiling with Intel Visual Fortran 11.1.070 [IA-32]...
FMVPMAIN.FOR
Block_Data_FMplotV_Version_History.for
Linking...
Creating library C:\Intel_Fortran_Projects\FMplotV2\trunk\fmvplot2_exe\Debug\fmvplot2_exe.lib and object C:\Intel_Fortran_Projects\FMplotV2\trunk\fmvplot2_exe\Debug\fmvplot2_exe.exp
Embedding manifest...
Performing Post-Build Event...
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Neill Smith\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=WIN-5CK88TVTOK5
ComSpec=C:\Windows\system32\cmd.exe
FOR__IS_DEBUGGER_PRESENT=1
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Neill Smith
IFORT_COMPILER10=C:\Program Files\Intel\Compiler\Fortran\10.1.034\
IFORT_COMPILER11=C:\Program Files\Intel\Compiler\11.1\070\
INCLUDE=C:\Program Files\Intel\Compiler\11.1\070\include;C:\Program Files\Intel\Compiler\11.1\070\include\ia32;C:\Program Files\Intel\Compiler\11.1\070\mkl\include;c:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include;c:\Program Files\Microsoft Visual Studio 9.0\VC\include;c:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\include;c:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\include
INTEL_LICENSE_FILE=C:\Program Files\Common Files\Intel\Licenses
LIB=C:\Program Files\Intel\Compiler\11.1\070\lib\ia32;C:\Program Files\Intel\Compiler\11.1\070\mkl\ia32\lib;c:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib;c:\Program Files\Microsoft Visual Studio 9.0\VC\lib;c:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\lib;c:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\lib\x86;c:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\lib
LOCALAPPDATA=C:\Users\Neill Smith\AppData\Local
LOGONSERVER=\\WIN-5CK88TVTOK5
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Path=C:\Program Files\Intel\Compiler\11.1\070\bin\ia32;C:\Program Files\Common Files\Intel\Shared Files\Ia32\Bin;c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN;c:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools;c:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\bin;C:\Windows\Microsoft.NET\Framework\v2.0.50727;c:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\bin;C:\Program Files\Intel\Compiler\11.1\070\lib\ia32;C:\Program Files\Common Files\Microsoft Shared\VSA\9.0\VsaEnv;C:\Program Files\Intel\Compiler\11.1\070\mkl\ia32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Intel\Compiler\Fortran\10.1.034\\IA32\Lib
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 37 Stepping 5, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2505
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\NEILLS~1\AppData\Local\Temp
TMP=C:\Users\NEILLS~1\AppData\Local\Temp
USERDOMAIN=WIN-5CK88TVTOK5
USERNAME=Neill Smith
USERPROFILE=C:\Users\Neill Smith
VisualStudioDir=C:\Users\Neill Smith\Documents\Visual Studio 2008
WecVersionForRosebud.6F0=2
windir=C:\Windows
__iflSearch=C:\Program Files\Intel\Compiler\11.1\070\bin\ia32;C:\Program Files\Common Files\Intel\Shared Files\Ia32\Bin;c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN;c:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools;c:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\bin;C:\Windows\Microsoft.NET\Framework\v2.0.50727;c:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\bin;C:\Program Files\Intel\Compiler\11.1\070\lib\ia32;C:\Program Files\Common Files\Microsoft Shared\VSA\9.0\VsaEnv;C:\Program Files\Intel\Compiler\11.1\070\mkl\ia32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Intel\Compiler\Fortran\10.1.034\\IA32\Lib

Build log written to "file://C:\Intel_Fortran_Projects\FMplotV2\trunk\fmvplot2_exe\Debug\BuildLog.htm"
fmvplot2_exe - 0 error(s), 0 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

If there is a way to test for a substring within a string I suppose I could then test on either path or __iflSearch for the substring "11.1\070" or "10.1\034".

Thanks,

Neill
0 Kudos
Steven_L_Intel1
Employee
1,278 Views
Hmm. Seems I may have led you astray a bit. The names won't show up in a SET command, but they are recognized in $(envvarname) strings in a build event command. So they won't work in a .BAT file.

I am not 100% sure what these look like in 11.1. Try adding as a build event:

echo $(IfortInstallDir)

and see what you get.

You will not find those environment variables documented. As for the help, the Fortran help is separate from the VS help - there isn't a way for us to combine it in those versions of Visual Studio. You will see a separate entry for Fortran when you pull down the Help menu.
0 Kudos
Smith__Neill
Beginner
1,278 Views
Thanks Steve, that seems to work. I tried it with both compilers, and the post-build output from echo $IFortInstallDir) changed as expected. Typical output is

Linking...
Creating library C:\Intel_Fortran_Projects\FMplotV2\trunk\fmvplot2_exe\Debug\fmvplot2_exe.lib and object C:\Intel_Fortran_Projects\FMplotV2\trunk\fmvplot2_exe\Debug\fmvplot2_exe.exp
Embedding manifest...
Performing Post-Build Event...
C:\Program Files\Intel\Compiler\Fortran\10.1.034\IA32\

Build log written to "file://C:\Intel_Fortran_Projects\FMplotV2\trunk\fmvplot2_exe\Debug\BuildLog.htm"
fmvplot2_exe - 0 error(s), 2 warning(s)
========== Rebuild All: 3 succeeded, 0 failed, 0 skipped ==========

If I can get a BAT file to accept $IFortInstallDir) as an input argument, I should be able to direct where I copy the final Exe file to.

Thanks,

Neill
0 Kudos
Steven_L_Intel1
Employee
1,278 Views
You will want to enclose it in quotes. "($IfortInstallDir)"
0 Kudos
Reply