packages feed

nano-ui-sdl-0.1.0.0: nano-ui-sdl.cabal

cabal-version:      3.4
name:               nano-ui-sdl
version:            0.1.0.0
synopsis:           SDL3 window backend for nano-ui
description:
    Runs nano-ui views in an SDL3 window with TrueType text and native file
    dialogs. Requires SDL3, SDL3_ttf, and pkg-config.
license:            MIT AND OFL-1.1
license-file:       LICENSE
author:             goolord
maintainer:         zacharyachurchill@gmail.com
category:           Graphics
homepage:           https://github.com/goolord/nano-ui
bug-reports:        https://github.com/goolord/nano-ui/issues
build-type:         Simple
tested-with:        GHC ==9.10.3 || ==9.14.1
extra-doc-files:
    CHANGELOG.md
    README.md
    data/inter-LICENSE.txt

extra-source-files:
    data/inter.ttf
    cbits/*.h

source-repository head
    type:     git
    location: https://github.com/goolord/nano-ui.git
    subdir:   packages/nano-ui-sdl

flag sdl
    description: Build the SDL3 backend. Needs SDL3, SDL3_ttf, and pkg-config.
    manual: True
    default: True

flag simd
    description: Compile the batch culler with AVX2 (x86-64 only; the binary then requires an AVX2 CPU)
    manual: True
    default: False

common extensions
    default-language: GHC2024
    default-extensions:
        OverloadedStrings

common rts-options
    ghc-options:
        -rtsopts
        -threaded
        "-with-rtsopts=-N1 -A64m -T -I0"

-- -N1 keeps the threaded runtime on one capability. Do not pass tasty's -j1
-- via -with-rtsopts; use: cabal bench ... --benchmark-options=-j1
common bench-rts-options
    ghc-options: -rtsopts -threaded "-with-rtsopts=-N1 -T"

common warnings
  ghc-options:
    -Wall
    -Wextra
    -Wcompat
    -Widentities
    -Wincomplete-record-updates
    -Wincomplete-uni-patterns
    -Wmissing-export-lists
    -Wmissing-home-modules
    -Wpartial-fields
    -Wredundant-constraints
    -Wunused-packages

library
    import:           extensions
    import:           warnings
    exposed-modules:
        NanoUI.Backend.Sdl
        NanoUI.Sdl.Input
        NanoUI.Sdl.NanoUIFont
    other-modules:
        NanoUI.Sdl.Session
        NanoUI.Sdl.Runner
        NanoUI.Sdl.Clipboard
        NanoUI.Sdl.Cursor
        NanoUI.Sdl.Debug
        NanoUI.Sdl.Dialog
        NanoUI.Sdl.Dialog.Types
        NanoUI.Sdl.Display
        NanoUI.Sdl.Font
        NanoUI.Sdl.Font.Inter
        NanoUI.Sdl.Font.Resolve
        NanoUI.Sdl.Font.Search
        NanoUI.Sdl.Image
        NanoUI.Sdl.Render
        NanoUI.Sdl.Window
    build-depends:
        base >=4.20 && <4.23,
        bytestring >=0.11 && <0.13,
        containers >=0.6.7 && <0.9,
        directory >=1.3.7 && <1.4,
        dir-traverse >=0.2.3 && <0.3,
        effectful-core >=2.5 && <2.8,
        filepath >=1.4.100 && <1.6,
        file-embed >=0.0.16 && <0.1,
        hashable >=1.4 && <1.6,
        nano-ui ^>=0.1,
        primitive >=0.8 && <0.10,
        record-hasfield >=1.0 && <1.1,
        sdl3-bindgen-sys >=0.0.0.3 && <0.0.1,
        text >=2.1.2 && <2.2,
        unordered-containers >=0.2.19 && <0.3
    hs-source-dirs:   lib
    if !flag(sdl)
        buildable: False
    if flag(sdl)
        c-sources:        cbits/nano_ui_ttf.c
                          cbits/nano_ui_display.c
                          cbits/nano_ui_batch.c
                          cbits/nano_ui_text_atlas.c
        include-dirs:     cbits
        pkgconfig-depends: sdl3 >= 3.2, sdl3-ttf >= 3.2
        -- nano_ui_batch.c falls back to a scalar cull loop without __AVX2__.
        if flag(simd) && arch(x86_64)
            cc-options:   -mavx2

test-suite nano-ui-font-search-test
    import:           extensions, warnings
    type:             exitcode-stdio-1.0
    main-is:          FontSearch.hs
    hs-source-dirs:   test, lib
    other-modules:    NanoUI.Sdl.Font.Search
    build-depends:
        base >=4.20 && <4.23,
        containers >=0.6.7 && <0.9,
        directory >=1.3.7 && <1.4,
        dir-traverse >=0.2.3 && <0.3,
        filepath >=1.4.100 && <1.6

test-suite nano-ui-font-effects-test
    import:           extensions, warnings, rts-options
    type:             exitcode-stdio-1.0
    main-is:          FontEffects.hs
    hs-source-dirs:   test
    build-depends:
        base >=4.20 && <4.23,
        nano-ui,
        nano-ui-sdl,
        primitive >=0.8 && <0.10,
        text >=2.1.2 && <2.2
    if !flag(sdl)
        buildable: False

executable nano-ui-sdl-anim
    import:           extensions
    import:           rts-options
    import:           warnings
    main-is:          SdlAnim.hs
    build-depends:
        base >=4.20 && <4.23,
        nano-ui,
        nano-ui-sdl,
        text >=2.1.2 && <2.2
    hs-source-dirs:   examples
    if os(windows)
        ghc-options: -optl-mconsole
    if !flag(sdl)
        buildable: False

benchmark nano-ui-sdl-bench
    import:           extensions
    import:           bench-rts-options
    import:           warnings
    default-extensions: CPP
    type:             exitcode-stdio-1.0
    main-is:          SdlBench.hs
    build-depends:
        base >=4.20 && <4.23,
        nano-ui,
        nano-ui-sdl,
        tasty-bench >=0.3 && <0.6
    if os(windows)
        build-depends: Win32 >=2.13 && <2.15
    hs-source-dirs:   benchmark
    if os(windows)
        ghc-options: -optl-mconsole
    if !flag(sdl)
        buildable: False