packages feed

nano-ui-sdl-0.1.0.1: nano-ui-sdl.cabal

cabal-version:      3.4
name:               nano-ui-sdl
version:            0.1.0.1
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
license-file:       LICENSE
author:             goolord
maintainer:         zacharyachurchill@gmail.com
category:           Graphics
build-type:         Simple
extra-doc-files:
    CHANGELOG.md
    README.md

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

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.22.0.0,
        bytestring ^>=0.12,
        containers ^>=0.8,
        directory ^>=1.3,
        dir-traverse ^>=0.2.3.0,
        effectful-core ^>=2.6,
        filepath ^>=1.5,
        file-embed ^>=0.0.16,
        hashable ^>=1.5,
        nano-ui ^>=0.1,
        primitive ^>=0.9,
        record-hasfield ^>=1.0,
        sdl3-bindgen-sys ^>=0.0.0.2,
        text ^>=2.1,
        unordered-containers ^>=0.2
    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.22.0.0,
        containers ^>=0.8,
        directory ^>=1.3,
        dir-traverse ^>=0.2.3.0,
        filepath ^>=1.5

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.22.0.0,
        nano-ui,
        nano-ui-sdl,
        primitive ^>=0.9,
        text ^>=2.1
    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.22.0.0,
        nano-ui,
        nano-ui-sdl,
        text ^>=2.1
    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.22.0.0,
        nano-ui,
        nano-ui-sdl,
        tasty-bench ^>=0.4
    if os(windows)
        build-depends: Win32 ^>=2.14
    hs-source-dirs:   benchmark
    if os(windows)
        ghc-options: -optl-mconsole
    if !flag(sdl)
        buildable: False