hare-module - Hare module layout
Contents
Dependency Resolution
The "use" directives in each Hare source file used as an input to hare-build(1), hare-run(1), or hare-test(1) are scanned and used to determine the dependencies for a program. This process is repeated for
each dependency to obtain a complete dependency tree.
Dependencies are searched for by examining first the current working directory, then each component of
the HAREPATH, which is a list of paths separated by colons. HAREPATH is obtained from the environment
variable of the same name. If the environment variable is unset, a default value is used, which can be
viewed with the hareversion-v command. Typically, it is set to include the path to the standard library
installed on the system, as well as a system-provided location for third-party modules installed via the
system package manager.
hare-deps(1) may be used to print the dependency tree of a Hare module.
Description
Hare modules are represented as directories in the filesystem. A directory is a valid Hare module if it
contains at least one Hare source file (with the file extension .ha), or if it contains a file named
README.
All files which end in .ha, .s, and .o are treated as inputs to the module, and are respectively treated
as Hare sources, assembly sources, and objects to be linked into the final binary.
The list of files considered eligible may be filtered by build tags (see BUILDTAGS below). The format
for the filename is name[tagset].ext, where the name is user-defined, the ext is either ha, s, or o, and
a tagset (see BUILDTAGS) is optionally provided after the name. A file will only be included if all tags
included (with +) in the tagset are present, and no tags excluded (with -) in the tagset are present.
Only one file for a given combination of name and ext will be selected for the build; the file selected
is the one with the most tag specifiers. If there are two or more such files, the build driver will error
out.
For example, if the following files are present in a directory:
• foo.ha
• bar.ha
• bar+linux.ha
• bar+plan9.ha
• baz+x86_64.s
• bat-x86_64.ha
If the build tags are +linux+x86_64, then the files which are included in the module are foo.ha,
bar+linux.ha, and baz+x86_64.s. If the following files are added:
• meep+linux-libc.ha
• meep+linux+x86_64.ha
then the build driver will error out, unless +libc is added to the build tags.
Additionally, subdirectories in a module will be considered part of that module if their name consists
only of a tagset, e.g. "+linux" or "-x86_64". A directory with only a name (but without a tagset, e.g.
"example") is considered a submodule, and as such must be imported separately. For example, "foo::bar"
refers to foo/bar/. If a directory name contains both a name and a tagset, the build driver will error
out.
Name
hare-module - Hare module layout
See Also
hare(1), hare-build(1), hare-run(1), hare-test(1)
2025-03-27 HARE-MODULE(5)
