Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify setup #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
47 changes: 14 additions & 33 deletions uuagc/trunk/Setup.hs
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
-- Note: to bootstrap uuagc with a commandline uuagc,
-- pass the -DEXTERNAL_UUAGC to GHC
-- when building setup.hs. This can be accomplished using
-- cabal install with --ghc-options="-DEXTERNAL_UUAGC".
--
-- When this option is used, a cabal flag will be set so
-- that the Haskell sources will be regenerated from
-- the attribute grammar sources
--
-- Note: it would be nicer if this behavior could be enabled
-- with a configure flag. However, a compiled Setup.hs is
-- required in order to perform 'configure', so configure
-- flags are regarded too late in the process.
-- Also note that this Setup.hs has conditional package
-- requirements depending on what code is used.

{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
{-# LANGUAGE CPP #-}
module Main where

#ifdef EXTERNAL_UUAGC
import System.Environment (getArgs)
import Distribution.Simple (defaultMainWithHooksArgs)
import Distribution.Simple (defaultMainWithHooksArgs, UserHooks (..), simpleUserHooks)
import Distribution.Simple.LocalBuildInfo (flagAssignment)
import Distribution.Simple.UUAGC (uuagcUserHook)
import Distribution.Types.Flag (lookupFlagAssignment, mkFlagName)
import Debug.Trace

main :: IO ()
main = args >>= defaultMainWithHooksArgs uuagcUserHook

args :: IO [String]
args = do
as <- getArgs
let addFlags | "configure" `elem` as = ("--flags=bootstrap_external" :)
| otherwise = id
return (addFlags as)
#else
import Distribution.Simple (defaultMain, defaultMainWithHooksArgs)

main :: IO ()
main = defaultMain
#endif
main = do
args <- getArgs
defaultMainWithHooksArgs hooks args
where
hooks = uuagcUserHook { buildHook = myBuildHook }
myBuildHook pd lbi uh bf
| lookupFlagAssignment (mkFlagName "bootstrap_external") (flagAssignment lbi) == Just True
= buildHook uuagcUserHook pd lbi uh bf
| otherwise
= buildHook simpleUserHooks pd lbi uh bf
8 changes: 4 additions & 4 deletions uuagc/trunk/src/LOAG/Chordal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ scheduleLOAG ag@(Ag nbounds pbounds dps nts) putStrLn opts = do
, let pred = varMap M.! (i,s)
]
forM dps $ \(f,t) -> do
modifyArray edp t (f `IS.insert`)
LOAG.Common.modifyArray edp t (f `IS.insert`)
f_idsf <- freeze idsf
f_idst <- freeze idst
f_edp <- freeze edp
Expand All @@ -145,10 +145,10 @@ scheduleLOAG ag@(Ag nbounds pbounds dps nts) putStrLn opts = do
-> IOArray Vertex Vertices
-> IO [()]
addEdges (f,t) es (idsf,idst) edp = do
modifyArray idsf f (t `IS.insert`)
modifyArray idst t (f `IS.insert`)
LOAG.Common.modifyArray idsf f (t `IS.insert`)
LOAG.Common.modifyArray idst t (f `IS.insert`)
forM es $ \(f,t) -> do --edp does not reflect flow
modifyArray edp t (f `IS.insert`)
LOAG.Common.modifyArray edp t (f `IS.insert`)

noCyclesNt :: Sat -> NtGraph -> IO ()
noCyclesNt sat g | IM.null g = return ()
Expand Down
4 changes: 2 additions & 2 deletions uuagc/trunk/src/LOAG/Optimise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ newSchedule sat varMap nbounds tp@(Nt nt _ _ inhs outs _ ) sched = do
-> (IOArray Vertex Vertices, IOArray Vertex Vertices)
-> IO ()
addEdges (f,t) (idsf,idst) = do
modifyArray idsf f (t `IS.insert`)
modifyArray idst t (f `IS.insert`)
LOAG.Common.modifyArray idsf f (t `IS.insert`)
LOAG.Common.modifyArray idst t (f `IS.insert`)

-- | count the (max, avg, total) number of visits
getVisCount :: [Nt] -> InterfaceRes -> VisCount
Expand Down
4 changes: 2 additions & 2 deletions uuagc/trunk/update-src-generated.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rm -rf dist-newstyle
cabal v2-configure --ghc-options="-DEXTERNAL_UUAGC" -fwith-loag
cabal v2-build --ghc-options="-DEXTERNAL_UUAGC"
set -e
cabal v2-build -fbootstrap_external -fwith-loag
cp dist-newstyle/build/x86_64-linux/ghc-*/uuagc-*/build/*.hs src-generated/
cp dist-newstyle/build/x86_64-linux/ghc-*/uuagc-*/build/LOAG/*.hs src-generated/LOAG/
# Patch the line pragma's a bit
Expand Down
10 changes: 6 additions & 4 deletions uuagc/trunk/uuagc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ extra-source-files: src-ag/*.ag
extra-source-files: src-ag/*.lag
extra-source-files: src-ag/LOAG/*.ag

-- This flag will be set by Setup.hs, use
-- cabal configure --ghc-options="-DEXTERNAL_UUAGC"
flag bootstrap_external
description: Use an external uuagc executable for bootstrapping
default: False
Expand Down Expand Up @@ -55,8 +53,12 @@ library
build-depends: haskell-src-exts >= 1.11.1
build-depends: filepath >= 1.1.0.4
build-depends: aeson >= 1.4.7.1, bytestring >= 0.9.2.1
hs-source-dirs: src, src-version, src-ag, src-options
if !flag(bootstrap_external)
hs-source-dirs: src, src-version, src-options
if flag(bootstrap_external)
-- we need to avoid any *.ag files if we're not bootstrapping,
-- because we now always use the ag preprocessor.
hs-source-dirs: src-ag
else
hs-source-dirs: src-generated
exposed-modules: UU.UUAGC, UU.UUAGC.Version
default-extensions: TypeSynonymInstances, MultiParamTypeClasses
Expand Down