Add buildPackageDeps rule.
authorAndrey Mokhov <andrey.mokhov@gmail.com>
Tue, 30 Dec 2014 03:57:22 +0000 (03:57 +0000)
committerAndrey Mokhov <andrey.mokhov@gmail.com>
Tue, 30 Dec 2014 03:57:22 +0000 (03:57 +0000)
doc/deepseq-build-progress.txt
src/Package.hs

index 2c64fab..07214c6 100644 (file)
@@ -3,7 +3,6 @@
 Skipping.
 
 
-
 "inplace/bin/ghc-cabal.exe"                        configure libraries/deepseq dist-install "" --with-ghc="C:/msys/home/chEEtah/ghc/inplace/bin/ghc-stage1.exe" --with-ghc-pkg="C:/msys/home/chEEtah/ghc/inplace/bin/ghc-pkg.exe"  --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci --enable-library-profiling --disable-shared --configure-option=CFLAGS=" -fno-stack-protector   " --configure-option=LDFLAGS="   " --configure-option=CPPFLAGS="   " --gcc-options=" -fno-stack-protector       " --with-gcc="C:/msys/home/chEEtah/ghc/inplace/mingw/bin/gcc.exe" --with-ld="C:/msys/home/chEEtah/ghc/inplace/mingw/bin/ld.exe" --configure-option=--with-cc="C:/msys/home/chEEtah/ghc/inplace/mingw/bin/gcc.exe" --with-ar="/usr/bin/ar"          --with-alex="/usr/local/bin/alex"          --with-happy="/usr/local/bin/happy"
 C:/msys/home/chEEtah/ghc/inplace/bin/ghc-cabal.exe configure libraries\deepseq dist-install    --with-ghc= C:/msys/home/chEEtah/ghc/inplace/bin/ghc-stage1.exe  --with-ghc-pkg= C:/msys/home/chEEtah/ghc/inplace/bin/ghc-pkg.exe   --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci --enable-library-profiling --disable-shared --configure-option=CFLAGS=-fno-stack-protector       --configure-option=LDFLAGS=      --configure-option=CPPFLAGS=      --gcc-options=-fno-stack-protector           --with-gcc= C:/msys/home/chEEtah/ghc/inplace/mingw/bin/gcc.exe  --with-ld= C:/msys/home/chEEtah/ghc/inplace/mingw/bin/ld.exe  --configure-option=--with-cc= C:/msys/home/chEEtah/ghc/inplace/mingw/bin/gcc.exe  --with-ar=C:/msys/usr/bin/ar.exe --with-alex=C:/msys/usr/local/bin/alex.exe --with-happy=C:/msys/usr/local/bin/happy.exe
 
@@ -12,52 +11,18 @@ Configuring deepseq-1.4.0.0...
 "C:/msys/home/chEEtah/ghc/inplace/bin/ghc-pkg.exe" update --force  libraries/deepseq/dist-install/inplace-pkg-config
  C:/msys/home/chEEtah/ghc/inplace/bin/ghc-pkg.exe  update --force  libraries\deepseq\dist-install\inplace-pkg-config
 
-
 Reading package info from "libraries/deepseq/dist-install/inplace-pkg-config" ... done.
-deepseq-1.4.0.0: Warning: haddock-interfaces: C:\msys\home\chEEtah\ghc\libraries\deepseq\dist-install\doc\html\deepseq\deepseq.haddock doesn't exist or isn't a file
-deepseq-1.4.0.0: cannot find any of ["Control\\DeepSeq.hi","Control\\DeepSeq.p_hi","Control\\DeepSeq.dyn_hi"] (ignoring)
-deepseq-1.4.0.0: cannot find any of ["libHSdeeps_FT5iVCELxOr62eHY0nbvnU.a","libHSdeeps_FT5iVCELxOr62eHY0nbvnU.p_a","libHSdeeps_FT5iVCELxOr62eHY0nbvnU-ghc7.11.20141222.so","libHSdeeps_FT5iVCELxOr62eHY0nbvnU-ghc7.11.20141222.dylib","HSdeeps_FT5iVCELxOr62eHY0nbvnU-ghc7.11.20141222.dll"] on library path (ignoring)
-
-libraries/deepseq/ghc.mk:4: libraries/deepseq/dist-install/build/.depend-v-p.haskell: No such file or directory
-libraries/deepseq/ghc.mk:4: libraries/deepseq/dist-install/build/.depend-v-p.c_asm: No such file or directory
-
-
-Primop bits:
-
-C:/msys/home/chEEtah/ghc/inplace/mingw/bin/gcc.exe -E  -undef -traditional -P -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header  -Icompiler/stage2 -x c compiler/prelude/primops.txt.pp | grep -v '^#pragma GCC' > compiler/stage2/build/primops.txt
-"inplace/bin/genprimopcode.exe" --data-decl          < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-data-decl.hs-incl
-"inplace/bin/genprimopcode.exe" --primop-tag         < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-tag.hs-incl
-"inplace/bin/genprimopcode.exe" --primop-list        < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-list.hs-incl
-"inplace/bin/genprimopcode.exe" --has-side-effects   < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-has-side-effects.hs-incl
-"inplace/bin/genprimopcode.exe" --out-of-line        < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-out-of-line.hs-incl
-"inplace/bin/genprimopcode.exe" --commutable         < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-commutable.hs-incl
-"inplace/bin/genprimopcode.exe" --code-size          < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-code-size.hs-incl
-"inplace/bin/genprimopcode.exe" --can-fail           < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-can-fail.hs-incl
-"inplace/bin/genprimopcode.exe" --strictness         < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-strictness.hs-incl
-"inplace/bin/genprimopcode.exe" --fixity             < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-fixity.hs-incl
-"inplace/bin/genprimopcode.exe" --primop-primop-info < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-primop-info.hs-incl
-"inplace/bin/genprimopcode.exe" --primop-vector-uniques     < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-vector-uniques.hs-incl
-"inplace/bin/genprimopcode.exe" --primop-vector-tys         < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-vector-tys.hs-incl
-"inplace/bin/genprimopcode.exe" --primop-vector-tys-exports < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-vector-tys-exports.hs-incl
-"inplace/bin/genprimopcode.exe" --primop-vector-tycons      < compiler/stage2/build/primops.txt > compiler/stage2/build/primop-vector-tycons.hs-incl
-
-
-"inplace/bin/ghc-cabal.exe" check libraries/deepseq
-"inplace/bin/ghc-cabal.exe" configure libraries/deepseq dist-install "" --with-ghc="C:/msys/home/chEEtah/ghc/inplace/bin/ghc-stage1.exe" --with-ghc-pkg="C:/msys/home/chEEtah/ghc/inplace/bin/ghc-pkg.exe"  --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci --enable-library-profiling --disable-shared --configure-option=CFLAGS=" -fno-stack-protector   " --configure-option=LDFLAGS="   " --configure-option=CPPFLAGS="   " --gcc-options=" -fno-stack-protector       " --with-gcc="C:/msys/home/chEEtah/ghc/inplace/mingw/bin/gcc.exe" --with-ld="C:/msys/home/chEEtah/ghc/inplace/mingw/bin/ld.exe" --configure-option=--with-cc="C:/msys/home/chEEtah/ghc/inplace/mingw/bin/gcc.exe" --with-ar="/usr/bin/ar" --with-alex="/usr/local/bin/alex" --with-happy="/usr/local/bin/happy"
-Configuring deepseq-1.4.0.0...
-"C:/msys/home/chEEtah/ghc/inplace/bin/ghc-pkg.exe" update --force  libraries/deepseq/dist-install/inplace-pkg-config
-Reading package info from "libraries/deepseq/dist-install/inplace-pkg-config" ... done.
-deepseq-1.4.0.0: Warning: haddock-interfaces: C:\msys\home\chEEtah\ghc\libraries\deepseq\dist-install\doc\html\deepseq\deepseq.haddock doesn't exist or isn't a file
-deepseq-1.4.0.0: cannot find any of ["Control\\DeepSeq.hi","Control\\DeepSeq.p_hi","Control\\DeepSeq.dyn_hi"] (ignoring)
-deepseq-1.4.0.0: cannot find any of ["libHSdeeps_FT5iVCELxOr62eHY0nbvnU.a","libHSdeeps_FT5iVCELxOr62eHY0nbvnU.p_a","libHSdeeps_FT5iVCELxOr62eHY0nbvnU-ghc7.11.20141222.so","libHSdeeps_FT5iVCELxOr62eHY0nbvnU-ghc7.11.20141222.dylib","HSdeeps_FT5iVCELxOr62eHY0nbvnU-ghc7.11.20141222.dll"] on library path (ignoring)
 
 
 "rm" -f libraries/deepseq/dist-install/build/.depend-v-p.c_asm.tmp
 "rm" -f libraries/deepseq/dist-install/build/.depend-v-p.c_asm.bit
+
 echo "libraries/deepseq_dist-install_depfile_c_asm_EXISTS = YES" >> libraries/deepseq/dist-install/build/.depend-v-p.c_asm.tmp
 mv libraries/deepseq/dist-install/build/.depend-v-p.c_asm.tmp libraries/deepseq/dist-install/build/.depend-v-p.c_asm
 "rm" -f libraries/deepseq/dist-install/build/.depend-v-p.haskell.tmp
+
 "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
+
 echo "libraries/deepseq_dist-install_depfile_haskell_EXISTS = YES" >> libraries/deepseq/dist-install/build/.depend-v-p.haskell.tmp
 for dir in libraries/deepseq/dist-install/build/Control/; do if test ! -d $dir; then mkdir -p $dir; fi done
 grep -v ' : [a-zA-Z]:/' libraries/deepseq/dist-install/build/.depend-v-p.haskell.tmp > libraries/deepseq/dist-install/build/.depend-v-p.haskell.tmp2
index f5eae9b..a6df921 100644 (file)
@@ -114,7 +114,7 @@ configureArgs stage settings =
         ]
 
 buildPackageData :: Package -> TodoItem -> Rules ()
-buildPackageData pkg @ (Package name path todo) (stage, dist, settings) =
+buildPackageData pkg @ (Package name path _) (stage, dist, settings) =
         ((path </> dist) </>) <$>
         [ "package-data.mk",
           "haddock-prologue.txt",
@@ -127,9 +127,12 @@ buildPackageData pkg @ (Package name path todo) (stage, dist, settings) =
             when (doesFileExist $ path </> "configure.ac") $ need [path </> "configure"]
             run GhcCabal cabalArgs
             when (registerPackage settings) $ run (GhcPkg stage) ghcPkgArgs
+            let pkgDataFile = path </> dist </> "package-data.mk"                 
+            pkgData <- lines <$> liftIO (readFile pkgDataFile)
+            length pkgData `seq` writeFileLines pkgDataFile $ map (replaceChar '/' '_') $ filter ('$' `notElem`) pkgData
               where
                 cabalArgs, ghcPkgArgs :: Args
-                cabalArgs = mconcat $
+                cabalArgs = mconcat
                     [ arg ["configure", path, dist]
                     -- this is a positional argument, hence:
                     -- * if it is empty, we need to emit one empty string argument
@@ -153,20 +156,97 @@ buildPackageData pkg @ (Package name path todo) (stage, dist, settings) =
                     , with Happy
                     ] -- TODO: reorder with's
 
-                ghcPkgArgs = mconcat $
+                ghcPkgArgs = mconcat
                     [ arg ["update", "--force"]
                     , when (stage == Stage0) $ arg ["--package-db=libraries/bootstrapping.conf"]
                     , 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_HC_OPTS = \
+--  $$(WAY_$3_HC_OPTS) \
+--  $$(CONF_HC_OPTS) \
+--  $$(SRC_HC_OPTS) \
+--  $$($1_HC_OPTS) \
+--  $$($1_$2_HC_PKGCONF) \
+--  $$(if $$($1_$2_PROG),, \
+--         $$(if $$($1_PACKAGE),$$($4_THIS_PACKAGE_KEY) $$($1_$2_PACKAGE_KEY))) \
+--  $$(if $$($1_PACKAGE),-hide-all-packages) \
+--  -i $$(if $$($1_$2_HS_SRC_DIRS),$$(foreach dir,$$($1_$2_HS_SRC_DIRS),-i$1/$$(dir)),-i$1) \
+--  -i$1/$2/build -i$1/$2/build/autogen \
+--  -I$1/$2/build -I$1/$2/build/autogen \
+--  $$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
+--  $$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
+--  $$(foreach inc,$$($1_$2_INCLUDE),-\#include "$$(inc)") \
+--  $$(foreach opt,$$($1_$2_CPP_OPTS),-optP$$(opt)) \
+--  $$(if $$($1_PACKAGE),-optP-include -optP$1/$2/build/autogen/cabal_macros.h) \
+--  $$($1_$2_$4_DEP_OPTS) \
+--  $$($1_$2_HC_OPTS) \
+--  $$(CONF_HC_OPTS_STAGE$4) \
+--  $$($1_$2_MORE_HC_OPTS) \
+--  $$($1_$2_EXTRA_HC_OPTS) \
+--  $$($1_$2_$3_HC_OPTS) \
+--  $$($$(basename $$(subst ./,,$$<))_HC_OPTS) \
+--  $$(SRC_HC_WARNING_OPTS) \
+--  $$(EXTRA_HC_OPTS)
+
+
+-- $1_$2_$3_MOST_DIR_HC_OPTS = \
+--  $$($1_$2_$3_MOST_HC_OPTS) \
+--  -odir $1/$2/build -hidir $1/$2/build -stubdir $1/$2/build
+
+-- # Some of the Haskell files (e.g. utils/hsc2hs/Main.hs) (directly or
+-- # indirectly) include the generated includes files.
+-- $$($1_$2_depfile_haskell) : $$(includes_H_CONFIG) $$(includes_H_PLATFORM)
+-- 
+-- $$($1_$2_depfile_haskell) : $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS) $$$$($1_$2_HC_MK_DEPEND_DEP) | $$$$(dir $$$$@)/.
+--     $$(call removeFiles,$$@.tmp)
+-- ifneq "$$($1_$2_HS_SRCS)" ""
+--     "$$($1_$2_HC_MK_DEPEND)" -M \
+--         $$($1_$2_$$(firstword $$($1_$2_WAYS))_MOST_DIR_HC_OPTS) \
+--         $$($1_$2_MKDEPENDHS_FLAGS) \
+--         $$($1_$2_HS_SRCS)
+-- endif
+--     echo "$1_$2_depfile_haskell_EXISTS = YES" >> $$@.tmp
+-- ifneq "$$($1_$2_SLASH_MODS)" ""
+--     for dir in $$(sort $$(foreach mod,$$($1_$2_SLASH_MODS),$1/$2/build/$$(dir $$(mod)))); do \
+--         if test ! -d $$$$dir; then mkdir -p $$$$dir; fi \
+--     done
+-- endif
+
+-- TODO: double-check that ignoring $1_$2_HS_SRC_DIRS is safe
+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
+        src  <- getDirectoryFiles "" $ do
+                    start <- map (replaceChar '.' '/') mods
+                    end   <- [".hs", ".lhs"]
+                    return $ path ++ "//" ++ start ++ end
+        run (Ghc stage) $ mconcat
+                [ arg ["-M"]
+                , arg ["-dep-makefile", out, "-dep-suffix", "", "-include-pkg-deps"]
+                , arg [unwords src]
+                ]
+
+-- $1_$2_MKDEPENDHS_FLAGS = -dep-makefile $$($1_$2_depfile_haskell).tmp $$(foreach way,$$($1_$2_WAYS),-dep-suffix "$$(-- patsubst %o,%,$$($$(way)_osuf))")
+-- $1_$2_MKDEPENDHS_FLAGS += -include-pkg-deps
+
+
 buildPackage :: Package -> TodoItem -> Rules ()
 buildPackage pkg todoItem = do
     buildPackageData pkg todoItem
+    buildPackageDeps pkg todoItem
 
 packageRules :: Rules ()
 packageRules = do
 
-    want ["libraries/deepseq/dist-install/package-data.mk"]
+    want ["libraries/deepseq/dist-install/build/deepseq.m"]
     forM_ packages $ \pkg -> do
         forM_ (pkgTodo pkg) $ \todoItem -> do
             buildPackage pkg todoItem