how to automate conversion of visual studio project to use Intel C++ Compiler.

706 Views Asked by At

We are using Intel C++ compiler for improving the performance of our C++ code. In order to use it, we need to convert our visual studio project into intel project through the IDE. Since Intel compiler isn't installed everywhere, hence we do this step only on those machines where we need to create intel builds.

We wanted to explore a method to automate this conversion process through some script. We were wondering if we could use EnvDTE API to do the same.

So far we have been able to reach up to the following in VBScript:

Dim objDTE
' Creates an instance of the Visual Studio  
Set objDTE = CreateObject("VisualStudio.DTE")  

' Make it visible   
objDTE.MainWindow.Visible = True  

' Open a .sln file   
objDTE.Solution.Open("Path to solution file")  

Dim sol    
Set sol = objDTE.Solution.SolutionBuild  

At this point we can call functions like this:

sol.Clean  
sol.Build  

and they run fine.

Beyond this, we couldn't figure out a way to identify other commands which could be applied on a solution. For example, Intel C++ Compiler integrates itself as a plugin to Visual Studio. We were wondering if we could figure out a way to identify the list of commands available to the solution object and then execute the appropriate command to convert the visual studio project to use Intel Compiler.

Is it possible to automate this conversion?

Thanks in advance.

2

There are 2 best solutions below

0
On

COM automation via DTE looks as follows:

/// Intel convertion 
Project proj;
proj = DTE.Solution.Projects.Item(1) // Should be vc++ one

ProjectConversions pconv = (ProjectConversions)EnvDTE.GetObject("PrjConvert");
pconv.EnableUsingIntelCppCompiler(prj1.Name);

You just need to add .NET reference IntelCppOptPkg.dll from /Common7\IDE\PublicAssemblies

Additionally, There is a conversion tool, which located at "\Common Files\Intel\shared files\ia32\Bin\ICProjConvert.exe". A help info about the tool available with key /? or by the URL

Almost everything you need you can find in MSDN automation documentation

0
On

In the interests of those who might stumble into the same - you can use DTE.ExecuteCommand to run arbitrary commands, including those exposed by extensions. To print out a list of all available commands, you can run this VBScript:

Set DTE = CreateObject("VisualStudio.DTE.10.0") ' adjust version as needed
For Each cmd In DTE.Commands
    WScript.Echo cmd.Name
Next