This repository has been archived by the owner on Feb 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
106 lines (68 loc) · 1.96 KB
/
Rakefile
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
# Helper function used to figure out location of erlang headers.
def erlang_headers
loc = %x{which erl}
if loc.empty?
puts "Error locating erlang erl binary, make sure it's in the path."
exit
end
idx = loc.index('/bin')
if not idx
puts "Invalid erlang path, make sure installation is correct."
exit
end
"#{loc[0, idx]}/lib/erlang/usr/include"
end
task :default => [:help]
# List help.
desc "Help"
task :help do
puts %x{rake --tasks}
end
# This will pull all the dependencies required by project.
desc "Download project dependencies"
task :deps do
sh 'rebar get-deps'
end
# This will clean all binary files.
desc "Clean wflz-nif"
task :clean do
sh 'rebar clean'
sh 'rm -rf priv'
end
# This will compile erlang related code.
desc "Compile wflz-nif"
task :compile do
sh 'rebar compile'
end
# This will compile the linux 32 bit project.
desc "Compile Linux 32 bit"
task :linux32 do
if not Dir.exists? "priv"
sh 'mkdir priv'
end
sh "gcc -o priv/wflz.so -fpic -shared src.c/wlfz_nif.c deps/wflz/wfLZ.c -I#{erlang_headers} -m32"
end
# This will compile the linux 32 bit project.
desc "Compile Linux 64 bit"
task :linux64 do
if not Dir.exists? "priv"
sh 'mkdir priv'
end
sh "gcc -o priv/wflz.so -fpic -shared src.c/wlfz_nif.c deps/wflz/wfLZ.c -I#{erlang_headers} -m64"
end
# This will compile the OS X 32 bit project.
desc "Compile OS X Darwin 32 bit"
task :darwin32 do
if not Dir.exists? "priv"
sh 'mkdir priv'
end
sh "gcc -undefined dynamic_lookup -dynamiclib -o priv/wflz.so src.c/wlfz_nif.c deps/wflz/wfLZ.c -I#{erlang_headers} -m32"
end
# This will compile the OS X 64 bit project.
desc "Compile OS X Darwin 64 bit"
task :darwin64 do
if not Dir.exists? "priv"
sh 'mkdir priv'
end
sh "gcc -undefined dynamic_lookup -dynamiclib -o priv/wflz.so src.c/wlfz_nif.c deps/wflz/wfLZ.c -I#{erlang_headers} -m64"
end