eqlog_runtime/lib.rs
1// This is here to support our cursed way of finding the eqlog runtime rlib file in the cargo
2// target directory. Cargo does not let build scripts know where it put rlib files of dependencies.
3// The build script in a crate that compiles eqlog modules must know where the rlib is though (at
4// least for component builds) so that it can pass the eqlog runtime rlib path as --extern
5// parameter to rustc when compiling eqlog modules.
6//
7// As a workaround, the build script scans the target directory for files that look like they might
8// be the eqlog runtime rlib file. I haven't found a way to narrow this down to a single file
9// though; there are several libeqlog_runtime-<hash>.rlib files. I think they might be there for
10// macros and for the build script of the runtime crate. We're only interested in the actual
11// runtime crate from this crate though. To find this file, the build script scans the .rlib file
12// for the value of the TAG variable below.
13//
14// We also can't use a fixed tag value here because I think eqlog-runtime is built twice depending
15// on whether it's a dependency for the build script or the crate itself. To single it down, we use
16// the OUT_DIR variable as part of the tag. The OUT_DIR variable is also available in the buidl
17// script of eqlog-runtime, which emits its value as link metadata value, see the cargo "link"
18// feature. This metadata value is then available in the build scripts of crates that dependend on
19// eqlog-runtime. The eqlog compiler crate can thus read it and scan potential eqlog-runtime rlib
20// for whether they contain this tag.
21#[used]
22static TAG: &'static str = concat!("EQLOG_RUNTIME_TAG_", env!("OUT_DIR"));
23
24mod prefix_tree;
25mod toposort;
26mod unification;
27#[doc(hidden)]
28pub mod wbtree;
29
30#[doc(hidden)]
31pub use crate::prefix_tree::{
32 PrefixTree0, PrefixTree1, PrefixTree2, PrefixTree3, PrefixTree4, PrefixTree5, PrefixTree6,
33 PrefixTree7, PrefixTree8, PrefixTree9,
34};
35#[doc(hidden)]
36pub use crate::unification::Unification;
37
38#[doc(hidden)]
39pub use crate::toposort::{morphism_toposort, MorphismWithSignature, ToposortError};
40
41/// Declare an eqlog module.
42///
43/// # Examples
44///
45/// ```ignore
46/// use eqlog_runtime::eqlog_mod;
47/// eqlog_mod!(foo);
48/// ```
49///
50/// Eqlog modules can be annotated with a visibility, or with attributes:
51/// ```ignore
52/// eqlog_mod!(#[cfg(test)] pub foo);
53/// ```
54#[macro_export]
55macro_rules! eqlog_mod {
56 ($(#[$attr:meta])* $vis:vis $modname:ident) => {
57 $(#[$attr])* $vis mod $modname {
58 include!(concat!(
59 env!("EQLOG_OUT_DIR"),
60 "/",
61 file!(),
62 "/",
63 "..",
64 "/",
65 stringify!($modname),
66 ".eql.rs"
67 ));
68 }
69 };
70}