Commit 2117cc22 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Disentangle the testsuite from the compiler's build system

parent e6fc6a9c
TESTSUITE_TOP := $(TOP)
TOP:=$(TOP)/..
ifneq "$(wildcard $(TOP)/ghc.mk)" "" # XXX This whole file should disappear
NEWBUILD=YES
# New build system:
# include mk/newconfig.mk
# default : all
# Old build system:
# include mk/boilerplate.mk
default: all
define get-ghc-rts-field # $1 = rseult variable, $2 = field name
$1 := $$(shell $$(TEST_HC) +RTS --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
endef
define get-ghc-field # $1 = rseult variable, $2 = field name
$1 := $$(shell $$(TEST_HC) --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
endef
define get-ghc-feature-bool # $1 = rseult variable, $2 = field name
SHELL_RES := $$(shell $$(TEST_HC) --info | grep '^ .("$2",' | sed -e 's/.*", *"//' -e 's/")$$$$//')
$1 := $$(strip \
$$(if $$(SHELL_RES), \
$$(if $$(subst YES,,$$(SHELL_RES)), \
$$(if $$(subst NO,,$$(SHELL_RES)), \
$$(warning ghc info field not YES or NO: $2: $$(SHELL_RES)), \
NO), \
YES), \
$$(warning ghc info field not found: $2)))
endef
ifeq "$(TEST_HC)" ""
OLD_BUILD_SYSTEM_STAGE1_GHC := $(abspath $(TOP)/../ghc/stage1-inplace/ghc)
OLD_BUILD_SYSTEM_STAGE2_GHC := $(abspath $(TOP)/../ghc/stage2-inplace/ghc)
OLD_BUILD_SYSTEM_STAGE3_GHC := $(abspath $(TOP)/../ghc/stage3-inplace/ghc)
OLD_BUILD_SYSTEM_GHC_PKG := $(abspath $(TOP)/../utils/ghc-pkg/install-inplace/bin/ghc-pkg)
OLD_BUILD_SYSTEM_HP2PS := $(abspath $(TOP)/../utils/hp2ps/hp2ps)
ifneq "$(wildcard $(OLD_BUILD_SYSTEM_STAGE1_GHC))" ""
ifeq "$(stage)" "1"
TEST_HC := $(OLD_BUILD_SYSTEM_STAGE1_GHC)
else
ifeq "$(stage)" "3"
TEST_HC := $(OLD_BUILD_SYSTEM_STAGE3_GHC)
else else
NEWBUILD=NO # use stage2 by default
TEST_HC := $(OLD_BUILD_SYSTEM_STAGE2_GHC)
endif
GHC_PKG := $(OLD_BUILD_SYSTEM_GHC_PKG)
HP2PS_ABS := $(OLD_BUILD_SYSTEM_HP2PS)
endif endif
ifeq "$(NEWBUILD)" "YES" else
NEW_BUILD_SYSTEM_STAGE1_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage1)
NEW_BUILD_SYSTEM_STAGE2_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage2)
NEW_BUILD_SYSTEM_STAGE3_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage3)
ifneq "$(wildcard $(NEW_BUILD_SYSTEM_STAGE1_GHC))" ""
FPTOOLS_TOP:=$(TOP) else
include $(FPTOOLS_TOP)/mk/newconfig.mk TEST_HC := $(shell which ghc)
endif
endif
endif
default : all ifeq "$(GHC_PKG)" ""
GHC_PKG := $(dir $(TEST_HC))/ghc-pkg
endif
else ifeq "$(HP2PS_ABS)" ""
HP2PS_ABS := $(dir $(TEST_HC))/hp2ps
endif
ifeq "$(wildcard $(TEST_HC))" ""
$(error Cannot find ghc)
endif
include $(TOP)/mk/boilerplate.mk ifeq "$(wildcard $(GHC_PKG))" ""
$(error Cannot find ghc-pkg)
endif
ifeq "$(wildcard $(HP2PS_ABS))" ""
$(error Cannot find hp2ps)
endif endif
TOP:=$(TESTSUITE_TOP) $(eval $(call get-ghc-field,GhcRTSWays,RTS ways))
GS = gs
CP = cp
RM = rm -f
PYTHON = /usr/bin/python
...@@ -17,76 +17,59 @@ ...@@ -17,76 +17,59 @@
# #
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
include $(TOP)/mk/wordsize.mk
$(TOP)/mk/wordsize.mk : $(TOP)/mk/wordsize.mk.in
$(CPP) $(RAWCPP_FLAGS) -x c $(TOP)/mk/wordsize.mk.in > $(TOP)/mk/wordsize.mk
ifeq "$(PYTHON)" ""
$(error Python must be installed in order to use the testsuite)
endif
# export the value of $MAKE for invocation in ghc-regress/driver/ # export the value of $MAKE for invocation in ghc-regress/driver/
export MAKE export MAKE
# ghastly hack, because the driver requires that $tool be an absolute path name.
HP2PS_ABS = $(GHC_HP2PS_DIR_ABS)/hp2ps
GS = gs
RUNTESTS = $(TOP)/driver/runtests.py RUNTESTS = $(TOP)/driver/runtests.py
COMPILER = ghc COMPILER = ghc
CONFIGDIR = $(TOP)/config CONFIGDIR = $(TOP)/config
CONFIG = $(CONFIGDIR)/$(COMPILER) CONFIG = $(CONFIGDIR)/$(COMPILER)
ifeq "$(NEWBUILD)" "YES" RUNTEST_OPTS =
# can be overriden from the command line
ifneq "$(stage)" "" $(eval $(call get-ghc-rts-field,WORDSIZE,Word size))
TEST_HC = $(GHC_STAGE$(stage)_ABS) $(eval $(call get-ghc-rts-field,TARGETPLATFORM,Target platform))
else $(eval $(call get-ghc-rts-field,TargetOS_CPP,Target OS))
TEST_HC = $(GHC_STAGE2_ABS) ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
endif exeext =
GHC_PKG = $(FPTOOLS_TOP_ABS)/$(GHC_PKG_INPLACE)
else
ifneq "$(stage)" ""
TEST_HC = $(GHC_STAGE$(stage))
else else
TEST_HC = $(GHC_STAGE2) exeext = .exe
endif endif
GHC_PKG = $(GHC_PKG_INPLACE)
endif
RUNTEST_OPTS =
$(eval $(call get-ghc-feature-bool,GhcWithNativeCodeGen,Have native code generator))
ifeq "$(GhcWithNativeCodeGen)" "YES" ifeq "$(GhcWithNativeCodeGen)" "YES"
RUNTEST_OPTS += -e ghc_with_native_codegen=1 RUNTEST_OPTS += -e ghc_with_native_codegen=1
else else
RUNTEST_OPTS += -e ghc_with_native_codegen=0 RUNTEST_OPTS += -e ghc_with_native_codegen=0
endif endif
ifeq "$(filter p, $(GhcLibWays))" "p" ifeq "$(filter p, $(GhcRTSWays))" "p"
RUNTEST_OPTS += -e ghc_with_profiling=1 RUNTEST_OPTS += -e ghc_with_profiling=1
else else
RUNTEST_OPTS += -e ghc_with_profiling=0 RUNTEST_OPTS += -e ghc_with_profiling=0
endif endif
ifeq "$(filter thr, $(GhcRTSWays))" "thr"
RUNTEST_OPTS += -e ghc_with_threaded_rts=1
else
RUNTEST_OPTS += -e ghc_with_threaded_rts=0
endif
$(eval $(call get-ghc-feature-bool,GhcWithInterpreter,Have interpreter))
ifeq "$(GhcWithInterpreter)" "YES" ifeq "$(GhcWithInterpreter)" "YES"
RUNTEST_OPTS += -e ghc_with_interpreter=1 RUNTEST_OPTS += -e ghc_with_interpreter=1
else else
RUNTEST_OPTS += -e ghc_with_interpreter=0 RUNTEST_OPTS += -e ghc_with_interpreter=0
endif endif
$(eval $(call get-ghc-feature-bool,GhcUnregisterised,Unregisterised))
ifeq "$(GhcUnregisterised)" "YES" ifeq "$(GhcUnregisterised)" "YES"
RUNTEST_OPTS += -e ghc_unregisterised=1 RUNTEST_OPTS += -e ghc_unregisterised=1
else else
RUNTEST_OPTS += -e ghc_unregisterised=0 RUNTEST_OPTS += -e ghc_unregisterised=0
endif endif
ifeq "$(filter thr, $(GhcRTSWays))" "thr" $(eval $(call get-ghc-feature-bool,GhcWithSMP,Support SMP))
RUNTEST_OPTS += -e ghc_with_threaded_rts=1
else
RUNTEST_OPTS += -e ghc_with_threaded_rts=0
endif
ifeq "$(GhcWithSMP)" "YES" ifeq "$(GhcWithSMP)" "YES"
RUNTEST_OPTS += -e ghc_with_smp=1 RUNTEST_OPTS += -e ghc_with_smp=1
else else
...@@ -102,7 +85,6 @@ RUNTEST_OPTS += \ ...@@ -102,7 +85,6 @@ RUNTEST_OPTS += \
--config=$(CONFIG) \ --config=$(CONFIG) \
-e config.confdir=\"$(CONFIGDIR)\" \ -e config.confdir=\"$(CONFIGDIR)\" \
-e config.compiler=\"$(TEST_HC)\" \ -e config.compiler=\"$(TEST_HC)\" \
-e config.compiler_always_flags.append"(\"-D$(HostPlatform_CPP)\")" \
-e config.compiler_always_flags.append"(\"$(EXTRA_HC_OPTS)\")" \ -e config.compiler_always_flags.append"(\"$(EXTRA_HC_OPTS)\")" \
-e config.ghc_pkg=\"$(GHC_PKG)\" \ -e config.ghc_pkg=\"$(GHC_PKG)\" \
-e config.hp2ps=\"$(HP2PS_ABS)\" \ -e config.hp2ps=\"$(HP2PS_ABS)\" \
...@@ -117,9 +99,6 @@ RUNTEST_OPTS += \ ...@@ -117,9 +99,6 @@ RUNTEST_OPTS += \
-e config.top=\"$(FPTOOLS_TOP_ABS)/testsuite\" \ -e config.top=\"$(FPTOOLS_TOP_ABS)/testsuite\" \
$(EXTRA_RUNTEST_OPTS) $(EXTRA_RUNTEST_OPTS)
# HostPlatform_CPP should ideally be TargetPlatform_CPP, but that
# doesn't exist; they're always the same anyway
ifeq "$(fast)" "YES" ifeq "$(fast)" "YES"
setfast = -e config.fast=1 setfast = -e config.fast=1
else else
...@@ -138,36 +117,13 @@ WAY = ...@@ -138,36 +117,13 @@ WAY =
all :: test all :: test
ifeq "$(NEWBUILD)" "YES"
TIMEOUT_PROGRAM = $(FPTOOLS_TOP)/inplace/bin/timeout$(exeext)
$(TIMEOUT_PROGRAM) :
@echo "Looks like you don't have timeout, building it first..."
cd $(FPTOOLS_TOP) && $(MAKE) $(MFLAGS) inplace/bin/timeout$(exeext)
pwd : $(FPTOOLS_TOP)/utils/pwd$(exeext)
$(FPTOOLS_TOP)/utils/pwd$(exeext) :
@echo "Looks like you don't have pwd, building utils first..."
cd $(FPTOOLS_TOP) && $(MAKE) $(MFLAGS) utils/pwd$(exeext)
else
TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext) TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
$(TIMEOUT_PROGRAM) : $(TIMEOUT_PROGRAM) :
@echo "Looks like you don't have timeout, building it first..." @echo "Looks like you don't have timeout, building it first..."
cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all
pwd : $(TOP)/utils/pwd$(exeext) test: $(TIMEOUT_PROGRAM)
$(TOP)/utils/pwd$(exeext) :
@echo "Looks like you don't have pwd, building utils first..."
cd $(TOP)/utils && $(MAKE) $(MFLAGS) all
endif
test: $(TIMEOUT_PROGRAM) pwd
$(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \ $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
$(patsubst %, --only=%, $(TEST)) \ $(patsubst %, --only=%, $(TEST)) \
$(patsubst %, --only=%, $(TESTS)) \ $(patsubst %, --only=%, $(TESTS)) \
...@@ -183,3 +139,4 @@ accept: ...@@ -183,3 +139,4 @@ accept:
fast: fast:
$(MAKE) fast=YES $(MAKE) fast=YES
#include "../../includes/MachDeps.h"
WORDSIZE = WORD_SIZE_IN_BITS
...@@ -4,14 +4,11 @@ include $(TOP)/mk/test.mk ...@@ -4,14 +4,11 @@ include $(TOP)/mk/test.mk
# The libraries that we actually know about. We don't want to test # The libraries that we actually know about. We don't want to test
# extralibs that are in our tree but which we haven't built. # extralibs that are in our tree but which we haven't built.
ifeq "$(NEWBUILD)" "YES"
LIBRARIES := $(shell $(FPTOOLS_TOP_ABS)/$(GHC_PKG_INPLACE) list --simple-output --names-only)
else
LIBRARIES := $(shell $(GHC_PKG) list --simple-output --names-only) LIBRARIES := $(shell $(GHC_PKG) list --simple-output --names-only)
endif
# XXX Do this better?
# Now find the "tests" directories of those libraries, where they exist # Now find the "tests" directories of those libraries, where they exist
LIBRARY_TEST_PATHS := $(wildcard $(patsubst %, $(FPTOOLS_TOP)/libraries/%/tests, $(LIBRARIES))) LIBRARY_TEST_PATHS := $(wildcard $(patsubst %, $(TOP)/../libraries/%/tests, $(LIBRARIES)))
# Add tests from packages # Add tests from packages
RUNTEST_OPTS += $(patsubst %, --rootdir=%, $(LIBRARY_TEST_PATHS)) RUNTEST_OPTS += $(patsubst %, --rootdir=%, $(LIBRARY_TEST_PATHS))
TOP = ../.. TOP = ..
include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/cabal-flags.mk
TIMEOUT_PROGRAM = install-inplace/bin/timeout$(exeext) TIMEOUT_PROGRAM = install-inplace/bin/timeout$(exeext)
ifeq "$(findstring thr,$(GhcRTSWays))" "" ifeq "$(filter thr, $(GhcRTSWays))" ""
$(TIMEOUT_PROGRAM): timeout.py $(TIMEOUT_PROGRAM): timeout.py
$(MKDIRHIER) `dirname $@` rm -rf install-inplace
mkdir install-inplace
mkdir install-inplace/bin
cp $< $@ cp $< $@
chmod +x $@ chmod +x $@
else else
$(TIMEOUT_PROGRAM): timeout.hs $(TIMEOUT_PROGRAM): timeout.hs
$(CABAL) configure $(USE_STAGE1_CONFIGURE_FLAGS) \ rm -rf install-inplace
$(INPLACE_DIRS_CONFIGURE_FLAGS) \ $(TEST_HC) --make Setup
$(COMMON_CONFIGURE_FLAGS) \ ./Setup configure --with-compiler=$(TEST_HC) --with-hc-pkg=$(GHC_PKG) \
--ghc-option=-threaded --ghc-option=-threaded --prefix=$(abspath install-inplace)
$(CABAL) build ./Setup build
$(CABAL) install ./Setup install
endif endif
boot all :: calibrate.out $(TIMEOUT_PROGRAM) boot all :: calibrate.out $(TIMEOUT_PROGRAM)
......
module Main (main) where
import Distribution.Simple
main :: IO ()
main = defaultMain
TIMEOUT_PROGRAM = $(INPLACE_BIN)/timeout$(exeext)
ifeq "$(findstring thr,$(GhcRTSWays))" ""
$(TIMEOUT_PROGRAM): testsuite/timeout/timeout.py
$(MKDIRHIER) `dirname $@`
cp $< $@
chmod +x $@
else
testsuite/timeout_dist_MODULES = Main WinCBindings
testsuite/timeout_dist_PROG = timeout
testsuite/timeout_dist_DEP_INCLUDE_DIRS = $(GHC_INCLUDE_DIR)
testsuite/timeout_HC_OPTS = -threaded -XCPP -package process
ifeq "$(Windows)" "YES"
testsuite/timeout_HC_OPTS += -package Win32
else
testsuite/timeout_HC_OPTS += -package unix
endif
# XXX when GHC generates dependencies it uses the module name, not the
# filename, so we get dependencies on Main.o rather than timeout.o.
# If we don't fix this, timeout gets compiled before the libraries.
testsuite/timeout/dist/build/Main.hs : testsuite/timeout/timeout.hs $(MKDIRHIER)
@$(MKDIRHIER) $(dir $@)
$(CP) $< $@
$(eval $(call build-prog,testsuite/timeout,dist,1))
endif
all : testsuite/timeout/calibrate.out
# depend on $(GHC_STAGE2) so we can be sure all the libs are built
testsuite/timeout/calibrate.out: $(GHC_STAGE2)
$(RM) -f testsuite/timeout/TimeMe.o testsuite/timeout/TimeMe.hi testsuite/timeout/TimeMe testsuite/timeout/TimeMe.exe
cd testsuite/timeout && $(PYTHON) calibrate "$(GHC_STAGE1_ABS)" > ../../$@
CLEAN_FILES += testsuite/timeout/calibrate.out
# We use stage 1 to do the calibration, as stage 2 may not exist.
# This isn't necessarily the compiler we'll be running the testsuite
# with, but it's really the performance of the machine that we're
# interested in
TOP = ..
include $(TOP)/mk/boilerplate.mk
HC = $(GHC_INPLACE)
all ::
$(HC) --make pwd
clean ::
rm -f *.o
rm -f *.hi
rm -f pwd
include $(TOP)/mk/target.mk
module Main where
import System.Directory
import System.Environment
main :: IO ()
main = do args <- getArgs
let escape = case args of
["quadruple-backslash"] -> escape_quadruple_backslash
["forwardslash"] -> escape_forwardslash
_ -> error ("pwd: Bad args: " ++ show args)
d <- getCurrentDirectory
putStr $ concatMap escape d
-- In prog006 we have to escape \ twice, once to get through sed and
-- again to get through parsing pkg.conf
escape_quadruple_backslash :: Char -> String
escape_quadruple_backslash '\\' = "\\\\\\\\"
escape_quadruple_backslash c = [c]
-- Normally we can get away with just replacing backslashes with forwardslashes
escape_forwardslash :: Char -> String
escape_forwardslash '\\' = "/"
escape_forwardslash c = [c]
Markdown is supported
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