forked from tweag/rules_haskell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
executable file
·86 lines (66 loc) · 1.84 KB
/
start
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
MIN_BAZEL_MAJOR=0
MIN_BAZEL_MINOR=8
set -e
actual_raw=$(bazel version | egrep '^Build label:' | egrep -o '[0-9.]+')
IFS=. read actual_major actual_minor actual_patch <<EOF
$actual_raw
EOF
expected=$MIN_BAZEL_MAJOR.$MIN_BAZEL_MINOR.0
cmp=$expected'\n'$actual
if ! ( [ "$actual_major" -gt "$MIN_BAZEL_MAJOR" ] || (
[ "$actual_major" -eq "$MIN_BAZEL_MAJOR" ] &&
[ "$actual_minor" -ge "$MIN_BAZEL_MINOR" ] ) )
then
echo Need at least Bazel v${expected}. v${actual_raw} detected. >/dev/stderr
exit 1
fi
if [ -e WORKSPACE ] || [ -e BUILD ]
then
echo Current directory already has WORKSPACE and/or BUILD files. >/dev/stderr
exit 1
fi
cat > WORKSPACE <<EOF
workspace(name = "YOUR_PROJECT_NAME_HERE")
http_archive(
name = "io_tweag_rules_haskell",
strip_prefix = "rules_haskell-0.3",
urls = ["https://github.com/tweag/rules_haskell/archive/v0.3.tar.gz"]
)
load("@io_tweag_rules_haskell//haskell:repositories.bzl", "haskell_repositories")
haskell_repositories()
http_archive(
name = "io_tweag_rules_nixpkgs",
strip_prefix = "rules_nixpkgs-0.1.1",
urls = ["https://github.com/tweag/rules_nixpkgs/archive/v0.1.1.tar.gz"],
)
load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_package")
nixpkgs_package(
name = "ghc",
attribute_path = "haskell.compiler.ghc822",
)
register_toolchains("//:ghc")
EOF
cat > BUILD <<EOF
package(default_visibility = ["//visibility:public"])
load(
"@io_tweag_rules_haskell//haskell:haskell.bzl",
"haskell_library",
"haskell_toolchain",
)
haskell_toolchain(
name = "ghc",
version = "8.2.2",
tools = "@ghc//:bin",
)
haskell_library(
name = "MY_LIBRARY_NAME",
src_strip_prefix = "src",
srcs = glob(['src/**/*.hs']),
prebuilt_dependencies = ["base"],
)
EOF
cat <<EOF
WORKSPACE and initial BUILD files created. To run Bazel:
$ bazel build //...
EOF