-
Notifications
You must be signed in to change notification settings - Fork 2
/
rakefile.rb
129 lines (112 loc) · 2.71 KB
/
rakefile.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
require 'rake/clean'
require 'benchmark'
Out="bin"
directory Out
Output="output.out"
module OS
def OS.windows?
(RUBY_PLATFORM =~ /cygwin|mswin|mingw|bccwin|wince|emx/) != nil
end
def OS.mac?
(RUBY_PLATFORM =~ /darwin/) != nil
end
def OS.unix?
!OS.windows?
end
def OS.linux?
OS.unix? and not OS.mac?
end
end
if OS.unix?
def exeName(n) File.join(Out,n) end
else
def exeName(n) File.join(Out,"#{n}.exe") end
end
MainHs="Main.hs"
LuaMainHs="LuaMain.hs"
DiagScripterHs="DiagScripterMain.hs"
DiagTool = exeName "diagTool"
LuaScripter = exeName "luaexecuter"
DiagScripter = exeName "diag_scripter"
ProfArgs={
:time=>"+RTS -p -K100M",
:heap=>"+RTS -hc -p -K100M",
:allocType=>"+RTS -hy -p -K100M",
:constructorAlloc=>"+RTS -hd -p -K100M"
}
CLEAN.include(Output,"**/*.o","**/*.hi","dist")
CLOBBER.include(Out)
SrcFiles = FileList.new('**/*.hs')
def buildExe(exe,main)
puts "building executable:" + exe
sh "ghc -O2 -o #{exe} -outputdir #{Out} --make #{main} -fforce-recomp -fspec-constr-count=6"
# sh "ghc -O2 -o #{exe} -outputdir #{Out} --make #{main} -threaded -fforce-recomp -fspec-constr-count=6"
# stripExec exe
end
file DiagScripter => SrcFiles << Out do
buildExe(DiagScripter,DiagScripterHs)
end
file DiagTool => SrcFiles << Out do
buildExe(DiagTool,MainHs)
end
file LuaScripter => SrcFiles << Out do
buildExe(LuaScripter,LuaMainHs)
end
desc "rebuild all executables"
task :build => [:clean,DiagTool,DiagScripter,LuaScripter]
desc "rebuild diagScripter"
task :scripter => [:clean,DiagScripter]
namespace "lua" do
desc "build luaScripter"
task :scripter => [:clean,LuaScripter]
desc "run lua_scripter"
task :run, :scriptName do |t,args|
cd "Lua" do
sh "../#{LuaScripter} #{args[:scriptName]}"
end
end
task :run => LuaScripter
end
desc "run all testcases"
task :test do
sh 'runhaskell Tests/testMain.hs'
end
desc "cabal test"
task :cabalTest do
sh "cabal clean"
sh "cabal configure --enable-tests"
sh "cabal build"
sh "cabal test"
end
desc 'install all cabal dependencies'
task :all_deps do
sh "sudo cabal install --only-dependencies"
end
task :deps do
sh "cabal-dev install --only-dependencies"
end
desc "prepare cabal-dev build"
task :dev => :deps do
sh "cabal-dev clean"
sh "cabal-dev configure"
sh "cabal-dev build"
end
def stripExec (x)
if OS.unix?
sh "strip #{x}"
sh "upx #{x}"
end
end
desc 'execute nvramtest.skr test files'
task :nvram do
sh "runghc Test/DiagScriptTester.hs \"Script/nvramtest.skr\""
end
task :default => [:clean, :build]
desc "generate tag file"
task :tags do
sh "find . | egrep '\.hs$' | xargs hothasktags > tags"
end
desc "run webserver on port 8899 using cabal"
task :run do
sh "cabal run -- \"-p 8899\""
end