Generate the bit in the user guide where we say what -fglasgow-exts does
authorIan Lynagh <igloo@earth.li>
Sun, 22 Aug 2010 15:55:14 +0000 (15:55 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 22 Aug 2010 15:55:14 +0000 (15:55 +0000)
Stops the docs going out of sync with the code.

compiler/main/DynFlags.hs
docs/users_guide/ghc.mk
docs/users_guide/glasgow_exts.xml
docs/users_guide/ug-ent.xml.in
ghc.mk
utils/mkUserGuidePart/Main.hs [new file with mode: 0644]
utils/mkUserGuidePart/Makefile [new file with mode: 0644]
utils/mkUserGuidePart/ghc.mk [new file with mode: 0644]

index b00424c..2e7e1fe 100644 (file)
@@ -17,6 +17,7 @@ module DynFlags (
         DOpt(..),
         DynFlag(..),
         ExtensionFlag(..),
+        glasgowExtsFlags,
         flattenExtensionFlags,
         ensureFlattenedExtensionFlags,
         lopt_set_flattened,
index f78ebca..9334784 100644 (file)
 #
 # -----------------------------------------------------------------------------
 
-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))
 
index d156de8..aeb9314 100644 (file)
@@ -56,38 +56,7 @@ documentation</ulink> describes all the libraries that come with GHC.
     <para>The flag <option>-fglasgow-exts</option>
           <indexterm><primary><option>-fglasgow-exts</option></primary></indexterm>
          is equivalent to enabling the following extensions: 
-          <option>-XPrintExplicitForalls</option>,
-          <option>-XForeignFunctionInterface</option>,
-          <option>-XUnliftedFFITypes</option>,
-          <option>-XGADTs</option>,
-          <option>-XImplicitParams</option>,
-          <option>-XScopedTypeVariables</option>,
-          <option>-XUnboxedTuples</option>,
-          <option>-XTypeSynonymInstances</option>,
-          <option>-XStandaloneDeriving</option>,
-          <option>-XDeriveDataTypeable</option>,
-          <option>-XFlexibleContexts</option>,
-          <option>-XFlexibleInstances</option>,
-          <option>-XConstrainedClassMethods</option>,
-          <option>-XMultiParamTypeClasses</option>,
-          <option>-XFunctionalDependencies</option>,
-          <option>-XMagicHash</option>,
-          <option>-XPolymorphicComponents</option>,
-          <option>-XExistentialQuantification</option>,
-          <option>-XUnicodeSyntax</option>,
-          <option>-XPostfixOperators</option>,
-          <option>-XPatternGuards</option>,
-          <option>-XLiberalTypeSynonyms</option>,
-          <option>-XExplicitForAll</option>,
-          <option>-XRankNTypes</option>,
-          <option>-XImpredicativeTypes</option>,
-          <option>-XTypeOperators</option>,
-          <option>-XDoRec</option>,
-          <option>-XParallelListComp</option>,
-          <option>-XEmptyDataDecls</option>,
-          <option>-XKindSignatures</option>,
-          <option>-XGeneralizedNewtypeDeriving</option>,
-          <option>-XTypeFamilies</option>.
+          &what_glasgow_exts_does;
            Enabling these options is the <emphasis>only</emphasis> 
            effect of <option>-fglasgow-exts</option>.
           We are trying to move away from this portmanteau flag, 
index cbfc891..47d2f77 100644 (file)
@@ -21,6 +21,7 @@
 <!ENTITY win32-dll      SYSTEM "win32-dlls.xml">
 <!ENTITY ffi-chap       SYSTEM "ffi-chap.xml">
 <!ENTITY shared_libs    SYSTEM "shared_libs.xml">
+<!ENTITY what_glasgow_exts_does SYSTEM "what_glasgow_exts_does.gen.xml">
 <!ENTITY libraryBaseLocation    "../libraries/base-@LIBRARY_base_VERSION@">
 <!ENTITY libraryCabalLocation   "../libraries/Cabal-@LIBRARY_Cabal_VERSION@">
 <!ENTITY libraryGhcPrimLocation "../libraries/ghc-prim-@LIBRARY_ghc_prim_VERSION@">
diff --git a/ghc.mk b/ghc.mk
index 89de086..b7c81d1 100644 (file)
--- 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 (file)
index 0000000..114114c
--- /dev/null
@@ -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 (file)
index 0000000..1af00bf
--- /dev/null
@@ -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 (file)
index 0000000..ef91767
--- /dev/null
@@ -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))