|
1
|
|
-{-# LANGUAGE MultiWayIf #-}
|
|
|
1
|
+module Rules.Rts (rtsRules) where
|
|
2
|
2
|
|
|
3
|
|
-module Rules.Rts (rtsRules, needRtsSymLinks) where
|
|
4
|
|
-
|
|
5
|
|
-import qualified Data.Set as Set
|
|
6
|
|
-
|
|
7
|
|
-import Packages (rts)
|
|
8
|
3
|
import Hadrian.Utilities
|
|
9
|
4
|
import Settings.Builders.Common
|
|
10
|
5
|
|
| ... |
... |
@@ -12,17 +7,7 @@ import Settings.Builders.Common |
|
12
|
7
|
-- library files (see Rules.Library.libraryRules).
|
|
13
|
8
|
rtsRules :: Rules ()
|
|
14
|
9
|
rtsRules = priority 3 $ do
|
|
15
|
|
- -- Dynamic RTS library files need symlinks without the dummy version number.
|
|
16
|
|
- -- This is for backwards compatibility (the old make build system omitted the
|
|
17
|
|
- -- dummy version number).
|
|
18
|
10
|
root <- buildRootRules
|
|
19
|
|
- [ root -/- "**/libHSrts_*-ghc*.so",
|
|
20
|
|
- root -/- "**/libHSrts_*-ghc*.dylib",
|
|
21
|
|
- root -/- "**/libHSrts-ghc*.so",
|
|
22
|
|
- root -/- "**/libHSrts-ghc*.dylib"]
|
|
23
|
|
- |%> \ rtsLibFilePath' -> createFileLink
|
|
24
|
|
- (addRtsDummyVersion $ takeFileName rtsLibFilePath')
|
|
25
|
|
- rtsLibFilePath'
|
|
26
|
11
|
-- An import lib for the ghc-internal dll, to be linked into the rts dll.
|
|
27
|
12
|
forM_ [Stage1, Stage2, Stage3] $ \stage -> do
|
|
28
|
13
|
let buildPath = root -/- buildDir (rtsContext stage)
|
| ... |
... |
@@ -36,35 +21,3 @@ buildGhcInternalImportLib target = do |
|
36
|
21
|
output = target -- the .dll.a import lib
|
|
37
|
22
|
need [input]
|
|
38
|
23
|
runBuilder Dlltool ["-d", input, "-l", output] [input] [output] |
|
39
|
|
-
|
|
40
|
|
--- Need symlinks generated by rtsRules.
|
|
41
|
|
-needRtsSymLinks :: Stage -> Set.Set Way -> Action ()
|
|
42
|
|
-needRtsSymLinks stage rtsWays
|
|
43
|
|
- = forM_ (Set.filter (wayUnit Dynamic) rtsWays) $ \ way -> do
|
|
44
|
|
- let ctx = Context stage rts way Final
|
|
45
|
|
- distDir <- distDynDir ctx
|
|
46
|
|
- rtsLibFile <- takeFileName <$> pkgLibraryFile ctx
|
|
47
|
|
- need [removeRtsDummyVersion (distDir </> rtsLibFile)]
|
|
48
|
|
-
|
|
49
|
|
-prefix, versionlessPrefix :: String
|
|
50
|
|
-versionlessPrefix = "libHSrts"
|
|
51
|
|
-prefix = versionlessPrefix ++ "-1.0.3"
|
|
52
|
|
-
|
|
53
|
|
--- removeRtsDummyVersion "a/libHSrts-1.0-ghc1.2.3.4.so"
|
|
54
|
|
--- == "a/libHSrts-ghc1.2.3.4.so"
|
|
55
|
|
-removeRtsDummyVersion :: FilePath -> FilePath
|
|
56
|
|
-removeRtsDummyVersion = replaceLibFilePrefix prefix versionlessPrefix
|
|
57
|
|
-
|
|
58
|
|
--- addRtsDummyVersion "a/libHSrts-ghc1.2.3.4.so"
|
|
59
|
|
--- == "a/libHSrts-1.0-ghc1.2.3.4.so"
|
|
60
|
|
-addRtsDummyVersion :: FilePath -> FilePath
|
|
61
|
|
-addRtsDummyVersion = replaceLibFilePrefix versionlessPrefix prefix
|
|
62
|
|
-
|
|
63
|
|
-replaceLibFilePrefix :: String -> String -> FilePath -> FilePath
|
|
64
|
|
-replaceLibFilePrefix oldPrefix newPrefix oldFilePath = let
|
|
65
|
|
- oldFileName = takeFileName oldFilePath
|
|
66
|
|
- newFileName = maybe
|
|
67
|
|
- (error $ "Expected RTS library file to start with " ++ oldPrefix)
|
|
68
|
|
- (newPrefix ++)
|
|
69
|
|
- (stripPrefix oldPrefix oldFileName)
|
|
70
|
|
- in replaceFileName oldFilePath newFileName |