From: Ian Lynagh Date: Sun, 22 Aug 2010 15:55:14 +0000 (+0000) Subject: Generate the bit in the user guide where we say what -fglasgow-exts does X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=ab90e5fa171913fe777b2b6909030e3967e72bc6 Generate the bit in the user guide where we say what -fglasgow-exts does Stops the docs going out of sync with the code. --- diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index b00424c..2e7e1fe 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -17,6 +17,7 @@ module DynFlags ( DOpt(..), DynFlag(..), ExtensionFlag(..), + glasgowExtsFlags, flattenExtensionFlags, ensureFlattenedExtensionFlags, lopt_set_flattened, diff --git a/docs/users_guide/ghc.mk b/docs/users_guide/ghc.mk index f78ebca..9334784 100644 --- a/docs/users_guide/ghc.mk +++ b/docs/users_guide/ghc.mk @@ -10,9 +10,17 @@ # # ----------------------------------------------------------------------------- -docs/users_guide_DOCBOOK_SOURCES := \ - $(wildcard docs/users_guide/*.xml) \ - $(basename $(wildcard docs/users_guide/*.xml.in)) +docs/users_guide_GENERATED_DOCBOOK_SOURCES := \ + docs/users_guide/what_glasgow_exts_does.gen.xml + +# sort remove duplicates +docs/users_guide_DOCBOOK_SOURCES := \ + $(sort $(docs/users_guide_GENERATED_DOCBOOK_SOURCES) \ + $(wildcard docs/users_guide/*.xml) \ + $(basename $(wildcard docs/users_guide/*.xml.in))) + +$(docs/users_guide_GENERATED_DOCBOOK_SOURCES): %.gen.xml: inplace/bin/mkUserGuidePart + inplace/bin/mkUserGuidePart $@ $(eval $(call docbook,docs/users_guide,users_guide)) diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index d156de8..aeb9314 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -56,38 +56,7 @@ documentation describes all the libraries that come with GHC. The flag is equivalent to enabling the following extensions: - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - , - . + &what_glasgow_exts_does; Enabling these options is the only effect of . We are trying to move away from this portmanteau flag, diff --git a/docs/users_guide/ug-ent.xml.in b/docs/users_guide/ug-ent.xml.in index cbfc891..47d2f77 100644 --- a/docs/users_guide/ug-ent.xml.in +++ b/docs/users_guide/ug-ent.xml.in @@ -21,6 +21,7 @@ + diff --git a/ghc.mk b/ghc.mk index 89de086..b7c81d1 100644 --- a/ghc.mk +++ b/ghc.mk @@ -574,6 +574,11 @@ BUILD_DIRS += \ $(GHC_TOUCHY_DIR) endif +ifneq "$(BINDIST)" "YES" +BUILD_DIRS += \ + utils/mkUserGuidePart +endif + BUILD_DIRS += utils/count_lines BUILD_DIRS += utils/compare_sizes @@ -608,6 +613,7 @@ utils/ghctags_dist_DISABLE = YES utils/hpc_dist_DISABLE = YES utils/hsc2hs_dist-install_DISABLE = YES utils/ghc-pkg_dist-install_DISABLE = YES +utils/mkUserGuidePart_dist_DISABLE = YES utils/compare_sizes_dist_DISABLE = YES compiler_stage2_DISABLE = YES compiler_stage3_DISABLE = YES diff --git a/utils/mkUserGuidePart/Main.hs b/utils/mkUserGuidePart/Main.hs new file mode 100644 index 0000000..114114c --- /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 -> "" ++ [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 0000000..1af00bf --- /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 0000000..ef91767 --- /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))