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

Package generated code in ZIP file for relocation

Syntax

Description

packNGo([buildInfo](#d126e51480),[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

When generating standalone code by using the codegen command, you can use the -package option to both generate code and package the code in a ZIP file in a single step.

example

Examples

collapse all

Run packNGo from Command Window

After the build process is complete, you can run packNGo 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

buildInfo — Object that provides build information

buildInfo object | path to buildInfo.mat

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

You can specify the argument as a buildInfo object:

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

Or, 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');

Name-Value Arguments

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

packType — Specify structure type of ZIP file

'flat' (default) | 'hierarchical'

If 'flat', package the generated code files in a ZIP file as a single, flat folder. 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:

Example: 'packType','flat'

nestedZipFiles — Determines whether the paths for files in the secondary ZIP files are relative to the root folder of the primary ZIP file

true (default) | false

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, your code generation folder and matlabroot.

Example: 'nestedZipFiles',true

fileName — Specifies a file name for the primary ZIP file

'_`modelOrFunctionName`_.zip' (default) | '_`myName`_'

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'

minimalHeaders — Selects whether to include only the minimal header files

true (default) | false

If true, include only the minimal header files required to build the code in the ZIP file.

If false, include header files found on the include path in the ZIP file.

Example: 'minimalHeaders',true

includeReport — Selects whether to include the html folder for your code generation report

false (default) | true

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

If true, include the html folder in the ZIP file.

Example: 'includeReport',false

ignoreParseError — Instruct packNGo not to terminate on parse errors

false (default) | true

If false, terminate on parse errors.

If true, do not terminate on parse errors.

Example: 'ignoreParseError',false

ignoreFileMissing — Instruct packNGo not to terminate if files are missing

false (default) | true

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