Skip to content

Shake tries to build existing target #236

@cblp

Description

@cblp
{-# LANGUAGE DeriveDataTypeable #-}

import Control.Exception  ( Exception, throwIO )
import Data.Typeable      ( Typeable )
import Development.Shake  ( (%>), liftIO, shakeArgs, shakeOptions, want )
import System.Directory   ( doesFileExist )

main = shakeArgs shakeOptions $ do
    want ["a"]
    "a" %> \_ -> do
        liftIO $ create "a"

data FileExists = FileExists FilePath
    deriving (Show, Typeable)
instance Exception FileExists

create :: FilePath -> IO ()
create name = do
    exists <- doesFileExist name
    if exists then
        throwIO $ FileExists name
    else
        writeFile name ""
$ ./build.hs
Error when running Shake build system:
* a
FileExists "a"

How can I tell Shake that the file already exists and it doesn't need to reset it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions