Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in / Register
Toggle navigation
N
nofib
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
nofib
Commits
3b4210fa
Commit
3b4210fa
authored
May 18, 2019
by
Ben Gamari
🐢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write results to file
parent
64e48129
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
12 deletions
+42
-12
Main.hs
shake/Main.hs
+41
-12
nofib-run.cabal
shake/nofib-run.cabal
+1
-0
No files found.
shake/Main.hs
View file @
3b4210fa
...
...
@@ -11,6 +11,7 @@ import Data.List
import
Data.Maybe
import
Data.Time.Clock
import
qualified
System.Directory
as
IO
import
qualified
Data.ByteString.Char8
as
BS
import
System.Exit
import
System.Info
import
System.IO
...
...
@@ -179,6 +180,8 @@ main = do
--
-- * .hi/.o - files produced by ghc -c.
--
-- * .result - the stdout and stderr output from the build
--
-- Most complication comes from modules not named Main, which still produce
-- Main.o object files (I think ghc -M gets these wrong).
buildRules
::
Nofib
->
Rules
()
...
...
@@ -190,6 +193,15 @@ buildRules Build{..} = do
want
$
concat
[
[
s
</>
"Main"
<.>
exe
,
s
</>
"config.txt"
]
|
t
<-
tests
,
let
s
=
output
</>
t
]
"//all-results"
%>
\
out
->
do
let
results
=
[
s
</>
"Main"
<.>
exe
<.>
"result"
|
t
<-
tests
,
let
s
=
output
</>
t
]
need
results
xs
<-
mapM
readFileLines
results
writeFileLines
out
(
concat
xs
)
"//config.txt"
%>
\
out
->
do
let
dir
=
unoutput
out
src
<-
readFileLines
$
dir
</>
"Makefile"
...
...
@@ -200,7 +212,7 @@ buildRules Build{..} = do
x
:
_
->
"MAIN = "
++
x
writeFileLines
out
$
mainMod
:
convertConfig
src
(
"//Main"
<.>
exe
)
%>
\
out
->
do
[
"//Main"
<.>
exe
,
"//Main"
<.>
exe
<.>
"result"
]
&%>
\
[
out
,
result
]
->
do
deps
<-
readFile'
$
replaceExtension
out
"deps"
let
os
=
nub
[
if
isLower
$
head
$
takeFileName
x
then
replaceExtension
out
"o"
else
output
</>
x
|
x
<-
words
deps
,
takeExtension
x
==
".o"
]
...
...
@@ -209,13 +221,26 @@ buildRules Build{..} = do
let
dir
=
unoutput
out
obj
=
takeDirectory
out
name
=
takeFileName
dir
putNormal
$
"==nofib== "
++
name
++
" : time to link "
++
name
++
" follows..."
withResource
r
1
$
cmd_
compiler
$
[
"-Rghc-timing"
,
"-rtsopts"
,
"-o"
,
out
]
++
os
++
way
++
words
(
config
"SRC_HC_OPTS"
)
putNormal
$
"==nofib== "
++
name
++
": size of "
++
name
++
" follows..."
cmd_
"size"
[
out
]
[
"//*.o"
,
"//*.hi"
]
&%>
\
[
o
,
hi
]
->
do
resultHdl
<-
liftIO
$
openFile
result
WriteMode
-- Add results from object compilation to results output
forM
os
$
\
o
->
do
ls
<-
liftIO
$
BS
.
readFile
(
o
<.>
"result"
)
liftIO
$
BS
.
hPutStr
resultHdl
ls
-- Link executable
liftIO
$
hPutStrLn
resultHdl
$
"==nofib== "
++
name
++
" : time to link "
++
name
++
" follows..."
Stdouterr
out_err
<-
withResource
r
1
$
cmd
compiler
$
[
"-Rghc-timing"
,
"-rtsopts"
,
"-o"
,
out
]
++
os
++
way
++
words
(
config
"SRC_HC_OPTS"
)
liftIO
$
BS
.
hPutStr
resultHdl
out_err
liftIO
$
hPutStrLn
resultHdl
$
"==nofib== "
++
name
++
": size of "
++
name
++
" follows..."
-- Report executable size
Stdout
out_err
<-
cmd
"size"
[
out
]
liftIO
$
BS
.
hPutStr
resultHdl
out_err
liftIO
$
hClose
resultHdl
[
"//*.o"
,
"//*.hi"
,
"//*.o.result"
]
&%>
\
[
o
,
hi
,
result
]
->
do
let
dir
=
unoutput
o
obj
=
output
</>
dir
config
<-
readConfig'
$
obj
</>
"config.txt"
...
...
@@ -227,11 +252,15 @@ buildRules Build{..} = do
need
[
if
takeExtension
r
`
elem
`
[
".h"
,
".hs"
,
".lhs"
]
then
r
else
output
</>
r
|
lhs
:
":"
:
rhs
<-
map
words
$
deps
,
dir
</>
mod
<.>
"o"
==
lhs
,
r
<-
rhs
]
let
name
=
takeFileName
dir
putNormal
$
"==nofib== "
++
name
++
" : time to compile "
++
mod
++
" follows..."
cmd_
compiler
$
[
"-Rghc-timing"
,
"-c"
,
src
,
"-w"
,
"-i"
++
obj
,
"-odir="
++
obj
,
"-hidir="
++
obj
]
++
resultHdl
<-
liftIO
$
openFile
result
WriteMode
liftIO
$
hPutStrLn
resultHdl
$
"==nofib== "
++
name
++
" : time to compile "
++
mod
++
" follows..."
Stdouterr
out_err
<-
cmd
compiler
$
[
"-Rghc-timing"
,
"-c"
,
src
,
"-w"
,
"-i"
++
obj
,
"-odir="
++
obj
,
"-hidir="
++
obj
]
++
way
++
words
(
config
"SRC_HC_OPTS"
)
putNormal
$
"==nofib== "
++
name
++
": size of "
++
takeFileName
o
++
" follows..."
cmd_
"size"
[
o
]
liftIO
$
BS
.
hPutStr
resultHdl
out_err
liftIO
$
hPutStrLn
resultHdl
$
"==nofib== "
++
name
++
": size of "
++
takeFileName
o
++
" follows..."
Stdout
out_err
<-
cmd
"size"
[
o
]
liftIO
$
BS
.
hPutStr
resultHdl
out_err
liftIO
$
hClose
resultHdl
"//Main.deps"
%>
\
out
->
do
let
dir
=
unoutput
out
...
...
shake/nofib-run.cabal
View file @
3b4210fa
...
...
@@ -18,6 +18,7 @@ executable nofib-run
other-extensions: RecordWildCards, DeriveDataTypeable
build-depends: base >=4.11 && <4.12,
time >=1.8 && <1.9,
bytestring,
directory >=1.3 && <1.4,
process >=1.6 && <1.7,
cmdargs,
...
...
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