cabal-version:   3.0
name:            kempe
version:         0.1.0.0
license:         BSD-3-Clause
license-file:    LICENSE
copyright:       Copyright: (c) 2020 Vanessa McHale
maintainer:      vamchale@gmail.com
author:          Vanessa McHale
synopsis:        Kempe compiler
description:     Kempe is a stack-based language
category:        Language, Compilers
build-type:      Simple
data-files:
    test/data/*.kmp
    prelude/*.kmp
    lib/*.kmp
    docs/manual.pdf

extra-doc-files:
    README.md
    CHANGELOG.md

source-repository head
    type:     git
    location: https://github.com/vmchale/kempe

flag cross
    description: Enable to ease cross-compiling
    default:     False
    manual:      True

library kempe-modules
    exposed-modules:
        Kempe.Lexer
        Kempe.Parser
        Kempe.AST
        Kempe.TyAssign
        Kempe.File
        Kempe.Monomorphize
        Kempe.Pipeline
        Kempe.Shuttle
        Kempe.Inline
        Kempe.IR
        Kempe.IR.Opt
        Kempe.Asm.X86
        Kempe.Asm.X86.ControlFlow
        Kempe.Asm.X86.Liveness
        Kempe.Asm.X86.Linear

    hs-source-dirs:   src
    other-modules:
        Kempe.Unique
        Kempe.Name
        Kempe.Error
        Kempe.Asm.X86.Type
        Kempe.Proc.Nasm
        Prettyprinter.Ext
        Data.Bifunctor.Ext
        Data.Foldable.Ext

    default-language: Haskell2010
    other-extensions:
        DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable
        FlexibleContexts GeneralizedNewtypeDeriving OverloadedStrings
        StandaloneDeriving TupleSections DeriveAnyClass

    ghc-options:      -Wall -O2
    build-depends:
        base >=4.11 && <5,
        array -any,
        bytestring -any,
        containers -any,
        deepseq -any,
        text -any,
        mtl -any,
        microlens -any,
        transformers -any,
        extra -any,
        prettyprinter >=1.7.0,
        composition-prelude >=1.1.0.1,
        microlens-mtl -any,
        process >=1.2.3.0,
        temporary -any

    if !flag(cross)
        build-tool-depends: alex:alex -any, happy:happy -any

    if impl(ghc >=8.0)
        ghc-options:
            -Wincomplete-uni-patterns -Wincomplete-record-updates
            -Wredundant-constraints -Widentities

    if impl(ghc >=8.4)
        ghc-options: -Wmissing-export-lists

    if impl(ghc >=8.2)
        ghc-options: -Wcpp-undef

    if impl(ghc >=8.10)
        ghc-options: -Wunused-packages

executable kc
    main-is:          Main.hs
    hs-source-dirs:   run
    other-modules:    Paths_kempe
    autogen-modules:  Paths_kempe
    default-language: Haskell2010
    ghc-options:      -Wall
    build-depends:
        base -any,
        optparse-applicative -any,
        kempe-modules -any

    if impl(ghc >=8.0)
        ghc-options:
            -Wincomplete-uni-patterns -Wincomplete-record-updates
            -Wredundant-constraints -Widentities

    if impl(ghc >=8.4)
        ghc-options: -Wmissing-export-lists

    if impl(ghc >=8.2)
        ghc-options: -Wcpp-undef

    if impl(ghc >=8.10)
        ghc-options: -Wunused-packages

test-suite kempe-test
    type:             exitcode-stdio-1.0
    main-is:          Spec.hs
    hs-source-dirs:   test
    other-modules:
        Parser
        Type
        Backend

    default-language: Haskell2010
    ghc-options:      -threaded -rtsopts "-with-rtsopts=-N -K1K" -Wall
    build-depends:
        base -any,
        kempe-modules -any,
        tasty -any,
        tasty-hunit -any,
        bytestring -any,
        prettyprinter >=1.7.0,
        deepseq -any

    if impl(ghc >=8.0)
        ghc-options:
            -Wincomplete-uni-patterns -Wincomplete-record-updates
            -Wredundant-constraints -Widentities

    if impl(ghc >=8.4)
        ghc-options: -Wmissing-export-lists

    if impl(ghc >=8.2)
        ghc-options: -Wcpp-undef

    if impl(ghc >=8.10)
        ghc-options: -Wunused-packages

test-suite kempe-golden
    type:             exitcode-stdio-1.0
    main-is:          Golden.hs
    hs-source-dirs:   test
    other-modules:    Harness
    default-language: Haskell2010
    ghc-options:      -threaded -rtsopts "-with-rtsopts=-N -K1K" -Wall
    build-depends:
        base -any,
        kempe-modules -any,
        tasty -any,
        bytestring -any,
        process -any,
        temporary -any,
        filepath -any,
        tasty-golden -any

    if impl(ghc >=8.0)
        ghc-options:
            -Wincomplete-uni-patterns -Wincomplete-record-updates
            -Wredundant-constraints -Widentities

    if impl(ghc >=8.4)
        ghc-options: -Wmissing-export-lists

    if impl(ghc >=8.2)
        ghc-options: -Wcpp-undef

    if impl(ghc >=8.10)
        ghc-options: -Wunused-packages

benchmark kempe-bench
    type:             exitcode-stdio-1.0
    main-is:          Bench.hs
    hs-source-dirs:   bench
    default-language: Haskell2010
    ghc-options:      -O3 -Wall
    build-depends:
        base -any,
        kempe-modules -any,
        bytestring -any,
        criterion -any,
        prettyprinter -any,
        text -any

    if impl(ghc >=8.0)
        ghc-options:
            -Wincomplete-uni-patterns -Wincomplete-record-updates
            -Wredundant-constraints -Widentities

    if impl(ghc >=8.4)
        ghc-options: -Wmissing-export-lists

    if impl(ghc >=8.2)
        ghc-options: -Wcpp-undef

    if impl(ghc >=8.10)
        ghc-options: -Wunused-packages