-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
72 lines (63 loc) · 2.04 KB
/
build.rs
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
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::{env, fs, path::Path, process::Command};
use cc::Build;
fn build_image() {
let path = Path::new("./romfs/assets.t3x");
if path.exists() {
let _ = fs::remove_file(path);
}
let res = Command::new("tex3ds")
.arg("-i")
.arg("./assets/assets.t3s")
.arg("-o")
.arg("./romfs/assets.t3x")
.output()
.expect("failed to generate assets.t3x");
if !res.status.success() {
panic!("failed to generate assets.t3x");
}
}
fn _copy_font() {
let path = Path::new("./romfs/font.bcfnt");
if path.exists() {
return;
}
fs::copy("./assets/font.bcfnt", path).expect("copy font.bcfnt");
}
fn cc_build() -> Build {
let devkitarm = env::var("DEVKITARM").unwrap();
let cc = Path::new(devkitarm.as_str()).join("bin/arm-none-eabi-gcc");
let ar = Path::new(devkitarm.as_str()).join("bin/arm-none-eabi-ar");
let mut build = cc::Build::new();
build
.target("armv6k-nintendo-3ds")
.compiler(&cc)
.archiver(&ar)
.include("/opt/devkitpro/devkitARM/arm-none-eabi/include")
.include("/opt/devkitpro/libctru/include")
.include("/opt/devkitpro/portlibs/3ds/include")
.flag("-march=armv6k")
.flag("-mtune=mpcore")
.flag("-mfloat-abi=hard")
.flag("-mfpu=vfp")
.flag("-mtp=soft")
.flag("-Wno-deprecated-declarations");
build
}
fn main() {
build_image();
// copy_font();
println!("cargo:rerun-if-changed=./build.rs");
println!("cargo:rerun-if-changed=./assets");
println!("cargo:rerun-if-changed=./romfs");
println!("cargo:rustc-link-search=all=./c");
println!("cargo:rustc-link-search=all=/opt/devkitpro/portlibs/3ds/lib");
// citro2d
println!("cargo:rustc-link-lib=static=citro2d");
println!("cargo:rustc-link-lib=static=citro3d");
// c2d
cc_build().file("./c/c2d.c").compile("libc2d.a");
// platform
cc_build().file("./c/platform.c").compile("libplatform.a");
// util
cc_build().file("./c/util.c").compile("libutil.a");
}