Relocating Code to Another Development Environment

Introduction

If you need to relocate the static and generated code files for a model to another development environment, such as a secure system or an integrated development environment (IDE) that does not include MATLAB® and Simulink® products, use the Real-Time Workshop® pack-and-go utility. This utility uses the tools for customizing the build process after code generation and a packNGo function to find and package all files needed to build an executable image. The files are packaged in a compressed file that you can relocate and unpack using a standard zip utility.

To relocate a model's code files,

  1. Decide on a structure of the zip file.

  2. Decide on a name for the zip file.

  3. Package the model code files in the zip file.

  4. Relocate and unpack the zip file.

Deciding on a Structure for the Zip File

Before you generate and package the files for a model build, decide whether you want the files to be packaged in a flat or hierarchical directory structure. By default, the packNGo function packages all the necessary files in single, flat directory structure. This is the simplest approach and might be the optimal choice.

If...Then Use a...
You are relocating files to an IDE that does not use the generated makefile or the code is not dependent on the relative location of required static files Single, flat directory structure
The target development environment must maintain the directory structure of the source environment because it uses the generated makefile or the code is dependent on the relative location of filesHierarchical structure

If you use a hierarchical structure, the packNGo function creates two levels of zip files, a primary zip file, which in turn contains the following secondary zip files:

Paths for the secondary zip files are relative to the root directory of the primary zip file, maintaining the source development directory structure.

Deciding on a Name for the Zip File

By default, the packNGo function names the primary zip file model.zip. You have the option of specifying a different name. If you specify a file name and omit the file type extension, the function appends .zip to the name you specify.

Packaging Model Code Files in a Zip File

You package model code files by using the PostCodeGenCommand configuration parameter, packNGo function, and the model's build information object. You can set up the packaging operation to use

To change the default behavior of packNGo, see the following examples:

To... Specify...
Change the structure of the file packaging to hierarchicalpackNGo(buildInfo, {'packType' 'hierarchical'});
Rename the primary zip file packNGo(buildInfo, {'fileName' 'zippedsrcs'});
Change the structure of the file packaging to hierarchical and rename the primary zip filepackNGo(buildInfo, {'packType' 'hierarchical'...
'fileName' 'zippedsrcs'});

Inspecting the Generated Zip File

Inspect the resulting zip file in your working directory on the source system to verify that it is ready for relocation to the destination system. Depending on the zip tool you use you might be able to open and inspect the file without unpacking it. If you need to unpack the file and you packaged the model code files as a hierarchical structure, you will need to unpack the primary and secondary zip files. When you unpack the secondary zip files, relative paths of all files are preserved.

Relocating and Unpacking the Zip File

Relocate the resulting zip file to the destination development environment and unpack the file.

Code Packaging Example

The following example guides you through the steps for packaging code files generated for the demo model rtwdemo_f14.

  1. Set your working directory to a writable directory.

  2. Open the model rtwdemo_f14 and save a copy to your working directory.

  3. Enter the following command in the MATLAB Command Window:

    set_param('rtwdemo_f14', 'PostCodeGenCommand',...
    'packNGo(buildInfo, {''packType'' ''hierarchical''})'); 

    Note that it is necessary to double the single-quotes due to the nesting of character arrays 'packType' and 'hierarchical' within the character array that specifies the call to packNGo.

  4. Generate code for the model.

  5. Inspect the generated zip file, rtwdemo_f14.zip. The zip file contains the two secondary zip files, mlrFiles.zip and sDirFiles.zip.

  6. Inspect the zip files mlrFiles.zip and sDirFiles.zip.

  7. Relocate the zip file to a destination environment and unpack it.

packNGo Function Limitations

The following limitations apply to use of the packNGo function:

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS