summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/compute/sys.rs
blob: 6404e6252badd914483a69031ea585e8281555f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! System-related things.

use typst::eval::{Module, Scope, Version};

/// Hook up all calculation definitions.
pub(super) fn define(global: &mut Scope) {
    global.category("sys");
    global.define_module(module());
}

/// A module with system-related things.
fn module() -> Module {
    let mut scope = Scope::deduplicating();
    scope.category("sys");
    scope.define(
        "version",
        Version::from_iter([
            env!("CARGO_PKG_VERSION_MAJOR").parse::<u32>().unwrap(),
            env!("CARGO_PKG_VERSION_MINOR").parse::<u32>().unwrap(),
            env!("CARGO_PKG_VERSION_PATCH").parse::<u32>().unwrap(),
        ]),
    );
    Module::new("sys", scope)
}