[Git][ghc/ghc][wip/js-staging] Testsuite: better fix for finding prefixed tools

Sylvain Henry (@hsyl20) gitlab at gitlab.haskell.org
Wed Aug 31 18:59:03 UTC 2022



Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC


Commits:
577b4845 by Sylvain Henry at 2022-08-31T21:00:30+02:00
Testsuite: better fix for finding prefixed tools

- - - - -


2 changed files:

- hadrian/src/Rules/Test.hs
- testsuite/mk/boilerplate.mk


Changes:

=====================================
hadrian/src/Rules/Test.hs
=====================================
@@ -9,6 +9,7 @@ import Expression
 import Flavour
 import Hadrian.Haskell.Cabal.Type (packageDependencies)
 import Hadrian.Oracles.Cabal (readPackageData)
+import Hadrian.Oracles.Path (fixAbsolutePathOnWindows)
 import Oracles.Setting
 import Oracles.TestSettings
 import Oracles.Flag
@@ -191,9 +192,31 @@ testRules = do
         -- Prepare Ghc configuration file for input compiler.
         need [root -/- timeoutPath]
 
+        cross <- flag CrossCompiling
+
+        -- get absolute path for the given program in the given stage
+        let absolute_path_stage s p = do
+              rel_path <- programPath =<< programContext s p
+              abs_path <- liftIO (IO.makeAbsolute rel_path)
+              fixAbsolutePathOnWindows abs_path
+
+        -- get absolute path for the given program in the target stage
+        let absolute_path = absolute_path_stage stg
+
+        -- get absolute path for the given program in stage1 (useful for
+        -- cross-compilers)
+        let absolute_path1
+              | cross     = absolute_path_stage (Stage0 InTreeLibs)
+              | otherwise = absolute_path_stage stg
 
         ghcPath <- getCompilerPath testCompilerArg
 
+        prog_ghc_pkg     <- absolute_path ghcPkg
+        prog_hsc2hs      <- absolute_path hsc2hs
+        prog_hp2ps       <- absolute_path hp2ps
+        prog_hpc         <- absolute_path1 hpc
+        prog_haddock     <- absolute_path1 haddock
+        prog_runghc      <- absolute_path1 runGhc
 
         makePath        <- builderPath $ Make ""
         top             <- topDirectory
@@ -222,6 +245,14 @@ testRules = do
             setEnv "TEST_HC_OPTS_INTERACTIVE" ghciFlags
             setEnv "TEST_CC" ccPath
             setEnv "TEST_CC_OPTS" ccFlags
+
+            setEnv "GHC_PKG"   prog_ghc_pkg
+            setEnv "HSC2HS"    prog_hsc2hs
+            setEnv "HP2PS_ABS" prog_hp2ps
+            setEnv "HPC"       prog_hpc
+            setEnv "HADDOCK"   prog_haddock
+            setEnv "RUNGHC"    prog_runghc
+
             setEnv "CHECK_PPR" (top -/- root -/- checkPprProgPath)
             setEnv "CHECK_EXACT" (top -/- root -/- checkExactProgPath)
             setEnv "COUNT_DEPS" (top -/- root -/- countDepsProgPath)


=====================================
testsuite/mk/boilerplate.mk
=====================================
@@ -150,17 +150,7 @@ BIN_ROOT = $(shell dirname '$(TEST_HC)')
 ifeq "$(IMPLICIT_COMPILER)" "YES"
 find_tool = $(shell which $(1))
 else
-find_tool = $(BIN_ROOT)/$(PLATFORM_PREFIX)$(1)
-endif
-
-ifeq "$(IMPLICIT_COMPILER)" "YES"
-find_other_tool = $(shell which $(1))
-else
-	ifeq "$(TOOL_ROOT)" ""
-    find_other_tool = $(BIN_ROOT)/$(PLATFORM_PREFIX)$(1)
-  else
-  	find_other_tool = $(TOOL_ROOT)/$(PLATFORM_PREFIX)$(1)
-  endif
+find_tool = $(BIN_ROOT)/$(1)
 endif
 
 ifeq "$(GHC_PKG)" ""
@@ -168,11 +158,11 @@ GHC_PKG := $(call find_tool,ghc-pkg)
 endif
 
 ifeq "$(RUNGHC)" ""
-RUNGHC := $(call find_other_tool,runghc)
+RUNGHC := $(call find_tool,runghc)
 endif
 
 ifeq "$(HADDOCK)" ""
-HADDOCK := $(call find_other_tool,haddock)
+HADDOCK := $(call find_tool,haddock)
 endif
 
 ifeq "$(HSC2HS)" ""
@@ -184,7 +174,7 @@ HP2PS_ABS := $(call find_tool,hp2ps)
 endif
 
 ifeq "$(HPC)" ""
-HPC := $(call find_other_tool,hpc)
+HPC := $(call find_tool,hpc)
 endif
 
 $(eval $(call canonicaliseExecutable,TEST_HC))



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/577b4845277443f721e394bd41621aee393efe9f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/577b4845277443f721e394bd41621aee393efe9f
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220831/af727a0d/attachment-0001.html>


More information about the ghc-commits mailing list