From b6d62fe9d33aab6af644e94c4b9018cdb7c77fb9 Mon Sep 17 00:00:00 2001 From: brandon s allbery kf8nh Date: Mon, 18 Apr 2022 15:53:16 -0400 Subject: [PATCH] migrate build scripts from xmonad-testing The testing repo was not a good location for them, and is now deprecated. They are now in `scripts/build`, and will be documented in the main repo's `INSTALL.md`. --- CHANGES.md | 6 ++++ scripts/build/build-with-cabal.sh | 59 +++++++++++++++++++++++++++++++ scripts/build/build-with-stack.sh | 23 ++++++++++++ 3 files changed, 88 insertions(+) create mode 100755 scripts/build/build-with-cabal.sh create mode 100755 scripts/build/build-with-stack.sh diff --git a/CHANGES.md b/CHANGES.md index b3ae97d5..dcf347f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -181,6 +181,12 @@ - Added support for dynamic scratchpads in the form of `dynamicNSPAction` and `toggleDynamicNSP`. +### Other changes + + * Migrated the sample build scripts from the deprecated `xmonad-testing` repo to + `scripts/build`. This will be followed by a documentation update in the `xmonad` + repo. + ## 0.17.0 (October 27, 2021) ### Breaking Changes diff --git a/scripts/build/build-with-cabal.sh b/scripts/build/build-with-cabal.sh new file mode 100755 index 00000000..713926f1 --- /dev/null +++ b/scripts/build/build-with-cabal.sh @@ -0,0 +1,59 @@ +#! /bin/sh -eu + +# Your source directory. Default is the config dir, if it can be found. +SRC_DIR= + +# Executable name, from the executable stanza of your cabal file. +# The script will try to guess it if not specified. +EXE_NAME= + +############################################################################## + +# config + +output="$1" + +if [ "$SRC_DIR" = "" ]; then + # look for the config directory, fall back to the old one + SRC_DIR="${XMONAD_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config/xmonad}}" + if test -f "$SRC_DIR/build"; then + : + else + SRC_DIR="$HOME/.xmonad" + fi +fi +cd "$SRC_DIR" + +if [ "$EXE_NAME" = "" ]; then + # try to extract the name of the executable + EXE_NAME="$(awk '!done && /^executable / {print $2; done = 1}' *.cabal)" + # note that there should be only one cabal file or cabal will report a + # conflict; any utilities should be listed after the xmonad executable +fi + +# do it to it + +d="$(dirname "$output")" +f="$(basename "$output")" +first=0 +for exe in $EXE_NAME; do + cabal install exe:"$EXE_NAME" \ + --enable-executable-stripping \ + --enable-optimization=2 \ + --installdir="$d" \ + --overwrite-policy=always + # NB. a cabal bug may mean it doesn't actually get stripped + # we assume the first executable in the list is the new xmonad + if [ $first = 0 ]; then + first=1 + if [ "$f" = "$exe" ]; then + : someone will try it… + else + ln -sf "$exe" "$output" + fi + elif [ "$f" = "$exe" ]; then + # the link above just got replaced with a direct link into the + # cabal package + echo I hope you know what you\'re doing... >&2 + fi +done diff --git a/scripts/build/build-with-stack.sh b/scripts/build/build-with-stack.sh new file mode 100755 index 00000000..abe0b134 --- /dev/null +++ b/scripts/build/build-with-stack.sh @@ -0,0 +1,23 @@ +#!/bin/sh -eu + +################################################################################ +# Edit the following constants and then rename this script to ~/.xmonad/build + +# The directory holding your source code and stack.yaml file: +SRC_DIR=~/develop/oss/xmonad-testing + +# The name of the executable produced by stack. This comes from the +# executable section of your *.cabal or package.yaml file. +EXE_NAME=xmonad-testing + +################################################################################ + +# Unset STACK_YAML, to ensure that $SRC_DIR/stack.yaml is used. +unset STACK_YAML + +# Do the build. +cd $SRC_DIR +stack build + +# Create a hard link at the requested destination, replacing any existing one. +ln -f -T $(stack exec -- which $EXE_NAME) $1