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:
- Source files (for example,
.c
,.cu
, and.cpp
files) - Header files (for example,
.h
,.cuh
, and.hpp
files) - MAT-file that contains the build information object (
.mat
file) - Nonbuild-related files (for example,
.dll
files and.txt
informational files) required for a final executable - Build-generated binary files (for example, executable
.exe
file or dynamic link library.dll
).
The code generator includes the build-generated binary files (if present) in the ZIP file. The ignoreFileMissing property does not apply to build-generated binary files. - CMake configuration files (
CMakeLists.txt
) that you use to generate makefiles or projects for a compiler environment.
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.
Examples
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.
- Change folders to the build folder. For example, using MATLAB Coder™,
codegen/dll/zingbit
or for Simulink® code generation,zingbit_grt_rtw
. - Load the
buildInfo
object that describes the build. - Run
packNGo
with property settings forpackType
andfileName
.
cd codegen/dll/zingbit; load buildInfo.mat packNGo(buildInfo,'packType', 'hierarchical', ... 'fileName','portzingbit');
Configure packNGo in the Simulink Editor
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.
- Select > . Optionally, provide a Zip file name. To apply the changes, click OK.
- 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.
Configure packNGo for Simulink from the Command Line
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
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:
- Child
buildInfo.mat
files. CMakeLists.txt
files.
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:
- The corresponding
buildInfo.mat
files for the folders. CMakeLists.txt
files in the build folder.
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:
mlrFiles.zip
— Files in your_matlabroot
_ folder treesDirFiles.zip
— Files in and under your code generation folderotherFiles.zip
— Required files not in the_matlabroot
_ orstart
folder trees
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
- The function operates on source files only, such as
*.c
,*.cpp
,cuh
, and*.h
files. The function does not support compile flags, defines, or makefiles. - The function does not package source files for reusable library subsystems.
- Unnecessary files might be included. The function might find additional files from source paths and include paths recorded in the build information, even if those files are not used.
- For MATLAB Coder, the function does not package example main source and header files that you generate with the default configuration settings. To package the example main files, configure code generation to generate and compile the example main function, generate your code, and then package the build files.
packNGo
does not package the code generated for MEX targets.
Version History
Introduced in R2006b