{-# LANGUAGE CPP #-} #ifdef FILE_EMBED {-# LANGUAGE TemplateHaskell #-} #endif -- | The information from Paths_shake cleaned upmoduleDevelopment.Shake.Internal.Paths(shakeVersionString ,initDataDirectory ,hasManualData ,copyManualData ,readDataFileHTML )whereimportControl.Monad.ExtraimportData.VersionimportSystem.FilePathimportGeneral.Extra importqualifiedData.ByteString.LazyasLBSimportPaths_shake #ifdef FILE_EMBED importqualifiedData.ByteStringasBSimportData.FileEmbed #else importControl.ExceptionimportSystem.DirectoryimportSystem.Info.ExtraimportSystem.IO.UnsafeimportSystem.Environment #endif shakeVersionString ::StringshakeVersionString :: FilePath shakeVersionString =Version -> FilePath showVersionVersion version #ifdef FILE_EMBED initDataDirectory::IO()initDataDirectory=pure()htmlDataFiles::[(FilePath,BS.ByteString)]htmlDataFiles=[("profile.html",$(embedFile"html/profile.html")),("progress.html",$(embedFile"html/progress.html")),("shake.js",$(embedFile"html/shake.js"))]readDataFileHTML::FilePath->IOLBS.ByteStringreadDataFileHTMLfile=docaselookupfilehtmlDataFilesofNothing->fail$"Could not find data file "++file++" in embedded data files!"Justx->pure(LBS.fromStrictx)manualDirData::[(FilePath,BS.ByteString)]manualDirData=$(embedDir"docs/manual")hasManualData::IOBoolhasManualData=pureTruecopyManualData::FilePath->IO()copyManualDatadest=docreateDirectoryRecursivedestforM_manualDirData$\(file,bs)->doBS.writeFile(dest</>file)bs #else -- We want getDataFileName to be relative to the current directory on program startup,-- even if we issue a change directory command. Therefore, first call caches, future ones read.{-# NOINLINEdataDirs #-}dataDirs ::[String]dataDirs :: [FilePath] dataDirs =IO [FilePath] -> [FilePath] forall a. IO a -> a unsafePerformIO(IO [FilePath] -> [FilePath]) -> IO [FilePath] -> [FilePath] forall a b. (a -> b) -> a -> b $doFilePath datdir <-IO FilePath getDataDir FilePath exedir <-FilePath -> FilePath takeDirectory(FilePath -> FilePath) -> IO FilePath -> IO FilePath forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$>IO FilePath getExecutablePathIO FilePath -> (IOException -> IO FilePath) -> IO FilePath forall a. IO a -> (IOException -> IO a) -> IO a `catchIO` \IOException _->FilePath -> IO FilePath forall a. a -> IO a forall (f :: * -> *) a. Applicative f => a -> f a pureFilePath ""FilePath curdir <-IO FilePath getCurrentDirectory[FilePath] -> IO [FilePath] forall a. a -> IO a forall (f :: * -> *) a. Applicative f => a -> f a pure([FilePath] -> IO [FilePath]) -> [FilePath] -> IO [FilePath] forall a b. (a -> b) -> a -> b $[FilePath datdir ][FilePath] -> [FilePath] -> [FilePath] forall a. [a] -> [a] -> [a] ++[FilePath exedir |FilePath exedir FilePath -> FilePath -> Bool forall a. Eq a => a -> a -> Bool /=FilePath ""][FilePath] -> [FilePath] -> [FilePath] forall a. [a] -> [a] -> [a] ++[FilePath curdir ]-- The data files may be located relative to the current directory, if so cache it in advanceinitDataDirectory ::IO()initDataDirectory :: IO () initDataDirectory =IO [FilePath] -> IO () forall (f :: * -> *) a. Functor f => f a -> f () void(IO [FilePath] -> IO ()) -> IO [FilePath] -> IO () forall a b. (a -> b) -> a -> b $[FilePath] -> IO [FilePath] forall a. a -> IO a evaluate[FilePath] dataDirs getDataFile ::FilePath->IOFilePathgetDataFile :: FilePath -> IO FilePath getDataFile FilePath file =doletposs :: [FilePath] poss =(FilePath -> FilePath) -> [FilePath] -> [FilePath] forall a b. (a -> b) -> [a] -> [b] map(FilePath -> FilePath -> FilePath </>FilePath file )[FilePath] dataDirs [FilePath] res <-(FilePath -> IO Bool) -> [FilePath] -> IO [FilePath] forall (m :: * -> *) a. Applicative m => (a -> m Bool) -> [a] -> m [a] filterMFilePath -> IO Bool doesFileExist_ [FilePath] poss case[FilePath] res of[]->FilePath -> IO FilePath forall a. FilePath -> IO a forall (m :: * -> *) a. MonadFail m => FilePath -> m a fail(FilePath -> IO FilePath) -> FilePath -> IO FilePath forall a b. (a -> b) -> a -> b $[FilePath] -> FilePath unlines([FilePath] -> FilePath) -> [FilePath] -> FilePath forall a b. (a -> b) -> a -> b $(FilePath "Could not find data file "FilePath -> FilePath -> FilePath forall a. [a] -> [a] -> [a] ++FilePath file FilePath -> FilePath -> FilePath forall a. [a] -> [a] -> [a] ++FilePath ", looked in:")FilePath -> [FilePath] -> [FilePath] forall a. a -> [a] -> [a] :(FilePath -> FilePath) -> [FilePath] -> [FilePath] forall a b. (a -> b) -> [a] -> [b] map(FilePath " "FilePath -> FilePath -> FilePath forall a. [a] -> [a] -> [a] ++)[FilePath] poss FilePath x :[FilePath] _->FilePath -> IO FilePath forall a. a -> IO a forall (f :: * -> *) a. Applicative f => a -> f a pureFilePath x hasDataFile ::FilePath->IOBoolhasDataFile :: FilePath -> IO Bool hasDataFile FilePath file =(FilePath -> IO Bool) -> [FilePath] -> IO Bool forall (m :: * -> *) a. Monad m => (a -> m Bool) -> [a] -> m Bool anyM(\FilePath dir ->FilePath -> IO Bool doesFileExist_ (FilePath -> IO Bool) -> FilePath -> IO Bool forall a b. (a -> b) -> a -> b $FilePath dir FilePath -> FilePath -> FilePath </>FilePath file )[FilePath] dataDirs readDataFileHTML ::FilePath->IOLBS.ByteStringreadDataFileHTML :: FilePath -> IO ByteString readDataFileHTML FilePath file =FilePath -> IO ByteString LBS.readFile(FilePath -> IO ByteString) -> IO FilePath -> IO ByteString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<<FilePath -> IO FilePath getDataFile (FilePath "html"FilePath -> FilePath -> FilePath </>FilePath file )manualFiles ::[FilePath]manualFiles :: [FilePath] manualFiles =(FilePath -> FilePath) -> [FilePath] -> [FilePath] forall a b. (a -> b) -> [a] -> [b] map(FilePath "docs/manual"FilePath -> FilePath -> FilePath </>)[FilePath "Shakefile.hs",FilePath "main.c",FilePath "constants.c",FilePath "constants.h",FilePath "build"FilePath -> FilePath -> FilePath <.>ifBool isWindowsthenFilePath "bat"elseFilePath "sh"]hasManualData ::IOBoolhasManualData :: IO Bool hasManualData =(FilePath -> IO Bool) -> [FilePath] -> IO Bool forall (m :: * -> *) a. Monad m => (a -> m Bool) -> [a] -> m Bool allMFilePath -> IO Bool hasDataFile [FilePath] manualFiles copyManualData ::FilePath->IO()copyManualData :: FilePath -> IO () copyManualData FilePath dest =doFilePath -> IO () createDirectoryRecursive FilePath dest [FilePath] -> (FilePath -> IO ()) -> IO () forall (t :: * -> *) (m :: * -> *) a b. (Foldable t, Monad m) => t a -> (a -> m b) -> m () forM_[FilePath] manualFiles ((FilePath -> IO ()) -> IO ()) -> (FilePath -> IO ()) -> IO () forall a b. (a -> b) -> a -> b $\FilePath file ->doFilePath src <-FilePath -> IO FilePath getDataFile FilePath file FilePath -> FilePath -> IO () copyFileFilePath src (FilePath dest FilePath -> FilePath -> FilePath </>FilePath -> FilePath takeFileNameFilePath file ) #endif