Skip to content

Commit

Permalink
Merge pull request #124 from hvr/pr/issue-123
Browse files Browse the repository at this point in the history
Improve Makefile
  • Loading branch information
simonmar authored Mar 29, 2018
2 parents 1b382ce + 463422a commit f492334
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ install:

script:
- make sdist
- cd dist
- tar xvzf alex-*.tar.gz
- cd alex-*/
- "echo 'packages: .' > cabal.project"
- cabal new-test --enable-tests
- make sdist-test-only
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
CABAL = cabal

HAPPY = happy
HAPPY_OPTS = -agc

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

sdist ::
@case "`$(CABAL) --numeric-version`" in \
2.[2-9].* | [3-9].* ) ;; \
* ) echo "Error: needs cabal 2.2.0.0 or later (but got : `$(CABAL) --numeric-version`)" ; exit 1 ;; \
esac
@if [ "`git status -s`" != '' ]; then \
echo Tree is not clean; \
echo "Error: Tree is not clean"; \
exit 1; \
fi
rm -rf dist/
$(HAPPY) $(HAPPY_OPTS) src/Parser.y -o src/Parser.hs
$(ALEX) $(ALEX_OPTS) src/Scan.x -o src/Scan.hs
mv src/Parser.y src/Parser.y.boot
mv src/Scan.x src/Scan.x.boot
cabal new-run gen-alex-sdist
cabal sdist
$(CABAL) new-run gen-alex-sdist
$(CABAL) sdist
@if [ ! -f "dist/alex-$(ALEX_VER).tar.gz" ]; then \
echo "Error: source tarball not found: dist/alex-$(ALEX_VER).tar.gz"; \
exit 1; \
fi
git checkout .
git clean -f

sdist-test :: sdist sdist-test-only
@rm -rf "dist/alex-$(ALEX_VER)/"

sdist-test-only ::
@if [ ! -f "dist/alex-$(ALEX_VER).tar.gz" ]; then \
echo "Error: source tarball not found: dist/alex-$(ALEX_VER).tar.gz"; \
exit 1; \
fi
rm -rf "dist/alex-$(ALEX_VER)/"
tar -xf "dist/alex-$(ALEX_VER).tar.gz" -C dist/
echo "packages: ." > "dist/alex-$(ALEX_VER)/cabal.project"
cd "dist/alex-$(ALEX_VER)/" && cabal new-test --enable-tests all
@echo ""
@echo "Success! dist/alex-$(ALEX_VER).tar.gz is ready for distribution!"
@echo ""
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ new-run gen-alex-sdist` pre-preprocessing step):
$ make sdist
$ cabal install dist/alex-*.tar.gz

For convenience, there's also a `make sdist-test` target which builds the
source source tarball and runs the test-suite from within the source dist.

## Contributing & Reporting Issues

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

0 comments on commit f492334

Please sign in to comment.