Documentation

coder.BuildConfig class

Package:coder
Superclasses:

Build context during code generation

Description

The code generator creates an object of this class to facilitate access to thebuild context. The build context encapsulates the settings used by the code generator including:

  • Target language

  • Code generation target

  • Target hardware

  • Build toolchain

Usecoder.BuildConfigmethods in the methods that you write for thecoder.ExternalDependencyclass.

Construction

The code generator creates objects of this class.

方法

getHardwareImplementation Get handle of copy of hardware implementation object
getStdLibInfo Get standard library information
getTargetLang Get target code generation language
GetToolChainInfo 返回工具链信息对象的副本
isCodeGenTarget Determine if build configuration represents specified target
isMatlabHostTarget 确定硬件实现对象目标是否为MATLABhost computer

Copy Semantics

Value. To learn how value classes affect copy operations, seeCopying Objects(MATLAB)。

Examples

collapse all

This example shows how to usecoder.BuildConfigmethods to access the build context incoder.ExternalDependency方法。在此示例中,您使用:

  • coder.buildconfig.ismatlabhosttargetto verify that the code generation target is the MATLAB®host. If the host is not MATLAB report an error.

  • coder.BuildConfig.getStdLibInfoto get the link-time and run-time library file extensions. Use this information to update the build information.

Write a class definition file for an external library that contains the functionadder.

%===========================================================%此类将API抽取到外部加法库中。% It implements static methods for updating the build information% at compile time and build time.%===========================================================classdefAdderAPI < coder.ExternalDependency%#codegenmethods(Static)functionbName = getDescriptiveName(~) bName ='AdderAPI';endfunctiontf = isSupportedContext(buildContext)ifbuildContext.isMatlabHostTarget() tf = true;else错误('adder library not available for this target');endendfunctionupdateBuildInfo(buildInfo, buildContext)% Get file extensions for the current platform[~, linkLibExt, execLibExt, ~] = buildContext.getStdLibInfo();%添加文件路径hdrFilePath = fullfile(pwd,'codgen','dll','adder'); buildInfo.addIncludePaths(hdrFilePath);% Link fileslinkFiles = strcat('adder', linkLibExt); linkPath = hdrFilePath; linkPriority =''; linkPrecompiled = true; linkLinkOnly = true; group =''; buildInfo.addLinkObjects(linkFiles, linkPath,...linkPriority,link Proped,linklinkonly,组);% Non-build files for packagingnbFiles ='adder'; nbFiles = strcat(nbFiles, execLibExt); buildInfo.addNonBuildFiles(nbFiles,'','');end%API for library function 'adder'functionc = adder(a, b)ifcoder.target('MATLAB')% running in MATLAB, use built-in additionc = a + b;else%添加所需的语句对生成的功能代码coder.cinclude('adder.h'); coder.cinclude('adder_initialize.h'); coder.cinclude('adder_terminate.h'); c = 0;%因为MATLAB编码器生成了加法器,请使用% housekeeping functions before and after calling% adder with coder.ceval.coder.ceval('adder_initialize'); c = coder.ceval('adder', a, b); coder.ceval('adder_terminate');endendendend

Introduced in R2013b

Was this topic helpful?