Commit 6c796d23 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Handle unbuildable packages differently

Now we require that configure fails, and use our own signalling rather
than Cabal's buildable field.
parent 13949af5
......@@ -110,8 +110,7 @@ ifBuildable/ifBuildable: ifBuildable.hs stamp/$(BOOTSTRAPPING_CABAL)
-$(RM) -rf ifBuildable
mkdir ifBuildable
$(CP) ifBuildable.hs ifBuildable/
cd ifBuildable && $(GHC) -Wall --make -i../$(BOOTSTRAPPING_CABAL) \
ifBuildable -o ifBuildable
cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
stamp/$(BOOTSTRAPPING_CABAL):
$(RM) -rf $(BOOTSTRAPPING_CABAL)
......@@ -140,7 +139,7 @@ configure: $(foreach SUBDIR,$(SUBDIRS), \
$(foreach SUBDIR,$(SUBDIRS), \
stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
-$(RM) -f stamp/configure.library.*.$*
-$(RM) -f stamp/configure.library.*.$* $*/unbuildable
cd $* && setup/Setup configure \
$(CONFIGURE_OPTS) \
--prefix=$(prefix) \
......@@ -151,15 +150,16 @@ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
--datasubdir=ghc \
--haddock-args="--use-contents=../index.html --use-index=../doc-index.html" \
$(addprefix --configure-option=,$(CONFIGURE_ARGS)) \
--configure-option=--with-cc=$(CC)
--configure-option=--with-cc=$(CC) \
|| touch unbuildable
touch $@
$(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
%/setup/Setup
cd $* && ../ifBuildable/ifBuildable setup/Setup build \
ifBuildable/ifBuildable $* setup/Setup build \
$(addprefix --ghc-option=,$(GhcLibHcOpts))
cd $* && ../ifBuildable/ifBuildable setup/Setup register --inplace
ifBuildable/ifBuildable $* setup/Setup register --inplace
.PHONY: doc
......@@ -171,7 +171,7 @@ doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
$(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
%/setup/Setup
cd $* && ../ifBuildable/ifBuildable setup/Setup haddock
ifBuildable/ifBuildable $* setup/Setup haddock
.PHONY: install install-docs install.library.%
......@@ -197,7 +197,7 @@ install-docs:
$(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
stamp/configure.library.install.%: %/setup/Setup
-$(RM) -f stamp/configure.library.*.$*
cd $* && ../ifBuildable/ifBuildable setup/Setup configure \
ifBuildable/ifBuildable $* setup/Setup configure \
$(CONFIGURE_OPTS) \
--prefix=$(prefix) \
--with-compiler=$(bindir)/ghc \
......@@ -207,7 +207,7 @@ stamp/configure.library.install.%: %/setup/Setup
# We need to reconfigure as we now need to register with the normal ghc-pkg
$(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
install.library.%: stamp/configure.library.install.% %/setup/Setup
cd $* && ../ifBuildable/ifBuildable setup/Setup install
ifBuildable/ifBuildable $* setup/Setup install
.PHONY: distclean clean clean.library.%
......@@ -221,7 +221,7 @@ clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
$(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
clean.library.%:
$(RM) -f stamp/configure.library.*.$*
$(RM) -f stamp/configure.library.*.$* $*/unbuildable
-cd $* && setup/Setup clean
$(RM) -rf $*/setup
......@@ -2,37 +2,27 @@
module Main (main) where
import Control.Monad
import Data.Maybe
import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.Utils
import System.Cmd
import System.Directory
import System.Environment
import System.Exit
main :: IO ()
main = do let verbosity = 0
mustBeBuildables <- getMustBeBuildablePackages
dfd <- defaultPackageDesc verbosity
pkgDescr <- readPackageDescription verbosity dfd
mInfolFile <- defaultHookedPackageDesc
info <- case mInfolFile of
Nothing -> return emptyHookedBuildInfo
Just infoFile -> readHookedBuildInfo verbosity infoFile
let pkgDescr' = updatePackageDescription info pkgDescr
pkg = pkgName (package pkgDescr')
mustBeBuildable = pkg `elem` mustBeBuildables
buildInfos = map libBuildInfo (maybeToList (library pkgDescr'))
++ map buildInfo (executables pkgDescr')
isBuildable = any buildable buildInfos
when (mustBeBuildable || isBuildable) $ do
args <- getArgs
case args of
prog : progArgs ->
do ec <- rawSystem prog progArgs
exitWith ec
[] ->
error "ifBuildable: No command given"
main = do args <- getArgs
case args of
[] ->
error "No package or command given"
[_] ->
error "No command given"
package : prog : progArgs ->
do setCurrentDirectory package
unbuildable <- doesFileExist "unbuildable"
if unbuildable
then do mustBeBuildables <- getMustBeBuildablePackages
when (package `elem` mustBeBuildables)
(error (package ++ " is unbuildable"))
else do ec <- rawSystem prog progArgs
exitWith ec
getMustBeBuildablePackages :: IO [String]
getMustBeBuildablePackages
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment