Skip to content

Commit f492334

Browse files
authored
Merge pull request #124 from hvr/pr/issue-123
Improve Makefile
2 parents 1b382ce + 463422a commit f492334

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,4 @@ install:
2121

2222
script:
2323
- make sdist
24-
- cd dist
25-
- tar xvzf alex-*.tar.gz
26-
- cd alex-*/
27-
- "echo 'packages: .' > cabal.project"
28-
- cabal new-test --enable-tests
24+
- make sdist-test-only

Makefile

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,47 @@
1+
CABAL = cabal
2+
13
HAPPY = happy
24
HAPPY_OPTS = -agc
35

46
ALEX = alex
57
ALEX_OPTS = -g
8+
ALEX_VER = `awk '/^version:/ { print $$2 }' alex.cabal`
69

710
sdist ::
11+
@case "`$(CABAL) --numeric-version`" in \
12+
2.[2-9].* | [3-9].* ) ;; \
13+
* ) echo "Error: needs cabal 2.2.0.0 or later (but got : `$(CABAL) --numeric-version`)" ; exit 1 ;; \
14+
esac
815
@if [ "`git status -s`" != '' ]; then \
9-
echo Tree is not clean; \
16+
echo "Error: Tree is not clean"; \
1017
exit 1; \
1118
fi
19+
rm -rf dist/
1220
$(HAPPY) $(HAPPY_OPTS) src/Parser.y -o src/Parser.hs
1321
$(ALEX) $(ALEX_OPTS) src/Scan.x -o src/Scan.hs
1422
mv src/Parser.y src/Parser.y.boot
1523
mv src/Scan.x src/Scan.x.boot
16-
cabal new-run gen-alex-sdist
17-
cabal sdist
24+
$(CABAL) new-run gen-alex-sdist
25+
$(CABAL) sdist
26+
@if [ ! -f "dist/alex-$(ALEX_VER).tar.gz" ]; then \
27+
echo "Error: source tarball not found: dist/alex-$(ALEX_VER).tar.gz"; \
28+
exit 1; \
29+
fi
1830
git checkout .
1931
git clean -f
32+
33+
sdist-test :: sdist sdist-test-only
34+
@rm -rf "dist/alex-$(ALEX_VER)/"
35+
36+
sdist-test-only ::
37+
@if [ ! -f "dist/alex-$(ALEX_VER).tar.gz" ]; then \
38+
echo "Error: source tarball not found: dist/alex-$(ALEX_VER).tar.gz"; \
39+
exit 1; \
40+
fi
41+
rm -rf "dist/alex-$(ALEX_VER)/"
42+
tar -xf "dist/alex-$(ALEX_VER).tar.gz" -C dist/
43+
echo "packages: ." > "dist/alex-$(ALEX_VER)/cabal.project"
44+
cd "dist/alex-$(ALEX_VER)/" && cabal new-test --enable-tests all
45+
@echo ""
46+
@echo "Success! dist/alex-$(ALEX_VER).tar.gz is ready for distribution!"
47+
@echo ""

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ new-run gen-alex-sdist` pre-preprocessing step):
7878
$ make sdist
7979
$ cabal install dist/alex-*.tar.gz
8080

81+
For convenience, there's also a `make sdist-test` target which builds the
82+
source source tarball and runs the test-suite from within the source dist.
83+
8184
## Contributing & Reporting Issues
8285

8386
Please report any bugs or comments at https://github.com/simonmar/alex/issues

0 commit comments

Comments
 (0)