[commit: ghc] wip/nfs-locking: Implement more arguments for ghc -M. (21bfb81)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:00:55 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/21bfb816a7be0bcd0ef72d562001d5948998565a/ghc

>---------------------------------------------------------------

commit 21bfb816a7be0bcd0ef72d562001d5948998565a
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Tue Dec 30 19:35:13 2014 +0000

    Implement more arguments for ghc -M.


>---------------------------------------------------------------

21bfb816a7be0bcd0ef72d562001d5948998565a
 src/Oracles.hs | 24 +++++++++++++-----------
 src/Package.hs | 28 ++++++++++++++++++++++------
 2 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/src/Oracles.hs b/src/Oracles.hs
index ff4bd95..9b63c4f 100644
--- a/src/Oracles.hs
+++ b/src/Oracles.hs
@@ -136,7 +136,7 @@ argOption opt = do
 
 data Flag = LaxDeps | DynamicGhcPrograms | GhcWithInterpreter | HsColourSrcs
           | GccIsClang | GccLt46 | CrossCompiling | Validating | PlatformSupportsSharedLibs
-          | WindowsHost
+          | WindowsHost | SupportsPackageKey
 
 test :: Flag -> Action Bool
 test GhcWithInterpreter = do
@@ -161,12 +161,13 @@ test WindowsHost = do
 
 test flag = do
     (key, defaultValue) <- return $ case flag of
-        LaxDeps            -> ("lax-dependencies"    , False) -- TODO: move flags to a separate file
-        DynamicGhcPrograms -> ("dynamic-ghc-programs", False)
-        GccIsClang         -> ("gcc-is-clang"        , False)
-        GccLt46            -> ("gcc-lt-46"           , False)
-        CrossCompiling     -> ("cross-compiling"     , False)
-        Validating         -> ("validating"          , False)
+        LaxDeps            -> ("lax-dependencies"     , False) -- TODO: move flags to a separate file
+        DynamicGhcPrograms -> ("dynamic-ghc-programs" , False)
+        GccIsClang         -> ("gcc-is-clang"         , False)
+        GccLt46            -> ("gcc-lt-46"            , False)
+        CrossCompiling     -> ("cross-compiling"      , False)
+        Validating         -> ("validating"           , False)
+        SupportsPackageKey -> ("supports-package-key" , False)
     let defaultString = if defaultValue then "YES" else "NO"
     value <- askConfigWithDefault key $
         do putLoud $ "\nFlag '" -- TODO: Give the warning *only once* per key
@@ -264,13 +265,14 @@ packagaDataOptionWithDefault file key defaultAction = do
         Just value -> return value
         Nothing    -> defaultAction
 
-data PackageDataKey = Modules | SrcDirs
+data PackageDataKey = Modules | SrcDirs | PackageKey
 
 packagaDataOption :: FilePath -> PackageDataKey -> Action String
 packagaDataOption file key = do
-    let keyName = replaceIf isSlash '_' $ takeDirectory file ++ case key of
-           Modules -> "_MODULES"
-           SrcDirs -> "_HS_SRC_DIRS"
+    let keyName = replaceIf isSlash '_' $ takeDirectory file ++ "_" ++ case key of
+           Modules    -> "MODULES"
+           SrcDirs    -> "HS_SRC_DIRS" -- TODO: add "." as a default?
+           PackageKey -> "PACKAGE_KEY"
     packagaDataOptionWithDefault file keyName $
         error $ "\nCannot find key '" ++ keyName ++ "' in " ++ file ++ "."
 
diff --git a/src/Package.hs b/src/Package.hs
index 9e60a24..ba77bdf 100644
--- a/src/Package.hs
+++ b/src/Package.hs
@@ -161,7 +161,6 @@ buildPackageData pkg @ (Package name path _) (stage, dist, settings) =
                     , arg [path </> dist </> "inplace-pkg-config"]
                     ]
 
--- "inplace/bin/ghc-stage1.exe" -M -static  -H32m -O    -this-package-key deeps_FT5iVCELxOr62eHY0nbvnU -hide-all-packages -i -ilibraries/deepseq/. -ilibraries/deepseq/dist-install/build -ilibraries/deepseq/dist-install/build/autogen -Ilibraries/deepseq/dist-install/build -Ilibraries/deepseq/dist-install/build/autogen -Ilibraries/deepseq/.    -optP-include -optPlibraries/deepseq/dist-install/build/autogen/cabal_macros.h -package-key array_3w0nMK0JfaFJPpLFn2yWAJ -package-key base_469rOtLAqwTGFEOGWxSUiQ -package-key ghcpr_FgrV6cgh2JHBlbcx1OSlwt -Wall -XHaskell2010 -O2  -no-user-package-db -rtsopts      -odir libraries/deepseq/dist-install/build -hidir libraries/deepseq/dist-install/build -stubdir libraries/deepseq/dist-install/build -dep-makefile libraries/deepseq/dist-install/build/.depend-v-p.haskell.tmp -dep-suffix "" -dep-suffix "p_" -include-pkg-deps  libraries/deepseq/./Control/DeepSeq.hs
 
 -- $1_$2_$3_MOST_DIR_HC_OPTS = \
 --  $$($1_$2_$3_MOST_HC_OPTS) \
@@ -186,6 +185,8 @@ buildPackageData pkg @ (Package name path _) (stage, dist, settings) =
 --     done
 -- endif
 
+-- "inplace/bin/ghc-stage1.exe" -M -static  -H32m -O    -this-package-key deeps_FT5iVCELxOr62eHY0nbvnU -hide-all-packages -i -ilibraries/deepseq/. -ilibraries/deepseq/dist-install/build -ilibraries/deepseq/dist-install/build/autogen -Ilibraries/deepseq/dist-install/build -Ilibraries/deepseq/dist-install/build/autogen -Ilibraries/deepseq/.    -optP-include -optPlibraries/deepseq/dist-install/build/autogen/cabal_macros.h -package-key array_3w0nMK0JfaFJPpLFn2yWAJ -package-key base_469rOtLAqwTGFEOGWxSUiQ -package-key ghcpr_FgrV6cgh2JHBlbcx1OSlwt -Wall -XHaskell2010 -O2  -no-user-package-db -rtsopts      -odir libraries/deepseq/dist-install/build -hidir libraries/deepseq/dist-install/build -stubdir libraries/deepseq/dist-install/build -dep-makefile libraries/deepseq/dist-install/build/.depend-v-p.haskell.tmp -dep-suffix "" -dep-suffix "p_" -include-pkg-deps  libraries/deepseq/./Control/DeepSeq.hs
+
 -- $1_$2_$3_MOST_HC_OPTS = \
 --  $$(WAY_$3_HC_OPTS) \
 --  $$(CONF_HC_OPTS) \
@@ -213,24 +214,39 @@ buildPackageData pkg @ (Package name path _) (stage, dist, settings) =
 --  $$(SRC_HC_WARNING_OPTS) \
 --  $$(EXTRA_HC_OPTS)
 
--- TODO: double-check that ignoring $1_$2_HS_SRC_DIRS is safe
--- Options CONF_HC_OPTS and 
+-- TODO: double-check that ignoring SrcDirs ($1_$2_HS_SRC_DIRS) is safe
+-- TODO: add $1_HC_OPTS
+-- TODO: check that the package is not a program ($1_$2_PROG == "")
+-- TODO: handle empty $1_PACKAGE
+-- Option CONF_HC_OPTS is skipped
 buildPackageDeps :: Package -> TodoItem -> Rules ()
 buildPackageDeps pkg @ (Package name path _) (stage, dist, settings) =
     let buildDir = path </> dist
     in
     (buildDir </> "build" </> name <.> "m") %> \out -> do
-        let pkgData = buildDir </> "package-data.mk"
-            autogen = dist </> "build" </> "autogen"
-        mods <- words <$> packagaDataOption pkgData Modules
+        let pkgData    = buildDir </> "package-data.mk"
+            autogen    = dist </> "build" </> "autogen"
+        mods    <- words <$> packagaDataOption pkgData Modules
+        srcDirs <- words <$> packagaDataOption pkgData SrcDirs
         src  <- getDirectoryFiles "" $ do
                     start <- map (replaceEq '.' '/') mods
                     end   <- [".hs", ".lhs"]
                     return $ path ++ "//" ++ start ++ end
+        packageKey <- packagaDataOption pkgData PackageKey
         run (Ghc stage) $ mconcat
                 [ arg ["-M"]
                 , wayHcOpts vanilla -- TODO: is this needed? shall we run GHC -M multiple times?
                 , splitArgs $ argOption SrcHcOpts
+                , when (stage == Stage0) $ arg ["-package-db libraries/bootstrapping.conf"]
+                , when (not SupportsPackageKey && stage == Stage0) $ arg ["-package-name"]
+                , when (    SupportsPackageKey || stage /= Stage0) $ arg ["-this-package-key"]
+                , arg [packageKey]
+                , arg ["-hide-all-packages"]
+                , arg $ map (\d -> "-i" ++ path ++ "/" ++ d) srcDirs
+                , arg $ do
+                    prefix <- ["-i", "-I"]
+                    suffix <- ["build", "build/autogen"]
+                    return $ prefix ++ path </> dist </> suffix
                 , arg ["-dep-makefile", out, "-dep-suffix", "", "-include-pkg-deps"]
                 , arg [unwords src]
                 ]



More information about the ghc-commits mailing list