Commit 609748dd authored by Unknown's avatar Unknown
Browse files

Merge remote-tracking branch 'origin/master' into NoForeign

parents 2360d91e c73d10fa
......@@ -93,6 +93,7 @@ Library
, Checks.WarnCheck
, CompilerEnv
, CompilerOpts
, CondCompile
, CurryBuilder
, CurryDeps
, Env.Class
......
......@@ -494,7 +494,11 @@ extDescriptions = map toDescr extensions
where
toDescr (flag, name, desc)
= (name, desc,
\ opts -> opts { optExtensions = addFlag flag (optExtensions opts)})
\opts -> let cppOpts = optCppOpts opts
in opts { optCppOpts =
cppOpts { cppRun = cppRun cppOpts || flag == CPP }
, optExtensions = addFlag flag (optExtensions opts)
})
caseModeDescriptions :: OptErrTable Options
......
{- |
Module : $Header$
Description : Conditional compilation
Copyright : (c) 2017 Finn Teegen
License : BSD-3-clause
Maintainer : fte@informatik.uni-kiel.de
Stability : experimental
Portability : portable
TODO
-}
module CondCompile (condCompile) where
import Curry.Base.Monad
import Curry.CondCompile.Transform (condTransform)
import CompilerOpts (CppOpts (..))
condCompile :: CppOpts -> FilePath -> String -> CYIO String
condCompile opts fn p
| not (cppRun opts) = return p
| otherwise = either (failMessages . (: []))
ok
(condTransform (cppDefinitions opts) fn p)
......@@ -5,7 +5,7 @@
2005 Martin Engelke
2007 Sebastian Fischer
2011 - 2013 Björn Peemöller
2016 Finn Teegen
2016 - 2017 Finn Teegen
License : BSD-3-clause
Maintainer : bjp@informatik.uni-kiel.de
......@@ -30,12 +30,13 @@ import Curry.Base.Pretty
import Curry.Files.Filenames
import Curry.Files.PathUtils
import Curry.Syntax
( Module (..), ModulePragma (..), ImportDecl (..), parseHeader, patchModuleId
, hasLanguageExtension)
( Module (..), ModulePragma (..), ImportDecl (..), parseHeader, parsePragmas
, patchModuleId, hasLanguageExtension)
import Base.Messages
import Base.SCC (scc)
import CompilerOpts (Options (..), KnownExtension (..))
import CompilerOpts (Options (..), CppOpts (..), KnownExtension (..))
import CondCompile (condCompile)
-- |Different types of source files
data Source
......@@ -91,7 +92,7 @@ targetDeps opts sEnv fn = do
-- |Retrieve the dependencies of a given source file
sourceDeps :: Options -> SourceEnv -> FilePath -> CYIO SourceEnv
sourceDeps opts sEnv fn = readHeader fn >>= moduleDeps opts sEnv fn
sourceDeps opts sEnv fn = readHeader opts fn >>= moduleDeps opts sEnv fn
-- |Retrieve the dependencies of a given module
moduleDeps :: Options -> SourceEnv -> FilePath -> Module a -> CYIO SourceEnv
......@@ -124,17 +125,22 @@ moduleIdentDeps opts sEnv m = case Map.lookup m sEnv of
| icurryExt `isSuffixOf` fn ->
return $ Map.insert m (Interface fn) sEnv
| otherwise -> do
hdr@(Module _ m' _ _ _) <- readHeader fn
hdr@(Module _ m' _ _ _) <- readHeader opts fn
if (m == m') then moduleDeps opts sEnv fn hdr
else failMessages [errWrongModule m m']
readHeader :: FilePath -> CYIO (Module ())
readHeader fn = do
readHeader :: Options -> FilePath -> CYIO (Module ())
readHeader opts fn = do
mbFile <- liftIO $ readModule fn
case mbFile of
Nothing -> failMessages [errMissingFile fn]
Just src -> do
hdr <- liftCYM $ parseHeader fn src
prgs <- liftCYM $ parsePragmas fn src
let cppOpts = optCppOpts opts
cppOpts' =
cppOpts { cppRun = cppRun cppOpts || hasLanguageExtension prgs CPP }
condC <- condCompile cppOpts' fn src
hdr <- liftCYM $ parseHeader fn condC
return $ patchModuleId fn hdr
-- If we want to compile the program instead of generating Makefile
......
......@@ -39,7 +39,6 @@ import Curry.Base.Monad
import Curry.Base.Position
import Curry.Base.Pretty
import Curry.Base.Span
import Curry.CondCompile.Transform
import Curry.FlatCurry.InterfaceEquivalence (eqInterface)
import Curry.Files.Filenames
import Curry.Files.PathUtils
......@@ -59,6 +58,7 @@ import qualified IL as IL
import Checks
import CompilerEnv
import CompilerOpts
import CondCompile (condCompile)
import Exports
import Generators
import Html.CurryHtml (source2html)
......@@ -172,13 +172,6 @@ withTempFile act = do
removeFile fn
return res
condCompile :: CppOpts -> FilePath -> String -> CYIO String
condCompile opts fn p
| not (cppRun opts) = return p
| otherwise = either (failMessages . (: []))
ok
(condTransform (cppDefinitions opts) fn p)
checkModuleHeader :: Monad m => Options -> ModuleIdent -> FilePath
-> CS.Module () -> CYT m (CS.Module ())
checkModuleHeader opts m fn = checkModuleId m
......
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