Commit 78dc201b authored by Michael Hanus 's avatar Michael Hanus

Fix for compiling non-local modules

parent dacc5d1f
......@@ -45,10 +45,13 @@ In the following, we describe various uses of the `icurry` tool.
> icurry Prog
This will generate the file `.curry/Prog.icy`, i.e., the suffix `icy`
is used for generated ICurry programs. If the program is located
in a non-local directory, the generated file is placed relative
to the directory of the source program.
This will generate the file `Prog.icy` in the directory where
the Curry system stores intermediate files, e.g., `.curry/pakcs-3.2.0`.
Hence, the suffix `icy` is used for generated ICurry programs.
If the program is located in a non-local directory, i.e., `Prog` is
not a module name but prefixed by a directory `DIR`, this command
switches to the directory `DIR` so that the generated file
is placed in the intermediate files in directory `DIR`.
In order to see a human-readable presentation of the generated program,
use option `-v`, i.e.,
......
......@@ -2,7 +2,7 @@
--- This module contains a simple compiler from FlatCurry to ICurry programs.
---
--- @author Michael Hanus
--- @version November 2020
--- @version December 2020
------------------------------------------------------------------------------
module ICurry.Main where
......@@ -12,7 +12,8 @@ import Numeric ( readNat )
import System.Environment ( getArgs )
import System.Console.GetOpt
import System.CurryPath ( stripCurrySuffix )
import System.CurryPath ( splitValidProgramName, stripCurrySuffix )
import System.Directory ( getCurrentDirectory, setCurrentDirectory )
import System.Process ( exitWith )
import ICurry.Compiler
......@@ -45,12 +46,17 @@ main = do
_ -> error "Too many module names provided"
mainProg :: ICOptions -> String -> IO ()
mainProg opts p = do
iprog <- icCompile opts p
mainProg opts progname = do
let (progdir,mname) = splitValidProgramName progname
curdir <- getCurrentDirectory
unless (progdir == ".") $ do
printStatus opts $ "Switching to directory '" ++ progdir ++ "'..."
setCurrentDirectory progdir
iprog <- icCompile opts mname
let imain = optMain opts
if null imain
then do
icyname <- iCurryFilePath p
icyname <- iCurryFilePath mname
writeICurryFile icyname iprog
printStatus opts $ "ICurry program written to '" ++ icyname ++ "'"
else do
......@@ -65,6 +71,7 @@ mainProg opts p = do
else opts1 { interactive = True }
else opts1
execIProg opts2 iprog imain
unless (progdir == ".") $ setCurrentDirectory curdir
--- Process the actual command line argument and return the options
--- and the name of the main program.
......
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