name:                clr-host
version:             0.1.0.0
synopsis:            Hosting the Common Language Runtime
description:         clr-host is a library that provides the ability to host (also known as embed) the
                     common language runtime within the current Haskell process. Generally you'll only
                     interface directly to this library to start the CLR, and the other code here is
                     for higher level abstractions to use.
homepage:            https://gitlab.com/tim-m89/clr-haskell/tree/master/libs/clr-host
bug-reports:         https://gitlab.com/tim-m89/clr-haskell/issues 
license:             BSD3
license-file:        LICENSE
author:              Tim Matthews
maintainer:          tim.matthews7@gmail.com
copyright:           2016-2017 Tim Matthews
category:            Language, FFI, CLR, .NET
build-type:          Custom
extra-source-files:  src/Driver.cs
extra-tmp-files:     src/Driver.dll
cabal-version:       >=1.24

source-repository head
    type:            git
    location:        https://gitlab.com/tim-m89/clr-haskell/tree/master

flag enable_dotnet
  description: build with .Net support
  default: False

flag enable_mono
  description: build with mono support
  default: False

-- Deps for running the setup itself (compilation of the C# code).
custom-setup
  setup-depends:       base, directory, filepath, Cabal, transformers

library
  hs-source-dirs:      src
  c-sources:           src/clrHost.c, src/dotNetHost.c
  default-language:    Haskell2010
  -- Common modules
  exposed-modules:     Clr.Host
                     , Clr.Host.Config
                     , Clr.Host.BStr
  other-modules:       Clr.Host.Driver
                     , Clr.Host.BStr.Type
  -- Common build deps
  build-depends:       base >= 4.7 && < 5, bytestring, file-embed
  -- Windows extra build deps
  if os(windows)
    build-depends:       Win32
  -- .Net specific options
  if flag(enable_dotnet)
    Cpp-options:         -DHAVE_DOTNET
    cc-options:          -DHAVE_DOTNET
    other-modules:       Clr.Host.BStr.DotNet
                       , Clr.Host.DotNet
                       , Clr.Host.DotNet.Common
                       , Clr.Host.DotNet.Guid
                       , Clr.Host.DotNet.SafeArray
                       , Clr.Host.DotNet.Variant
    Extra-Libraries:     oleaut32, ole32
  -- Mono specific options
  if flag(enable_mono)
    Cpp-options:         -DHAVE_MONO
    cc-options:          -DHAVE_MONO
    other-modules:       Clr.Host.BStr.Mono
                       , Clr.Host.Mono
    Extra-Libraries:     glib-2.0, mono-2.0
  -- If neither .Net / Mono chosen, default to .Net on Windows and Mono otherwise.
  if !flag(enable_dotnet) && !flag(enable_mono)
    if os(windows)
      Cpp-options:         -DHAVE_DOTNET
      cc-options:          -DHAVE_DOTNET
      other-modules:       Clr.Host.BStr.DotNet
                         , Clr.Host.DotNet
                         , Clr.Host.DotNet.Common
                         , Clr.Host.DotNet.Guid
                         , Clr.Host.DotNet.SafeArray
                         , Clr.Host.DotNet.Variant
      Extra-Libraries:     oleaut32, ole32
    else
      Cpp-options:         -DHAVE_MONO
      cc-options:          -DHAVE_MONO
      other-modules:       Clr.Host.BStr.Mono
                         , Clr.Host.Mono
      Extra-Libraries:     glib-2.0, mono-2.0


test-suite clr-host-test
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  main-is:             Spec.hs
  build-depends:       base
                     , clr-host
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  default-language:    Haskell2010

source-repository head
  type:     git
  location: https://gitlab.com/tim-m89/clr-host