7.2. Message Definitions
This section explains some details on the look-up of message definitions. For an introduction to the involved concepts, please see the section Message Definition Names in the tutorial. For the accepted contents and grammar of a message-definition file itself, see Syntax of Message Definitions.
7.2.1. How message definitions are looked up
ln-generate expects names of needed message definitions as command line parameters. These names are used to search for message definitions in the file system. However, they are not absolute path names of files, and by design could be stored differently, similar as Java classes can be stored in a JAR archive.
Importantly, message definitions are never looked up in the current working directory of an LNM config file. One should also never use the “parent directory” shorthand “..” to refer to message definitions.
The lookup for a message definition is always done like this:
given a message definition name (example my_project/some_type), iterate across the list of known md-directories in order and form a filename md-dir + “/” + md-name. If that file exists, use it and stop searching. This means that the first matching md-directory wins; later directories never override an earlier match.
the list of known md-directories is assembled in a deterministic way:
first any md-dirs added via the
add_message_definition_dirdirective (in order shown in the config file) or the--md-diroption given to ln_generatethen some built-in md-dirs from ln’s install $PREFIX/share/links_and_nodes/message_definitions (or when run from source tree: SRC/share/message_definitions (this might not result in useful dir-names when lnm or python was run from within a conan env) and from $PREFIX/share/ln_runtime/message_definitions
then add
~/ln_message_definitionsfor user-private md’s (bad idea) and the contents of theLN_MESSAGE_DEFINITION_DIRSenvironment variable
After assembling this initial list, the LN tools (LN Manager and
ln_generate) iterate it and check in each md-dir whether it
contains a file named md.conf: If so, additional
md-directories are read from it (one per line) and appended to the list
of known md-dirs.
Both ln_generate and ln_manager use this look-up. The mechanism to pass additional directories is slightly different:
ln_generate uses the option --md-dir, while
the ln_manager uses the global directive add_message_definition_dir.