~starkingdoms/starkingdoms

ref: 0493bcf580ead3c8304a74b5b56403fe7de8962c starkingdoms/spacetime_rs/src/commands/api.rs -rw-r--r-- 1.5 KiB
0493bcf5 — ghostlyzsh now it builds 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use crate::configure::create_writer;
use crate::configure::rust::configure_rust_target;
use crate::ninja::{exec, exec_ninja};
use std::error::Error;
use std::path::PathBuf;

pub fn build_api(_: Vec<String>, root: PathBuf) -> Result<(), Box<dyn Error>> {
    let mut config_file_writer = create_writer(&root)?;

    configure_rust_target("api", "dev", &mut config_file_writer, &root)?;

    exec_ninja(&root, vec!["api".to_string()])?;

    Ok(())
}

pub fn build_api_prod(_: Vec<String>, root: PathBuf) -> Result<(), Box<dyn Error>> {
    let mut config_file_writer = create_writer(&root)?;

    configure_rust_target("api", "prod", &mut config_file_writer, &root)?;

    exec_ninja(&root, vec!["api".to_string()])?;

    Ok(())
}

pub fn run_api(args: Vec<String>, root: PathBuf) -> Result<(), Box<dyn Error>> {
    let mut config_file_writer = create_writer(&root)?;

    configure_rust_target("api", "dev", &mut config_file_writer, &root)?;

    exec_ninja(&root, vec!["api".to_string()])?;

    exec(
        root.join("target/debug/starkingdoms-api").to_str().unwrap(),
        &root.join("api"),
        args,
    )?;

    Ok(())
}

pub fn run_api_prod(args: Vec<String>, root: PathBuf) -> Result<(), Box<dyn Error>> {
    let mut config_file_writer = create_writer(&root)?;

    configure_rust_target("api", "prod", &mut config_file_writer, &root)?;

    exec_ninja(&root, vec!["api".to_string()])?;

    exec(
        root.join("target/release/starkingdoms-api")
            .to_str()
            .unwrap(),
        &root.join("api"),
        args,
    )?;

    Ok(())
}