gdritter repos GRUtils / 459db7c
Added cabal file scripts Getty Ritter 7 years ago
2 changed file(s) with 50 addition(s) and 18 deletion(s). Collapse all Expand all
1010 EXENAME="$1"
1111 TGT="$2"
1212 else
13 echo "USAGE: $0 [library name]" >&2
13 echo "USAGE: $0 [executable name]" >&2
1414 exit 99
1515 fi
1616
1919 USER="${NAME} <${EMAIL}>"
2020 YEAR=$(date '+%Y')
2121
22 if [ "${CATEGORY}x" = "x" ]; then
23 CAT_LINE="-- category:"
22 if [ -z "${CATEGORY}" ]; then
23 CAT_FIELD="-- category:"
2424 else
25 CAT_LINE="category: ${CATEGORY}"
25 CAT_FIELD="category: ${CATEGORY}"
26 fi
27
28 if [ -z "${SYNOPSIS}" ]; then
29 SYN_FIELD="-- synopsis:"
30 else
31 SYN_FIELD="synopsis: ${SYNOPSIS}"
32 fi
33
34 if [ -z "${DESCRIPTION}" ]; then
35 DESCR_FIELD="-- description:"
36 else
37 DESCR_FIELD="description: ${DESCRIPTION}"
2638 fi
2739
2840 function cabal_file {
2941 cat <<EOF
3042 name: ${EXENAME}
3143 version: 0.1.0.0
32 -- synopsis:
33 -- description:
44 ${SYN_FIELD}
45 ${DESCR_FIELD}
3446 license: BSD3
3547 license-file: LICENSE
3648 author: ${USER}
3749 maintainer: ${USER}
3850 copyright: ©${YEAR} ${NAME}
39 ${CAT_LINE}
51 ${CAT_FIELD}
4052 build-type: Simple
41 cabal-version: >= 1.12
53 cabal-version: >= 1.14
4254
4355 executable ${EXENAME}
4456 hs-source-dirs: src
4658 default-extensions: OverloadedStrings,
4759 ScopedTypeVariables
4860 ghc-options: -Wall
49 build-depends: base >=4.7 && <4.9
61 build-depends: base >=4.7 && <4.10
5062 default-language: Haskell2010
5163 EOF
5264 }
11 #!/bin/bash -e
2
3 if [ $# -lt 1 ]; then
4 echo "USAGE: $0 [library name]" >&2
5 exit 99
2 if [ $# -eq 0 ]; then
3 LIBNAME="$(basename $(pwd))"
4 TGT="-"
65 elif [ $# -eq 1 ]; then
76 LIBNAME="$1"
87 TGT='-'
98 elif [ $# -eq 2 ]; then
109 LIBNAME="$1"
1110 TGT="$2"
11 else
12 echo "USAGE: $0 [library name]" >&2
13 exit 99
1214 fi
1315
1416 NAME=$(git config user.name)
1618 USER="${NAME} <${EMAIL}>"
1719 YEAR=$(date '+%Y')
1820
21 if [ -z "${CATEGORY}" ]; then
22 CAT_FIELD="-- category:"
23 else
24 CAT_FIELD="category: ${CATEGORY}"
25 fi
26
27 if [ -z "${SYNOPSIS}" ]; then
28 SYN_FIELD="-- synopsis:"
29 else
30 SYN_FIELD="synopsis: ${SYNOPSIS}"
31 fi
32
33 if [ -z "${DESCRIPTION}" ]; then
34 DESCR_FIELD="-- description:"
35 else
36 DESCR_FIELD="description: ${DESCRIPTION}"
37 fi
38
1939 function cabal_file {
2040 cat <<EOF
2141 name: ${LIBNAME}
2242 version: 0.1.0.0
23 -- synopsis:
24 -- description:
43 ${SYN_FIELD}
44 ${DESCR_FIELD}
2545 license: BSD3
2646 license-file: LICENSE
2747 author: ${USER}
2848 maintainer: ${USER}
2949 copyright: ©${YEAR} ${NAME}
30 -- category:
50 ${CAT_FIELD}
3151 build-type: Simple
32 cabal-version: >= 1.12
52 cabal-version: >= 1.14
3353
3454 library
3555 -- exposed-modules:
3656 ghc-options: -Wall
37 build-depends: base >=4.7 && <4.9
57 build-depends: base >=4.7 && <4.10
3858 default-language: Haskell2010
3959 default-extensions: OverloadedStrings,
4060 ScopedTypeVariables