cabal-version:  2.2

name:           hw-json-simd
version:        0.1.0.0
synopsis:       SIMD-based JSON semi-indexer
description:    Please see the README on GitHub at <https://github.com/haskell-works/hw-json-simd#readme>
category:       Data
homepage:       https://github.com/haskell-works/hw-json-simd#readme
bug-reports:    https://github.com/haskell-works/hw-json-simd/issues
author:         John Ky
maintainer:     newhoggy@gmail.com
copyright:      2018 - 2019 John Ky
license:        BSD-3-Clause
license-file:   LICENSE
build-type:     Simple
tested-with:    GHC == 8.6.1, GHC == 8.4.3, GHC == 8.2.2
extra-source-files:
    cbits/debug.h
    cbits/simd.h
    cbits/simd.c
    cbits/simd-spliced.c
    cbits/simd-state.c
    cbits/simd-phi-table-32.c
    cbits/simd-transition-table-32.c
    README.md
    ChangeLog.md

source-repository head
  type: git
  location: https://github.com/haskell-works/hw-json-simd

flag avx2
  description: Enable avx2 instruction set
  manual: False
  default: False

flag bmi2
  description: Enable bmi2 instruction set
  manual: False
  default: False

flag sse42
  description: Enable SSE 4.2 optimisations.
  manual: False
  default: True

common base                   { build-depends: base                 >= 4          && < 5      }
common bytestring             { build-depends: bytestring           >= 0.10.6     && < 0.11   }
common hw-prim                { build-depends: hw-prim              >= 0.6.2.21   && < 0.7    }
common lens                   { build-depends: lens                 >= 4          && < 5      }
common optparse-applicative   { build-depends: optparse-applicative >= 0.14       && < 0.15   }
common vector                 { build-depends: vector               >= 0.12       && < 0.13   }

common semigroups     { if (!impl(ghc >=8.0.1)) { build-depends: { semigroups   >= 0.8.4  && < 0.19 } } }
common transformers   { if (!impl(ghc >=8.0.1)) { build-depends: { transformers >= 0.4    && < 0.6  } } }

library
  import:   base
          , bytestring
          , hw-prim
          , lens
          , vector
  exposed-modules:
      HaskellWorks.Data.Json.Simd.Capabilities
      HaskellWorks.Data.Json.Simd.Index.Simple
      HaskellWorks.Data.Json.Simd.Index.Standard
      HaskellWorks.Data.Json.Simd.Internal.Foreign
      HaskellWorks.Data.Json.Simd.Internal.Index.Simple
      HaskellWorks.Data.Json.Simd.Internal.Index.Standard
      HaskellWorks.Data.Json.Simd.Internal.List
  autogen-modules:  Paths_hw_json_simd
  other-modules:    Paths_hw_json_simd
  hs-source-dirs:
      src
  ghc-options: -Wall
  cc-options: -mssse3 -mlzcnt -mbmi2 -mavx2
  include-dirs:
      cbits
  c-sources:
      cbits/debug.c
      cbits/simd.c
      cbits/simd-spliced.c
      cbits/simd-state.c
      cbits/simd-phi-table-32.c
      cbits/simd-transition-table-32.c
  build-tools:
      c2hs
  if flag(sse42)
    ghc-options: -msse4.2
    cc-options: -msse4.2
  if flag(bmi2)
    cc-options: -mbmi2
  if (flag(bmi2)) && (impl(ghc >=8.4.1))
    ghc-options: -mbmi2 -msse4.2
  if flag(avx2)
    cc-options: -mavx2
  if (flag(avx2)) && (impl(ghc >=8.4.1))
    ghc-options: -mbmi2 -msse4.2
  if (impl(ghc >=8.0.1))
    ghc-options: -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
  default-language: Haskell2010

executable hw-json-simd
  import:   base
          , bytestring
          , hw-prim
          , lens
          , optparse-applicative
          , semigroups
          , vector
  main-is: Main.hs
  autogen-modules:  Paths_hw_json_simd
  other-modules:
      App.Commands
      App.Commands.Capabilities
      App.Commands.CreateIndex
      App.Commands.Types
      App.Lens
      Paths_hw_json_simd
  hs-source-dirs:   app
  ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
  build-depends: hw-json-simd
  if flag(sse42)
    ghc-options: -msse4.2
    cc-options: -msse4.2
  if flag(bmi2)
    cc-options: -mbmi2
  if (flag(bmi2)) && (impl(ghc >=8.4.1))
    ghc-options: -mbmi2 -msse4.2
  if flag(avx2)
    cc-options: -mavx2
  if (flag(avx2)) && (impl(ghc >=8.4.1))
    ghc-options: -mbmi2 -msse4.2
  if (impl(ghc >=8.0.1))
    ghc-options: -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
  default-language: Haskell2010

test-suite hw-json-simd-test
  import:   base
          , bytestring
          , hw-prim
          , lens
          , vector
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  autogen-modules:  Paths_hw_json_simd
  other-modules:    Paths_hw_json_simd
  hs-source-dirs:   test
  ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
  build-depends: hw-json-simd
  if flag(sse42)
    ghc-options: -msse4.2
    cc-options: -msse4.2
  if flag(bmi2)
    cc-options: -mbmi2
  if (flag(bmi2)) && (impl(ghc >=8.4.1))
    ghc-options: -mbmi2 -msse4.2
  if flag(avx2)
    cc-options: -mavx2
  if (flag(avx2)) && (impl(ghc >=8.4.1))
    ghc-options: -mbmi2 -msse4.2
  if (impl(ghc >=8.0.1))
    ghc-options: -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
  if (!impl(ghc >=8.0.1))
    build-depends:
        semigroups >=0.8.4 && <0.19
      , transformers >=0.4 && <0.6
  default-language: Haskell2010