|
1 | 1 | using BinaryProvider
|
2 | 2 | import Libdl
|
3 | 3 |
|
4 |
| -version = "0.2.7" |
| 4 | +version = v"0.2.8" |
5 | 5 |
|
6 | 6 | if arch(platform_key_abi()) != :x86_64
|
7 | 7 | @warn "FastTransforms has only been tested on x86_64 architectures."
|
8 | 8 | end
|
9 |
| -if !Sys.islinux() && !Sys.isapple() |
10 |
| - error("Sorry ... unsupported OS. Feel free to file a PR to add support.") |
11 |
| -end |
12 | 9 |
|
13 |
| -const extension = Sys.isapple() ? "dylib" : "so" |
| 10 | +const extension = Sys.isapple() ? "dylib" : Sys.islinux() ? "so" : Sys.iswindows() ? "dll" : "" |
| 11 | + |
14 | 12 | 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@8 fftw mpfr\n" |
| 13 | + "FastTransforms could not be properly installed.\n Please check that you have all dependencies installed. " * |
| 14 | + "Sample installation of dependencies:\n" * |
| 15 | + print_platform_error(platform_key_abi()) |
21 | 16 | )
|
22 | 17 |
|
| 18 | +print_platform_error(p::Platform) = "On $(BinaryProvider.platform_name(p)), please consider opening a pull request to add support.\n" |
| 19 | +print_platform_error(::MacOS) = "On MacOS\n\tbrew install gcc@8 fftw mpfr\n" |
| 20 | +print_plaftorm_error(::Linux) = "On Linux\n\tsudo apt-get install gcc-8 libblas-dev libopenblas-base libfftw3-dev libmpfr-dev\n" |
| 21 | +print_plaftorm_error(::Windows) = "On Windows\n\tvcpkg install openblas:x64-windows fftw3[core,threads]:x64-windows mpir:x64-windows mpfr:x64-windows\n" |
| 22 | + |
23 | 23 | # Rationale is as follows: The build is pretty fast, so on Linux it is typically easiest
|
24 | 24 | # to just use the gcc of the system to build the library and include it. On MacOS, however,
|
25 | 25 | # we need to actually install a gcc first, because Apple's OS comes only shipped with clang,
|
26 | 26 | # so here we download the binary.
|
27 | 27 | ft_build_from_source = get(ENV, "FT_BUILD_FROM_SOURCE", Sys.isapple() ? "false" : "true")
|
28 | 28 | if ft_build_from_source == "true"
|
29 |
| - println("Building from source.") |
30 |
| - |
31 |
| - extra = Sys.isapple() ? "FT_USE_APPLEBLAS=1" : "" |
| 29 | + extra = Sys.isapple() ? "FT_USE_APPLEBLAS=1" : Sys.iswindows() ? "FT_FFTW_WITH_COMBINED_THREADS=1" : "" |
| 30 | + compiler = Sys.isapple() ? "CC=gcc-8" : "CC=gcc" |
32 | 31 | script = """
|
33 | 32 | set -e
|
34 | 33 | set -x
|
35 |
| -
|
36 | 34 | if [ -d "FastTransforms" ]; then
|
37 | 35 | cd FastTransforms
|
38 | 36 | git fetch
|
39 |
| - git reset --hard |
40 |
| - git checkout -b v$version |
| 37 | + git checkout v$version |
41 | 38 | cd ..
|
42 | 39 | else
|
43 | 40 | git clone -b v$version https://github.com/MikaelSlevinsky/FastTransforms.git FastTransforms
|
44 | 41 | fi
|
45 |
| - ln -sf FastTransforms/libfasttransforms.$extension libfasttransforms.$extension |
46 |
| -
|
47 |
| - echo |
48 |
| - echo |
49 |
| -
|
50 | 42 | cd FastTransforms
|
51 |
| - make clean |
52 |
| - make lib $extra |
| 43 | + make lib $compiler $extra |
| 44 | + cd .. |
| 45 | + mv -f FastTransforms/libfasttransforms.$extension libfasttransforms.$extension |
53 | 46 | """
|
54 |
| - |
55 | 47 | try
|
56 | 48 | run(`/bin/bash -c $(script)`)
|
57 |
| - catch IOError |
| 49 | + catch |
58 | 50 | print_error()
|
59 | 51 | end
|
| 52 | + println("FastTransforms built from source.") |
60 | 53 | else
|
61 |
| - println("Installing by downloading binaries.") |
62 |
| - |
63 | 54 | const GCC = BinaryProvider.detect_compiler_abi().gcc_version
|
64 | 55 | namemap = Dict(:gcc4 => "gcc-4.9", :gcc5 => "gcc-5", :gcc6 => "gcc-6",
|
65 | 56 | :gcc7 => "gcc-7", :gcc8 => "gcc-8", :gcc9 => "gcc-9")
|
66 | 57 | if !(GCC in keys(namemap))
|
67 | 58 | error("Please ensure you have a version of gcc from gcc-4.9 to gcc-9.")
|
68 | 59 | 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() |
| 60 | + try |
| 61 | + download("https://github.com/MikaelSlevinsky/FastTransforms/releases/download/" * |
| 62 | + "v$version/libfasttransforms.v$version.$(namemap[GCC]).$extension", |
| 63 | + joinpath(dirname(@__DIR__), "deps", "libfasttransforms.$extension")) |
| 64 | + catch |
| 65 | + print_error() |
| 66 | + end |
| 67 | + println("FastTransforms installed by downloading binaries.") |
78 | 68 | end
|
0 commit comments