coder.BuildConfig クラス
名前空間: coder
コード生成時のビルド コンテキスト
説明
コード ジェネレーターで、このクラスのオブジェクトを作成し、"ビルド コンテキスト" へのアクセスを容易にします。ビルド コンテキストは、次を含むコード ジェネレーターで使用される設定をカプセル化します。
ターゲット言語
コード生成ターゲット
ターゲット ハードウェア
ビルド ツールチェーン
coder.ExternalDependency
クラスで作成したメソッドで coder.BuildConfig
メソッドを使用します。
作成
コード ジェネレーターはこのクラスのオブジェクトを作成します。
メソッド
getHardwareImplementation | ハードウェア実行オブジェクトのコピーのハンドルの取得 |
getStdLibInfo | 標準ライブラリの情報の取得 |
getTargetLang | ターゲット コード生成言語の取得 |
getToolchainInfo | ツールチェーン情報オブジェクトのコピーのハンドルの返却 |
isCodeGenTarget | ビルド コンテキストが指定されたターゲットを表すかどうかを判別 |
isMatlabHostTarget | ハードウェア実行オブジェクト ターゲットが MATLAB ホスト コンピューターであるかどうかを判別 |
例
次の例では、coder.BuildConfig
メソッドを使用して、coder.ExternalDependency
メソッドでビルド コンテキストにアクセスする方法を示します。この例では、次を使用します。
coder.BuildConfig.isMatlabHostTarget
。コード生成ターゲットが MATLAB® ホストであるか検証します。ホストが MATLAB でない場合は、エラーが報告されます。coder.BuildConfig.getStdLibInfo
。リンク時ライブラリ ファイル拡張子と実行時ライブラリ ファイル拡張子を取得します。この情報を使用して、ビルド情報を更新します。
関数 adder
を含む外部ライブラリのクラス定義ファイルを作成します。
%================================================================ % This class abstracts the API to an external Adder library. % It implements static methods for updating the build information % at compile time and build time. %================================================================ classdef AdderAPI < coder.ExternalDependency %#codegen methods (Static) function bName = getDescriptiveName(~) bName = 'AdderAPI'; end function tf = isSupportedContext(buildContext) if buildContext.isMatlabHostTarget() tf = true; else error('adder library not available for this target'); end end function updateBuildInfo(buildInfo, buildContext) % Get file extensions for the current platform [~, linkLibExt, execLibExt, ~] = buildContext.getStdLibInfo(); % Add file paths hdrFilePath = fullfile(pwd, 'codegen', 'dll', 'adder'); buildInfo.addIncludePaths(hdrFilePath); % Link files linkFiles = strcat('adder', linkLibExt); linkPath = hdrFilePath; linkPriority = ''; linkPrecompiled = true; linkLinkOnly = true; group = ''; buildInfo.addLinkObjects(linkFiles, linkPath, ... linkPriority, linkPrecompiled, linkLinkOnly, group); % Non-build files for packaging nbFiles = 'adder'; nbFiles = strcat(nbFiles, execLibExt); buildInfo.addNonBuildFiles(nbFiles,'',''); end %API for library function 'adder' function c = adder(a, b) if coder.target('MATLAB') % running in MATLAB, use built-in addition c = a + b; else % Add the required include statements to the generated function code coder.cinclude('adder.h'); coder.cinclude('adder_initialize.h'); coder.cinclude('adder_terminate.h'); c = 0; % Because MATLAB Coder generated adder, use the % housekeeping functions before and after calling % adder with coder.ceval. coder.ceval('adder_initialize'); c = coder.ceval('adder', a, b); coder.ceval('adder_terminate'); end end end end
拡張機能
C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。
バージョン履歴
R2013b で導入
参考
coder.target
| coder.ExternalDependency
| coder.HardwareImplementation
(MATLAB Coder)
トピック
- 外部 C/C++ コードのインターフェイスの開発 (MATLAB Coder)
- ビルド プロセスのカスタマイズ (MATLAB Coder)
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)