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
pub mod types;
pub use types::*;

use std::borrow::Borrow;
use std::{fs, env};
use crate::binaries::platform::binary_platform_name;
use crate::binaries::{fetch_engine, global_cache_dir};
use std::path::Path;

fn add_defaults(input: &mut Root) -> &mut Root {
    match input.generator.config.get("package") {
        Some(_) => {},
        None => { input.generator.config.insert(
            "package".to_owned(),
            "db".to_owned());
        }
    };

    input
}

pub fn run(input: &mut Root) {
    add_defaults(input);

    let mut targets = input.generator.binary_targets.clone();

    targets.push("native".to_string());
    targets.push("linux".to_string());

    for name in targets {
        let binary_name = if name == "native" {
            binary_platform_name()
        } else {
            name
        };

        fetch_engine(global_cache_dir(), "query-engine".to_string(), binary_name).unwrap();
    }

    let file_path = env::current_dir().unwrap().join("prisma.rs");
    fs::write( file_path, "FFFFFFFF".to_string()).unwrap();
}