-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dong Han
committed
Aug 24, 2023
1 parent
5944ae9
commit 0cf1afb
Showing
77 changed files
with
12,404 additions
and
11,589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
lib: | ||
cabal build | ||
|
||
clean: | ||
cabal clean | ||
|
||
doctest: | ||
cabal repl --with-ghc=doctest | ||
|
||
doctest_verbose: | ||
cabal repl --with-ghc=doctest --repl-options=--verbose | ||
|
||
doc: | ||
cabal haddock \ | ||
--haddock-options="--mathjax=https://z.haskell.world/haddock.inject.utterances.via.mathjax.js?repo=ZHaskell/z-data"\ | ||
--haddock-hyperlink-sources --haddock-css=doc-assets/z.haddock.css \ | ||
--haddock-html-location='https://hackage.haskell.org/package/$$pkg-$$version/docs' | ||
|
||
cndoc: | ||
cabal -fbuild-chinese-doc haddock \ | ||
--haddock-options="--mathjax=https://z.haskell.world/haddock.inject.utterances.via.mathjax.js?repo=ZHaskell/z-data"\ | ||
--haddock-hyperlink-sources --haddock-css=doc-assets/z.haddock.css \ | ||
--haddock-html-location='https://hackage.haskell.org/package/$$pkg-$$version/docs' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,102 @@ | ||
{-# LANGUAGE CPP #-} | ||
import Distribution.Simple | ||
import System.Environment | ||
module Main (main) where | ||
|
||
import Control.Monad | ||
import Distribution.Pretty | ||
import Distribution.Simple | ||
import Distribution.Simple.Setup | ||
import Distribution.Simple.LocalBuildInfo | ||
import Distribution.Verbosity | ||
import Distribution.Simple.Utils | ||
import Distribution.Simple.Program | ||
import Distribution.Simple.Program.Db | ||
import Distribution.System | ||
import Distribution.Utils.NubList | ||
import Distribution.Types.BuildInfo | ||
import Distribution.Types.HookedBuildInfo | ||
import Distribution.Types.Library | ||
import Distribution.Types.LocalBuildInfo | ||
import Distribution.Types.PackageDescription | ||
import Data.Maybe | ||
import Data.List | ||
import System.Directory | ||
import System.FilePath | ||
import qualified System.Environment as System | ||
|
||
main :: IO () | ||
main = do | ||
#if __GLASGOW_HASKELL__ < 810 | ||
defaultMain | ||
#else | ||
args <- getArgs | ||
if head args == "configure" | ||
then defaultMainArgs $ [ "--ghc-options", "-optcxx-std=c++11" | ||
] ++ args | ||
else defaultMain | ||
#endif | ||
defaultMainWithHooks simpleUserHooks { | ||
preConf = zPreConf, | ||
confHook = \ pd flags -> do | ||
lbi <- confHook simpleUserHooks pd flags | ||
baseDir <- getCurrentDirectory | ||
let verbosity = fromFlag (configVerbosity flags) | ||
configFile = baseDir </> "third_party" </> "botan" </> "configure.py" | ||
configFolder = baseDir </> "third_party" </> "botan" | ||
headerFile = baseDir </> "third_party" </> "botan" </> "botan_all.h" | ||
placeholder = "build" </> "include" </> "external" </> "cabal.placeholder" | ||
headerFileExists <- doesFileExist headerFile | ||
unless headerFileExists $ do | ||
confExists <- doesFileExist configFile | ||
if confExists | ||
then do | ||
runConfigureScript configFolder configFile verbosity flags lbi | ||
runTouch configFolder placeholder verbosity flags | ||
else die' verbosity "botan configure script not found." | ||
|
||
return lbi | ||
, regHook = \ _ _ _ _ -> return () | ||
} | ||
|
||
zPreConf :: Args -> ConfigFlags -> IO HookedBuildInfo | ||
zPreConf args flags = do | ||
preConf simpleUserHooks args flags | ||
|
||
runConfigureScript :: FilePath -> FilePath -> Verbosity -> ConfigFlags -> LocalBuildInfo -> IO () | ||
runConfigureScript configFolder configFile verbosity flags lbi = do | ||
env <- System.getEnvironment | ||
configureFile <- makeAbsolute configFile | ||
|
||
let extraPath = fromNubList $ configProgramPathExtra flags | ||
spSep = [searchPathSeparator] | ||
pathEnv = maybe (intercalate spSep extraPath) | ||
((intercalate spSep extraPath ++ spSep)++) $ lookup "PATH" env | ||
pyProgs = simpleProgram <$> ["python", "python2", "python3"] | ||
progDb = modifyProgramSearchPath | ||
(\p -> map ProgramSearchPathDir extraPath ++ p) emptyProgramDb | ||
overEnv = [("PATH", Just pathEnv) | not (null extraPath)] | ||
hp@(Platform arch os) = hostPlatform lbi | ||
-- use gcc/mingw bunlded with GHC | ||
osStr = if os == Windows then "mingw" else (show (pretty os)) | ||
hostFlag = [ "--cpu=" ++ show (pretty arch), "--os=" ++ osStr] | ||
-- pass amalgamation to produce botan_all.cpp | ||
args = configureFile:"--amalgamation":"--disable-shared":hostFlag | ||
|
||
pyConfiguredProg <- forM pyProgs $ \ pyProg -> | ||
lookupProgram pyProg <$> configureProgram verbosity pyProg progDb | ||
|
||
case msum (pyConfiguredProg) of | ||
Just py -> runProgramInvocation verbosity $ | ||
(programInvocation (py {programOverrideEnv = overEnv}) args) | ||
{ progInvokeCwd = Just configFolder } | ||
Nothing -> die' verbosity notFoundMsg | ||
where | ||
notFoundMsg = "The package's dep(botan) has a 'configure.py' script. " | ||
++ "This requires python is discoverable in your path." | ||
|
||
|
||
runTouch :: FilePath -> FilePath -> Verbosity -> ConfigFlags -> IO () | ||
runTouch configFolder placeholder verbosity flags = do | ||
let extraPath = fromNubList $ configProgramPathExtra flags | ||
progDb = modifyProgramSearchPath | ||
(\p -> map ProgramSearchPathDir extraPath ++ p) emptyProgramDb | ||
touchPG = simpleProgram "touch" | ||
touch <- lookupProgram touchPG <$> configureProgram verbosity touchPG progDb | ||
case touch of | ||
Just touch' -> | ||
runProgramInvocation verbosity $ | ||
(programInvocation touch' [placeholder]) | ||
{ progInvokeCwd = Just configFolder } | ||
Nothing -> warn verbosity notFoundMsg | ||
where | ||
notFoundMsg = "touch is required to keep a cabal placeholder file, otherwise cabal sdist may produce an unbuildable tarball" |
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ Maintainer : [email protected] | |
Stability : experimental | ||
Portability : non-portable | ||
ASCII Chars utility. | ||
ASCII Chars utility, all funcions works on <https://en.wikipedia.org/wiki/ASCII US-ASCII> chars. | ||
-} | ||
|
||
|
@@ -57,24 +57,6 @@ toUpper w | |
| 97 <= w && w <= 122 = w - 32 | ||
| otherwise = w | ||
|
||
-- | @A ~ Z@ => @a ~ z@, @À ~ Ö@ => @à ~ ö@, @Ø ~ Þ@ => @ø ~ þ@ | ||
toLowerLatin :: Word8 -> Word8 | ||
{-# INLINE toLowerLatin #-} | ||
toLowerLatin w | ||
| 65 <= w && w <= 90 || | ||
192 <= w && w <= 214 || | ||
216 <= w && w <= 222 = w + 32 | ||
| otherwise = w | ||
|
||
-- | @a ~ z@ => @A ~ Z@, @à ~ ö@ => @À ~ Ö@, @ø ~ þ@ => @Ø ~ Þ@ | ||
toUpperLatin :: Word8 -> Word8 | ||
{-# INLINE toUpperLatin #-} | ||
toUpperLatin w | ||
| 97 <= w && w <= 122 || | ||
224 <= w && w <= 246 || | ||
248 <= w && w <= 254 = w - 32 | ||
| otherwise = w | ||
|
||
-- | @ISO-8859-1@ control letter. | ||
isControl :: Word8 -> Bool | ||
{-# INLINE isControl #-} | ||
|
@@ -90,6 +72,11 @@ isDigit :: Word8 -> Bool | |
{-# INLINE isDigit #-} | ||
isDigit w = w - DIGIT_0 <= 9 | ||
|
||
-- | @a-z A-Z@ | ||
isLetter :: Word8 -> Bool | ||
{-# INLINE isLetter #-} | ||
isLetter w = isLower w || isUpper w | ||
|
||
-- | @0 ~ 7@ | ||
isOctDigit :: Word8 -> Bool | ||
{-# INLINE isOctDigit #-} | ||
|
Oops, something went wrong.