Skip to content

Commit

Permalink
Fix purescript#624 - remove xdg-basedir dependency, simplify build.
Browse files Browse the repository at this point in the history
  • Loading branch information
paf31 committed Oct 15, 2014
1 parent e070c0e commit 7bad2ae
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 46 deletions.
34 changes: 1 addition & 33 deletions Setup.hs
@@ -1,38 +1,6 @@
{-# LANGUAGE CPP #-}

#ifndef POSIX_LIKE
#define POSIX_LIKE !(defined(_WIN32_HOST_OS) || defined(_WIN64_HOST_OS)) && \
(defined(unix_HOST_OS) || defined(__unix___HOST_OS) || \
defined(__unix_HOST_OS) || defined(linux_HOST_OS) || \
defined(__linux___HOST_OS) || defined(__linux_HOST_OS) || \
(defined(__APPLE___HOST_OS) && defined(__MACH___HOST_OS)))
#endif

module Main where

import Control.Monad

import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup

import System.Directory
import System.Environment.XDG.BaseDir
#if POSIX_LIKE
import System.Posix.Files
#endif

main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks {postInst = setupXDG}

setupXDG :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
setupXDG _ _ _ _ = do
configDir <- getUserConfigDir "purescript"
configExists <- doesDirectoryExist configDir
unless configExists $ do
createDirectoryIfMissing True configDir
#if POSIX_LIKE
setFileMode configDir ownerModes
#endif
#undef POSIX_LIKE
main = defaultMain
7 changes: 5 additions & 2 deletions psci/Main.hs
Expand Up @@ -43,7 +43,6 @@ import System.Directory
findExecutable, getHomeDirectory, getCurrentDirectory)
import System.Process (readProcessWithExitCode)
import System.Exit
import System.Environment.XDG.BaseDir
import System.FilePath
(pathSeparator, takeDirectory, (</>), isPathSeparator)
import qualified System.Console.CmdTheLine as Cmd
Expand Down Expand Up @@ -114,7 +113,11 @@ findNodeProcess = runMaybeT . msum $ map (MaybeT . findExecutable) names
-- Grabs the filename where the history is stored.
--
getHistoryFilename :: IO FilePath
getHistoryFilename = getUserConfigFile "purescript" "psci_history"
getHistoryFilename = do
home <- getHomeDirectory
let filename = home </> ".purescript" </> "psci_history"
mkdirp filename
return filename

-- |
-- Loads a file for use with imports.
Expand Down
6 changes: 3 additions & 3 deletions purescript.cabal
@@ -1,7 +1,7 @@
name: purescript
version: 0.5.6.3
cabal-version: >=1.8
build-type: Custom
build-type: Simple
license: MIT
license-file: LICENSE
copyright: (c) 2013-14 Phil Freeman, (c) 2014 Gary Burgess, and other contributors
Expand Down Expand Up @@ -30,7 +30,7 @@ library
transformers >= 0.3 && < 0.5, utf8-string -any,
pattern-arrows >= 0.0.2 && < 0.1,
monad-unify >= 0.2.2 && < 0.3,
xdg-basedir -any, time -any
time -any
if (!os(windows))
build-depends: unix -any
exposed-modules: Language.PureScript
Expand Down Expand Up @@ -115,7 +115,7 @@ executable psci
build-depends: base >=4 && <5, containers -any, directory -any, filepath -any,
mtl -any, parsec -any, haskeline >= 0.7.0.0, purescript -any,
transformers -any, utf8-string -any, process -any,
xdg-basedir -any, cmdtheline -any
cmdtheline -any
main-is: Main.hs
buildable: True
hs-source-dirs: psci
Expand Down
10 changes: 2 additions & 8 deletions src/Language/PureScript.hs
Expand Up @@ -51,7 +51,6 @@ import qualified Data.Set as S

import System.FilePath ((</>), pathSeparator)
import System.Directory (getHomeDirectory, doesFileExist)
import System.Environment.XDG.BaseDir (getUserConfigDir)

-- |
-- Compile a collection of modules
Expand Down Expand Up @@ -272,16 +271,11 @@ importPrelude = addDefaultImport (ModuleName [ProperName C.prelude])

preludeFilename :: IO FilePath
preludeFilename = fromMaybe missingPrelude . listToMaybe <$> do
fs <- sequence [xdsPrelude, homePrelude, cabalPrelude]
fs <- sequence [homePrelude, cabalPrelude]
filterM doesFileExist fs
where
missingPrelude :: FilePath
missingPrelude = error "No Prelude found in user home, XDS user config directory or cabal path."

xdsPrelude :: IO FilePath
xdsPrelude = do
configDir <- getUserConfigDir "purescript"
return $ configDir </> "prelude" </> "prelude.purs"
missingPrelude = error "No Prelude found in user home or cabal path."

homePrelude :: IO FilePath
homePrelude = do
Expand Down

0 comments on commit 7bad2ae

Please sign in to comment.