• Aucun résultat trouvé

LIBRARY SEARCH STRATEGY

Dans le document LOGITECH SOFIWARE ENGINEERING LIBRARY (Page 163-166)

MODULA-2/86 INTERFACING ASSEMBLY CODE LIBRARIES

5.5 LIBRARY SEARCH STRATEGY

No special manipulation is required to build or to use the library of modules. All on-line modules, residing on hard disk or floppy disk, comprise the library. The compiler, linker, and debugger automatically search for referenced modules. The default search strategy can be modified by command options. Note that during the operation of the MODULA-2/86 compiler, linker and debugger, all needed files must be on-line. By default, several drives or directories are searched to find a library module.

For the following discussion we will use the term 'path' or 'path name' as an abbreviation for 'drive and/or directory name'.

5.5.1 Default Names

The MODULA-2/86 compiler, linker, post-mortem debugger, and run-time debugger construct the default filename for a library module from its module name. This is done by truncating the module name if it is longer than a file name may be, and by appending the appropriate extension (SYM, LNK, etc.) to the resulting name. This default filename is then used to find the corresponding file.

5.5.2 The Default Search Strategy

When a library module is needed, several paths will be checked automatically to find the

corresponding file. A search strategy, as explained below, is applied by the compiler (for files with extension .SYM), by the linker (for .LNK and .MAP files), and by the debugger (for .REF, .MOD and .DEF files).

The first search is always done using the 'source' or 'master' path. The source or master path is the path you specify when entering the name of the file to compile or link. If the file is not found using

UBRARYSEARCHSTRATEGY MODUlA-2/86 This default search strategy is adequate only if your system has floppy disks. For hard disk systems it is recommended that you organize the disk as described in the installation section of this manual and that you change the default search strategy by setting up the environment (in DOS) for MODULA-2/86. This is done by the following DOS commands:

• SET M2SYM=\M2UB\SYM<CR>

• SET M2LNK=\M2LIB\LNK<CR>

• SET M2REF=\M2LIB\REF<CR>

• SET M2MAP=\M2LIB\MAP<CR>

It is recommended that these DOS commands be included in your AUTOEXEC.BAT file, which is executed by DOS automatically every time you boot your system. If these environment strings (M2SYM, M2LNK, M2REF, M2MAP) are defined in DOS, they will be used by the MODULA-2/86 system in order to determine which paths are searched automatically. If these environment strings are not defined, then three automatic searches as explained above will be performed. If you use the recommended disk organization, then you should define these environment strings.

Each of these environment strings can denote a number of paths. Different paths must be separated by semicolons. If the environment strings are defined, then the MODULA-2/86 system - the compiler, linker and debugger - will search the library files using all the paths specified by the

corresponding environment string. However, the first search is still done using the 'source' or 'master' path. If it fails, the paths specified in the corresponding environment string are checked one after the other according to the order in which they appear. If the file is not found, then you will be prompted to type in the (path and) file name.

Example:

Let us assume, that the M2SYM" string has been set by set m2Sym=i\mystufr\mylibi\m2Iib\Sym and that a compilation was started by

C>

m2 comp<CR>

LOGITECH MODULA-2/86 Compiler, ReI. m.n

MODUIA-2/86 LIBRARY SEARCH STRATEGY

In this case; the compiler will always perform a first search for symbol files on drive A, using the path you specified with the source file. If the file is not found there, it will try to open the file using the first path from M2SYM. In our case, this first path is empty, because the string starts with a semicolon.

An empty path denotes the current directory on the current drive. If a symbol file is not found using the current path, the second path '\mystuft\mylib' is searched. If this search and the last automatic attempt to open a symbol file using the path '\m2lib\sym' both fail, you will be prompted to type in the file name.

This way of searching library files gives you a lot of flexibility to add your own library modules. The simplest way to add your own library modules is to put them into the directories with the standard library. As the example shows, you can also add new libraries of your own and organize it in your own way. Note that, unlike in the case where no environment strings are defined, the current directory is

only searched if you did not specify a path when entering the source file name, or when an empty path occurs in the environment string.

5.5.3 The Query Search Strategy

The query search strategy is always applied by the MODULA-2/86 system when you are prompted to type in the (path and) file name of a library file. This can happen when a file is not found using the default search strategy, or when you specify the Query option when compiling (or linking, or debugging).

When you are prompted, several responses are available. They are discussed in the following paragraphs.

• You can enter <ESC>, which means 'no file'. This can be used to indicate that the file is not available or, in the case of the linker, that it should not be included. Depending on the context, entering <ESC> may not allow the successful completion of the program you are currently using.

• You can enter <CR> only, which means that the file name should be constructed from the module name, and that the default search strategy (as explained above) will be applied.

Dans le document LOGITECH SOFIWARE ENGINEERING LIBRARY (Page 163-166)