forked from moonpolysoft/dynomite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
114 lines (97 loc) · 3.59 KB
/
Copy pathRakefile
File metadata and controls
114 lines (97 loc) · 3.59 KB
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
# Common build system
require 'fileutils'
require 'rubygems'
require 'rake'
ERLC_TEST_FLAGS = "-pa deps/eunit/ebin -I deps/eunit/include -DTEST"
ERLC_FLAGS = "+debug_info -W0 -I include -pa deps/mochiweb/ebin -I deps/mochiweb/include -pa deps/rfc4627/ebin -I deps/rfc4627/include -I gen-erl/ -o ebin"
task :default => [:build_deps] do
puts "building #{ENV['TEST']}"
sh "erlc #{ERLC_FLAGS} #{ENV['TEST'] ? ERLC_TEST_FLAGS : ''} elibs/*.erl gen-erl/*.erl"
if ENV['TEST']
files = Dir["etest/*.erl"].select {|d| d !~ /^.*_test.erl$/}
sh "erlc #{ERLC_FLAGS} #{ERLC_TEST_FLAGS} #{files.join(' ')}"
end
# Dir["templates/*"].each do |template|
# sh %Q(erl -pz ebin -noshell -eval 'erltl:compile("#{template}", [{outdir, "ebin"}, debug_info, show_errors, show_warnings])' -s erlang halt)
# end
end
task :test_env => [:build_test_deps, :test_config] do
puts "test env"
ENV['TEST'] = 'test'
end
task :native do
ERLC_FLAGS = "+native #{ERLC_FLAGS}"
end
task :debug do
ERLC_FLAGS ="-DDEBUG #{ERLC_FLAGS}"
end
task :run do
sh %Q{erl -boot start_sasl +K true +A 128 -smp enable -pz ./ebin/ -sname local_console#{$$} -mnesia dir '"/tmp/mbd"' -noshell -run dynomite start}
end
task :build_dist => [:build_deps] do
sh "erlc #{ERLC_FLAGS} elibs/*.erl"
# Dir["templates/*"].each do |template|
# sh %Q(erl -pz ebin -noshell -eval 'erltl:compile("#{template}", [{outdir, "ebin"}, debug_info, show_errors, show_warnings])' -s erlang halt)
# end
end
task :econsole do
sh "erl +Bc +K true -smp enable -pz ./ebin -pz ./etest -pa ./deps/eunit/ebin -pa deps/rfc4627/ebin -pa deps/mochiweb/ebin -sname local_console_#{$$} -kernel"
end
task :stress => [:default] do
sh "erl -boot start_sasl +Bc +K true -smp enable +A 128 -pz ./ebin -pz ./etest -pa ./deps/eunit/ebin -pa deps/rfc4627/ebin -pa deps/mochiweb/ebin -sname local_console_#{$$} -noshell -run dmerkle stress -run erlang halt"
end
task :console do
sh "irb -I rlibs/"
end
task :test => [:test_env, :default] do
mods = []
mod_directives = ""
env_peek = ENV['MOD'] || ENV['MODS'] || ENV['MODULE'] || ENV['MODULES']
if env_peek
mods = env_peek.split(",")
else
mods = Dir["etest/*_test.erl"].map { |x| x.match(/etest\/(.*)_test.erl/)[1] }
end
mod_directives = mods.join(" ")
priv = priv_dir()
# -run #{ENV['MOD']} test
sh %Q{erl -boot start_sasl +K true -smp enable -pz ./etest ./ebin -pa ./deps/eunit/ebin ./deps/mochiweb/ebin ./deps/rfc4627/ebin ./deps/thrift/ebin -sname local_console_#{$$} -noshell -priv_dir "#{priv}" -config test -s eunit test #{mod_directives} -run init stop}
puts "-> Test logs in #{priv}"
end
task :docs do
#files = (Dir["elibs/*.erl"] - ["elibs/json.erl"]).sort.map { |x| "\'../" + x + "\'"}.join(" ")
#sh %|cd doc && erl -noshell -run edoc_run files #{files}|
files = Dir["elibs/*.erl"].map { |x| "'../" + x + "'"}.join " "
sh %|cd doc && erl -noshell -s init stop -run edoc files #{files}|
end
task :build_deps do
Dir["deps/*"].each do |dir|
sh "cd #{dir} && make"
end
end
task :build_test_deps do
sh "erlc +debug_info -I include #{ERLC_TEST_FLAGS} -o etest etest/t.erl"
end
task :test_config do
# ensure the test log dir exists
priv = priv_dir()
FileUtils.mkpath(priv)
# write config file to configure sasl, etc to
cfg = File.new("test.config", "w+")
# write their error logs to the log files in log dir
cfg.write(<<EOC)
[{kernel,
[{error_logger, {file, "#{priv}/kernel.log"}}
]},
{sasl,
[{sasl_error_logger, {file, "#{priv}/sasl.log"}}
]}
].
EOC
cfg.close()
end
def priv_dir
base = File.dirname(__FILE__)
priv = File.join(base, "etest", "log", "#{$$}")
return priv
end