Skip to content

Commit ca247da

Browse files
committed
Add Randompack v0.1.1
1 parent a8c8a4a commit ca247da

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

R/Randompack/build_tarballs.jl

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Note that this script can accept some limited command-line arguments, run
2+
# `julia build_tarballs.jl --help` to see a usage message.
3+
using BinaryBuilder, Pkg
4+
5+
name = "Randompack"
6+
version = v"0.1.1"
7+
8+
sources = [
9+
ArchiveSource(
10+
"https://raw.githubusercontent.com/jonasson2/randompack-src/v0.1.1/randompack-0.1.1.tar.gz",
11+
"db3f048ddce772a77cacdf2d23a6bed58db4836b9d60f3dc6d1d910662926294",
12+
),
13+
]
14+
15+
script = raw"""
16+
set -e
17+
# Work around stray AppleDouble files that can break Python site.py decoding.
18+
find /usr/lib/python3.9/site-packages -maxdepth 1 -name '._*' -delete \
19+
2>/dev/null || true
20+
21+
cd $WORKSPACE/srcdir
22+
SRC=$WORKSPACE/srcdir/randompack-0.1.1
23+
# Meson fails to detect the macOS/aarch64 linker in BinaryBuilder;
24+
# build manually here.
25+
if echo "$target" | grep -q 'apple-darwin'; then
26+
BUILD=$WORKSPACE/build-manual
27+
rm -rf $BUILD
28+
mkdir -p $BUILD $prefix/lib $prefix/include \
29+
$prefix/share/licenses/Randompack
30+
31+
CDEFS="-D_POSIX_C_SOURCE=200809L -D_DARWIN_C_SOURCE -DLOCAL_DPSTRF -DUSE_ACCEL_VV"
32+
if echo "$target" | grep -q '^aarch64-apple-darwin'; then
33+
COPTS="-O3 -mcpu=apple-m1 -fPIC -fno-math-errno -fno-trapping-math -fomit-frame-pointer -fno-semantic-interposition"
34+
else
35+
COPTS="-O3 -fPIC -fno-math-errno -fno-trapping-math -fomit-frame-pointer -fno-semantic-interposition"
36+
fi
37+
38+
AR=${target}-ar
39+
RANLIB=${target}-ranlib
40+
$FC -O3 -c $SRC/src/lapack_dpstrf.f -o $BUILD/lapack_dpstrf.f.o
41+
$CC -std=c11 $COPTS $CDEFS -I$SRC/src -c $SRC/src/printX.c \
42+
-o $BUILD/printX.c.o
43+
$CC -std=c11 $COPTS $CDEFS -I$SRC/src -c $SRC/src/randompack.c \
44+
-o $BUILD/randompack.c.o
45+
46+
$CC -shared -o $prefix/lib/librandompack.dylib \
47+
$BUILD/randompack.c.o $BUILD/printX.c.o $BUILD/lapack_dpstrf.f.o \
48+
-framework Accelerate -lm -lgfortran \
49+
-Wl,-install_name,@rpath/librandompack.dylib
50+
51+
$AR rcs $prefix/lib/librandompack.a \
52+
$BUILD/randompack.c.o $BUILD/printX.c.o $BUILD/lapack_dpstrf.f.o
53+
$RANLIB $prefix/lib/librandompack.a || true
54+
55+
if [ -f $SRC/src/randompack.h ]; then
56+
cp $SRC/src/randompack.h $prefix/include/
57+
fi
58+
if [ -f $SRC/src/randompack_config.h ]; then
59+
cp $SRC/src/randompack_config.h $prefix/include/
60+
fi
61+
if [ -f $SRC/randompack.h ]; then
62+
cp $SRC/randompack.h $prefix/include/
63+
fi
64+
if [ -f $SRC/randompack_config.h ]; then
65+
cp $SRC/randompack_config.h $prefix/include/
66+
fi
67+
68+
cp $SRC/LICENSE $prefix/share/licenses/Randompack/LICENSE
69+
else
70+
cd $WORKSPACE
71+
rm -rf build
72+
73+
export PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:${prefix}/lib64/pkg<config:${prefix}/share/pkgconfig:${PKG_CONFIG_PATH:-}"
74+
export CPPFLAGS="-I${prefix}/include ${CPPFLAGS:-}"
75+
export LDFLAGS="-L${prefix}/lib -L${prefix}/lib64 ${LDFLAGS:-}"
76+
77+
meson setup build $SRC \
78+
--cross-file=${MESON_TARGET_TOOLCHAIN} \
79+
--buildtype=release \
80+
--prefix=${prefix} \
81+
-Dblas=openblas \
82+
-Dbuild_examples=false \
83+
-Dbuild_tests=false \
84+
-Dbuild_fortran_interface=false
85+
ninja -C build
86+
ninja -C build install
87+
fi
88+
"""
89+
90+
# These are the platforms we will build for by default, unless further
91+
# platforms are passed in on the command line
92+
platforms = [
93+
Platform("aarch64", "macos", libgfortran_version="5.0.0"),
94+
Platform("x86_64", "macos", libgfortran_version="5.0.0"),
95+
Platform("x86_64", "linux"; libgfortran_version="5.0.0", cxxstring_abi="cxx11"),
96+
Platform("aarch64", "linux"; libgfortran_version="5.0.0", cxxstring_abi="cxx11"),
97+
Platform("x86_64", "windows"; libgfortran_version="5.0.0"),
98+
]
99+
100+
# The products that we will ensure are always built
101+
products = [
102+
LibraryProduct("librandompack", :librandompack)
103+
]
104+
105+
dependencies = [
106+
Dependency(PackageSpec(name="CompilerSupportLibraries_jll",
107+
uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")),
108+
Dependency(PackageSpec(name="OpenBLAS32_jll",
109+
uuid="656ef2d0-ae68-5445-9ca0-591084a874a2")),
110+
]
111+
112+
# Build the tarballs, and possibly a `build.jl` as well.
113+
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.10")

0 commit comments

Comments
 (0)