Commit 27dd3ddf authored by Bernd Brassel's avatar Bernd Brassel
Browse files

debugger installable in cabal for real

parent eb3030da
......@@ -10,10 +10,18 @@ semantic.cache
*~
# files generated by cabal
dist/*
debugger/dist/*
dist/
debugger/Curry/DebugModule/*.hs
debugger/Curry/DebugModule/*.fcy
debugger/Curry/Module/Oracle*.f*
src/lib/Curry/Module/*.fcy
src/lib/Curry/Module/*.fint
src/lib/Curry/Module/*.efc
src/lib/Curry/Module/*.acy
src/lib/Curry/Module/*.uacy
src/lib/Curry/Module/*.cy
debugger/prophecy/Curry/Module/*.f*
# frequently coming files
*.patch
......
module Curry.Files.KiCSDebugPath (getProphecy,getMkstrict,getOracleLibDir,debugVersion) where
module Curry.Files.KiCSDebugPath
(getMkstrict
,debugVersion
,module Curry.Files.ProphecyPath
) where
import Data.Version
import System.FilePath
import Paths_KiCS_debugger
import Curry.Files.ProphecyPath
debugVersion = showVersion version
getExecutable s = do
getMkstrict = do
execDir <- getBinDir
return (execDir </> s)
getProphecy = getExecutable "prophecy"
getMkstrict = getExecutable "mkstrict"
return (execDir </> "mkstrict")
getOracleLibDir = getDataDir
......@@ -11,11 +11,13 @@ build-type: Custom
Synopsis: debug features for kics
Description: This package contains the debugger for the Curry to Haskell compiler "kics".
Stability: experimental
extra-tmp-files: Curry/Module/*.fcy, Curry/Module/*.fint, Curry/DebugModule
extra-tmp-files: Curry/Module/*.fcy,
Curry/Module/*.fint,
Curry/DebugModule/*.fcy
Curry/DebugModule/*.hs
extra-source-files:
Curry/Module/*.hs.include
Curry/DebugModule/*.hs.include
biosphere/src/Curry/Module/*.hs.include
prophecy/Curry/Module/*.hs.include
Data-Dir: .
Data-Files:
Curry/Module/*.fcy
......@@ -36,9 +38,6 @@ Library
Exposed-Modules:
Curry.Files.KiCSDebugPath
Curry.Module.Oracle
Curry.Module.CEventOracle
Curry.Debugger.DebugMonad
Curry.Debugger.DebugInfo
Curry.Debugger.PartCalls
......@@ -55,8 +54,6 @@ Library
Curry.Debugger.Tools.Observe.Monad
Other-Modules:
Curry.Module.EventOracle
Curry.Debugger.Logic
Curry.Debugger.BoolStack
Curry.Debugger.Oracle
......@@ -68,25 +65,6 @@ Library
Paths_KiCS_debugger
install-includes: coracle/coracle.h
c-sources: coracle/coracle.c
Executable prophecy
main-is: prophecy.hs
hs-source-dirs: ., prophecy, .curry/kics
Build-Depends:
base == 4.1.*,
KiCS >= 0.9.0
Other-Modules:
Curry.Module.AddWorld
Curry.Module.Wrapper
Curry.Module.LiftCases
Curry.Module.Make
Curry.Module.Transform
Curry.Module.DebuggerPath
Curry.Files.KiCSDebugPath
Paths_KiCS_debugger
Executable mkstrict
main-is: mkstrict.hs
hs-source-dirs: prophecy, biosphere/src, .curry/kics
......@@ -95,10 +73,9 @@ Executable mkstrict
haskell-src,
directory,
curry-base >= 0.2.6,
KiCS >= 0.9.0
KiCS >= 0.9.0,
KiCS-prophecy >= 0.1.0
Other-Modules:
Curry.Module.LiftCases
Curry.Module.Make
Curry.Module.SrcRef
Curry.Module.AbstractHaskell
Curry.Module.FlatToAbstractCurry
......
......@@ -16,29 +16,33 @@ import Distribution.ModuleName (ModuleName(..))
import Curry.Files.CymakePath
import Curry.Files.KiCSPath
import Curry.Files.ProphecyPath
withLibs :: Bool
withLibs = True
kics, cymake :: IO Program
kics = mkProg getKiCS
cymake = mkProg getCymake
kics, cymake, prophecy :: IO Program
kics = mkProg getKiCS
cymake = mkProg getCymake
prophecy = mkProg getProphecy
mkProg getProg = do
call <- getProg
return (simpleProgram (takeBaseName call))
{programFindLocation = \_-> return (Just call)}
prophecy, mkstrict :: Program
prophecy = simpleProgram "prophecy"
mkstrict :: Program
mkstrict = simpleProgram "mkstrict"
main :: IO ()
main = do
cymakeProg <- cymake
kicsProg <- kics
cymakeProg <- cymake
kicsProg <- kics
prophecyProg <- prophecy
defaultMainWithHooks simpleUserHooks
{hookedPrograms=kicsProg:cymakeProg:prophecy:hookedPrograms simpleUserHooks
{hookedPrograms=mkstrict:kicsProg:cymakeProg:prophecyProg:
hookedPrograms simpleUserHooks
,confHook=myConfHook
,postConf=myPostConf
,hookedPreProcessors=[("curry",mkModule),
......@@ -50,9 +54,9 @@ main = do
modName :: [String] -> ModuleName
modName xs = read $ "ModuleName " ++ show xs
myConfHook :: (Either GenericPackageDescription PackageDescription, HookedBuildInfo)
-> ConfigFlags
-> IO LocalBuildInfo
myConfHook ::
(Either GenericPackageDescription PackageDescription, HookedBuildInfo)
-> ConfigFlags -> IO LocalBuildInfo
myConfHook info flags = do
lbi <- confHook simpleUserHooks info flags
if not withLibs
......@@ -62,16 +66,20 @@ myConfHook info flags = do
dataPath <- getKiCSDataDir
allFiles <- getDirectoryContents libPath
let stdfiles = filter (isSuffixOf ".fcy") allFiles
goodlibs = filter (not . (`elem` badlibs) . takeBaseName) stdfiles
stdlibs = map takeBaseName stdfiles
let stdfiles = filter (isSuffixOf ".fcy") allFiles
goodfiles = filter (not . (`elem` badlibs) . takeBaseName) stdfiles
stdlibs = map takeBaseName stdfiles
goodlibs = map takeBaseName goodfiles
libs = map (\ l -> modName ("Curry":"Module":["Oracle" ++ l])) stdlibs
++map (\ l -> modName ("Curry":"DebugModule":[l])) goodlibs
dbgPath = "Curry" </> "DebugModule"
createDirectoryIfMissing True dbgPath
mapM_ (\ lib -> copyFile (libPath </> lib) (dbgPath </> lib)) goodlibs
mapM_ (\ lib -> copyFile (libPath </> lib) (dbgPath </> lib)) goodfiles
let require = requireProg flags lbi
prop <- require prophecy
mapM_ (mkOracleLib (unflag $ configVerbosity flags) prop) stdlibs
let package = localPkgDescr lbi
Just lib = library package
ex = exposedModules lib
......@@ -96,13 +104,19 @@ callProg :: Verbosity -> LocalBuildInfo -> IO Program -> Args -> IO ()
callProg verb lbi prog args = do
p <- prog
rawSystemProgramConf verb p (withPrograms lbi) args
mkOracleLib :: Verbosity -> ConfiguredProgram -> FilePath -> IO ()
mkOracleLib verb prop stdlib = do
rawSystemProgram verb prop ["-o","Curry/Module/",stdlib]
return ()
myPostConf ::
Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
myPostConf args confFlags descrs lbi = do
let require = requireProg confFlags lbi
require cymake
require kics
require prophecy
postConf simpleUserHooks args confFlags descrs lbi
badlibs =
......@@ -178,9 +192,9 @@ runKics datadir lbi infile outfile verb
then ["-executable","prophecy"]
else []
| isPrefixOf "biosphere" infile
= do callCymake ["-iprophecy/Curry/Module","-ibiosphere/Curry/Module"]
= do callCymake ["-iprophecy/Curry/Module","-ibiosphere/src/Curry/Module"]
callKics $ ["-userlibpath",
"prophecy/Curry/Module:biosphere/Curry/Module"] ++
"prophecy/Curry/Module:biosphere/src/Curry/Module"] ++
if isSuffixOf "TransformationDependencies.lcurry" infile
then ["-executable","mkstrict"]
else []
......@@ -200,14 +214,18 @@ mkOracleModule buildInfo lbi = PreProcessor
runKicsFcy :: LocalBuildInfo -> FilePath -> FilePath -> Verbosity -> IO ()
runKicsFcy lbi infile outfile verb
| isPrefixOf "Curry/Module" infile
= callKics ["-userlibpath","Curry/Module:Curry/Module"]
| isPrefixOf "Curry/Module" outfile
= do
call (return prophecy) ["-o","Curry/Module/",stdlib]
call kics ["-userlibpath","Curry/Module:Curry/Module"]
= do
libPath <- getOracleLibDir
callKics ["-userlibpath",libPath ++ pathSeparator:"Curry/Module"]
| isPrefixOf "Curry/DebugModule" infile
= call (return mkstrict) ["-o","Curry/Module/",stdlib]
rawSystemProgram verb strict ["-o","./",stdlib]
= do
let dir = addTrailingPathSeparator $
joinPath $
reverse $ drop 2 $ reverse $
splitDirectories (takeDirectory outfile)
print dir
call (return mkstrict) ["-o",dir,dropExtension infile]
--rawSystemProgram verb strict ["-o","./",stdlib]
where
call = callProg verb lbi
......
module Curry.Files.ProphecyPath
(getProphecy
,getOracleLibDir
,prophecyVersion
) where
import Data.Version
import System.FilePath
import Paths_KiCS_prophecy
prophecyVersion = showVersion version
getProphecy = do
execDir <- getBinDir
return (execDir </> "prophecy")
getOracleLibDir = getDataDir
......@@ -20,7 +20,7 @@ import Distribution as D
import FiniteMap
import IOExts
import Sort (leqString)
import FileGoodies (dirName,lookupFileInPath,getFileInPath)
import FileGoodies
import Time
import Directory
import System (getArgs)
......@@ -37,7 +37,7 @@ type Done a = IORef (FM String a)
data Parameter = Parameter Bool Bool (Maybe String) (Maybe String) String
defaults :: Parameter
defaults = Parameter False False Nothing ""
defaults = Parameter False False Nothing Nothing ""
type Getter a = Parameter -> a
type Setter a = a -> Parameter -> Parameter
......@@ -95,8 +95,11 @@ make :: Bool -> ModuleName -> TestAct a -> ProgAct a -> IO ()
make = makeWithFrontendParams defaultParams
makeWithFrontendParams :: FrontendParams -> Bool -> ModuleName -> TestAct a -> ProgAct a -> IO ()
makeWithFrontendParams params qu modu test act = do
loadPath <- maybe getLoadPath return (fullPath params)
makeWithFrontendParams givenParams qu file test act = do
let (dir,modu) = splitDirectoryBaseName file
path <- maybe getLoadPath return (fullPath givenParams)
let loadPath = if dir=="." then path else dir:path
params = setFullPath loadPath givenParams
mCurryFile <- lookupFileInPath modu [".curry",".lcurry"] loadPath
unless (mCurryFile==Nothing)
(do
......
Name: KiCS-prophecy
Version: 0.1.0
Cabal-Version: == 1.6.*
Author: Bernd Braßel
Maintainer: Bernd Braßel
Homepage: http://curry-language.org
License: OtherLicense
License-File: LICENSE
Category: Debug
build-type: Custom
Synopsis: a transformation used by the kics debugger
Description: This package contains a transformation of the debugger
for the Curry to Haskell compiler "kics".
Stability: experimental
extra-tmp-files: Curry/Module/*.fcy,
Curry/Module/*.fint
extra-source-files:
Curry/Module/*.hs.include
Data-Dir: .
Data-Files:
Curry/Module/*.fcy
Curry/Module/*.fint
Library
hs-source-dirs: .
Build-Depends:
base == 4.1.*,
filepath,
KiCS >= 0.9.1
Exposed-Modules:
Curry.Files.ProphecyPath
Curry.Module.Oracle
Curry.Module.CEventOracle
Curry.Module.LiftCases
Curry.Module.Make
Other-Modules:
Curry.Module.EventOracle
Paths_KiCS_prophecy
install-includes: coracle/coracle.h
c-sources: coracle/coracle.c
Executable prophecy
main-is: prophecy.hs
hs-source-dirs: ., .curry/kics
Build-Depends:
base == 4.1.*,
KiCS >= 0.9.0
Other-Modules:
Curry.Module.AddWorld
Curry.Module.Wrapper
Curry.Module.Transform
Curry.Module.Make
Curry.Module.LiftCases
KiCS (Kiel Curry System) License
Copyright (c) 2009, University of Kiel
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.
- None of the names of the copyright holders and 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 Main where
import System.FilePath
import System.Directory
import Monad
import Data.List
import Distribution.Simple
import Distribution.Simple.Setup
import Distribution.Simple.Program
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.PreProcess
import Distribution.PackageDescription
import Distribution.Verbosity
import Distribution.ModuleName (ModuleName(..))
import Curry.Files.CymakePath
import Curry.Files.KiCSPath
kics, cymake :: IO Program
kics = mkProg getKiCS
cymake = mkProg getCymake
mkProg getProg = do
call <- getProg
return (simpleProgram (takeBaseName call))
{programFindLocation = \_-> return (Just call)}
prophecy, mkstrict :: Program
prophecy = simpleProgram "prophecy"
mkstrict = simpleProgram "mkstrict"
main :: IO ()
main = do
cymakeProg <- cymake
kicsProg <- kics
defaultMainWithHooks simpleUserHooks
{hookedPrograms=kicsProg:cymakeProg:hookedPrograms simpleUserHooks
,postConf=myPostConf
,hookedPreProcessors=[("curry",mkModule)]
}
unflag = fromFlagOrDefault silent
requireProg :: ConfigFlags -> LocalBuildInfo -> IO Program
-> IO ConfiguredProgram
requireProg verb lbi prog = do
p <- prog
(cp,_) <- requireProgram (unflag $ configVerbosity verb) p AnyVersion
(withPrograms lbi)
return cp
callProg :: Verbosity -> LocalBuildInfo -> IO Program -> Args -> IO ()
callProg verb lbi prog args = do
p <- prog
rawSystemProgramConf verb p (withPrograms lbi) args
myPostConf ::
Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
myPostConf args confFlags descrs lbi = do
let require = requireProg confFlags lbi
require cymake
require kics
postConf simpleUserHooks args confFlags descrs lbi
mkModule :: BuildInfo -> LocalBuildInfo -> PreProcessor
mkModule _ lbi = PreProcessor
{platformIndependent = True
,runPreProcessor = mkSimplePreProcessor $ \ inf outf verb -> do
datadir <- getKiCSLibDir
runKics datadir lbi inf outf verb}
runKics :: FilePath -> LocalBuildInfo
-> FilePath -> FilePath -> Verbosity -> IO ()
runKics datadir lbi infile outfile verb
= do call cymake ["-iCurry/Module","-i"++datadir,
"--no-hidden-subdir",
"-e","--flat",infile]
callKics $ ["-userlibpath","Curry/Module"] ++
if isSuffixOf "Transform.curry" infile
then ["-executable","prophecy"]
else []
where
call = callProg verb lbi
callKics args =
call kics $ args ++ ["-nomake","-o",outfile,infile]
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