Chapter 5. Renaming Files with gnatchop

Table of Contents
5.1. Handling Files with Multiple Units
5.2. Command Line for gnatchop
5.3. Switches for gnatchop
5.4. Examples of gnatchop Use

This chapter discusses how to handle files with multiple units by using the gnatchop utility. This utility is also useful in renaming files to meet the standard XGC Ada default file naming conventions.

5.1. Handling Files with Multiple Units

The basic compilation model of XGC Ada requires a file submitted to the compiler have only one unit and there must be a strict correspondence between the file name and the unit name.

The gnatchop utility allows both of these rules to be relaxed, allowing XGC Ada to process files which contain multiple compilation units and files with arbitrary file names. The approach used by gnatchop is to read the specified file and generate one or more output files, containing one unit per file and with proper file names as required by XGC Ada.

If you want to permanently restructure a set of foreign files so that they match the XGC Ada rules and do the remaining development using the XGC Ada structure, you can simply use gnatchop once, generate the new set of files and work with them from that point on.

Alternatively, if you want to keep your files in the foreign format, perhaps to maintain compatibility with some other Ada compilation system, you can set up a procedure where you use gnatchop each time you compile, regarding the source files that it writes as temporary files that you throw away.