aboutsummaryrefslogtreecommitdiff
path: root/Setup.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2024-02-09 11:35:05 -0700
committerJosh Rahm <rahm@google.com>2024-02-09 11:35:05 -0700
commitdc9c17145c8774738d8b1c395d8796aabfcb828c (patch)
tree1e907c733b96c8d31200b6a1a48e7325c0184033 /Setup.hs
parent7adbf480555e803bded190b013b1d1f70ae471db (diff)
downloadmontis-dc9c17145c8774738d8b1c395d8796aabfcb828c.tar.gz
montis-dc9c17145c8774738d8b1c395d8796aabfcb828c.tar.bz2
montis-dc9c17145c8774738d8b1c395d8796aabfcb828c.zip
Put more logic in the build script.
The build script will now create the symbolic links to the binary and the shared library.
Diffstat (limited to 'Setup.hs')
-rw-r--r--Setup.hs29
1 files changed, 24 insertions, 5 deletions
diff --git a/Setup.hs b/Setup.hs
index 8ccd975..6a28ba8 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,16 +1,35 @@
+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
main = do
- args <- getArgs
- putStrLn $ "This is an MFing custom build script!!! " ++ show args
defaultMainWithHooks $
simpleUserHooks
- { preBuild = \_ _ -> do
- callCommand "cd wlroots && meson setup build -Dexamples=false --reconfigure && ninja -C build"
+ { preConf = \_ _ -> do
+ callCommand "cd wlroots && meson setup build -Dexamples=false --reconfigure"
+ return emptyHookedBuildInfo,
+ preBuild = \_ _ -> do
+ callCommand "cd wlroots && ninja -C build"
return emptyHookedBuildInfo,
cleanHook = \_ _ _ _ -> do
- callCommand "cd wlroots && ninja -C build clean"
+ callCommand "cd wlroots && ninja -C build clean",
+ postCopy = \a f pd _ -> do
+ forM_ (flagToMaybe (copyDistPref f)) $ \copyDest -> do
+ let harnessFile = copyDest </> "build" </> "wtr_harness" </> "wtr_harness"
+ let pluginFile = copyDest </> "build" </> "wtr.so" </> "wtr.so"
+
+ lnF harnessFile "wtr_harness"
+ lnF pluginFile "wtr.so"
}
+ where
+ lnF from to = do
+ printf "%s -> %s" from to
+ flip when (removeLink to) =<< doesFileExist to
+ createSymbolicLink from to