Skip to content

Commit

Permalink
Trigger rebuilds with build.touch file
Browse files Browse the repository at this point in the history
    Added build.touch to extra-source-files in futr.cabal.
    Updated Setup.hs to use touchFile to force rebuilds on resource changes.
  • Loading branch information
prolic committed Aug 16, 2024
1 parent fd5d2dc commit db55345
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import System.Process (rawSystem)
import System.Directory (listDirectory, createDirectoryIfMissing, doesDirectoryExist, doesFileExist, getModificationTime)
import System.Exit
import System.FilePath ((</>), makeRelative, takeExtension)
import System.Posix.Files (touchFile)

main = defaultMainWithHooks simpleUserHooks { preBuild = myPreBuild }

myPreBuild :: Args -> BuildFlags -> IO HookedBuildInfo
myPreBuild _ _ = do
let resourceDir = "resources"
qrcFile = "resources.qrc"
touchFileName = "build.touch"

-- Recursively get all file paths in the resource directory
allFiles <- listFilesRecursive resourceDir
Expand All @@ -43,6 +45,8 @@ myPreBuild _ _ = do
else
putStrLn "No resource file changes detected."

touchFile touchFileName

let buildInfo = emptyBuildInfo { cSources = ["resources.cpp"] }
return (Nothing, [(mkUnqualComponentName "futr", buildInfo)])

Expand Down
Empty file added build.touch
Empty file.
5 changes: 3 additions & 2 deletions futr.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ synopsis: nostr client application
description: A nostr client application written in Haskell and Qt5.
category: application
build-type: Custom
extra-source-files: README.md
extra-source-files: README.md build.touch

custom-setup
setup-depends:
Expand All @@ -21,7 +21,8 @@ custom-setup
directory >= 1.3.7.1 && < 1.4,
filepath >= 1.4.2 && <1.5,
process >= 1.6.18.0 && <1.7,
time >= 1.12.2 && < 1.13
time >= 1.12.2 && < 1.13,
unix >= 2.7.3 && < 2.8

executable futr
main-is: Main.hs
Expand Down

0 comments on commit db55345

Please sign in to comment.