Does exist something like "data-files" in Cabal, which works at compile time?

Hello guys, I'm pretty sure the answer is "no", but I was hoping to get some extra insight / best practices. The problem can be summarised by this SO question (not the OP, but I have the same problem): http://stackoverflow.com/questions/15731170/cabal-how-to-add-text-file-as-a-... As someone states, "data-files" in for run-time, whereas I need to tell cabal "please copy these files in place before trying to compile", so at compile-time. Does something similar exist? I think the best solution, unless someone prove me wrong, is to create a small startup script which copies the files for me (I *think* yesod is using something similar, namely a script called EmbeddedFiles.hs) and then triggers "cabal install" the usual way. Can you come up with a better way? Thanks in advance! Alfredo

What I have always done to solve this is to create a custom Setup.hs. Something like: Setup.hs ------------- import Distribution.Simple main :: IO () main = doThisBeforeInstall >> defaultMain ------------- Then you specify in your .cabal file that the Build-Type is Custom. Best regards, Daniel Díaz. On Fri, Aug 16, 2013 at 11:58 AM, Alfredo Di Napoli < alfredo.dinapoli@gmail.com> wrote:
Hello guys,
I'm pretty sure the answer is "no", but I was hoping to get some extra insight / best practices. The problem can be summarised by this SO question (not the OP, but I have the same problem):
http://stackoverflow.com/questions/15731170/cabal-how-to-add-text-file-as-a-...
As someone states, "data-files" in for run-time, whereas I need to tell cabal "please copy these files in place before trying to compile", so at compile-time.
Does something similar exist?
I think the best solution, unless someone prove me wrong, is to create a small startup script which copies the files for me (I *think* yesod is using something similar, namely a script called EmbeddedFiles.hs) and then triggers "cabal install" the usual way. Can you come up with a better way?
Thanks in advance!
Alfredo
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Daniel,
It's the path I've eventually took as well.
Many thanks,
Sent from my iPad
On 16/ago/2013, at 11:13, Daniel Díaz Casanueva
What I have always done to solve this is to create a custom Setup.hs. Something like:
Setup.hs ------------- import Distribution.Simple
main :: IO () main = doThisBeforeInstall >> defaultMain -------------
Then you specify in your .cabal file that the Build-Type is Custom.
Best regards, Daniel Díaz.
On Fri, Aug 16, 2013 at 11:58 AM, Alfredo Di Napoli
wrote: Hello guys, I'm pretty sure the answer is "no", but I was hoping to get some extra insight / best practices. The problem can be summarised by this SO question (not the OP, but I have the same problem):
http://stackoverflow.com/questions/15731170/cabal-how-to-add-text-file-as-a-...
As someone states, "data-files" in for run-time, whereas I need to tell cabal "please copy these files in place before trying to compile", so at compile-time.
Does something similar exist?
I think the best solution, unless someone prove me wrong, is to create a small startup script which copies the files for me (I *think* yesod is using something similar, namely a script called EmbeddedFiles.hs) and then triggers "cabal install" the usual way. Can you come up with a better way?
Thanks in advance!
Alfredo
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

You want extra-source-files. They'll be included in the tarball, and cabal always builds from the root of the package, so you can safely use relative paths. On Fri, Aug 16, 2013 at 11:58 AM, Alfredo Di Napoli < alfredo.dinapoli@gmail.com> wrote:
Hello guys,
I'm pretty sure the answer is "no", but I was hoping to get some extra insight / best practices. The problem can be summarised by this SO question (not the OP, but I have the same problem):
http://stackoverflow.com/questions/15731170/cabal-how-to-add-text-file-as-a-...
As someone states, "data-files" in for run-time, whereas I need to tell cabal "please copy these files in place before trying to compile", so at compile-time.
Does something similar exist?
I think the best solution, unless someone prove me wrong, is to create a small startup script which copies the files for me (I *think* yesod is using something similar, namely a script called EmbeddedFiles.hs) and then triggers "cabal install" the usual way. Can you come up with a better way?
Thanks in advance!
Alfredo
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thanks Dag, I'll give it a spin. Btw, I've successfully solved my problem with the following Setup.hs, I'm posting it here in case someone will find this useful in the future: #!/usr/bin/env runhaskell
import Distribution.Simple import Distribution.PackageDescription import Distribution.Package import Distribution.Simple import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Setup import Distribution.Verbosity import Distribution.Simple.Utils import Paths_myproject main :: IO () main = defaultMainWithHooks myHooks where myHooks = simpleUserHooks { preBuild = copyResources } copyResources :: Args -> BuildFlags -> IO HookedBuildInfo copyResources args flags = do installDir <- getDataDir installDirectoryContents verbose "resources" (installDir ++ "/resources") return emptyHookedBuildInfo
where "myproject" should be the name of your project, as in myproject.cabal.
On 16 August 2013 13:11, Dag Odenhall
You want extra-source-files. They'll be included in the tarball, and cabal always builds from the root of the package, so you can safely use relative paths.
On Fri, Aug 16, 2013 at 11:58 AM, Alfredo Di Napoli < alfredo.dinapoli@gmail.com> wrote:
Hello guys,
I'm pretty sure the answer is "no", but I was hoping to get some extra insight / best practices. The problem can be summarised by this SO question (not the OP, but I have the same problem):
http://stackoverflow.com/questions/15731170/cabal-how-to-add-text-file-as-a-...
As someone states, "data-files" in for run-time, whereas I need to tell cabal "please copy these files in place before trying to compile", so at compile-time.
Does something similar exist?
I think the best solution, unless someone prove me wrong, is to create a small startup script which copies the files for me (I *think* yesod is using something similar, namely a script called EmbeddedFiles.hs) and then triggers "cabal install" the usual way. Can you come up with a better way?
Thanks in advance!
Alfredo
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Alfredo Di Napoli
-
Dag Odenhall
-
Daniel Díaz Casanueva