MCPcopy Create free account
hub / github.com/echQoQ/RustSL / thunk

Function thunk

src/thunk.rs:6–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4use std::{path::PathBuf};
5
6pub fn thunk() {
7 let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
8 let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
9
10 if target_os != "windows" || target_env != "msvc" {
11 println!("cargo:note=Skipped! Only Windows(MSVC) is supported!");
12 return;
13 }
14
15 let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
16
17 let vc_ltl_arch = if target_arch == "x86" { "Win32" } else { "x64" };
18 let vc_ltl_platform = "6.0.6000.0"; // Hardcoded for win7
19
20 let vc_ltl_path = if let Ok(vc_ltl_env) = env::var("VC_LTL") {
21 PathBuf::from(vc_ltl_env).join(&format!(
22 "TargetPlatform/{}/lib/{}",
23 vc_ltl_platform, vc_ltl_arch
24 ))
25 } else {
26 println!("cargo:note=VC_LTL environment variable not set, skipping VC-LTL5");
27 return;
28 };
29
30 println!("cargo::rustc-link-search={}", vc_ltl_path.to_string_lossy());
31 println!(
32 "cargo:note=VC-LTL5 Enabled: {}({})",
33 vc_ltl_platform, vc_ltl_arch
34 );
35
36 let yy_thunks_arch = if target_arch == "x86" { "x86" } else { "x64" };
37 let yy_thunks_platform = "Win7"; // Hardcoded for win7
38
39 let yy_thunks = if let Ok(yy_thunks_env) = env::var("YY_THUNKS") {
40 PathBuf::from(yy_thunks_env).join(format!(
41 "objs/{}/YY_Thunks_for_{}.obj",
42 yy_thunks_arch, yy_thunks_platform
43 ))
44 } else {
45 println!("cargo:note=YY_THUNKS environment variable not set, skipping YY-Thunks");
46 return;
47 };
48
49 println!("cargo::rustc-link-arg={}", yy_thunks.to_string_lossy());
50 println!(
51 "cargo:note=YY-Thunks Enabled: {}({})",
52 yy_thunks_platform, yy_thunks_arch
53 );
54
55 if env::var("CARGO_FEATURE_DEBUG").is_err() && env::var("PROFILE").unwrap() != "debug" { // subsystem_windows hardcoded
56 println!("cargo::rustc-link-arg=/SUBSYSTEM:WINDOWS");
57 println!("cargo::rustc-link-arg=/ENTRY:mainCRTStartup");
58 println!("cargo:note=Subsystem is set to WINDOWS");
59 } else {
60 println!("cargo::rustc-link-arg=/SUBSYSTEM:CONSOLE");
61 }
62}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected