Skip to content

Commit 18ea09d

Browse files
committed
Add a Meson build system
1 parent df6ca6a commit 18ea09d

15 files changed

Lines changed: 3480 additions & 1 deletion

.github/julia/build_tarballs.jl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using BinaryBuilder, Pkg
2+
3+
haskey(ENV, "DIFFBLAS_RELEASE") || error("The environment variable DIFFBLAS_RELEASE is not defined.")
4+
haskey(ENV, "DIFFBLAS_COMMIT") || error("The environment variable DIFFBLAS_COMMIT is not defined.")
5+
haskey(ENV, "DIFFBLAS_URL") || error("The environment variable DIFFBLAS_URL is not defined.")
6+
7+
name = "diffblas"
8+
version = VersionNumber(ENV["DIFFBLAS_RELEASE"])
9+
10+
# Collection of sources required to complete build
11+
sources = [
12+
GitSource(ENV["DIFFBLAS_URL"], ENV["DIFFBLAS_COMMIT"])
13+
]
14+
15+
# Bash recipe for building across all platforms
16+
script = raw"""
17+
# Update Ninja
18+
cp ${host_prefix}/bin/ninja /usr/bin/ninja
19+
20+
cd ${WORKSPACE}/srcdir/diff-lapack
21+
meson setup builddir --cross-file=${MESON_TARGET_TOOLCHAIN%.*}_gcc.meson --prefix=$prefix
22+
meson compile -C builddir
23+
meson install -C builddir
24+
"""
25+
26+
# These are the platforms we will build for by default, unless further
27+
# platforms are passed in on the command line
28+
platforms = supported_platforms()
29+
platforms = expand_gfortran_versions(platforms)
30+
31+
# The products that we will ensure are always built
32+
products = [
33+
FileProduct("lib/libdiffblas.a", :libdiffblas),
34+
]
35+
36+
# Dependencies that must be installed before this package can be built
37+
dependencies = [
38+
HostBuildDependency(PackageSpec(name="Ninja_jll", uuid="76642167-d241-5cee-8c94-7a494e8cb7b7")),
39+
Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")),
40+
]
41+
42+
# Build the tarballs, and possibly a `build.jl` as well.
43+
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version=v"9.1", julia_compat="1.6")

.github/julia/generate_binaries.jl

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Version
2+
haskey(ENV, "DIFFBLAS_RELEASE") || error("The environment variable DIFFBLAS_RELEASE is not defined.")
3+
version = VersionNumber(ENV["DIFFBLAS_RELEASE"])
4+
version2 = ENV["DIFFBLAS_RELEASE"]
5+
package = "diffblas"
6+
7+
platforms = [
8+
("aarch64-apple-darwin-libgfortran5" , "lib", "dylib"),
9+
# ("aarch64-linux-gnu-libgfortran3" , "lib", "so" ),
10+
# ("aarch64-linux-gnu-libgfortran4" , "lib", "so" ),
11+
("aarch64-linux-gnu-libgfortran5" , "lib", "so" ),
12+
# ("aarch64-linux-musl-libgfortran3" , "lib", "so" ),
13+
# ("aarch64-linux-musl-libgfortran4" , "lib", "so" ),
14+
# ("aarch64-linux-musl-libgfortran5" , "lib", "so" ),
15+
# ("powerpc64le-linux-gnu-libgfortran3" , "lib", "so" ),
16+
# ("powerpc64le-linux-gnu-libgfortran4" , "lib", "so" ),
17+
# ("powerpc64le-linux-gnu-libgfortran5" , "lib", "so" ),
18+
# ("x86_64-apple-darwin-libgfortran3" , "lib", "dylib"),
19+
# ("x86_64-apple-darwin-libgfortran4" , "lib", "dylib"),
20+
("x86_64-apple-darwin-libgfortran5" , "lib", "dylib"),
21+
# ("x86_64-linux-gnu-libgfortran3" , "lib", "so" ),
22+
# ("x86_64-linux-gnu-libgfortran4" , "lib", "so" ),
23+
("x86_64-linux-gnu-libgfortran5" , "lib", "so" ),
24+
# ("x86_64-linux-musl-libgfortran3" , "lib", "so" ),
25+
# ("x86_64-linux-musl-libgfortran4" , "lib", "so" ),
26+
# ("x86_64-linux-musl-libgfortran5" , "lib", "so" ),
27+
# ("x86_64-unknown-freebsd-libgfortran3", "lib", "so" ),
28+
# ("x86_64-unknown-freebsd-libgfortran4", "lib", "so" ),
29+
# ("x86_64-unknown-freebsd-libgfortran5", "lib", "so" ),
30+
# ("x86_64-w64-mingw32-libgfortran3" , "bin", "dll" ),
31+
# ("x86_64-w64-mingw32-libgfortran4" , "bin", "dll" ),
32+
("x86_64-w64-mingw32-libgfortran5" , "bin", "dll" ),
33+
]
34+
35+
for (platform, libdir, ext) in platforms
36+
37+
tarball_name = "$package.v$version.$platform.tar.gz"
38+
39+
if isfile("products/$(tarball_name)")
40+
# Unzip the tarball generated by BinaryBuilder.jl
41+
isdir("products/$platform") && rm("products/$platform", recursive=true)
42+
mkdir("products/$platform")
43+
run(`tar -xzf products/$(tarball_name) -C products/$platform`)
44+
45+
# Create the archives *_binaries
46+
isfile("$(package)_binaries.$version2.$platform.tar.gz") && rm("$(package)_binaries.$version2.$platform.tar.gz")
47+
isfile("$(package)_binaries.$version2.$platform.zip") && rm("$(package)_binaries.$version2.$platform.zip")
48+
cd("products/$platform")
49+
50+
# Create a folder with the version number of the package
51+
mkdir("$(package)_binaries.$version2")
52+
for folder in ("lib")
53+
cp(folder, "$(package)_binaries.$version2/$folder")
54+
end
55+
56+
cd("$(package)_binaries.$version2")
57+
if ext == "dll"
58+
run(`zip -r --symlinks ../../../$(package)_binaries.$version2.$platform.zip lib`)
59+
else
60+
run(`tar -czf ../../../$(package)_binaries.$version2.$platform.tar.gz lib`)
61+
end
62+
cd("../../..")
63+
64+
# Remove the folder used to unzip the tarball generated by BinaryBuilder.jl
65+
rm("products/$platform", recursive=true)
66+
else
67+
@warn("The tarball for the platform $platform was not generated!")
68+
end
69+
end

.github/julia/make_dashboard.jl

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
using Printf
2+
3+
# --- ANSI colored dots (render fine in GitHub markdown) ---
4+
const RED = "🔴"
5+
const GREEN = "🟢"
6+
const YELLOW = "🟡"
7+
const ORANGE = "🟠"
8+
const CYAN = ""
9+
const MAGENTA = "🟣"
10+
11+
# --- Modes ---
12+
modes = ["forward", "vector-forward", "reverse", "vector-reverse"]
13+
14+
RESULTS_DIR = joinpath(@__DIR__, "..", "..", "results")
15+
16+
# ---------------------------
17+
# Load logs
18+
# ---------------------------
19+
20+
results = Dict{String,Dict{String,String}}()
21+
22+
logfiles = filter(f -> endswith(f, ".log"), readdir(RESULTS_DIR; join=true))
23+
24+
for file in logfiles
25+
for line in eachline(file)
26+
27+
isempty(strip(line)) && continue
28+
29+
parts = split(line, ":")
30+
31+
if length(parts) != 3
32+
continue
33+
end
34+
35+
routine, mode, status = parts
36+
37+
if !haskey(results, routine)
38+
results[routine] = Dict(m => "SKIPPED" for m in modes)
39+
end
40+
41+
results[routine][mode] = status
42+
end
43+
end
44+
45+
routines = sort(collect(keys(results)))
46+
47+
# ---------------------------
48+
# Status → dot
49+
# ---------------------------
50+
51+
status_to_dot = Dict(
52+
"MACHINE_PRECISION" => GREEN,
53+
"ACCEPTABLE" => GREEN,
54+
"OUTSIDE_TOLERANCE" => ORANGE,
55+
"EXECUTION_FAILED" => RED,
56+
"SKIPPED" => CYAN,
57+
"TAPENADE_FAILED" => MAGENTA
58+
)
59+
60+
# ---------------------------
61+
# Write dashboard.md
62+
# ---------------------------
63+
64+
open("dashboard.md", "w") do io
65+
# -------- Legend --------
66+
println(io, "## Legend")
67+
println(io, "")
68+
println(io, "- $(GREEN) MACHINE_PRECISION")
69+
println(io, "- $(GREEN) ACCEPTABLE")
70+
println(io, "- $(ORANGE) OUTSIDE_TOLERANCE")
71+
println(io, "- $(RED) EXECUTION_FAILED")
72+
println(io, "- $(CYAN) SKIPPED")
73+
println(io, "- $(MAGENTA) TAPENADE_FAILED")
74+
println(io, "")
75+
println(io, "---")
76+
println(io, "")
77+
78+
# -------- Summary per mode --------
79+
println(io, "## Summary by Mode")
80+
for m in modes
81+
counts = Dict("MACHINE_PRECISION"=>0, "ACCEPTABLE"=>0, "OUTSIDE_TOLERANCE"=>0,
82+
"EXECUTION_FAILED"=>0, "SKIPPED"=>0, "TAPENADE_FAILED"=>0)
83+
for r in routines
84+
status = get(results[r], m, "SKIPPED")
85+
counts[status] = get(counts, status, 0) + 1
86+
end
87+
println(io, "- **$m**: " *
88+
"$(GREEN) $(counts["MACHINE_PRECISION"]) " *
89+
"$(GREEN) $(counts["ACCEPTABLE"]) " *
90+
"$(ORANGE) $(counts["OUTSIDE_TOLERANCE"]) " *
91+
"$(RED) $(counts["EXECUTION_FAILED"]) " *
92+
"$(CYAN) $(counts["SKIPPED"]) " *
93+
"$(MAGENTA) $(counts["TAPENADE_FAILED"])")
94+
end
95+
println(io, "")
96+
println(io, "---")
97+
println(io, "")
98+
99+
# -------- Table header --------
100+
println(io, "| Routine | " * join(modes, " | ") * " |")
101+
println(io, "|---------|" * repeat("------|", length(modes)))
102+
103+
# -------- Table rows --------
104+
for r in routines
105+
line = "| $r "
106+
107+
for m in modes
108+
status = get(results[r], m, "SKIPPED")
109+
dot = get(status_to_dot, status, CYAN)
110+
line *= "| $dot "
111+
end
112+
113+
line *= "|"
114+
println(io, line)
115+
end
116+
end
117+
118+
println("Dashboard written to dashboard.md ✅")

0 commit comments

Comments
 (0)