Skip to content
This repository was archived by the owner on Feb 3, 2022. It is now read-only.

Commit 38197ae

Browse files
author
Gershom
committed
add stack executable install for linux, mac
1 parent 9cc6b27 commit 38197ae

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

hptool/src/Config.hs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ module Config
55
( askHpRelease
66
, askGhcBinDistTarFile
77
, askBuildConfig
8-
98
, addConfigOracle
9+
, askStackExe
1010
)
1111
where
1212

@@ -66,13 +66,25 @@ newtype BuildConfigQ = BuildConfigQ ()
6666
askBuildConfig :: Action BuildConfig
6767
askBuildConfig = readOracle "BuildConfig" (BuildConfigQ ())
6868

69+
newtype StackExeQ = StackExeQ ()
70+
deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
71+
72+
-- | Provide the stack executable
73+
-- The filepath will be tracked as a dependency
74+
askStackExe :: Action FilePath
75+
askStackExe = do
76+
stackexe <- askOracle $ StackExeQ ()
77+
need [stackexe]
78+
return stackexe
6979

70-
addConfigOracle :: Release -> FilePath -> Maybe FilePath -> Bool -> Rules BuildConfig
71-
addConfigOracle hpRel tarFile prefix includeExtra = do
80+
addConfigOracle :: Release -> FilePath -> FilePath -> Maybe FilePath -> Bool -> Rules BuildConfig
81+
addConfigOracle hpRel tarFile stackexe prefix includeExtra = do
7282
_ <- addOracle $
7383
\(HpReleaseQ _) -> return $ show hpRel
7484
_ <- addOracle $
7585
\(GhcBinDistTarFileQ _) -> return tarFile
86+
_ <- addOracle $
87+
\(StackExeQ _) -> return stackexe
7688
_ <- addOracle $
7789
\(BuildConfigQ _) -> either fail (return . show) buildConfig
7890
either fail return buildConfig

hptool/src/Main.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ main = shakeArgsWith opts flags main'
4242
if Info `elem` flgs
4343
then info
4444
else case args of
45-
(tarfile:what) -> return $ Just $ do
46-
allRules tarfile flgs
47-
want $ if null what then ["build-all"] else what
48-
[] -> usage
45+
(tarfile:stackexe:buildType) -> return $ Just $ do
46+
allRules tarfile stackexe flgs
47+
want $ if null buildType then ["build-all"] else buildType
48+
_ -> usage
4949

5050
info = do
5151
putStrLn $ "This hptool is built to construct " ++ hpFullName ++ "\n\
@@ -57,7 +57,7 @@ main = shakeArgsWith opts flags main'
5757

5858
usage = do
5959
putStrLn "usage: hptool --info\n\
60-
\ hptool [opts] <ghc-bindist.tar.bz> [target...]\n\
60+
\ hptool [opts] <ghc-bindist.tar.bz> <stack executable> [target...]\n\
6161
\ where target is one of:\n\
6262
\ build-all -- build everything (default)\n\
6363
\ build-source -- build the source tar ball\n\
@@ -67,8 +67,8 @@ main = shakeArgsWith opts flags main'
6767
\ build-website -- build the website\n"
6868
return Nothing
6969

70-
allRules tarfile flgs = do
71-
buildConfig <- addConfigOracle hpRelease tarfile (prefixSetting flgs) (Full `elem` flgs)
70+
allRules tarfile stackexe flgs = do
71+
buildConfig <- addConfigOracle hpRelease tarfile stackexe (prefixSetting flgs) (Full `elem` flgs)
7272
ghcDistRules
7373
packageRules
7474
targetRules buildConfig

hptool/src/OS/Mac.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Paths
1616
import Templates
1717
import Types
1818
import Utils
19+
import Config
1920

2021
macOsFromConfig :: BuildConfig -> OS
2122
macOsFromConfig BuildConfig{..} = OS{..}
@@ -109,7 +110,8 @@ macOsFromConfig BuildConfig{..} = OS{..}
109110
makeDirectory hpBinDir
110111
need [dir extrasDir]
111112
binFiles <- getDirectoryFiles "" [extrasDir </> "bin/*"]
112-
forM_ binFiles $ \f -> do
113+
stackFile <- askStackExe
114+
forM_ (stackFile:binFiles) $ \f -> do
113115
if takeExtension f == ".hs"
114116
then compileToBin f $ hpBinDir </> takeBaseName f
115117
else copyFile' f $ hpBinDir </> takeFileName f

hptool/src/OS/Posix.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Development.Shake
1212
import Development.Shake.FilePath
1313

1414
import Dirs
15+
import Config
1516
import OS.Internal
1617
import Paths
1718
import Templates
@@ -115,7 +116,8 @@ posixOS BuildConfig{..} = OS{..}
115116
makeDirectory hpBinDir
116117
need [dir extrasDir]
117118
binFiles <- getDirectoryFiles "" [extrasDir </> "bin/*"]
118-
forM_ binFiles $ \f -> do
119+
stackFile <- askStackExe
120+
forM_ (stackFile:binFiles) $ \f -> do
119121
copyFile' f $ hpBinDir </> takeFileName f
120122
return Nothing
121123

hptool/src/Website.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ extendedCtx name = mkStrContext ctx
137137
pCtx pName "package" = MuVariable pName
138138
pCtx pName "hackageUrl" =
139139
MuVariable $ "http://hackage.haskell.org/package/" ++ pName
140-
pCtx pName "releases" = mapListStrContext pvCtx $ packageVersionInfo pName
140+
pCtx pName "releases" = mapListStrContext pvCtx $ packageVersionInfo True pName
141141
pCtx _ _ = MuNothing
142142

143143
pvCtx (c, _) "class" = MuVariable c
144144
pvCtx (_, v) "version" = MuVariable v
145145
pvCtx _ _ = MuNothing
146146

147-
packageVersionInfo :: String -> [(String, String)]
148-
packageVersionInfo pName = curr $ zipWith comp vers (drop 1 vers ++ [Nothing])
147+
packageVersionInfo :: Bool -> String -> [(String, String)]
148+
packageVersionInfo searchFull pName = curr $ zipWith comp vers (drop 1 vers ++ [Nothing])
149149
where
150150
comp Nothing _ = ("missing", "")
151151
comp (Just v) Nothing = ("update", showVersion v)

0 commit comments

Comments
 (0)