Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
1167e1ca
Commit
1167e1ca
authored
Aug 24, 2004
by
ijones
Browse files
moved preprocessing function into its own module in preparation for preprocessor work
parent
168a3ba4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Distribution/PreProcess.hs
0 → 100644
View file @
1167e1ca
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.PreProcess
--
-- Maintainer : Isaac Jones <ijones@syntaxpolice.org>
-- Stability : alpha
-- Portability : GHC, Hugs
--
{- Copyright (c) 2003-2004, Isaac Jones, Malcolm Wallace
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Isaac Jones nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module
Distribution.PreProcess
(
preprocessSources
)
where
import
Distribution.Package
(
PackageDescription
(
..
),
BuildInfo
(
..
),
Executable
(
..
))
import
Distribution.Simple.Configure
(
LocalBuildInfo
(
..
))
import
Distribution.Simple.Utils
(
setupMessage
,
moveSources
,
pathJoin
,
withLib
)
-- |Copy and (possibly) preprocess sources from hsSourceDirs
preprocessSources
::
PackageDescription
->
LocalBuildInfo
->
FilePath
-- ^ Directory to put preprocessed
-- sources in
->
IO
()
preprocessSources
pkg_descr
_
pref
=
do
setupMessage
"Preprocessing"
pkg_descr
withLib
pkg_descr
$
\
lib
->
moveSources
(
hsSourceDir
lib
)
(
pathJoin
[
pref
,
hsSourceDir
lib
])
(
modules
lib
)
[
"hs"
,
"lhs"
]
sequence_
[
moveSources
(
hsSourceDir
exeBi
)
(
pathJoin
[
pref
,
hsSourceDir
exeBi
])
(
modules
exeBi
)
[
"hs"
,
"lhs"
]
|
Executable
_
_
exeBi
<-
executables
pkg_descr
]
Distribution/Simple/Build.hs
View file @
1167e1ca
...
...
@@ -51,12 +51,14 @@ import Distribution.Misc (Extension(..), extensionsToNHCFlag, extensionsToGHCFla
import
Distribution.Setup
(
Compiler
(
..
),
CompilerFlavor
(
..
))
import
Distribution.Package
(
PackageIdentifier
(
..
),
PackageDescription
(
..
),
BuildInfo
(
..
),
showPackageId
,
Executable
(
..
),
hasLibs
)
import
Distribution.PreProcess
(
preprocessSources
)
import
Distribution.Simple.Configure
(
LocalBuildInfo
(
..
),
compiler
,
exeDeps
)
import
Distribution.Simple.Utils
(
rawSystemExit
,
setupMessage
,
die
,
rawSystemPathExit
,
split
,
createIfNotExists
,
mkLibName
,
moveSources
,
pathJoin
,
splitFilePath
,
joinFilenameDir
,
joinExt
splitFilePath
,
joinFilenameDir
,
joinExt
,
withLib
)
...
...
@@ -153,27 +155,6 @@ objsuffix = "o"
dotToSep
::
String
->
String
dotToSep
s
=
pathJoin
(
split
'.'
s
)
-- |Copy and (possibly) preprocess sources from hsSourceDirs
preprocessSources
::
PackageDescription
->
LocalBuildInfo
->
FilePath
-- ^ Directory to put preprocessed
-- sources in
->
IO
()
preprocessSources
pkg_descr
lbi
pref
=
do
setupMessage
"Preprocessing"
pkg_descr
withLib
pkg_descr
$
\
lib
->
moveSources
(
hsSourceDir
lib
)
(
pathJoin
[
pref
,
hsSourceDir
lib
])
(
modules
lib
)
[
"hs"
,
"lhs"
]
sequence_
[
moveSources
(
hsSourceDir
exeBi
)
(
pathJoin
[
pref
,
hsSourceDir
exeBi
])
(
modules
exeBi
)
[
"hs"
,
"lhs"
]
|
Executable
exeName
modPath
exeBi
<-
executables
pkg_descr
]
-- FIX: includes, includeDirs
-- |If the package description has a library section, call the given
-- function with the library build info as argument.
withLib
::
PackageDescription
->
(
BuildInfo
->
IO
()
)
->
IO
()
withLib
pkg_descr
f
=
when
(
hasLibs
pkg_descr
)
$
f
(
fromJust
(
library
pkg_descr
))
-- ------------------------------------------------------------
-- * Testing
-- ------------------------------------------------------------
...
...
Distribution/Simple/Utils.hs
View file @
1167e1ca
...
...
@@ -63,6 +63,7 @@ module Distribution.Simple.Utils (
copyFile
,
pathJoin
,
removeFileRecursive
,
withLib
,
#
ifdef
DEBUG
hunitTests
#
endif
...
...
@@ -72,7 +73,8 @@ module Distribution.Simple.Utils (
#
include
"config.h"
#
endif
import
Distribution.Package
(
PackageDescription
(
..
),
showPackageId
)
import
Distribution.Package
(
PackageDescription
(
..
),
showPackageId
,
BuildInfo
(
..
),
hasLibs
)
import
Control.Monad
(
when
,
unless
,
liftM
,
mapM
)
import
Data.List
(
inits
,
nub
,
intersperse
,
findIndices
,
partition
)
...
...
@@ -458,6 +460,12 @@ filesWithExtensions dir extension
=
do
allFiles
<-
getDirectoryContents
dir
return
$
filter
((
flip
hasExt
)
extension
)
allFiles
-- |If the package description has a library section, call the given
-- function with the library build info as argument.
withLib
::
PackageDescription
->
(
BuildInfo
->
IO
()
)
->
IO
()
withLib
pkg_descr
f
=
when
(
hasLibs
pkg_descr
)
$
f
(
fromJust
(
library
pkg_descr
))
-- ------------------------------------------------------------
-- * Testing
-- ------------------------------------------------------------
...
...
README
View file @
1167e1ca
...
...
@@ -47,6 +47,7 @@ Cabal Coders:
- Simon Marlow
- Martin Sjögren
- Krasimir Angelov
- Malcolm Wallace (via hmake)
Cabal proposal:
- Isaac Jones
...
...
copyright
View file @
1167e1ca
Copyright (c) 2003-2004, Isaac Jones, Simon Marlow, Martin Sjögren,
Bjorn Bringert, Krasimir Angelov
Bjorn Bringert, Krasimir Angelov,
Malcolm Wallace
All rights reserved.
Redistribution and use in source and binary forms, with or without
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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