Skip to content

Commit 4afd0bc

Browse files
committed
Revamped build script and Travis setup
1 parent f092c24 commit 4afd0bc

File tree

3 files changed

+79
-75
lines changed

3 files changed

+79
-75
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ julia:
1212
matrix:
1313
allow_failures:
1414
- julia: nightly
15+
addons:
16+
apt:
17+
packages:
18+
- libquadmath0
19+
- libgomp1
20+
- libopenblas-dev
21+
- libfftw3-dev
22+
- libmpfr-dev
23+
homebrew:
24+
packages:
25+
- gcc@9
26+
- fftw
27+
- mpfr
28+
1529
notifications:
1630
email: false
1731
after_success:

deps/build.jl

Lines changed: 62 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,78 @@
11
using BinaryProvider
2+
import Libdl
3+
4+
version = "0.2.7"
25

36
if arch(platform_key_abi()) != :x86_64
47
@warn "FastTransforms has only been tested on x86_64 architectures."
58
end
9+
if !Sys.islinux() && !Sys.isapple()
10+
error("Sorry ... unsupported OS. Feel free to file a PR to add support.")
11+
end
612

7-
ft_build_from_source = get(ENV, "FT_BUILD_FROM_SOURCE", "false")
13+
const extension = Sys.isapple() ? "dylib" : "so"
14+
print_error() = error(
15+
"FastTransforms could not be properly installed.\nCheck you have all dependencies installed." *
16+
" To install the dependencies you can use:\n" *
17+
"On Ubuntu / Debian \n" *
18+
" sudo apt install gcc libblas-dev libopenblas-base libfftw3-dev libmpfr-dev\n" *
19+
"On MacOS \n" *
20+
" brew install gcc libblas-dev libopenblas-base libfftw3-dev libmpfr-dev\n"
21+
)
822

23+
# Rationale is as follows: The build is pretty fast, so on Linux it is typically easiest
24+
# to just use the gcc of the system to build the library and include it. On MacOS, however,
25+
# we need to actually install a gcc first, because Apple's OS comes only shipped with clang,
26+
# so here we download the binary.
27+
ft_build_from_source = get(ENV, "FT_BUILD_FROM_SOURCE", Sys.isapple() ? "false" : "true")
928
if ft_build_from_source == "true"
1029
println("Building from source.")
11-
if Sys.isapple()
12-
script = raw"""
13-
brew update
14-
brew install gcc@8 fftw mpfr
15-
rm -rf FastTransforms
16-
git clone -b v0.2.7 https://github.com/MikaelSlevinsky/FastTransforms.git FastTransforms
17-
cd FastTransforms
18-
make lib CC=gcc-8 FT_USE_APPLEBLAS=1
19-
cd ..
20-
ln -sf FastTransforms/libfasttransforms.dylib libfasttransforms.dylib
21-
"""
22-
run(`/bin/bash -c $(script)`)
23-
elseif Sys.islinux()
24-
script = raw"""
25-
sudo apt-get update
26-
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
27-
sudo apt-get install gcc-8 libblas-dev libopenblas-base libfftw3-dev libmpfr-dev
28-
rm -rf FastTransforms
29-
git clone -b v0.2.7 https://github.com/MikaelSlevinsky/FastTransforms.git FastTransforms
30+
31+
extra = Sys.isapple() ? "FT_USE_APPLEBLAS=1" : ""
32+
script = """
33+
set -e
34+
set -x
35+
36+
if [ -d "FastTransforms" ]; then
37+
cd FastTransforms
38+
git fetch
39+
git reset --hard
40+
git checkout -b v$version
41+
cd ..
42+
else
43+
git clone -b v$version https://github.com/MikaelSlevinsky/FastTransforms.git FastTransforms
44+
fi
45+
ln -sf FastTransforms/libfasttransforms.$extension libfasttransforms.$extension
46+
47+
echo
48+
echo
49+
3050
cd FastTransforms
31-
make lib CC=gcc-8
32-
cd ..
33-
ln -sf FastTransforms/libfasttransforms.so libfasttransforms.so
34-
"""
51+
make clean
52+
make lib $extra
53+
"""
54+
55+
try
3556
run(`/bin/bash -c $(script)`)
36-
else
37-
@warn "FastTransforms could not be built from source with the current build.jl script. Have you considered filing an issue? https://github.com/JuliaApproximation/FastTransforms.jl/issues"
57+
catch IOError
58+
print_error()
3859
end
3960
else
4061
println("Installing by downloading binaries.")
41-
if Sys.isapple()
42-
run(`brew update`)
43-
run(`brew install gcc@8 fftw mpfr`)
44-
const libfasttransforms = joinpath(dirname(@__DIR__), "deps", "libfasttransforms.dylib")
45-
GCC = BinaryProvider.detect_compiler_abi().gcc_version
46-
println("Building with ", GCC, ".")
47-
const release = "https://github.com/MikaelSlevinsky/FastTransforms/releases/download/v0.2.7/libfasttransforms.v0.2.7"
48-
if GCC == :gcc4
49-
download(release*".gcc-4.9.dylib", libfasttransforms)
50-
elseif GCC == :gcc5
51-
download(release*".gcc-5.dylib", libfasttransforms)
52-
elseif GCC == :gcc6
53-
download(release*".gcc-6.dylib", libfasttransforms)
54-
elseif GCC == :gcc7
55-
download(release*".gcc-7.dylib", libfasttransforms)
56-
elseif GCC == :gcc8
57-
download(release*".gcc-8.dylib", libfasttransforms)
58-
elseif GCC == :gcc9
59-
download(release*".gcc-9.dylib", libfasttransforms)
60-
else
61-
@warn "Please ensure you have a version of gcc from gcc-4.9 to gcc-9."
62-
end
63-
elseif Sys.islinux()
64-
run(`sudo add-apt-repository ppa:ubuntu-toolchain-r/test`)
65-
run(`sudo apt-get update`)
66-
run(`sudo apt-get install gcc-8 libblas-dev libopenblas-base libfftw3-dev libmpfr-dev`)
67-
const libfasttransforms = joinpath(dirname(@__DIR__), "deps", "libfasttransforms.so")
68-
GCC = BinaryProvider.detect_compiler_abi().gcc_version
69-
println("Building with ", GCC, ".")
70-
const release = "https://github.com/MikaelSlevinsky/FastTransforms/releases/download/v0.2.7/libfasttransforms.v0.2.7"
71-
if GCC == :gcc4
72-
download(release*".gcc-4.9.so", libfasttransforms)
73-
elseif GCC == :gcc5
74-
download(release*".gcc-5.so", libfasttransforms)
75-
elseif GCC == :gcc6
76-
download(release*".gcc-6.so", libfasttransforms)
77-
elseif GCC == :gcc7
78-
download(release*".gcc-7.so", libfasttransforms)
79-
elseif GCC == :gcc8
80-
download(release*".gcc-8.so", libfasttransforms)
81-
elseif GCC == :gcc9
82-
download(release*".gcc-9.so", libfasttransforms)
83-
else
84-
@warn "Please ensure you have a version of gcc from gcc-4.9 to gcc-9."
85-
end
86-
else
87-
@warn "FastTransforms could not be installed by downloading binaries. Have you tried building from source?"
62+
63+
const GCC = BinaryProvider.detect_compiler_abi().gcc_version
64+
namemap = Dict(:gcc4 => "gcc-4.9", :gcc5 => "gcc-5", :gcc6 => "gcc-6",
65+
:gcc7 => "gcc-7", :gcc8 => "gcc-8", :gcc9 => "gcc-9")
66+
if !(GCC in keys(namemap))
67+
error("Please ensure you have a version of gcc from gcc-4.9 to gcc-9.")
8868
end
69+
download("https://github.com/MikaelSlevinsky/FastTransforms/releases/download/" *
70+
"v$version/libfasttransforms.v$version.$(namemap[GCC]).$extension",
71+
joinpath(dirname(@__DIR__), "deps", "libfasttransforms.$extension"))
72+
end
73+
74+
const lft_directiory = joinpath(dirname(@__DIR__), "deps")
75+
const libfasttransforms = Libdl.find_library("libfasttransforms", [lft_directiory])
76+
if libfasttransforms === nothing || length(libfasttransforms) == 0
77+
print_error()
8978
end

src/libfasttransforms.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const libfasttransforms = joinpath(dirname(@__DIR__), "deps", "libfasttransforms")
1+
const lft_directiory = joinpath(dirname(@__DIR__), "deps")
2+
const libfasttransforms = find_library("libfasttransforms", [lft_directiory])
23

3-
if !(find_library(libfasttransforms) libfasttransforms)
4+
if libfasttransforms === nothing || length(libfasttransforms) == 0
45
error("FastTransforms is not properly installed. Please run Pkg.build(\"FastTransforms\") ",
56
"and restart Julia.")
67
end

0 commit comments

Comments
 (0)