Permalink
Browse files

reorganize cabal templates

  * root cabal package.cabal file renamed to mega-regex

  * mega-regex generated from include files that are also used
    to make up the regex.cabal and regex-examples.cabal

  * mega-regex tested for test, install and basic sdist
  • Loading branch information...
cdornan committed Feb 19, 2017
1 parent 3aa00c4 commit ac8da837c3ef1bf9a8b55e5942504034ca9c8c27
View
@@ -18,6 +18,7 @@ module TestKit
, runTests
, checkThis
, test_pp
+ , include
, cmp
) where
@@ -163,6 +164,24 @@ test_pp lab loop test_file gold_file = do
tmp_pth = "tmp/mod.lhs"
\end{code}
+
+simple include processor
+------------------------
+
+\begin{code}
+include :: LBS.ByteString -> IO LBS.ByteString
+include = sed' $ Select
+ [ (,) [re|^%include ${file}(@{%string})$|] $ EDIT_fun TOP incl
+ , (,) [re|^.*$|] $ EDIT_fun TOP $ \_ _ _ _->return Nothing
+ ]
+ where
+ incl _ mtch _ _ = Just <$> LBS.readFile (prs_s $ mtch !$$ [cp|file|])
+ prs_s = maybe (error "include") T.unpack . parseString
+\end{code}
+
+cmp
+---
+
\begin{code}
cmp :: T.Text -> T.Text -> IO Bool
cmp src dst = handle hdl $ do
View
@@ -31,25 +31,26 @@ main = do
case as of
[] -> test
["test"] -> test
- ["gen"] -> gen "lib/cabal-masters/regex.cabal" "regex.cabal"
+ ["gen"] -> gen "lib/cabal-masters/mega-regex.cabal" "mega-regex.cabal"
_ -> do
hPutStrLn stderr $ "usage: " ++ pn ++ " [test|gen]"
exitWith $ ExitFailure 1
test :: IO ()
test = do
createDirectoryIfMissing False "tmp"
- gen "lib/cabal-masters/regex.cabal" "tmp/regex.cabal"
- ok <- cmp "tmp/regex.cabal" "regex.cabal"
+ gen "lib/cabal-masters/mega-regex.cabal" "tmp/mega-regex.cabal"
+ ok <- cmp "tmp/mega-regex.cabal" "mega-regex.cabal"
case ok of
True -> return ()
False -> exitWith $ ExitFailure 1
gen :: FilePath -> FilePath -> IO ()
gen in_f out_f = do
ctx <- setup
- substVersion in_f "tmp/regex-vrn.cabal"
- sed (gc_script ctx) "tmp/regex-vrn.cabal" out_f
+ LBS.writeFile out_f =<<
+ sed' (gc_script ctx) =<< substVersion_ =<< include =<<
+ LBS.readFile in_f
data Ctx =
Ctx
View
@@ -50,18 +50,18 @@ The Sed Script
loop :: FilePath -> FilePath -> IO ()
loop =
sed $ Select
- [ (,) [re|^%include ${file}(@{%string}) ${rex}(@{%string})$|] $ EDIT_fun TOP include
+ [ (,) [re|^%include ${file}(@{%string}) ${rex}(@{%string})$|] $ EDIT_fun TOP include_file
, (,) [re|^.*$|] $ EDIT_fun TOP $ \_ _ _ _->return Nothing
]
\end{code}
\begin{code}
-include :: LineNo
- -> Match LBS.ByteString
- -> Location
- -> Capture LBS.ByteString
- -> IO (Maybe LBS.ByteString)
-include _ mtch _ _ = fmap Just $
+include_file :: LineNo
+ -> Match LBS.ByteString
+ -> Location
+ -> Capture LBS.ByteString
+ -> IO (Maybe LBS.ByteString)
+include_file _ mtch _ _ = fmap Just $
extract fp =<< compileRegex () re_s
where
fp = prs_s $ captureText [cp|file|] mtch
View
@@ -790,21 +790,6 @@ pandoc_lhs' title repo_path in_file out_file = do
\end{code}
-simple include processor
-------------------------
-
-\begin{code}
-include :: LBS.ByteString -> IO LBS.ByteString
-include = sed' $ Select
- [ (,) [re|^%include ${file}(@{%string})$|] $ EDIT_fun TOP incl
- , (,) [re|^.*$|] $ EDIT_fun TOP $ \_ _ _ _->return Nothing
- ]
- where
- incl _ mtch _ _ = Just <$> LBS.readFile (prs_s $ mtch !$$ [cp|file|])
- prs_s = maybe (error "include") T.unpack . parseString
-\end{code}
-
-
branding
--------
@@ -0,0 +1,24 @@
+%- array >= 0.4
+%- base >= 4 && < 5
+%- base-compat >= 0.6.0
+%- bytestring >= 0.10.2.0
+%- containers >= 0.4
+%- directory >= 1.2.1.0
+%- hashable >= 1.2.3.3
+%- heredoc >= 0.2.0.0
+%- http-conduit >= 2.1.7.2
+%- regex-base >= 0.93.2
+%- regex-pcre-builtin >= 0.94.4.8.8.35
+%- regex-tdfa >= 1.2.0
+%- regex-tdfa-text >= 1.0.0.3
+%- shelly >= 1.6.1.2
+%- smallcheck >= 1.1.1
+%- tasty >= 0.10.1.2
+%- tasty-hunit >= 0.9.2
+%- tasty-smallcheck >= 0.8.0.1
+%- template-haskell >= 2.7
+%- text >= 1.2.0.6
+%- time >= 1.4.2
+%- time-locale-compat >= 0.1.0.1
+%- transformers >= 0.2.2
+%- unordered-containers >= 0.2.5.1
@@ -0,0 +1,116 @@
+%test-exe re-gen-cabals
+ Hs-Source-Dirs: examples
+
+ Main-Is: re-gen-cabals.lhs
+
+ Other-Modules:
+ TestKit
+
+ Default-Language: Haskell2010
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+%build-depends regex array base base-compat containers bytestring directory regex-base regex-tdfa shelly text
+
+%test-exe re-gen-modules
+ Hs-Source-Dirs: examples
+
+ Main-Is: re-gen-modules.lhs
+
+ Default-Language: Haskell2010
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+%build-depends regex array base base-compat bytestring directory regex-base regex-tdfa shelly text
+
+%test-exe re-include
+ Hs-Source-Dirs: examples
+
+ Main-Is: re-include.lhs
+
+ Default-Language: Haskell2010
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+ Other-Modules:
+ TestKit
+
+%build-depends regex base base-compat bytestring directory shelly text
+
+%test-exe re-nginx-log-processor
+ Hs-Source-Dirs: examples
+
+ Main-Is: re-nginx-log-processor.lhs
+
+ Default-Language: Haskell2010
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+%build-depends regex array base base-compat bytestring directory regex-base regex-tdfa shelly text time time-locale-compat transformers unordered-containers
+
+%test-exe re-prep
+ Hs-Source-Dirs: examples
+
+ Main-Is: re-prep.lhs
+
+ Default-Language: Haskell2010
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+ Other-Modules:
+ TestKit
+
+%build-depends regex base base-compat bytestring directory heredoc http-conduit shelly text
+
+%test-exe re-tests
+ Hs-Source-Dirs: examples
+
+ Main-Is: re-tests.lhs
+
+ Default-Language: Haskell2010
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+ Other-Modules:
+ TestKit
+
+%build-depends regex array base base-compat bytestring containers directory heredoc regex-base regex-tdfa regex-tdfa-text regex-pcre-builtin smallcheck tasty tasty-hunit tasty-smallcheck template-haskell text unordered-containers
+
+%test-exe re-tutorial
+ Hs-Source-Dirs: examples
+
+ Main-Is: re-tutorial.lhs
+
+ Other-Modules:
+ TestKit
+
+ Default-Language: Haskell2010
+ Default-Extensions: QuasiQuotes
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+%build-depends regex array base base-compat bytestring containers directory hashable heredoc regex-base regex-tdfa regex-tdfa-text regex-pcre-builtin shelly smallcheck tasty tasty-hunit tasty-smallcheck template-haskell transformers text time time-locale-compat unordered-containers
+
+%test re-tutorial-os
+ Hs-Source-Dirs: examples
+
+ Main-Is: re-tutorial.lhs
+
+ Other-Modules:
+ TestKit
+
+ Default-Language: Haskell2010
+ Extensions: OverloadedStrings
+ Default-Extensions: QuasiQuotes
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+%build-depends regex array base base-compat bytestring containers directory hashable heredoc regex-base regex-tdfa regex-tdfa-text regex-pcre-builtin shelly smallcheck tasty tasty-hunit tasty-smallcheck template-haskell transformers text time time-locale-compat unordered-containers
@@ -0,0 +1,43 @@
+Library
+ Hs-Source-Dirs: .
+ Exposed-Modules:
+ Text.RE
+ Text.RE.Capture
+ Text.RE.CaptureID
+ Text.RE.Edit
+ Text.RE.Internal.NamedCaptures
+ Text.RE.Internal.PreludeMacros
+ Text.RE.Internal.QQ
+ Text.RE.IsRegex
+ Text.RE.LineNo
+ Text.RE.Options
+ Text.RE.Parsers
+ Text.RE.PCRE
+ Text.RE.PCRE.ByteString
+ Text.RE.PCRE.ByteString.Lazy
+ Text.RE.PCRE.RE
+ Text.RE.PCRE.Sequence
+ Text.RE.PCRE.String
+ Text.RE.Replace
+ Text.RE.TDFA
+ Text.RE.TDFA.ByteString
+ Text.RE.TDFA.ByteString.Lazy
+ Text.RE.TDFA.RE
+ Text.RE.TDFA.Sequence
+ Text.RE.TDFA.String
+ Text.RE.TDFA.Text
+ Text.RE.TDFA.Text.Lazy
+ Text.RE.TestBench
+ Text.RE.Tools.Grep
+ Text.RE.Tools.Lex
+ Text.RE.Tools.Sed
+
+ Other-Modules:
+ Text.RE.Internal.AddCaptureNames
+
+ Default-Language: Haskell2010
+ GHC-Options:
+ -Wall
+ -fwarn-tabs
+
+%build-depends array bytestring base base-compat containers hashable heredoc regex-base regex-tdfa regex-tdfa-text regex-pcre-builtin template-haskell text time time-locale-compat transformers unordered-containers
@@ -0,0 +1,56 @@
+Name: mega-regex
+Version: <<$version$>>
+Synopsis: Toolkit for regex-base
+Description: A Regular Expression Toolkit for regex-base with
+ Compile-time checking of RE syntax, data types for
+ matches and captures, a text replacement toolkit,
+ portable options, high-level AWK-like tools
+ for building text processing apps, regular expression
+ macros and test bench, a tutorial and copious examples.
+Homepage: http://regex.uk
+Author: Chris Dornan
+License: BSD3
+license-file: LICENSE
+Maintainer: Chris Dornan <chris@regex.uk>
+Copyright: Chris Dornan 2016-2017
+Category: Text
+Build-type: Simple
+Stability: RFC
+bug-reports: http://issues.regex.uk
+
+Extra-Source-Files:
+ README.markdown
+ changelog
+ data/access-errors.log
+ data/access.log
+ data/error.log
+ data/events.log
+ data/include-result.lhs
+ data/pp-result-doc.lhs
+ data/pp-result-gen.lhs
+ data/pp-test.lhs
+ lib/cabal-masters/regex.cabal
+ lib/version.txt
+ src/Text/RE/TDFA/ByteString/Lazy.hs
+ docs/pcre-nginx-log-processor.txt
+ docs/tdfa-macros.txt
+ docs/pcre-macros.txt
+
+Cabal-Version: >= 1.16
+
+Source-Repository head
+ type: git
+ location: https://github.com/iconnect/regex.git
+
+Source-Repository this
+ Type: git
+ Location: https://github.com/iconnect/regex.git
+ Tag: <<$version$>>
+
+%include "lib/cabal-masters/constraints-incl.cabal"
+
+%include "lib/cabal-masters/library-incl.cabal"
+
+%include "lib/cabal-masters/executables-incl.cabal"
+
+-- Generated from lib/cabal-masters/mega-regex with re-gen-cabals
@@ -0,0 +1,41 @@
+Name: regex-examples
+Version: <<$version$>>
+Synopsis: Tutorial, tests and example programs for regex
+Description: Tutorial, tests and example programs for regex,
+ a Regular Expression Toolkit for regex-base with
+ Compile-time checking of RE syntax, data types for
+ matches and captures, a text replacement toolkit,
+ portable options, high-level AWK-like tools
+ for building text processing apps, regular expression
+ macros and test bench, a tutorial and copious examples.
+Homepage: http://regex.uk
+Author: Chris Dornan
+License: BSD3
+license-file: LICENSE
+Maintainer: Chris Dornan <chris@regex.uk>
+Copyright: Chris Dornan 2016-2017
+Category: Text
+Build-type: Simple
+Stability: RFC
+bug-reports: http://issues.regex.uk
+
+%include "lib/cabal-masters/test-extra-source-files-incl.cabal"
+
+Cabal-Version: >= 1.16
+
+Source-Repository head
+ type: git
+ location: https://github.com/iconnect/regex.git
+
+Source-Repository this
+ Type: git
+ Location: https://github.com/iconnect/regex.git
+ Tag: <<$version$>>
+
+%include "lib/cabal-masters/constraints-incl.cabal"
+
+%include "lib/cabal-masters/library-incl.cabal"
+
+%include "lib/cabal-masters/executables-incl.cabal"
+
+-- Generated from lib/cabal-masters/mega-regex with re-gen-cabals
Oops, something went wrong.

0 comments on commit ac8da83

Please sign in to comment.