Skip to content

Commit 38dcf76

Browse files
dmjiochessai
authored andcommitted
Add .travis.yml
- use haskell-ci - download arrayfire installer and unpack to /opt/arrayfire/ - remove Ord tests from test suite - use shouldBeEps for comparing Array Double nix updates - change shellHooks to use runhaskell instead of cabal-v1 - extend LD_LIBRARY_PATH to include $AF_LIB - ghcid shellHook uses -fno-nocode - get tests to build and _almost_ pass
1 parent c4e4aca commit 38dcf76

13 files changed

+310
-198
lines changed

Diff for: .travis.yml

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# This Travis job script has been generated by a script via
2+
#
3+
# haskell-ci 'travis' 'arrayfire.cabal'
4+
#
5+
# For more information, see https://github.com/haskell-CI/haskell-ci
6+
#
7+
# version: 0.3.20190814
8+
#
9+
language: c
10+
dist: xenial
11+
sudo: required
12+
git:
13+
# whether to recursively clone submodules
14+
submodules: false
15+
cache:
16+
directories:
17+
- $HOME/.cabal/packages
18+
- $HOME/.cabal/store
19+
before_cache:
20+
- rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
21+
# remove files that are regenerated by 'cabal update'
22+
- rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*
23+
- rm -fv $CABALHOME/packages/hackage.haskell.org/*.json
24+
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache
25+
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
26+
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
27+
- rm -rfv $CABALHOME/packages/head.hackage
28+
matrix:
29+
include:
30+
- compiler: ghc-8.8.1
31+
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}
32+
- compiler: ghc-8.6.5
33+
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4"]}}
34+
- compiler: ghc-8.4.4
35+
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4"]}}
36+
before_install:
37+
- HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
38+
- WITHCOMPILER="-w $HC"
39+
- HCPKG="$HC-pkg"
40+
- unset CC
41+
- CABAL=/opt/ghc/bin/cabal
42+
- CABALHOME=$HOME/.cabal
43+
- export PATH="$CABALHOME/bin:$PATH"
44+
- export LD_LIBRARY_PATH="/opt/arrayfire/lib64:$LD_LIBRARY_PATH"
45+
- TOP=$(pwd)
46+
- "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
47+
- echo $HCNUMVER
48+
- CABAL="$CABAL -vnormal+nowrap+markoutput"
49+
- set -o pipefail
50+
- |
51+
echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
52+
echo 'BEGIN { state = "output"; }' >> .colorful.awk
53+
echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
54+
echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
55+
echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
56+
echo ' if (state == "cabal") {' >> .colorful.awk
57+
echo ' print blue($0)' >> .colorful.awk
58+
echo ' } else {' >> .colorful.awk
59+
echo ' print $0' >> .colorful.awk
60+
echo ' }' >> .colorful.awk
61+
echo '}' >> .colorful.awk
62+
- cat .colorful.awk
63+
- |
64+
color_cabal_output () {
65+
awk -f $TOP/.colorful.awk
66+
}
67+
- echo text | color_cabal_output
68+
install:
69+
- echo "Downloading ArrayFire-3.6.4"
70+
- curl -O http://arrayfire.s3.amazonaws.com/3.6.4/ArrayFire-v3.6.4_Linux_x86_64.sh
71+
- chmod +x ArrayFire-v3.6.4_Linux_x86_64.sh
72+
- ./ArrayFire-v3.6.4_Linux_x86_64.sh --include-subdir --prefix=/opt
73+
- ls -lah /opt/arrayfire/
74+
- ${CABAL} --version
75+
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
76+
- TEST=--enable-tests
77+
- BENCH=--enable-benchmarks
78+
- HEADHACKAGE=false
79+
- rm -f $CABALHOME/config
80+
- |
81+
echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
82+
echo "remote-build-reporting: anonymous" >> $CABALHOME/config
83+
echo "write-ghc-environment-files: always" >> $CABALHOME/config
84+
echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
85+
echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
86+
echo "world-file: $CABALHOME/world" >> $CABALHOME/config
87+
echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
88+
echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
89+
echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
90+
echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
91+
echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
92+
echo "install-dirs user" >> $CABALHOME/config
93+
echo " prefix: $CABALHOME" >> $CABALHOME/config
94+
echo "repository hackage.haskell.org" >> $CABALHOME/config
95+
echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
96+
- cat $CABALHOME/config
97+
- rm -fv cabal.project cabal.project.local cabal.project.freeze
98+
- travis_retry ${CABAL} v2-update -v
99+
# Generate cabal.project
100+
- rm -rf cabal.project cabal.project.local cabal.project.freeze
101+
- touch cabal.project
102+
- |
103+
echo "packages: ." >> cabal.project
104+
- |
105+
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(arrayfire)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
106+
- cat cabal.project || true
107+
- cat cabal.project.local || true
108+
- ${CABAL} install $WITHCOMPILER hspec-discover | color_cabal_output # needed on $PATH for tests
109+
- if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
110+
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output
111+
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
112+
- rm cabal.project.freeze
113+
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output
114+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all | color_cabal_output
115+
script:
116+
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
117+
# Packaging...
118+
- ${CABAL} v2-sdist all | color_cabal_output
119+
# Unpacking...
120+
- mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
121+
- cd ${DISTDIR} || false
122+
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;
123+
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
124+
- PKGDIR_arrayfire="$(find . -maxdepth 1 -type d -regex '.*/arrayfire-[0-9.]*')"
125+
# Generate cabal.project
126+
- rm -rf cabal.project cabal.project.local cabal.project.freeze
127+
- touch cabal.project
128+
- |
129+
echo "packages: ${PKGDIR_arrayfire}" >> cabal.project
130+
- |
131+
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(arrayfire)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
132+
- cat cabal.project || true
133+
- cat cabal.project.local || true
134+
# Building...
135+
# this builds all libraries and executables (without tests/benchmarks)
136+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
137+
# Building with tests and benchmarks...
138+
# build & run tests, build benchmarks
139+
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
140+
# Testing...
141+
- ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
142+
# cabal check...
143+
- (cd ${PKGDIR_arrayfire} && ${CABAL} -vnormal check)
144+
# haddock...
145+
- ${CABAL} v2-haddock $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
146+
# Building without installed constraints for packages in global-db...
147+
- rm -f cabal.project.local
148+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
149+
150+
# REGENDATA ["travis","arrayfire.cabal"]
151+
# EOF

Diff for: Setup.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Main where
22

3-
import Distribution.Extra.Doctest (defaultMainWithDoctests)
3+
import Distribution.Simple
44

55
main :: IO ()
6-
main = defaultMainWithDoctests "doctests"
6+
main = defaultMain

Diff for: arrayfire.cabal

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: arrayfire
2-
version: 0.3.0.0
2+
version: 0.4.0.0
33
synopsis: Haskell bindings to the ArrayFire general-purpose GPU library
44
homepage: https://github.com/arrayfire/arrayfire-haskell
55
license: BSD3
@@ -8,25 +8,20 @@ author: David Johnson
88
maintainer: [email protected]
99
copyright: David Johnson (c) 2018-2020
1010
category: Math
11-
build-type: Custom
11+
build-type: Simple
1212
extra-source-files: CHANGELOG.md
1313
cabal-version: >=1.10
1414
description: High-level Haskell bindings to the ArrayFire General-purpose GPU library
1515
.
1616
<<https://user-images.githubusercontent.com/875324/59819388-9ff83f00-92f5-11e9-9ac0-51eef200c716.png>>
1717
.
18+
tested-with: GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.1
1819

1920
flag disable-default-paths
2021
description: When enabled, don't add default hardcoded include/link dirs by default. Needed for hermetic builds like in nix.
2122
default: False
2223
manual: True
2324

24-
custom-setup
25-
setup-depends:
26-
base <5,
27-
Cabal,
28-
cabal-doctest >=1 && <1.1
29-
3025
library
3126
exposed-modules:
3227
ArrayFire
@@ -94,9 +89,8 @@ library
9489
include-dirs:
9590
/opt/arrayfire/include
9691
extra-lib-dirs:
92+
/opt/arrayfire/lib64
9793
/opt/arrayfire/lib
98-
ld-options:
99-
-Wl,-rpath /opt/arrayfire/lib
10094

10195
executable main
10296
hs-source-dirs:

Diff for: default.nix

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1-
{ pkgs ? import <nixpkgs> { config.allowUnfree = true; } }:
2-
# Latest arrayfire is not yet procured w/ nix.
3-
let
4-
pkg = pkgs.haskellPackages.callCabal2nix "arrayfire" ./. {
5-
af = null;
6-
quickcheck-classes = pkgs.haskellPackages.quickcheck-classes_0_6_4_0;
1+
{ pkgs ? import ./nix/nixpkgs.nix
2+
, compiler ? "ghc865"
3+
}:
4+
5+
with pkgs;
6+
7+
with rec {
8+
hsPkgs = haskell.packages.${compiler}.override {
9+
overrides = hself: hsuper: {
10+
arrayfire = hsLib.overrideCabal (hself.callPackage ./pkg.nix { af = pkgs.arrayfire; }) (old: {
11+
configureFlags = (old.configureFlags or []) ++ [
12+
"-f+disable-default-paths"
13+
"--extra-include-dirs=${arrayfire}/include"
14+
"--extra-lib-dirs=${arrayfire}/lib"
15+
];
16+
17+
doCheck = true;
18+
doHaddock = false;
19+
});
20+
};
721
};
8-
in
9-
pkg
22+
23+
hsLib = haskell.lib;
24+
};
25+
26+
rec {
27+
inherit compiler pkgs hsPkgs;
28+
}

Diff for: nix/default.nix

-79
This file was deleted.

Diff for: nix/nixpkgs.nix

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
with {
2+
rev = "9fe4e068123146afda5f2b9a6d630ba76d1daff5";
3+
sha256 = "1fwjf3gvhinzs9yvp7dh3im0123lbzhfrg371ingp61n7jkb73c9";
4+
5+
config = {
6+
allowUnfree = true;
7+
};
8+
9+
overlays = [];
10+
};
11+
12+
import (builtins.fetchTarball {
13+
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
14+
inherit sha256;
15+
}) { inherit config overlays; }

Diff for: nix/no-download.patch

-28
This file was deleted.

Diff for: pkg.nix

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
{ mkDerivation, base, directory, parsec, stdenv, text, vector
2-
, hspec, hspec-discover
1+
{ mkDerivation, af, base, directory, filepath, hspec
2+
, hspec-discover, parsec, QuickCheck, quickcheck-classes, stdenv
3+
, text, vector
34
}:
45
mkDerivation {
56
pname = "arrayfire";
6-
version = "0.3.0.0";
7+
version = "0.4.0.0";
78
src = ./.;
89
isLibrary = true;
910
isExecutable = true;
10-
libraryHaskellDepends = [ base vector ];
11-
executableHaskellDepends = [ base directory parsec text ];
12-
testHaskellDepends = [ hspec hspec-discover ];
11+
libraryHaskellDepends = [ base filepath vector ];
12+
librarySystemDepends = [ af ];
13+
executableHaskellDepends = [ base directory parsec text vector ];
14+
testHaskellDepends = [
15+
base directory hspec hspec-discover QuickCheck quickcheck-classes
16+
vector
17+
];
18+
testToolDepends = [ hspec-discover ];
1319
homepage = "https://github.com/arrayfire/arrayfire-haskell";
14-
description = "Haskell bindings to ArrayFire";
20+
description = "Haskell bindings to the ArrayFire general-purpose GPU library";
1521
license = stdenv.lib.licenses.bsd3;
1622
}

0 commit comments

Comments
 (0)