Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions uuagc/trunk/cabal-plugin/src/Distribution/Simple/UUAGC/UUAGC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ import Data.List (nub,intersperse)
import Data.Map (Map)
import qualified Data.Map as Map

#if MIN_VERSION_Cabal(3,6,0)
import Distribution.Utils.Path (getSymbolicPath, PackageDir, SourceDir, SymbolicPath)
#endif

{-# DEPRECATED uuagcUserHook, uuagcUserHook', uuagc "Use uuagcLibUserHook instead" #-}

-- | 'uuagc' returns the name of the uuagc compiler
Expand Down Expand Up @@ -130,7 +134,7 @@ updateAGFile uuagc newOptions (file,(opts,Just (gen,sp))) = do
(ec, files) <- uuagc (optionsToString $ opts { genFileDeps = True, searchPath = sp }) file
case ec of
ExitSuccess -> do
let newOpts :: Options
let newOpts :: Options
newOpts = maybe noOptions fst $ Map.lookup file newOptions
optRebuild = optionsToString newOpts /= optionsToString opts
modRebuild <-
Expand Down Expand Up @@ -261,6 +265,10 @@ uuagc' :: ([String] -> FilePath -> IO (ExitCode, [FilePath]))
-> PreProcessor
uuagc' uuagc build lbi _ =
PreProcessor {
#if MIN_VERSION_Cabal(3,8,1)
-- The ppOrdering field was added in Cabal 3.8.1 (GHC 9.4)
ppOrdering = \_verbosity _files modules -> pure modules,
#endif
platformIndependent = True,
runPreProcessor = mkSimplePreProcessor $ \ inFile outFile verbosity ->
do notice verbosity $ "[UUAGC] processing: " ++ inFile ++ " generating: " ++ outFile
Expand All @@ -272,17 +280,31 @@ uuagc' uuagc build lbi _ =
return noOptions
Just (opt,gen) -> return opt
let search = dropFileName inFile
options = opts { searchPath = search : hsSourceDirs build ++ searchPath opts
options = opts { searchPath = search : hsSourceDirsFilePaths (hsSourceDirs build) ++ searchPath opts
, outputFiles = outFile : (outputFiles opts) }
(eCode,_) <- uuagc (optionsToString options) inFile
case eCode of
ExitSuccess -> writeFileOptions classesPath (Map.insert inFile (opts, Just (outFile, searchPath options)) fileOpts)
ex@(ExitFailure _) -> throwIO ex
}

-- | In Cabal 3.6.0.0 (GHC 9.2) and up, 'BuildInfo' member 'hsSourceDirs' has type
-- '[SymbolicPath PackageDir SourceDir]', but in versions before that, it is [FilePath].
#if MIN_VERSION_Cabal(3,6,0)
hsSourceDirsFilePaths :: [SymbolicPath PackageDir SourceDir] -> [FilePath]
hsSourceDirsFilePaths = map getSymbolicPath
#else
hsSourceDirsFilePaths :: [FilePath] -> [FilePath]
hsSourceDirsFilePaths = id
#endif

nouuagc :: BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor
nouuagc build lbi _ =
PreProcessor {
#if MIN_VERSION_Cabal(3,8,1)
-- The ppOrdering field was added in Cabal 3.8.1 (GHC 9.4)
ppOrdering = \_verbosity _files modules -> pure modules,
#endif
platformIndependent = True,
runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> do
info verbosity ("skipping: " ++ outFile)
Expand Down
3 changes: 2 additions & 1 deletion uuagc/trunk/src/KennedyWarren.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ type VG s a = ErrorT String (StateT (VGState s) (ST s)) a
------------------------------------------------------------
-- | Run the VG monad in the ST monad
runVG :: VG s a -> ST s a
runVG vg = do (Right a,_) <- runStateT (runErrorT vg) vgEmptyState
runVG vg = do result <- runStateT (runErrorT vg) vgEmptyState
let (Right a,_) = result
return a

-- | Insert an initial node for this nonterminal into the visit graph
Expand Down