-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
# language: haskell | ||
|
||
env: | ||
# - GHCVER=7.0.4 | ||
- GHCVER=7.4.2 | ||
- GHCVER=7.6.3 | ||
- GHCVER=7.8.4 | ||
- GHCVER=7.10.3 | ||
- GHCVER=8.0.1 | ||
- GHCVER=8.0.2 | ||
- GHCVER=8.2.2 | ||
- GHCVER=8.4.1 | ||
|
||
before_install: | ||
- sudo add-apt-repository -y ppa:hvr/ghc | ||
- sudo apt-get update | ||
- sudo apt-get install alex-3.1.7 happy-1.19.5 cabal-install-1.24 ghc-$GHCVER | ||
- export PATH=/opt/cabal/bin:/opt/ghc/$GHCVER/bin:/opt/alex/3.1.7/bin:/opt/happy/1.19.5/bin:$PATH | ||
- sudo apt-get install alex-3.1.7 happy-1.19.5 cabal-install-head ghc-$GHCVER | ||
- export PATH=/opt/cabal/head/bin:/opt/ghc/$GHCVER/bin:/opt/alex/3.1.7/bin:/opt/happy/1.19.5/bin:$PATH | ||
|
||
install: | ||
- cabal-1.24 update | ||
- cabal-1.24 install --only-dependencies --enable-tests | ||
- cabal update | ||
|
||
script: | ||
- make sdist | ||
- cd dist | ||
- tar xvzf alex-*.tar.gz | ||
- cd alex-*/ | ||
- cabal-1.24 configure --enable-tests | ||
- cabal-1.24 build | ||
- cabal-1.24 test | ||
- "echo 'packages: .' > cabal.project" | ||
- cabal new-test --enable-tests |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
packages: | ||
./ | ||
./gen-alex-sdist/ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module Main (main) where | ||
|
||
import Control.Monad | ||
import Language.Preprocessor.Cpphs | ||
import System.Directory | ||
import System.FilePath | ||
|
||
main :: IO () | ||
main = do | ||
sequence_ ([ cpp_template "GenericTemplate.hs" dst opts | (dst,opts) <- templates ] ++ | ||
[ cpp_template "wrappers.hs" dst opts | (dst,opts) <- wrappers ]) | ||
|
||
putStrLn "" | ||
putStrLn "-- fragment for alex.cabal file" | ||
putStrLn "data-dir: data/" | ||
putStrLn "" | ||
putStrLn "data-files:" | ||
forM_ all_template_files $ \fn -> putStrLn (" " ++ fn) | ||
putStrLn "-- end of fragment" | ||
putStrLn "" | ||
putStrLn "You can invoke `cabal sdist` now" | ||
|
||
cpp_template :: FilePath -> FilePath -> [String] -> IO () | ||
cpp_template src0 dst0 defs = do | ||
ex <- doesFileExist src | ||
unless ex $ | ||
fail ("file " ++ show src ++ " not found; are you in the right directory?") | ||
|
||
putStrLn ("generating " ++ show dst ++ " (from " ++ show src ++ ")...") | ||
createDirectoryIfMissing False "data" | ||
srcdat <- readFile src | ||
outdat <- runCpphs cppflags src =<< readFile src | ||
writeFile dst outdat | ||
|
||
return () | ||
where | ||
src = "templates" </> src0 | ||
dst = "data" </> dst0 | ||
|
||
cppflags = defaultCpphsOptions | ||
{ defines = [(d,"1") | d <- defs ] | ||
, boolopts = defaultBoolOptions | ||
{ hashline = False | ||
, locations = True | ||
, ansi = False | ||
, macros = True | ||
} | ||
} | ||
|
||
all_template_files :: [FilePath] | ||
all_template_files = map fst (templates ++ wrappers) | ||
|
||
templates :: [(FilePath,[String])] | ||
templates = [ | ||
("AlexTemplate", []), | ||
("AlexTemplate-ghc", ["ALEX_GHC"]), | ||
("AlexTemplate-ghc-nopred",["ALEX_GHC", "ALEX_NOPRED"]), | ||
("AlexTemplate-ghc-debug", ["ALEX_GHC","ALEX_DEBUG"]), | ||
("AlexTemplate-debug", ["ALEX_DEBUG"]) | ||
] | ||
|
||
wrappers :: [(FilePath,[String])] | ||
wrappers = [ | ||
("AlexWrapper-basic", ["ALEX_BASIC"]), | ||
("AlexWrapper-basic-bytestring", ["ALEX_BASIC_BYTESTRING"]), | ||
("AlexWrapper-strict-bytestring", ["ALEX_STRICT_BYTESTRING"]), | ||
("AlexWrapper-posn", ["ALEX_POSN"]), | ||
("AlexWrapper-posn-bytestring", ["ALEX_POSN_BYTESTRING"]), | ||
("AlexWrapper-monad", ["ALEX_MONAD"]), | ||
("AlexWrapper-monad-bytestring", ["ALEX_MONAD_BYTESTRING"]), | ||
("AlexWrapper-monadUserState", ["ALEX_MONAD", "ALEX_MONAD_USER_STATE"]), | ||
("AlexWrapper-monadUserState-bytestring", ["ALEX_MONAD_BYTESTRING", "ALEX_MONAD_USER_STATE"]), | ||
("AlexWrapper-gscan", ["ALEX_GSCAN"]) | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cabal-version: 1.12 | ||
name: gen-alex-sdist | ||
version: 0 | ||
synopsis: Tool for generating `alex` sdist | ||
category: Development | ||
build-type: Simple | ||
|
||
executable gen-alex-sdist | ||
default-language: Haskell2010 | ||
main-is: Main.hs | ||
build-depends: base < 5 | ||
, cpphs >= 1.20.8 && < 1.21 | ||
, directory < 1.4 | ||
, process < 1.7 | ||
, filepath < 1.5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
ALEX=../dist/build/alex/alex | ||
# NOTE: `cabal` will take care to build the local `alex` executable and place it into $PATH for us to pick up | ||
ALEX:=$(shell which alex) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hvr
Author
Member
|
||
# NOTE: This assumes that a working `ghc` is on $PATH; this may not necessarily be the same GHC used by `cabal` for building `alex`. | ||
HC=ghc | ||
HC_OPTS=-Wall -fno-warn-missing-signatures -fno-warn-unused-imports -fno-warn-tabs -Werror | ||
|
||
|
@@ -36,7 +38,9 @@ TESTS = \ | |
tokens_strict_bytestring.x \ | ||
unicode.x | ||
|
||
TEST_ALEX_OPTS = --template=.. | ||
# NOTE: `cabal` will set the `alex_datadir` env-var accordingly before invoking the test-suite | ||
#TEST_ALEX_OPTS = --template=../data/ | ||
TEST_ALEX_OPTS= | ||
|
||
%.n.hs : %.x | ||
$(ALEX) $(TEST_ALEX_OPTS) $< -o $@ | ||
|
@@ -62,6 +66,7 @@ all :: $(ALL_TESTS) | |
clean: | ||
rm -f $(CLEAN_FILES) | ||
|
||
# NOTE: The `../dist` path belows don't aren't accurate anymore for recent cabals | ||
interact: | ||
ghci -cpp -i../src -i../dist/build/autogen -i../dist/build/alex/alex-tmp Main -fbreak-on-exception | ||
# -args='--template=.. simple.x -o simple.n.hs' | ||
|
This change breaks the test suite for users who are running
./Setup test
instead of usingcabal
.