Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 259 lines (217 sloc) 8.897 kb
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
1 # Common build system
ceae03c Rakefile now sets priv dir, and generates test.config that puts kernel a...
Jason Pellerin authored
2 require 'fileutils'
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
3 require 'rubygems'
4 require 'rake'
fecb101 added native murmur and fnv hashing.
Cliff Moon authored
5 require 'rake/clean'
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
6
3d4b511 rake task based off of VERSION env variable
Cliff Moon authored
7 VERSION = ENV["VERSION"]
b3cdf8b rake target to make a release
Cliff Moon authored
8
b219311 refactored the build a bit and turned off native for mochiweb modules
Cliff Moon authored
9 ERLC_TEST_FLAGS = "-I deps/eunit/include -DTEST"
10 ERLC_FLAGS = "+debug_info -W0 -I include -I deps/mochiweb/include -I gen-erl/ -o ebin"
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
11
fecb101 added native murmur and fnv hashing.
Cliff Moon authored
12 CLEAN.include("ebin/*.beam")
9a89e65 add releases to clean
Cliff Moon authored
13 CLEAN.include("releases/dynomite-*")
fecb101 added native murmur and fnv hashing.
Cliff Moon authored
14 CLEAN.include("c/*.o")
b6b73a5 clean log files
Cliff Moon authored
15 CLEAN.include("etest/log/*")
a16e540 lib -> priv
Cliff Moon authored
16 CLEAN.include("priv/*.so")
a5bd42f adding deps to clean
Cliff Moon authored
17 CLEAN.include("deps/*/ebin/*.beam")
fecb101 added native murmur and fnv hashing.
Cliff Moon authored
18
3a2121c better versioning
Cliff Moon authored
19 task :clean do
20 CLEAN.each { |fn| rm_r fn rescue nil }
21 Dir["deps/*"].each do |dir|
22 sh "cd #{dir} && make clean"
23 end
24 end
25
b219311 refactored the build a bit and turned off native for mochiweb modules
Cliff Moon authored
26 task :default => [:build_deps, :build_c_drivers, :build_erl] do
27
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
28 end
29
ceae03c Rakefile now sets priv dir, and generates test.config that puts kernel a...
Jason Pellerin authored
30 task :test_env => [:build_test_deps, :test_config] do
652e45a nicerer rakefile
Cliff Moon authored
31 puts "test env"
32 ENV['TEST'] = 'test'
33 end
34
ae6010e Added test lib module, fixed storage server test to use priv dir instead...
Jason Pellerin authored
35 task :native do
ed0d24a added native compilation to the load testing deployment
Cliff Moon authored
36 ERLC_FLAGS = "-smp +native #{ERLC_FLAGS}"
ae6010e Added test lib module, fixed storage server test to use priv dir instead...
Jason Pellerin authored
37 end
38
7a70e0e Merged from cliffmoon master
Jason Pellerin authored
39 task :profile do
40 ERLC_FLAGS = "-DPROF #{ERLC_FLAGS}"
41 end
42
3cf81ce more work on the ext listener.
Cliff Moon authored
43 task :run do
9bd5f0d mods to rakefile
Cliff Moon authored
44 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}
3cf81ce more work on the ext listener.
Cliff Moon authored
45 end
46
72f65d2 make_dist, install, and uninstall tasks
Cliff Moon authored
47 task :make_dist => [:clean, :native, :default, :release] do
48 puts "made release version #{VERSION}"
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
49 end
50
72f65d2 make_dist, install, and uninstall tasks
Cliff Moon authored
51 task :install do
52 ERL = `which erl`
53 ERLDIR = `awk -F= '/ROOTDIR=/ { print $2; exit; }' #{ERL}`.chomp
54 sh "cp releases/dynomite-#{VERSION}/dynomite_rel-#{VERSION}.tar.gz #{ERLDIR}/releases/"
55 sh %Q(erl -boot start_sasl -noshell -eval "io:format(\\"~p~n\\", [release_handler:unpack_release(\\"dynomite_rel-#{VERSION}\\")])." -s init stop)
56 end
57
58 task :uninstall do
59 ERL = `which erl`
60 ERLDIR = `awk -F= '/ROOTDIR=/ { print $2; exit; }' #{ERL}`.chomp
61 sh %Q(erl -boot start_sasl -noshell -eval "io:format(\\"~p~n\\", [release_handler:remove_release(\\"dynomite_#{VERSION}\\")])." -s init stop)
62 end
b3cdf8b rake target to make a release
Cliff Moon authored
63
6ddae59 added the 'rebuild thrift clients' task
Christopher Brown authored
64 task :thrift_clients do
65 sh "thrift --gen rb if/dynomite.thrift"
66 sh "thrift -erl if/dynomite.thrift"
67 end
68
b3cdf8b rake target to make a release
Cliff Moon authored
69 task :release => [:default] do
3d4b511 rake task based off of VERSION env variable
Cliff Moon authored
70 rel_file_contents = File.read("releases/dynomite.rel").gsub(/\?VERSION/, VERSION)
3a2121c better versioning
Cliff Moon authored
71 app_file_contents = File.read("ebin/dynomite.app").gsub(/\?VERSION/, VERSION)
3d4b511 rake task based off of VERSION env variable
Cliff Moon authored
72
b3cdf8b rake target to make a release
Cliff Moon authored
73 release = "releases/dynomite-#{VERSION}"
3d4b511 rake task based off of VERSION env variable
Cliff Moon authored
74 rel_file = "#{release}/dynomite_rel-#{VERSION}.rel"
b3cdf8b rake target to make a release
Cliff Moon authored
75 puts "preparing release #{release.inspect}"
a16e540 lib -> priv
Cliff Moon authored
76 %w(ebin priv src include).each do |dir|
b3cdf8b rake target to make a release
Cliff Moon authored
77 FileUtils.mkdir_p("#{release}/#{dir}")
78 end
3d4b511 rake task based off of VERSION env variable
Cliff Moon authored
79 File.open(rel_file, 'w') do |f|
80 f.print(rel_file_contents)
81 end
b3cdf8b rake target to make a release
Cliff Moon authored
82 sh "cp -r elibs/* #{release}/src" rescue nil
83 sh "cp -r ebin/* #{release}/ebin" rescue nil
3a2121c better versioning
Cliff Moon authored
84 File.open("#{release}/ebin/dynomite.app", 'w') {|f| f.print(app_file_contents) }
a16e540 lib -> priv
Cliff Moon authored
85 sh "cp -r priv/* #{release}/priv" rescue nil
a378506 copy the web directory to priv for releases
Cliff Moon authored
86 sh "cp -r web #{release}/priv/web" rescue nil
b3cdf8b rake target to make a release
Cliff Moon authored
87 sh "cp -r include/* #{release}/include" rescue nil
88 sh "cp -r deps/thrift/src/* #{release}/src" rescue nil
89 sh "cp -r deps/thrift/ebin/* #{release}/ebin" rescue nil
90 sh "cp -r deps/thrift/include/* #{release}/include" rescue nil
91 sh "cp -r deps/thrift/priv/* #{release}/priv" rescue nil
92 sh "cp -r deps/mochiweb/src/* #{release}/src" rescue nil
93 sh "cp -r deps/mochiweb/ebin/* #{release}/ebin" rescue nil
94 sh "cp -r deps/mochiweb/include/* #{release}/include" rescue nil
95 sh "cp -r deps/mochiweb/priv/* #{release}/priv" rescue nil
96
72f65d2 make_dist, install, and uninstall tasks
Cliff Moon authored
97 sh %Q(cd #{release} && erl -pa ./ebin -noshell -eval "systools:make_script(\\"dynomite_rel-#{VERSION}\\")." -eval "systools:make_tar(\\"dynomite_rel-#{VERSION}\\")." -s init stop)
b3cdf8b rake target to make a release
Cliff Moon authored
98 end
99
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
100 task :econsole do
9bd5f0d mods to rakefile
Cliff Moon authored
101 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"
102 end
103
104 task :stress => [:default] do
4e1daa4 fix stress test
Cliff Moon authored
105 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"
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
106 end
107
108 task :console do
109 sh "irb -I rlibs/"
110 end
111
652e45a nicerer rakefile
Cliff Moon authored
112 task :test => [:test_env, :default] do
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
113 mods = []
114 mod_directives = ""
115 env_peek = ENV['MOD'] || ENV['MODS'] || ENV['MODULE'] || ENV['MODULES']
116 if env_peek
117 mods = env_peek.split(",")
118 else
119 mods = Dir["etest/*_test.erl"].map { |x| x.match(/etest\/(.*)_test.erl/)[1] }
120 end
990fa31 Changed Rakefile to run all selected module tests as unified test run
Jason Pellerin authored
121 mod_directives = mods.join(" ")
ceae03c Rakefile now sets priv dir, and generates test.config that puts kernel a...
Jason Pellerin authored
122 priv = priv_dir()
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
123 # -run #{ENV['MOD']} test
1f2e1f3 cleanup test command line
Cliff Moon authored
124 sh %Q{erl -boot start_sasl +K true -smp enable -pa ./etest ./ebin ./deps/mochiweb/ebin ./deps/thrift/ebin -sname local_console_#{$$} -noshell -priv_dir "#{priv}" -config test -s eunit test #{mod_directives} -run init stop}
ceae03c Rakefile now sets priv dir, and generates test.config that puts kernel a...
Jason Pellerin authored
125 puts "-> Test logs in #{priv}"
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
126 end
127
ff36d92 code coverage analysis
Cliff Moon authored
128 task :coverage => [:test_env] do
129 mods = []
130 mod_directives = ""
131 env_peek = ENV['MOD'] || ENV['MODS'] || ENV['MODULE'] || ENV['MODULES']
132 if env_peek
133 mods = env_peek.split(",")
134 else
135 mods = Dir["etest/*_test.erl"].map { |x| x.match(/etest\/(.*)_test.erl/)[1] }
136 end
137 mod_directives = mods.join(', ')#map{|m| %Q(\\"#{m}\\")}.join(", ")
138 priv = priv_dir()
139 cmd = %Q{erl -boot start_sasl +K true -smp enable -pz etest -pa ./deps/eunit/ebin ./deps/mochiweb/ebin ./deps/rfc4627/ebin ./deps/thrift/ebin -sname local_console_#{$$} -noshell -priv_dir "#{priv}" -config test\
140 -eval "\
320cfb3 fixed mediator tests for coverage
Cliff Moon authored
141 cover:compile_directory(\\"elibs\\", [{i,\\"include\\"},{i, \\"deps/eunit/include\\"},{d,'TEST'},{warn_format, 0}]), \
ff36d92 code coverage analysis
Cliff Moon authored
142 T = fun(X) -> io:format(user, \\"~-20.s\\", [X]), X:test() end, \
143 [T(X) || X <- [#{mod_directives}]], \
144 F = fun(X) -> cover:analyse_to_file(X, \\"doc/\\" ++ atom_to_list(X) ++ \\"_coverage.html\\", [html]) end, \
145 [F(X) || X <- [#{mod_directives}]]. \
146 " -s init stop;}
320cfb3 fixed mediator tests for coverage
Cliff Moon authored
147 puts cmd
ff36d92 code coverage analysis
Cliff Moon authored
148 sh cmd
149 puts "-> Test logs in #{priv}"
150 end
151
b33369e @KirinDave Bootstrapping the project to a more helpful inf.
KirinDave authored
152 task :docs do
153 #files = (Dir["elibs/*.erl"] - ["elibs/json.erl"]).sort.map { |x| "\'../" + x + "\'"}.join(" ")
154 #sh %|cd doc && erl -noshell -run edoc_run files #{files}|
155 files = Dir["elibs/*.erl"].map { |x| "'../" + x + "'"}.join " "
156 sh %|cd doc && erl -noshell -s init stop -run edoc files #{files}|
157 end
1199672 eunit submod integration
Cliff Moon authored
158
4b82ba2 adding c extensions to deal with ulimit
Cliff Moon authored
159 task :c_env do
160 ERL = `which erl`
161 ERLDIR = `awk -F= '/ROOTDIR=/ { print $2; exit; }' #{ERL}`.chomp
162 ERTSBASE = `erl -noshell -noinput -eval 'io:format (\"~s\", [[ \"/\" ++ filename:join (lists:reverse ([ \"erts-\" ++ erlang:system_info (version) | tl (lists:reverse (string:tokens (code:lib_dir (), \"/\"))) ])) ]]).' -s erlang halt `.chomp
163 ERL_INTERFACE = `ls #{ERLDIR}/lib`.split("\n").grep(/erl_interface/).last
fecb101 added native murmur and fnv hashing.
Cliff Moon authored
164 CPPFLAGS = "-I #{ERTSBASE}/include -I #{ERLDIR}/lib/#{ERL_INTERFACE}/include -Wall -g -O2 -fPIC -I./"
4b82ba2 adding c extensions to deal with ulimit
Cliff Moon authored
165 LIBEI = "#{ERLDIR}/lib/#{ERL_INTERFACE}/lib/libei.a"
166 if `uname` =~ /Linux/
167 LDFLAGS = " -shared"
168 else
169 LDFLAGS = " -dynamic -bundle -undefined suppress -flat_namespace"
170 end
171 end
172
1199672 eunit submod integration
Cliff Moon authored
173 task :build_deps do
174 Dir["deps/*"].each do |dir|
175 sh "cd #{dir} && make"
176 end
2845342 @toddlipcon Add thrift and a thrift service
toddlipcon authored
177 end
ae6010e Added test lib module, fixed storage server test to use priv dir instead...
Jason Pellerin authored
178
179 task :build_test_deps do
3ff13ce partitions will now consistently hash to a node.
Cliff Moon authored
180 sh "erlc +debug_info -I include #{ERLC_TEST_FLAGS} -o etest etest/t.erl etest/mock_genserver.erl etest/mock.erl"
ceae03c Rakefile now sets priv dir, and generates test.config that puts kernel a...
Jason Pellerin authored
181 end
182
33e2c2c moved the task
Christopher Brown authored
183 task :build_tarball => [:default, 'build'] do
6255f68 removed bash-isms from tarball task
Christopher Brown authored
184 sh "wd=$(pwd) && cd ./.. && tar czvf dynomite/build/dynomite.tar.tgz --exclude dynomite/build ./dynomite && (cd \"$wd\")"
33e2c2c moved the task
Christopher Brown authored
185 end
186
ceae03c Rakefile now sets priv dir, and generates test.config that puts kernel a...
Jason Pellerin authored
187 task :test_config do
188 # ensure the test log dir exists
189 priv = priv_dir()
190 FileUtils.mkpath(priv)
191
192 # write config file to configure sasl, etc to
193 cfg = File.new("test.config", "w+")
194 # write their error logs to the log files in log dir
195 cfg.write(<<EOC)
196 [{kernel,
197 [{error_logger, {file, "#{priv}/kernel.log"}}
198 ]},
199 {sasl,
200 [{sasl_error_logger, {file, "#{priv}/sasl.log"}}
201 ]}
202 ].
203 EOC
204 cfg.close()
205 end
206
207 def priv_dir
208 base = File.dirname(__FILE__)
209 priv = File.join(base, "etest", "log", "#{$$}")
210 return priv
ae6010e Added test lib module, fixed storage server test to use priv dir instead...
Jason Pellerin authored
211 end
4b82ba2 adding c extensions to deal with ulimit
Cliff Moon authored
212
a16e540 lib -> priv
Cliff Moon authored
213 DRIVERS = FileList['c/*_drv.c'].pathmap("%{c,priv}X.so")
b219311 refactored the build a bit and turned off native for mochiweb modules
Cliff Moon authored
214 BEAMS = FileList['elibs/*.erl'].pathmap("%{elibs,ebin}X.beam")
215 TEST_BEAMS = FileList['etest/*.erl'].select {|d| d !~ /^.*_test.erl$/}.pathmap("%{etest,ebin}X.beam")
cb51eb8 refactor left thrift beams out in the cold
Cliff Moon authored
216 THRIFT_BEAMS = FileList['gen-erl/*.erl'].pathmap("%{gen-erl,ebin}X.beam")
4b82ba2 adding c extensions to deal with ulimit
Cliff Moon authored
217
1aefb97 added build_tarball task
Christopher Brown authored
218 directory "build"
a16e540 lib -> priv
Cliff Moon authored
219 directory "priv"
4b82ba2 adding c extensions to deal with ulimit
Cliff Moon authored
220
a16e540 lib -> priv
Cliff Moon authored
221 # task "priv/murmur_drv.c" => ["c/murmur.o"]
fecb101 added native murmur and fnv hashing.
Cliff Moon authored
222
6a6c069 bloom filter
Cliff Moon authored
223 rule ".so" => ['%{priv,c}X.o', 'c/murmur.o', 'c/fnv.o', 'c/bloom.o'] do |t|
fecb101 added native murmur and fnv hashing.
Cliff Moon authored
224 puts "cc #{CPPFLAGS} #{LDFLAGS} -o #{t.name} #{t.prerequisites.join(' ')} #{LIBEI}"
225 sh "cc #{CPPFLAGS} #{LDFLAGS} -o #{t.name} #{t.prerequisites.join(' ')} #{LIBEI}"
4b82ba2 adding c extensions to deal with ulimit
Cliff Moon authored
226 end
227
228 rule ".o" => ".c" do |t|
5fd7f15 ulimit driver that can dynamically fiddle with the fd soft limits
Cliff Moon authored
229 puts "cc #{CPPFLAGS} -c -o #{t.name} #{t.source}"
230 sh "cc #{CPPFLAGS} -c -o #{t.name} #{t.source}"
4b82ba2 adding c extensions to deal with ulimit
Cliff Moon authored
231 end
232
bc71fd9 refactor so a clean build can go through
Cliff Moon authored
233 def compile(t)
b219311 refactored the build a bit and turned off native for mochiweb modules
Cliff Moon authored
234 cmd = "erlc #{ERLC_FLAGS} #{ENV['TEST'] ? ERLC_TEST_FLAGS : ''} #{t.source}"
235 # rude hack
236 cmd.gsub!("+native", "") if ["elibs/dynomite_web.erl", "elibs/dynomite_pb.erl"].include?(t.source)
237 puts cmd
238 sh cmd
239 end
240
bc71fd9 refactor so a clean build can go through
Cliff Moon authored
241 rule ".beam" => ["%{ebin,elibs}X.erl", "%{ebin,etest}X_test.erl"] do |t|
242 compile(t)
243 end
244
245 rule ".beam" => "%{ebin,elibs}X.erl" do |t|
246 compile(t)
247 end
248
249 rule ".beam" => "%{ebin,etest}X.erl" do |t|
250 compile(t)
251 end
6a6c069 bloom filter
Cliff Moon authored
252
cb51eb8 refactor left thrift beams out in the cold
Cliff Moon authored
253 rule ".beam" => "%{ebin,gen-erl}X.erl" do |t|
254 compile(t)
255 end
256
a16e540 lib -> priv
Cliff Moon authored
257 task :build_c_drivers => [:c_env, "priv"] + DRIVERS
cb51eb8 refactor left thrift beams out in the cold
Cliff Moon authored
258 task :build_erl => BEAMS + TEST_BEAMS + THRIFT_BEAMS
Something went wrong with that request. Please try again.