Skip to main content

lux_lib/lua_rockspec/build/
make.rs

1use std::{collections::HashMap, path::PathBuf};
2
3use serde::Serialize;
4
5#[cfg(not(target_env = "msvc"))]
6const MAKEFILE: &str = "Makefile";
7#[cfg(target_env = "msvc")]
8const MAKEFILE: &str = "Makefile.win";
9
10#[derive(Debug, PartialEq, Clone, Serialize)]
11pub struct MakeBuildSpec {
12    /// Makefile to be used.
13    /// Default is "Makefile" on Unix variants and "Makefile.win" under Win32.
14    pub makefile: PathBuf,
15    pub build_target: Option<String>,
16    /// Whether to perform a make pass on the target indicated by `build_target`.
17    /// Default is true (i.e., to run make).
18    pub build_pass: bool,
19    /// Default is "install"
20    pub install_target: String,
21    /// Whether to perform a make pass on the target indicated by `install_target`.
22    /// Default is true (i.e., to run make).
23    pub install_pass: bool,
24    /// Assignments to be passed to make during the build pass
25    pub build_variables: HashMap<String, String>,
26    /// Assignments to be passed to make during the install pass
27    pub install_variables: HashMap<String, String>,
28    /// Assignments to be passed to make during both passes
29    pub variables: HashMap<String, String>,
30}
31
32impl Default for MakeBuildSpec {
33    fn default() -> Self {
34        Self {
35            makefile: default_makefile_name(),
36            build_target: Option::default(),
37            build_pass: default_pass(),
38            install_target: default_install_target(),
39            install_pass: default_pass(),
40            build_variables: HashMap::default(),
41            install_variables: HashMap::default(),
42            variables: HashMap::default(),
43        }
44    }
45}
46
47fn default_makefile_name() -> PathBuf {
48    PathBuf::from(MAKEFILE)
49}
50
51fn default_pass() -> bool {
52    true
53}
54
55fn default_install_target() -> String {
56    "install".into()
57}