diff options
author | Ian Lynagh <igloo@earth.li> | 2010-08-22 15:55:14 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2010-08-22 15:55:14 +0000 |
commit | ab90e5fa171913fe777b2b6909030e3967e72bc6 (patch) | |
tree | 77684e18f29ef622181eba6b740e6de2aea8aab7 /utils/mkUserGuidePart | |
parent | c07d7849d440a1ff371690654205c02c06b56fd0 (diff) | |
download | haskell-ab90e5fa171913fe777b2b6909030e3967e72bc6.tar.gz |
Generate the bit in the user guide where we say what -fglasgow-exts does
Stops the docs going out of sync with the code.
Diffstat (limited to 'utils/mkUserGuidePart')
-rw-r--r-- | utils/mkUserGuidePart/Main.hs | 39 | ||||
-rw-r--r-- | utils/mkUserGuidePart/Makefile | 15 | ||||
-rw-r--r-- | utils/mkUserGuidePart/ghc.mk | 19 |
3 files changed, 73 insertions, 0 deletions
diff --git a/utils/mkUserGuidePart/Main.hs b/utils/mkUserGuidePart/Main.hs new file mode 100644 index 0000000000..114114ca1c --- /dev/null +++ b/utils/mkUserGuidePart/Main.hs @@ -0,0 +1,39 @@ + +module Main (main) where + +import DynFlags + +import Data.List +import System.Environment + +main :: IO () +main = do args <- getArgs + case args of + [] -> error "Need to give filename to generate as an argument" + [f] -> + case f of + "docs/users_guide/what_glasgow_exts_does.gen.xml" -> + writeFile f whatGlasgowExtsDoes + _ -> + error ("Don't know what to do for " ++ show f) + _ -> error "Bad args" + +whatGlasgowExtsDoes :: String +whatGlasgowExtsDoes = case maybeInitLast glasgowExtsFlags of + Just (xs, x) -> + let xs' = map mkInitLine xs + x' = mkLastLine x + in unlines (xs' ++ [x']) + Nothing -> + error "glasgowExtsFlags is empty?" + where mkInitLine = mkLine ',' + mkLastLine = mkLine '.' + mkLine c f = case stripPrefix "Opt_" (show f) of + Just ext -> "<option>-X" ++ ext ++ "</option>" ++ [c] + Nothing -> error ("Can't parse extension: " ++ show f) + +maybeInitLast :: [a] -> Maybe ([a], a) +maybeInitLast xs = case reverse xs of + (y : ys) -> Just (reverse ys, y) + _ -> Nothing + diff --git a/utils/mkUserGuidePart/Makefile b/utils/mkUserGuidePart/Makefile new file mode 100644 index 0000000000..1af00bf9da --- /dev/null +++ b/utils/mkUserGuidePart/Makefile @@ -0,0 +1,15 @@ +# ----------------------------------------------------------------------------- +# +# (c) 2009 The University of Glasgow +# +# This file is part of the GHC build system. +# +# To understand how the build system works and how to modify it, see +# http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture +# http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying +# +# ----------------------------------------------------------------------------- + +dir = utils/mkUserGuidePart +TOP = ../.. +include $(TOP)/mk/sub-makefile.mk diff --git a/utils/mkUserGuidePart/ghc.mk b/utils/mkUserGuidePart/ghc.mk new file mode 100644 index 0000000000..ef91767183 --- /dev/null +++ b/utils/mkUserGuidePart/ghc.mk @@ -0,0 +1,19 @@ +# ----------------------------------------------------------------------------- +# +# (c) 2009 The University of Glasgow +# +# This file is part of the GHC build system. +# +# To understand how the build system works and how to modify it, see +# http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture +# http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying +# +# ----------------------------------------------------------------------------- + +utils/mkUserGuidePart_dist_MODULES = Main +utils/mkUserGuidePart_dist_PROG = mkUserGuidePart +utils/mkUserGuidePart_HC_OPTS = -package ghc + +utils/mkUserGuidePart/dist/build/Main.o: $(compiler_stage2_v_LIB) + +$(eval $(call build-prog,utils/mkUserGuidePart,dist,1)) |