Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
c4cc0dc7
Commit
c4cc0dc7
authored
Dec 30, 2014
by
Andrey Mokhov
Browse files
Factor out postProcessPackageData to Util.hs.
parent
d2f3a74a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Package.hs
View file @
c4cc0dc7
...
...
@@ -122,15 +122,13 @@ buildPackageData pkg @ (Package name path _) (stage, dist, settings) =
"inplace-pkg-config"
,
"setup-config"
,
"build"
</>
"autogen"
</>
"cabal_macros.h"
,
"build"
</>
"autogen"
</>
(
"Paths_"
++
name
)
<.>
"hs"
-- TODO: Is this needed?
What's up with
Paths_cpsa.hs
?
"build"
</>
"autogen"
</>
(
"Paths_"
++
name
)
<.>
"hs"
-- TODO: Is this needed?
Also check out
Paths_cpsa.hs
.
]
&%>
\
_
->
do
need
[
path
</>
name
<.>
"cabal"
]
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
(
replaceIf
isSlash
'_'
)
$
filter
(
'$'
`
notElem
`)
pkgData
postProcessPackageData
$
path
</>
dist
</>
"package-data.mk"
where
cabalArgs
,
ghcPkgArgs
::
Args
cabalArgs
=
mconcat
...
...
src/Util.hs
View file @
c4cc0dc7
module
Util
(
module
Data
.
Char
,
isSlash
,
replaceIf
,
replaceEq
replaceIf
,
replaceEq
,
postProcessPackageData
)
where
import
Base
import
Data.Char
isSlash
::
Char
->
Bool
...
...
@@ -14,3 +16,11 @@ replaceIf p to = map (\from -> if p from then to else from)
replaceEq
::
Eq
a
=>
a
->
a
->
[
a
]
->
[
a
]
replaceEq
from
=
replaceIf
(
==
from
)
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$'
-- 2) Replace '/' and '\' with '_'
postProcessPackageData
::
FilePath
->
Action
()
postProcessPackageData
file
=
do
pkgData
<-
(
filter
(
'$'
`
notElem
`)
.
lines
)
<$>
liftIO
(
readFile
file
)
length
pkgData
`
seq
`
writeFileLines
file
$
map
(
replaceIf
isSlash
'_'
)
pkgData
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment