git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Process os stuff better.
e3e80c1joneshf
Setup.hs+18−4
@@ -1,7 +1,17 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2
2
3+#ifndef POSIX_LIKE
4+#define POSIX_LIKE !defined(_WIN32_HOST_OS) && \
5+ (defined(unix_HOST_OS) || defined(__unix___HOST_OS) || \
6+ defined(__unix_HOST_OS) || defined(linux_HOST_OS) || \
7+ defined(__linux___HOST_OS) || defined(__linux_HOST_OS) || \
8+ (defined(__APPLE___HOST_OS) && defined(__MACH___HOST_OS)))
9+#endif
10+
3module Main where
11module Main where
4
12
13+import Control.Monad
14+
5import Distribution.PackageDescription
15import Distribution.PackageDescription
6import Distribution.Simple
16import Distribution.Simple
7import Distribution.Simple.LocalBuildInfo
17import Distribution.Simple.LocalBuildInfo
@@ -9,7 +19,7 @@ import Distribution.Simple.Setup
9
19
10import System.Directory
20import System.Directory
11import System.Environment.XDG.BaseDir
21import System.Environment.XDG.BaseDir
12−#if !defined(mingw32_HOST_OS) || !defined(__MINGW32__)
22+#if POSIX_LIKE
13import System.Posix.Files
23import System.Posix.Files
14#endif
24#endif
15
25
@@ -19,7 +29,11 @@ main = defaultMainWithHooks $ simpleUserHooks {postInst = setupXDG}
19setupXDG :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
29setupXDG :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
20setupXDG _ _ _ _ = do
30setupXDG _ _ _ _ = do
21 configDir <- getUserConfigDir "purescript"
31 configDir <- getUserConfigDir "purescript"
32+ configExists <- doesDirectoryExist configDir
33+ putStrLn "\n\n\noh it worked!\n\n\n"
34+ unless configExists $ do
22− createDirectoryIfMissing True configDir
35+ createDirectoryIfMissing True configDir
23−#if !defined(mingw32_HOST_OS) || !defined(__MINGW32__)
36+#if POSIX_LIKE
24− setFileMode configDir ownerModes
37+ setFileMode configDir ownerModes
25#endif
38#endif
39+#undef POSIX_LIKE
purescript.cabal+3−1
@@ -20,7 +20,9 @@ library
20 build-depends: base >=4 && <5, cmdtheline -any, containers -any,
20 build-depends: base >=4 && <5, cmdtheline -any, containers -any,
21 directory -any, filepath -any, mtl -any, parsec -any, syb -any,
21 directory -any, filepath -any, mtl -any, parsec -any, syb -any,
22 transformers -any, utf8-string -any, pattern-arrows -any, monad-unify >= 0.2 && < 0.3,
22 transformers -any, utf8-string -any, pattern-arrows -any, monad-unify >= 0.2 && < 0.3,
23− xdg-basedir -any, unix -any
23+ xdg-basedir -any
24+ if (!os(windows))
25+ build-depends: unix -any
24 exposed-modules: Data.Generics.Extras
26 exposed-modules: Data.Generics.Extras
25 Language.PureScript
27 Language.PureScript
26 Language.PureScript.Options
28 Language.PureScript.Options