blob: 50385ed86c725b3ef8e146dce16488ed77092cc3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
import Control.Monad (forM_, when)
import Distribution.Simple
import Distribution.Simple.Setup
import Distribution.Types.HookedBuildInfo
import System.Directory
import System.Environment (getArgs)
import System.FilePath
import System.Posix.Files (createSymbolicLink, removeLink)
import System.Process
import Text.Printf
import Data.Maybe (fromJust)
main = do
putStrLn "Running Setup.hs"
defaultMainWithHooks $
simpleUserHooks
{ preConf = \_ conf -> do
let buildPath = fromJust (flagToMaybe $ configDistPref conf)
callCommand $
printf "cd wlroots && meson setup %s -Dexamples=false --reconfigure" (wlrootsDir buildPath)
callCommand $
printf "cmake -B %s -S harness" (harnessDir buildPath)
lnF ("../" ++ harnessDir buildPath) "harness/build"
return emptyHookedBuildInfo,
preBuild = \_ conf -> do
let path = fromJust (flagToMaybe $ buildDistPref conf)
callCommand $ printf "cd wlroots && ninja -C %s" (wlrootsDir path)
callCommand $
printf "make -C %s" (harnessDir path)
lnF (printf "%s/wtr_harness" (harnessDir path)) "wtr_harness"
return emptyHookedBuildInfo,
postCopy = \a f pd _ -> do
forM_ (flagToMaybe (copyDistPref f)) $ \copyDest -> do
let pluginFile = copyDest </> "build" </> "wtr.so" </> "wtr.so"
lnF pluginFile "wtr.so"
}
where
wlrootsDir :: String -> String
wlrootsDir = printf "../%s/build/wlroots"
harnessDir :: String -> String
harnessDir = printf "%s/build/wtr_harness"
lnF from to = do
printf "%s -> %s\n" from to
flip when (removeLink to) =<< doesExist to
createSymbolicLink from to
doesExist f = do
b1 <- doesFileExist f
b2 <- doesDirectoryExist f
return (b1 || b2)
|