packNGo - Package generated code in ZIP file for relocation - MATLAB (original) (raw)

Package generated code in ZIP file for relocation

Syntax

Description

packNGo([buildInfo](#d126e51846),[Name,Value](#namevaluepairarguments)) packages the code files in a compressed ZIP file so that you can relocate, unpack, and rebuild them in another development environment. The list of name-value pairs is optional.

The ZIP file can include these types of files:

Use this function to relocate files. You can then recompile the files for a specific target environment or rebuild them in a development environment in which MATLAB® is not installed. By default, the function packages the files as a flat folder structure in a ZIP file within the code generation folder. You can customize the output by specifying name-value pairs. After relocating the ZIP file, use a standard ZIP utility to unpack the compressed file.

The packNGo function can potentially modify the build information passed in the first packNGo argument. As part of code packaging,packNGo can find additional files from source and include paths recorded in the build information. When these files are found, packNGo adds them to the build information.

To ensure that packNGo finds header files, add their paths to buildInfo by using theaddIncludePaths function.

Note

example

Examples

collapse all

After the build process is complete, you can runpackNGo from the Command Window. Use packNGo for ZIP file packaging of generated code in the file portzingbit.zip. Maintain the relative file hierarchy.

  1. Change folders to the build folder. For example, using MATLAB Coder™, codegen/dll/zingbit or for Simulink® code generation, zingbit_grt_rtw.
  2. Load the buildInfo object that describes the build.
  3. Run packNGo with property settings forpackType and fileName.

cd codegen/dll/zingbit; load buildInfo.mat packNGo(buildInfo,'packType', 'hierarchical', ... 'fileName','portzingbit');

If you configure ZIP file packaging from the code generation pane, the code generator uses packNGo to output a ZIP file during the build process.

  1. Select > . Optionally, provide a Zip file name. To apply the changes, click OK.
  2. Build the model. At the end of the build process, the code generator outputs the ZIP file. The folder structure in the ZIP file is hierarchical.

You can configure ZIP file packaging by using theset_param function. During the build process, the code generator usespackNGo to create a ZIP file.

To configure ZIP file packaging for the model zingbit, run this command:

set_param('zingbit', 'PackageGeneratedCodeAndArtifacts', 'on');

The packNGo function creates the filezingbit.zip.

To specify another name for the ZIP file, for example,portzingbit.zip, run these commands:

set_param('zingbit', 'PackageGeneratedCodeAndArtifacts', 'on'); set_param('zingbit', 'PackageName', 'portzingbit.zip')

Input Arguments

collapse all

During the build process, the code generator places buildInfo.mat in the build folder. This MAT file contains the RTW.BuildInfo object. The object provides information that packNGo uses to produce the ZIP file.

You can specify the argument as the path to the buildInfo.mat file:

buildInfoFile = fullfile(pathToBuildFolder, 'buildInfo.mat'); packNGo(buildInfoFile,'packType', 'hierarchical', ... 'fileName','portzingbit');

Or, you can specify the argument as the path to the folder that containsbuildInfo.mat:

packNGo(pathToBuildFolder,'packType', 'hierarchical', ... 'fileName','portzingbit');

You can also specify the argument as an RTW.BuildInfo object:

load buildInfo.mat packNGo(buildInfo,'packType', 'hierarchical', ... 'fileName','portzingbit');

In situations where theRTW.BuildInfo object might not hold all the configuration information, use the path to thebuildInfo.mat file or the folder that contains the file.

Name-Value Arguments

collapse all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'packType','flat','nestedZipFiles',true

If 'flat', package the generated code files in a ZIP file as a single, flat folder. The function checks whether files from separate folders have identical names, producing an error if there are duplicate filenames. The function does not package:

If 'hierarchical', package the generated code files hierarchically in a primary ZIP file. The hierarchy contains top model, referenced model, and shared utility folders. The function also packages:

In the otherFiles folder orotherFiles.zip file, the function flattens files that are not located beneath matlabroot or the code generation folder.

If 'allHierarchical', package the generated code files hierarchically in a primary ZIP file. In the otherFiles folder orotherFiles.zip file, the function preserves the folder hierarchy relative to the root of the file system.

Example: 'packType','flat'

If true, create a primary ZIP file that contains three secondary ZIP files:

If false, create a primary ZIP file that contains folders, for example, the code generation folder and matlabroot.

Example: 'nestedZipFiles',true

If you do not specify the 'fileName'-value pair, the function packages the files in a ZIP file named_`modelOrFunctionName`_.zip and places the ZIP file in the code generation folder.

If you specify 'fileName' with the value,'_`myName`_', the function creates_`myName`_.zip in the code generation folder.

To specify another location for the primary ZIP file, provide the absolute path to the location,_`fullPath`_/_`myName`_.zip

Example: 'fileName','/home/user/myModel.zip'

Option to include only minimally required header files in the ZIP file, specified as true or false.

PackNGo uses the findIncludeFiles function with minimalHeaders to determine which header files to include, and updates buildInfo accordingly.

Note

GPU Coder™ requires that minimalHeaders is specified asfalse.

Example: minimalHeaders=true

If false, do not include the html folder in the ZIP file.

If true and packType is set to'hierarchical' or 'allHierarchical', include the html folder in the ZIP file.

Example: 'includeReport',false

If false, terminate on parse errors.

If true, do not terminate on parse errors.

Example: 'ignoreParseError',false

If false, terminate on missing file errors.

If true, do not terminate on missing files errors.

Example: 'ignoreFileMissing',false

Limitations

Version History

Introduced in R2006b

expand all

The packType name-value argument of the packNGo function provides the option 'allHierarchical'. If you specify the option, the function packages the generated code files hierarchically in a primary ZIP file. In the otherFiles folder or otherFiles.zip file, the function preserves the folder hierarchy relative to the root of the file system.