Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
30138cb1
Commit
30138cb1
authored
Jan 13, 2015
by
Andrey Mokhov
Browse files
Implement terseRun and arArgs functions.
parent
750a43fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Oracles/Builder.hs
View file @
30138cb1
...
...
@@ -2,7 +2,8 @@
module
Oracles.Builder
(
Builder
(
..
),
with
,
run
,
specified
with
,
run
,
terseRun
,
specified
,
arArgs
)
where
import
Data.Char
...
...
@@ -24,6 +25,7 @@ data Builder = Ar
|
GhcCabal
|
Ghc
Stage
|
GhcPkg
Stage
deriving
Show
instance
ShowArgs
Builder
where
showArgs
builder
=
showArgs
$
fmap
words
$
do
...
...
@@ -97,6 +99,33 @@ run builder args = do
[
exe
]
<-
showArgs
builder
cmd
[
exe
]
=<<
args
-- Run the builder with a given collection of arguments printing out a
-- terse commentary with only 'interesting' info for the builder.
-- Raises an error if the builder is not uniquely specified in config files
terseRun
::
Builder
->
Args
->
Action
()
terseRun
builder
args
=
do
needBuilder
builder
[
exe
]
<-
showArgs
builder
args'
<-
args
putNormal
$
"--------
\n
Running "
++
show
builder
++
" with arguments:"
mapM_
(
putNormal
.
(
" "
++
))
$
interestingInfo
builder
args'
putNormal
"--------"
quietly
$
cmd
[
exe
]
args'
interestingInfo
::
Builder
->
[
String
]
->
[
String
]
interestingInfo
builder
ss
=
case
builder
of
Ar
->
prefixAndSuffix
3
1
ss
Ghc
_
->
if
head
ss
==
"-M"
then
prefixAndSuffix
1
1
ss
else
prefixAndSuffix
0
4
ss
GhcPkg
_
->
prefixAndSuffix
2
0
ss
GhcCabal
->
prefixAndSuffix
3
0
ss
where
prefixAndSuffix
n
m
ss
=
if
length
ss
<=
n
+
m
then
ss
else
take
n
ss
++
[
"..."
]
++
drop
(
length
ss
-
m
)
ss
-- Check if the builder is uniquely specified in config files
specified
::
Builder
->
Condition
specified
builder
=
do
...
...
@@ -104,3 +133,7 @@ specified builder = do
return
$
case
exes
of
[
_
]
->
True
_
->
False
-- TODO: generalise for other builders
arArgs
::
Args
arArgs
=
arg
"q"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment