インテル® Fortran コンパイラー 18.0 デベロッパー・ガイドおよびリファレンス
ここでは、インテル® Visual Fortran コンパイラーで提供されるオートメーション・インターフェイスについて簡単に説明します。オートメーション・インターフェイスはプログラミング可能なオブジェクトで、基本となる IDE コンポーネントやプロジェクトにアクセスするために使用され、経験豊富な開発者に、一般的な作業を自動化する手段や、IDE や IDE 内で使用される Fortran プロジェクトを細かく制御する手段を提供します。
Visual Studio* の [オブジェクト ブラウザー] ([表示] > [オブジェクト ブラウザー]) を使用して、オブジェクトと関連プロパティーを参照することができます。ブラウザーで [参照] > [カスタム コンポーネント セットの編集] > [.NET] > [Microsoft.VisualStudio.VFProject] を開きます。
ここにリストされているオブジェクトは、オートメーション・オブジェクトおよび Visual Studio* オブジェクト・モデルの使用に慣れた開発者を対象に提供される高度な機能です。
オブジェクト |
説明 |
IVFCollection |
コレクション・オブジェクトで実行できる機能が含まれています。 |
VFConfiguration |
プロジェクトの [プロパティ ページ] ダイアログボックスの [全般] プロパティーにプログラムコードからアクセスします。このオブジェクトでは、この設定をビルドするのに使用されるツールにもアクセスできます。 |
VFCustomBuildTool |
プロジェクトの [プロパティ ページ] ダイアログボックスの [カスタム ビルド ステップ] プロパティーにプログラムコードからにアクセスします。 |
VFDebugSettings |
ユーザーが [デバッグ] プロパティーの設定をプログラムコードから操作することができるプロパティーが含まれています。 |
VFFile |
アクティブなプロジェクトのファイルで行える操作を示します。 |
VFFileConfiguration |
構成用にファイルに関連付けられたツールの情報など、ファイル (VFFile オブジェクト) についてのビルド情報が含まれます。 |
VFFilter |
[ソリューション エクスプローラー] にあるインテル® Visual Fortran プロジェクトのフォルダーに含まれる機能を公開します。 |
VFFortranCompilerTool |
IFORT ツールの機能を公開します。 |
VFFortranCompilerVersion |
インテル® Visual Fortran コンパイラーのバージョンに関連したプロパティーへのアクセスを提供します。 |
VFLibrarianTool |
LIB ツールの機能を公開します。 |
VFLinkerTool |
LINK ツールの機能を公開します。 |
VFManifestTool |
プロジェクトの [プロパティ ページ] ダイアログボックスの [マニフェスト ツール] プロパティーにプログラムコードからアクセスします。 |
VFMidlTool |
プロジェクトの [プロパティ ページ] ダイアログボックスの [MIDL] プロパティーにプログラムコードからアクセスします。 |
VFPlatform |
サポートされているプラットフォームに関連したプロパティーへのアクセスを提供します。 |
VFPreBuildEventTool |
プロジェクトの [プロパティ ページ] ダイアログボックスにある [ビルドイベント] の [ビルド前のイベント] プロパティーにプログラムコードからアクセスします。 |
VFPreLinkEventTool |
プロジェクトの [プロパティ ページ] ダイアログボックスにある [ビルドイベント] の [リンク前のイベント] プロパティーにプログラムコードからアクセスします。 |
VFPostBuildEventTool |
プロジェクトの [プロパティ ページ] ダイアログボックスにある [ビルドイベント] の [ビルド後のイベント] プロパティーにプログラムコードからアクセスします。 |
VFProject |
インテル® Visual Fortran プロジェクトのプロパティーを公開します。 |
VFResourceCompilerTool |
プロジェクトの [プロパティ ページ] ダイアログボックスの [リソース] プロパティーにプログラムコードからアクセスします。 |
Visual Basic* で記述されている次の例では、オートメーション・オブジェクトを使用して Visual Studio* IDE の [構成マネージャー] で利用可能なプラットフォームとバージョンのリストを変更する方法を示しています。
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VFProject
Imports System.Collections
Public Module MultiPV
' Create a Console application before executing this module
' Module demonstrates Multi Platform & Multi Version Automation Support
' Variable definition
Dim Prj As Project ' VS project
Dim VFPrj As VFProject ' Intel VF project
Dim o As Object ' Object
Sub run()
' Get the Project
Prj = DTE.Solution.Projects.Item(1)
'
' Get Intel VF project
VFPrj = Prj.Object
'
' Get list of Supported platforms
Dim pList As ArrayList = New ArrayList() ' list of platforms
Dim cList As ArrayList = New ArrayList() ' lost of compilers
Dim i As Integer
pList = getSupportedPlatforms()
For i = 0 To pList.Count - 1
cList = getCompilers(pList.Item(i))
printCompilers(pList.Item(i), cList)
Next
'
' Add configurations - x64
For i = 0 To pList.Count - 1
If pList.Item(i) <> "Win32" Then
addConfiguration(pList.Item(i))
End If
Next
Dim cfgsList As ArrayList = New ArrayList() ' list of configurations
cfgsList = getAllConfigurations()
'
' Set compiler
For i = 0 To pList.Count - 1
Dim pNm As String
Dim cvList As ArrayList = New ArrayList()
pNm = pList.Item(i)
cList = getCompilers(pNm)
cvList = getCompilerVersions(pNm)
Dim j As Integer
For j = 0 To cvList.Count - 1
Dim cv As String = cvList.Item(j)
If SetCmplrForPlatform(pNm, cv) Then
setActiveCfg(pNm)
SolutionRebuild()
Dim sOut As String = GetOutput()
Dim scv As String = CheckCompiler(sOut)
MsgBox(pNm + " " + cv + " " + scv)
End If
Next
Next
End Sub
' get context from Output window
Function GetOutput() As String
Dim win As Window
Dim w As OutputWindow
Dim wp As OutputWindowPane
Dim td As TextDocument
win = DTE.Windows.Item(Constants.vsWindowKindOutput)
w = win.Object
Dim i As Integer
For i = 1 To w.OutputWindowPanes.Count
wp = w.OutputWindowPanes.Item(i)
If wp.Name = "Build" Then
td = wp.TextDocument
td.Selection.SelectAll()
Dim ts As TextSelection = td.Selection
GetOutput = ts.Text
Exit Function
End If
Next
End Function
Function CheckCompiler(ByVal log As String) As String
Dim s As String
Dim beg_ As Integer
Dim end_ As Integer
beg_ = log.IndexOf("Compiling with")
beg_ = log.IndexOf("Intel", beg_)
end_ = log.IndexOf("]", beg_)
s = log.Substring(beg_, end_ - beg_ + 1)
CheckCompiler = s
End Function
Function SetCmplrForPlatform(ByVal plNm As String, ByVal vers As String) As Boolean
Dim pl As VFPlatform
Dim cll As IVFCollection
Dim cvs As IVFCollection
Dim cv As VFFortranCompilerVersion
Dim maj As String
Dim min As String
Dim ind As Integer
Try
ind = vers.IndexOf(".")
maj = vers.Substring(0, ind)
min = vers.Substring(ind + 1)
cll = VFPrj.Platforms
pl = cll.Item(plNm)
If pl Is Nothing Then
MsgBox("Platform " + plNm + " not exist")
Exit Function
End If
cvs = pl.FortranCompilerVersions
Dim j As Integer
For j = 1 To cvs.Count
cv = cvs.Item(j)
If cv.MajorVersion.ToString() = maj And cv.MinorVersion.ToString() = min Then
pl.SelectedFortranCompilerVersion = cv
SetCmplrForPlatform = True
Exit Function
End If
Next
MsgBox("Compiler version " + maj + "."+ min + " not exist for platform " + plNm)
SetCmplrForPlatform = False
Catch ex As Exception
SetCmplrForPlatform = False
End Try
End Function
Function getSupportedPlatforms() As ArrayList
Dim list As ArrayList = New ArrayList()
Dim pl As VFPlatform
Dim pls As IVFCollection
pls = VFPrj.Platforms
Dim i As Integer
For i = 1 To pls.Count
pl = pls.Item(i)
list.Add(pl.Name)
Next
getSupportedPlatforms = list
End Function
Function getCompilers(ByVal plNm As String) As ArrayList
Dim list As ArrayList = New ArrayList()
Dim pl As VFPlatform
Dim pls As IVFCollection
Dim cvs As IVFCollection
Dim cv As VFFortranCompilerVersion
Dim j As Integer
pls = VFPrj.Platforms
pl = pls.Item(plNm)
cvs = pl.FortranCompilerVersions
For j = 1 To cvs.Count
cv = cvs.Item(j)
list.Add(cv.DisplayName)
Next
getCompilers = list
End Function
Function getCompilerVersions(ByVal plNm As String) As ArrayList
Dim list As ArrayList = New ArrayList()
Dim pl As VFPlatform
Dim pls As IVFCollection
Dim cvs As IVFCollection
Dim cv As VFFortranCompilerVersion
pls = VFPrj.Platforms
pl = pls.Item(plNm)
cvs = pl.FortranCompilerVersions
Dim j As Integer
For j = 1 To cvs.Count
cv = cvs.Item(j)
Dim vers As String
vers = cv.MajorVersion.ToString() + "."+ cv.MinorVersion.ToString()
list.Add(vers)
Next
getCompilerVersions = list
End Function
Sub printCompilers(ByVal plNm As String, ByVal list As ArrayList)
Dim s As String
s = "Platform " + plNm + Chr(13)
Dim i As Integer
For i = 0 To list.Count - 1
s += " " + list.Item(i) + Chr(13)
Next
MsgBox(s)
End Sub
Sub addConfiguration(ByVal cfgNm As String)
Dim cM As ConfigurationManager
cM = Prj.ConfigurationManager
cM.AddPlatform(cfgNm, "Win32", True)
End Sub
Function getAllConfigurations() As ArrayList
Dim list As ArrayList = New ArrayList()
Dim cM As ConfigurationManager
Dim i As Integer
Dim c As Configuration
cM = Prj.ConfigurationManager
For i = 1 To cM.Count
c = cM.Item(i)
list.Add(c.ConfigurationName + "|" + c.PlatformName)
Next
getAllConfigurations = list
End Function
Sub setActiveCfg(ByVal pNm As String)
Dim scs As SolutionConfigurations = DTE.Solution.SolutionBuild.SolutionConfigurations
Dim i As Integer
Dim j As Integer
For i = 1 To scs.Count
Dim sc As SolutionConfiguration
Dim sctxs As SolutionContexts
sc = scs.Item(i)
sctxs = sc.SolutionContexts
For j = 1 To sctxs.Count
Dim sctx As SolutionContext = sctxs.Item(j)
If sctx.ConfigurationName = "Debug" And sctx.PlatformName = pNm Then
sc.Activate()
Exit Sub
End If
Next
Next
End Sub
Sub SolutionRebuild()
DTE.Solution.SolutionBuild.Clean(True)
DTE.Solution.SolutionBuild.Build(True)
End Sub
End Module