-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-rust-hash.jl
64 lines (55 loc) · 2.27 KB
/
create-rust-hash.jl
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
using SHA
include("config.jl")
# BinaryBuilder => Rust target triple name matching
RUST_TRIPLES = Dict(
"i686-linux-gnu" => "i686-unknown-linux-gnu",
"x86_64-linux-gnu" => "x86_64-unknown-linux-gnu",
"aarch64-linux-gnu" => "aarch64-unknown-linux-gnu",
"armv7l-linux-gnueabihf" => "armv7-unknown-linux-gnueabihf",
"powerpc64le-linux-gnu" => "powerpc64le-unknown-linux-gnu",
"i686-linux-musl" => "i686-unknown-linux-musl",
"x86_64-linux-musl" => "x86_64-unknown-linux-musl",
"aarch64-linux-musl" => "aarch64-unknown-linux-musl" ,
"armv7l-linux-musleabihf" => "armv7-unknown-linux-musleabihf",
"x86_64-apple-darwin" => "x86_64-apple-darwin",
"aarch64-apple-darwin" => "aarch64-apple-darwin",
"x86_64-unknown-freebsd" => "x86_64-unknown-freebsd",
"i686-w64-mingw32" => "i686-pc-windows-gnu",
"x86_64-w64-mingw32" => "x86_64-pc-windows-gnu",
# not an actual Julia triple, so we use the Rust triple on both sides
"x86_64-pc-windows-msvc" => "x86_64-pc-windows-msvc",
)
prebuilt = []
prefix = "chemfiles-static.v$version."
suffix = ".tar.gz"
for path in readdir("products/")
if !startswith(path, "chemfiles-static")
continue
end
julia_triple = path[length(prefix) + 1:end - length(suffix)]
if startswith(julia_triple, "armv6l")
# rust only provides arm7 targets
continue
end
fd = open(joinpath("products/", path))
sha = bytes2hex(sha256(fd))
close(fd)
push!(prebuilt, (RUST_TRIPLES[julia_triple], julia_triple, sha))
end
open("prebuilt.rs", "w") do fd
println(fd, "/// Get the julia triple & sha256 corresponding to the prebuilt chemfiles v$version")
println(fd, "/// for a given rust triple, if it exists")
println(fd, "pub fn get_prebuilt_info(target: &str) -> Option<(&'static str, &'static str)> {")
println(fd, " match target {")
for (rust_triple, julia_triple, sha) in prebuilt
println(fd, " \"$rust_triple\" => Some((")
println(fd, " \"$julia_triple\",")
println(fd, " \"$sha\",")
println(fd, " )),")
end
println(fd, " _ => None,")
println(fd, " }")
println(fd, "}")
end
println("====================================================\n")
println("Done generating prebuilt.rs")