aboutsummaryrefslogtreecommitdiff
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
parent7adbf480555e803bded190b013b1d1f70ae471db (diff)
downloadwetterhorn-dc9c17145c8774738d8b1c395d8796aabfcb828c.tar.gz
wetterhorn-dc9c17145c8774738d8b1c395d8796aabfcb828c.tar.bz2
wetterhorn-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.
-rw-r--r--Setup.hs29
-rw-r--r--package.yaml4
l---------wtr.so1
l---------wtr_harness1
4 files changed, 27 insertions, 8 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
diff --git a/package.yaml b/package.yaml
index 7966291..4fd7277 100644
--- a/package.yaml
+++ b/package.yaml
@@ -8,7 +8,6 @@ copyright: "2024 Author name here"
extra-source-files:
- README.md
-- CHANGELOG.md
# Metadata used when publishing your package
# synopsis: Short description of your package
@@ -25,6 +24,9 @@ custom-setup:
- base
- Cabal
- process
+ - filepath
+ - unix
+ - directory
dependencies:
- base >= 4.7 && < 5
diff --git a/wtr.so b/wtr.so
deleted file mode 120000
index 6f97167..0000000
--- a/wtr.so
+++ /dev/null
@@ -1 +0,0 @@
-./.stack-work/dist/x86_64-linux-tinfo6-libc6-pre232/ghc-9.4.7/build/wtr.so/wtr.so \ No newline at end of file
diff --git a/wtr_harness b/wtr_harness
deleted file mode 120000
index 6383cb0..0000000
--- a/wtr_harness
+++ /dev/null
@@ -1 +0,0 @@
-./.stack-work/install/x86_64-linux-tinfo6-libc6-pre232/f9d76f7cdc71c3e38ec09dbbb9cee45cabefb3429d6bf1fdf55c7a08b076c991/9.4.7/bin/wtr_harness \ No newline at end of file