-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.rs
106 lines (55 loc) · 2.19 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
extern crate cc;
/*
build release software
Ubuntu:
RUSTFLAGS='-C target-feature=+crt-static' RUST_BACKTRACE=1 cargo build --release --target x86_64-unknown-linux-gnu
cp target/x86_64-unknown-linux-gnu/release/hacash ../../download_rust/hacash_ubuntu
Windows:
set RUSTFLAGS='-C target-feature=+crt-static' ; set RUST_BACKTRACE=1 ; cargo build --release --target x86_64-pc-windows-msvc
cp target/x86_64-pc-windows-msvc/release/hacash.exe ./hacash_windows.exe
MacOS:
RUSTFLAGS='-C target-feature=+crt-static' RUST_BACKTRACE=1 cargo build --release --target x86_64-apple-darwin
cp target/x86_64-apple-darwin/release/hacash ./hacash_macos
*/
fn main() {
cc::Build::new()
.file("src/x16rs/x16rs.c")
.compile("x16rs");
println!("cargo:rerun-if-changed=src/x16rs/x16rs.c");
}
/*
RUST update:
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
*/
/*
# Step 1: create libx16rs.a
# Step 2: build and run
gcc -c src/x16rs/x16rs.c && ar rcs libx16rs.a x16rs.o && mv *.a ./src/x16rs && rm -f *.o
RUSTFLAGS="$RUSTFLAGS -Awarnings -L ./src/x16rs/" cargo run
# Build static release software
cargo build --release --target=x86_64-unknown-linux-musl
ldd target/x86_64-unknown-linux-musl/release/hacash
RUSTFLAGS="$RUSTFLAGS -Awarnings -L ./src/x16rs/" cargo build &&
cp ./target/debug/hacash ./test/hacash_dev1 &&
./test/hacash_dev1 hacash.dev1.config.ini
RUSTFLAGS="$RUSTFLAGS -Awarnings" RUST_BACKTRACE=1 cargo run -- --reptblk
*/
/*
use std::process::Command;
use std::env;
use std::path::Path;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
panic!("{}", out_dir);
Command::new("gcc").args(&["src/x16rs/x16rs.c", "-c", "-fPIC", "-o"])
.arg(&format!("{}/x16rs.o", out_dir))
.status().unwrap();
Command::new("ar").args(&["crus", "libx16rs.a", "x16rs.o"])
.current_dir(&Path::new(&out_dir))
.status().unwrap();
println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=x16rs");
println!("cargo:rerun-if-changed=src/x16rs/x16rs.c");
}
*/