-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
110 lines (92 loc) · 2.62 KB
/
Makefile
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
TMP = .tmp
VERSION ?= $(shell grep '^version:' oden.cabal | sed -Ee 's/^version\:(.+)$$/\1/' | xargs)
OS=$(shell tools/get_os.sh)
DIST_NAME=oden-$(VERSION)-$(OS)
DIST_ARCHIVE=dist/$(DIST_NAME).tar.gz
IMPORTER_SRC=$(shell find go/src/oden -name '*.go')
NODEMON=node_modules/.bin/nodemon
.PHONY: build
build: dist/go-lib/importer.a
cabal build oden
dist/go-lib/importer.a: $(IMPORTER_SRC)
mkdir -p dist/go-lib
(cd dist/go-lib \
&& GOPATH=$(PWD)/go go build -buildmode=c-archive oden/cmd/importer)
.PHONY: libs
libs: dist/go-lib/importer.a
.PHONY: clean
clean:
rm -rf dist
$(TMP):
mkdir -p $(TMP)
.PHONY: test
test:
cabal exec runhaskell -- -isrc -itest test/Spec.hs
.PHONY: watch-test
watch-test: $(NODEMON)
$(NODEMON) --watch src --watch test -e hs --exec make test
$(NODEMON):
npm install nodemon
init-dev:
cabal sandbox init
cabal install --enable-tests --only-dependencies
cabal configure --enable-tests
dist/build-oden-cli/bin/oden: build
rm -rf dist/build-oden-cli
cp -r dist/build dist/build-oden-cli
mkdir -p dist/build-oden-cli/bin
ghc \
--make \
-package-db .cabal-sandbox/*-packages.conf.d \
-odir dist/build-oden-cli \
-hidir dist/build-oden-cli \
-ioden \
-isrc \
-fPIC \
-static \
-threaded \
-o dist/build-oden-cli/bin/oden \
dist/build-oden-cli/libHSoden*.a \
dist/build-oden-cli/autogen/Paths_oden.hs \
dist/go-lib/importer.a \
$(shell find cli -name '*.hs')
.PHONY: cli
cli: dist/build-oden-cli/bin/oden
dist/oden: dist/build-oden-cli/bin/oden
@mkdir -p dist/oden/bin
cp README.md dist/oden/README.txt
cp LICENSE.md dist/oden/LICENSE.txt
cp CREDITS.md dist/oden/CREDITS.txt
cp CHANGELOG.md dist/oden/CHANGELOG.txt
cp dist/build-oden-cli/bin/oden dist/oden/bin/oden
$(DIST_ARCHIVE): dist/oden
(cd dist/oden && tar -czf ../$(DIST_NAME).tar.gz .)
dist: $(DIST_ARCHIVE)
docker-dist:
@(docker kill oden-builder &> /dev/null ; true)
@(docker rm oden-builder &> /dev/null ; true)
docker build \
-t oden-build:$(VERSION) \
.
docker run \
--env VERSION=$(VERSION) \
--name oden-builder \
oden-build:$(VERSION)
docker cp oden-builder:/src/dist/oden-$(VERSION)-linux.tar.gz dist
release: $(DIST_ARCHIVE)
@echo "\n\nDon't forget to set env variable GITHUB_TOKEN first!\n\n"
go get github.com/aktau/github-release
-git tag -a -m "Release $(VERSION)" $(VERSION) && git push origin +$(VERSION)
-github-release release \
--user oden-lang \
--repo oden \
--tag $(VERSION) \
--name $(VERSION) \
--pre-release
find dist -name 'oden-$(VERSION)-*.tar.gz' -execdir \
github-release upload \
--user oden-lang \
--repo oden \
--tag $(VERSION) \
--name {} \
--file {} \;