Skip to content

Commit 2ef919f

Browse files
committed
Support GHC-8.4
1 parent b0df4a9 commit 2ef919f

22 files changed

+143
-72
lines changed

.travis.yml

+77-40
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# This Travis job script has been generated by a script via
22
#
3-
# make_travis_yml_2.hs './usb.cabal'
3+
# runghc make_travis_yml_2.hs './usb.cabal'
44
#
55
# For more information, see https://github.com/hvr/multi-ghc-travis
66
#
77
language: c
88
sudo: false
9-
dist: trusty # Contains libusb-1.0.17
109

1110
git:
1211
submodules: false # whether to recursively clone submodules
@@ -25,82 +24,120 @@ before_cache:
2524
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
2625
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
2726

27+
- rm -rfv $HOME/.cabal/packages/head.hackage
28+
2829
matrix:
2930
include:
3031
- compiler: "ghc-7.4.1"
32+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
3133
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.4.1], sources: [hvr-ghc]}}
3234
- compiler: "ghc-7.4.2"
35+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
3336
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.4.2], sources: [hvr-ghc]}}
3437
- compiler: "ghc-7.6.1"
38+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
3539
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.6.1], sources: [hvr-ghc]}}
3640
- compiler: "ghc-7.6.2"
41+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
3742
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.6.2], sources: [hvr-ghc]}}
3843
- compiler: "ghc-7.6.3"
44+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
3945
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.6.3], sources: [hvr-ghc]}}
4046
- compiler: "ghc-7.8.1"
47+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
4148
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.8.1], sources: [hvr-ghc]}}
4249
- compiler: "ghc-7.8.2"
50+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
4351
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.8.2], sources: [hvr-ghc]}}
4452
- compiler: "ghc-7.8.3"
53+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
4554
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.8.3], sources: [hvr-ghc]}}
4655
- compiler: "ghc-7.8.4"
56+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
4757
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}}
4858
- compiler: "ghc-7.10.1"
59+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
4960
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.10.1], sources: [hvr-ghc]}}
5061
- compiler: "ghc-7.10.2"
62+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
5163
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.10.2], sources: [hvr-ghc]}}
5264
- compiler: "ghc-7.10.3"
65+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
5366
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}
5467
- compiler: "ghc-8.0.1"
68+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
5569
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-8.0.1], sources: [hvr-ghc]}}
5670
- compiler: "ghc-8.0.2"
71+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
5772
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
58-
- compiler: "ghc-head"
59-
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-head], sources: [hvr-ghc]}}
60-
61-
allow_failures:
62-
- compiler: "ghc-head"
73+
- compiler: "ghc-8.2.1"
74+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
75+
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
76+
- compiler: "ghc-8.2.2"
77+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
78+
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}}
79+
- compiler: "ghc-8.4.1"
80+
# env: TEST=--disable-tests BENCH=--disable-benchmarks
81+
addons: {apt: {packages: [libusb-1.0-0-dev,ghc-ppa-tools,cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}}
6382

6483
before_install:
65-
- HC=${CC}
66-
- unset CC
67-
- PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
68-
- PKGNAME='usb'
84+
- HC=${CC}
85+
- HCPKG=${HC/ghc/ghc-pkg}
86+
- unset CC
87+
- ROOTDIR=$(pwd)
88+
- mkdir -p $HOME/.local/bin
89+
- "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
90+
- HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
91+
- echo $HCNUMVER
6992

7093
install:
71-
- cabal --version
72-
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
73-
- BENCH=${BENCH---enable-benchmarks}
74-
- TEST=${TEST---enable-tests}
75-
- travis_retry cabal update -v
76-
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
77-
- rm -fv cabal.project.local
78-
- "echo 'packages: .' > cabal.project"
79-
- rm -f cabal.project.freeze
80-
- cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
81-
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all
94+
- cabal --version
95+
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
96+
- BENCH=${BENCH---enable-benchmarks}
97+
- TEST=${TEST---enable-tests}
98+
- HADDOCK=${HADDOCK-true}
99+
- INSTALLED=${INSTALLED-true}
100+
- GHCHEAD=${GHCHEAD-false}
101+
- travis_retry cabal update -v
102+
- "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
103+
- rm -fv cabal.project cabal.project.local
104+
- grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
105+
- "printf 'packages: \".\"\\n' > cabal.project"
106+
- cat cabal.project
107+
- if [ -f "./configure.ac" ]; then
108+
(cd "." && autoreconf -i);
109+
fi
110+
- rm -f cabal.project.freeze
111+
- cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
112+
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
113+
- rm -rf .ghc.environment.* "."/dist
114+
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
82115

83116
# Here starts the actual work to be performed for the package under test;
84117
# any command which exits with a non-zero exit code causes the build to fail.
85118
script:
86-
- if [ -f configure.ac ]; then autoreconf -i; fi
87-
- rm -rf .ghc.environment.* dist/
88-
- cabal sdist # test that a source-distribution can be generated
89-
- cd dist/
90-
- SRCTAR=(${PKGNAME}-*.tar.gz)
91-
- SRC_BASENAME="${SRCTAR/%.tar.gz}"
92-
- tar -xvf "./$SRC_BASENAME.tar.gz"
93-
- cd "$SRC_BASENAME/"
94-
## from here on, CWD is inside the extracted source-tarball
95-
- rm -fv cabal.project.local
96-
- "echo 'packages: .' > cabal.project"
97-
# this builds all libraries and executables (without tests/benchmarks)
98-
- rm -f cabal.project.freeze
99-
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
100-
# this builds all libraries and executables (including tests/benchmarks)
101-
# - rm -rf ./dist-newstyle
119+
# test that source-distributions can be generated
120+
- (cd "." && cabal sdist)
121+
- mv "."/dist/usb-*.tar.gz ${DISTDIR}/
122+
- cd ${DISTDIR} || false
123+
- find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
124+
- "printf 'packages: usb-*/*.cabal\\n' > cabal.project"
125+
- cat cabal.project
126+
# this builds all libraries and executables (without tests/benchmarks)
127+
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
128+
129+
# Build with installed constraints for packages in global-db
130+
- if $INSTALLED; then echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh; else echo "Not building with installed constraints"; fi
131+
132+
# build & run tests, build benchmarks
133+
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
134+
135+
# cabal check
136+
- (cd usb-* && cabal check)
102137

103-
# build & run tests
104-
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
138+
# haddock
139+
- rm -rf ./dist-newstyle
140+
- if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
105141

142+
# REGENDATA ["./usb.cabal"]
106143
# EOF

Changelog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.3.0.6 (2018-04-01)
2+
3+
* Support GHC-8.4
4+
5+
16
1.3.0.5 (2017-07-07)
27

38
* Fix segfault in registerHotplugCallback caused by a double-free.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2009–2017 Bas van Dijk
1+
Copyright (c) 2009–2018 Bas van Dijk
22

33
All rights reserved.
44

default.nix

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
let pkgs = import <nixpkgs> {};
2-
in pkgs.haskellPackages.callPackage ./usb.nix {}
1+
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default" }:
2+
3+
let
4+
5+
inherit (nixpkgs) pkgs;
6+
7+
haskellPackages = if compiler == "default"
8+
then pkgs.haskellPackages
9+
else pkgs.haskell.packages.${compiler};
10+
11+
drv = haskellPackages.callPackage (import ./usb.nix) {};
12+
13+
in
14+
15+
if pkgs.lib.inNixShell then drv.env else drv

shell.nix

-15
This file was deleted.

Event.hs src/Event.hs

File renamed without changes.

Poll.hsc src/Poll.hsc

File renamed without changes.

System/USB.hs src/System/USB.hs

File renamed without changes.

System/USB/Base.hs src/System/USB/Base.hs

+23-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ import Data.Function ( ($), (.), on )
4444
import Data.Data ( Data )
4545
import Data.Typeable ( Typeable )
4646
import Data.Maybe ( Maybe(Nothing, Just), maybe, fromMaybe )
47-
import Data.Monoid ( Monoid, mempty, mappend )
47+
import Data.Monoid ( Monoid, mempty
48+
#if !MIN_VERSION_base(4,11,0)
49+
, mappend
50+
#endif
51+
)
52+
#if MIN_VERSION_base(4,9,0)
53+
import Data.Semigroup ( Semigroup, (<>) )
54+
#endif
4855
import Data.List
4956
import Data.Int ( Int )
5057
import Data.Word ( Word8, Word16 )
@@ -714,11 +721,18 @@ getDevices ctx =
714721
-- 'registerHotplugCallback'.
715722
newtype HotplugEvent = HotplugEvent {unHotplugEvent :: C'libusb_hotplug_event}
716723

724+
#if MIN_VERSION_base(4,9,0)
725+
instance Semigroup HotplugEvent where
726+
ev1 <> ev2 = HotplugEvent $ unHotplugEvent ev1 .|. unHotplugEvent ev2
727+
#endif
728+
717729
-- | Use 'mempty' to specify the empty set of events. Use @'mappend' e1 e2@ to
718730
-- join the events in @e1@ and @e2@.
719731
instance Monoid HotplugEvent where
720732
mempty = HotplugEvent 0
733+
#if !MIN_VERSION_base(4,11,0)
721734
ev1 `mappend` ev2 = HotplugEvent $ unHotplugEvent ev1 .|. unHotplugEvent ev2
735+
#endif
722736

723737
-- | A device has been plugged in and is ready to use.
724738
deviceArrived :: HotplugEvent
@@ -748,11 +762,18 @@ isEvent c'ev = \ev -> unHotplugEvent ev .&. c'ev == c'ev
748762
-- | Set of configuration flags for 'registerHotplugCallback'.
749763
newtype HotplugFlag = HotplugFlag {unHotplugFlag :: C'libusb_hotplug_flag}
750764

765+
#if MIN_VERSION_base(4,9,0)
766+
instance Semigroup HotplugFlag where
767+
flg1 <> flg2 = HotplugFlag $ unHotplugFlag flg1 .|. unHotplugFlag flg2
768+
#endif
769+
751770
-- | Use 'mempty' to specify the empty set of flags. Use @'mappend' e1 e2@ to
752771
-- join the flags in @e1@ and @e2@.
753772
instance Monoid HotplugFlag where
754773
mempty = HotplugFlag 0
755-
ev1 `mappend` ev2 = HotplugFlag $ unHotplugFlag ev1 .|. unHotplugFlag ev2
774+
#if !MIN_VERSION_base(4,11,0)
775+
flg1 `mappend` flg2 = HotplugFlag $ unHotplugFlag flg1 .|. unHotplugFlag flg2
776+
#endif
756777

757778
-- | Fire events for all matching currently attached devices.
758779
enumerate :: HotplugFlag
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Utils.hs src/Utils.hs

File renamed without changes.

usb.cabal

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: usb
2-
version: 1.3.0.5
2+
version: 1.3.0.6
33
cabal-version: >=1.6
44
build-type: Simple
55
license: BSD3
@@ -55,9 +55,10 @@ tested-with: GHC == 7.4.1, GHC == 7.4.2,
5555
GHC == 7.8.1, GHC == 7.8.2, GHC == 7.8.3, GHC == 7.8.4
5656
GHC == 7.10.1, GHC == 7.10.2, GHC == 7.10.3
5757
GHC == 8.0.1, GHC == 8.0.2
58-
GHC == 8.3
58+
GHC == 8.2.1, GHC == 8.2.2
59+
GHC == 8.4.1
5960

60-
extra-source-files: README.markdown, Changelog, default.nix, shell.nix
61+
extra-source-files: README.markdown, Changelog
6162

6263
source-repository head
6364
Type: git
@@ -66,11 +67,13 @@ source-repository head
6667
Library
6768
GHC-Options: -Wall
6869

69-
build-depends: base >= 4 && < 4.11
70-
, bindings-libusb >= 1.4.5 && < 1.5
71-
, bytestring >= 0.9 && < 0.11
72-
, text >= 0.5 && < 1.3
73-
, vector >= 0.5 && < 0.13
70+
build-depends: base >= 4 && < 5
71+
, bindings-libusb >= 1.4.5
72+
, bytestring >= 0.9
73+
, text >= 0.5
74+
, vector >= 0.5
75+
76+
hs-source-dirs: src
7477

7578
exposed-modules: System.USB
7679
System.USB.Initialization
@@ -87,8 +90,8 @@ Library
8790
cpp-options: -DHAS_EVENT_MANAGER
8891
exposed-modules: System.USB.IO.Transfers
8992
other-modules: Poll, Event, SystemEventManager
90-
build-depends: containers >= 0.1 && < 0.6
93+
build-depends: containers >= 0.1
9194

9295
if impl(ghc >= 7.2.1)
9396
cpp-options: -DGENERICS
94-
build-depends: ghc-prim >= 0.2 && < 0.6
97+
build-depends: ghc-prim >= 0.2

usb.nix

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
{ mkDerivation, base, bindings-libusb, bytestring, containers
1+
{ mkDerivation, lib, base, bindings-libusb, bytestring, containers
22
, ghc-prim, stdenv, text, vector
33
}:
44
mkDerivation {
55
pname = "usb";
66
version = "HEAD";
7-
src = ./.;
7+
src = lib.sourceByRegex ./. [
8+
"^usb.cabal$"
9+
"^LICENSE$"
10+
"^README.markdown$"
11+
"^Changelog$"
12+
"^src$"
13+
"^src/.*"
14+
];
815
libraryHaskellDepends = [
916
base bindings-libusb bytestring containers ghc-prim text vector
1017
];

0 commit comments

Comments
 (0)