packages feed

nano-ui-sdl-0.2.0.0: nano-ui-sdl.cabal

cabal-version:      3.4
name:               nano-ui-sdl
version:            0.2.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
license-file:       LICENSE
author:             goolord
maintainer:         zacharyachurchill@gmail.com
homepage:           https://github.com/goolord/nano-ui
bug-reports:        https://github.com/goolord/nano-ui/issues
category:           Graphics
build-type:         Simple
tested-with:        GHC ==9.10.3 || ==9.14.1
extra-doc-files:
    CHANGELOG.md
    README.md

extra-source-files:
    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

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.Internal.Cursor
        NanoUI.Sdl.Internal.DialogState
        NanoUI.Sdl.Internal.Error
        NanoUI.Sdl.Internal.Image
        NanoUI.Sdl.Internal.Input
        NanoUI.Sdl.Internal.NanoUIFont
        NanoUI.Sdl.Internal.Render
        NanoUI.Sdl.Internal.Window
    other-modules:
        NanoUI.Sdl.Internal.Session
        NanoUI.Sdl.Internal.Children
        NanoUI.Sdl.Internal.Runner
        NanoUI.Sdl.Internal.Debug
        NanoUI.Sdl.Internal.Dialog
        NanoUI.Sdl.Internal.Chrome
        NanoUI.Sdl.Internal.Chrome.Types
        NanoUI.Sdl.Internal.Frame
        NanoUI.Sdl.Internal.Display
        NanoUI.Sdl.Internal.Env
        NanoUI.Sdl.Internal.Gpu
        NanoUI.Sdl.Internal.Pacing
        NanoUI.Sdl.Internal.Screenshot
        NanoUI.Sdl.Internal.Target
        NanoUI.Sdl.Internal.TargetPool
        NanoUI.Sdl.Internal.Font
        NanoUI.Sdl.Internal.Font.Search
        NanoUI.Sdl.Internal.Url
        NanoUI.Sdl.Internal.WindowOptions
    build-depends:
        base >=4.20 && <4.23,
        bytestring ^>=0.12,
        containers >=0.7 && <0.9,
        directory ^>=1.3,
        filepath ^>=1.5,
        nano-ui ^>=0.2,
        nano-ui-emit ^>=0.2,
        nano-ui-ttf ^>=0.2,
        primitive ^>=0.9,
        vector ^>=0.13,
        record-hasfield ^>=1.0,
        resourcet ^>=1.3,
        sdl3-bindgen-sys >=0.0.1.0 && <0.0.2,
        text >=2.1.2 && <2.2
    hs-source-dirs:   lib
    -- The frame and drop shadow under a window with no title bar are DWM's;
    -- see "NanoUI.Sdl.Internal.Frame".
    if os(windows)
        extra-libraries: dwmapi, user32
    if !flag(sdl)
        buildable: False
    if flag(sdl)
        c-sources:        cbits/nano_ui_frame.c
                          cbits/nano_ui_display.c
                          cbits/nano_ui_render.c
                          cbits/nano_ui_text_atlas.c
        include-dirs:     cbits
        pkgconfig-depends: sdl3 >= 3.2, sdl3-ttf >= 3.2

test-suite nano-ui-render-test
    import:           extensions, warnings, rts-options
    type:             exitcode-stdio-1.0
    main-is:          Rendering.hs
    hs-source-dirs:   test
    other-modules:    Input, WindowChecks
    if os(windows)
        ghc-options: -optl-mconsole
    build-depends:
        base >=4.20 && <4.23,
        bytestring ^>=0.12,
        nano-ui ^>=0.2,
        nano-ui-emit ^>=0.2,
        nano-ui-sdl,
        nano-ui-shader ^>=0.2,
        primitive ^>=0.9,
        sdl3-bindgen-sys >=0.0.1.0 && <0.0.2,
        vector ^>=0.13
    if !flag(sdl)
        buildable: False

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.Internal.Font.Search
    build-depends:
        base >=4.20 && <4.23,
        containers >=0.7 && <0.9,
        directory ^>=1.3,
        filepath ^>=1.5,
        nano-ui-ttf ^>=0.2
    if !flag(sdl)
        buildable: False

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
    if os(windows)
        ghc-options: -optl-mconsole
    build-depends:
        base >=4.20 && <4.23,
        bytestring ^>=0.12,
        directory ^>=1.3,
        filepath ^>=1.5,
        nano-ui ^>=0.2,
        nano-ui-sdl,
        nano-ui-ttf ^>=0.2,
        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.20 && <4.23,
        nano-ui ^>=0.2,
        nano-ui-sdl,
        text ^>=2.1
    hs-source-dirs:   examples
    if os(windows)
        ghc-options: -optl-mconsole
    if !flag(sdl)
        buildable: False

executable nano-ui-sdl-idle
    import:           extensions
    import:           rts-options
    import:           warnings
    main-is:          SdlIdle.hs
    build-depends:
        base >=4.20 && <4.23,
        nano-ui ^>=0.2,
        nano-ui-sdl,
        sdl3-bindgen-sys >=0.0.1.0 && <0.0.2,
        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.20 && <4.23,
        nano-ui ^>=0.2,
        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