erlbox 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/LICENSE +19 -0
- data/README.txt +1 -0
- data/Rakefile +48 -0
- data/VERSION.yml +4 -0
- data/bin/erlbox +202 -0
- data/erlbox.gemspec +61 -0
- data/lib/erlbox/build.rb +99 -0
- data/lib/erlbox/dialyzer.rb +81 -0
- data/lib/erlbox/driver.rb +98 -0
- data/lib/erlbox/edoc.rb +43 -0
- data/lib/erlbox/eunit +152 -0
- data/lib/erlbox/eunit.rb +96 -0
- data/lib/erlbox/faxien.rb +65 -0
- data/lib/erlbox/install.rb +38 -0
- data/lib/erlbox/recurse.rb +44 -0
- data/lib/erlbox/release.rb +72 -0
- data/lib/erlbox/snmp.rb +55 -0
- data/lib/erlbox/test.rb +165 -0
- data/lib/erlbox/utils.rb +105 -0
- data/lib/erlbox.rb +43 -0
- metadata +85 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2008 The Hive http://www.thehive.com/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
See http://wiki.github.com/toland/erlbox for documentation.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
## -------------------------------------------------------------------
|
2
|
+
##
|
3
|
+
## Erlang Toolbox: Project rakefile
|
4
|
+
## Copyright (c) 2008 The Hive. All rights reserved.
|
5
|
+
##
|
6
|
+
## -------------------------------------------------------------------
|
7
|
+
|
8
|
+
require 'yaml'
|
9
|
+
require 'rake'
|
10
|
+
require 'rake/clean'
|
11
|
+
|
12
|
+
CLEAN.include 'pkg'
|
13
|
+
|
14
|
+
begin
|
15
|
+
require 'jeweler'
|
16
|
+
|
17
|
+
module Git
|
18
|
+
class Lib
|
19
|
+
def tag(tag)
|
20
|
+
# Force an annotated tag
|
21
|
+
command('tag', [tag, '-a', '-m', tag])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Jeweler::Tasks.new do |s|
|
27
|
+
s.name = 'erlbox'
|
28
|
+
s.platform = Gem::Platform::RUBY
|
29
|
+
s.author = 'Phillip Toland'
|
30
|
+
s.email = 'phil.toland@gmail.com'
|
31
|
+
s.homepage = 'http://github.com/toland/erlbox'
|
32
|
+
s.summary = 'Erlang Toolbox'
|
33
|
+
s.description = 'Rake tasks and helper scripts for building Erlang applications.'
|
34
|
+
s.require_path = 'lib'
|
35
|
+
s.has_rdoc = false
|
36
|
+
|
37
|
+
s.rubyforge_project = 'erlbox'
|
38
|
+
|
39
|
+
s.files.include 'lib/erlbox/eunit'
|
40
|
+
|
41
|
+
# Dependencies
|
42
|
+
s.add_dependency 'rake', '>= 0.8.4'
|
43
|
+
end
|
44
|
+
rescue LoadError
|
45
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
46
|
+
end
|
47
|
+
|
48
|
+
task :default => :build
|
data/VERSION.yml
ADDED
data/bin/erlbox
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
# -*- ruby -*-
|
3
|
+
# Copyright (c) 2009 The Hive http://www.thehive.com/
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
#
|
23
|
+
|
24
|
+
require 'yaml'
|
25
|
+
require 'uri'
|
26
|
+
|
27
|
+
def erl_root(location = nil)
|
28
|
+
cmd = "erl -noshell -eval 'io:format(\"~s\\n\", [code:root_dir()]).' -s erlang halt"
|
29
|
+
if location
|
30
|
+
cmd = File.join(location, "bin", cmd)
|
31
|
+
end
|
32
|
+
`#{cmd}`
|
33
|
+
end
|
34
|
+
|
35
|
+
def load_yaml(file)
|
36
|
+
filename = File.expand_path(file)
|
37
|
+
return nil if not File.exist?(filename)
|
38
|
+
YAML::load(File.read(filename))
|
39
|
+
end
|
40
|
+
|
41
|
+
def load_config()
|
42
|
+
# Check for existence of the config file -- we MUST have one
|
43
|
+
config = load_yaml("~/.erlbox.yaml")
|
44
|
+
|
45
|
+
# Load the file and make sure required parameters are present
|
46
|
+
if config.nil? || config.empty?
|
47
|
+
puts "~/.erlbox.yaml does not exist or is empty; basic config required!"
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
|
51
|
+
# Fix up default repo URL
|
52
|
+
if config.has_key?('default_repo')
|
53
|
+
url = URI(config['default_repo'])
|
54
|
+
if url.scheme == nil or url.scheme == "file":
|
55
|
+
config['defaut_repo'] = File.expand_path(url.path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# If erlang repo is specified, expand the path and use that to determine the root
|
60
|
+
if config.has_key?('erlang')
|
61
|
+
config['erlang_root'] = erl_root(File.expand_path(config['erlang'])).strip()
|
62
|
+
else
|
63
|
+
config['erlang_root'] = erl_root().strip()
|
64
|
+
end
|
65
|
+
|
66
|
+
if !config.has_key?('site_dir')
|
67
|
+
config['site_dir'] = File.join(config['erlang_root'], "lib")
|
68
|
+
end
|
69
|
+
|
70
|
+
config
|
71
|
+
end
|
72
|
+
|
73
|
+
def download_app(appname, appurl)
|
74
|
+
# Work directory will be /tmp/erlbox.<pid>
|
75
|
+
tmpdir = "/tmp/erlbox_#{appname}.#{Process.pid}"
|
76
|
+
|
77
|
+
# Clone the desired url using GIT
|
78
|
+
# TODO: Support alternative systems
|
79
|
+
cmd = "git clone #{appurl} #{tmpdir}/"
|
80
|
+
puts cmd
|
81
|
+
system cmd
|
82
|
+
if $? != 0
|
83
|
+
exit 1
|
84
|
+
end
|
85
|
+
|
86
|
+
# Handle git submodules
|
87
|
+
if File.exist?("#{tmpdir}/.gitmodules")
|
88
|
+
system "(cd #{tmpdir} && git submodule update --init)"
|
89
|
+
end
|
90
|
+
|
91
|
+
# Return the tmp directory path
|
92
|
+
puts tmpdir
|
93
|
+
tmpdir
|
94
|
+
end
|
95
|
+
|
96
|
+
def cleanup(workdir, is_temp)
|
97
|
+
# clean up
|
98
|
+
puts "Cleaning up..."
|
99
|
+
FileUtils.rm_rf workdir if is_temp
|
100
|
+
end
|
101
|
+
|
102
|
+
def install_deps(workdir, appname = nil, stack = [])
|
103
|
+
# Process any dependencies in workdir/erlbox.yaml
|
104
|
+
app_config = load_yaml("#{workdir}/erlbox.yaml")
|
105
|
+
unless app_config.nil? || app_config.empty?
|
106
|
+
deps = app_config['dependencies'] || []
|
107
|
+
deps.each do |dep|
|
108
|
+
install_app(dep, stack << appname)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def install_app(appname, stack = [])
|
114
|
+
# Check for a dependency cycle
|
115
|
+
if stack.include?(appname)
|
116
|
+
puts "#{appname} already scheduled for installation"
|
117
|
+
return
|
118
|
+
end
|
119
|
+
|
120
|
+
# Default workdir is current working directory -- examination of appname may
|
121
|
+
# override this.
|
122
|
+
workdir = ""
|
123
|
+
is_temp = false
|
124
|
+
|
125
|
+
if appname.nil? || appname.empty?
|
126
|
+
# Appname was not specified -- we'll try to use the current directory
|
127
|
+
workdir = Dir.getwd
|
128
|
+
else
|
129
|
+
# Parse appname as URI
|
130
|
+
appname_uri = URI.parse(appname)
|
131
|
+
if appname_uri.scheme == nil or appname_uri.scheme == "file"
|
132
|
+
# Expand the file path -- however, it may not match anything local; in that
|
133
|
+
# case, prepend the default URL for git repos and try to get it from there.
|
134
|
+
appname_path = File.expand_path(appname_uri.path)
|
135
|
+
if File.directory?(appname_path)
|
136
|
+
workdir = appname_path
|
137
|
+
else
|
138
|
+
workdir = download_app(appname, File.join(CONFIG['default_repo'], appname))
|
139
|
+
is_temp = true
|
140
|
+
end
|
141
|
+
else
|
142
|
+
# Appname is a proper URL -- we'll pass this to git
|
143
|
+
workdir = download_app(appname, appname)
|
144
|
+
is_temp = true
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Now check the work directory for a Rakefile
|
149
|
+
if !File.exist?(File.join(workdir, "Rakefile"))
|
150
|
+
puts "No Rakefile available for #{appname} in #{workdir}; can't install this app!"
|
151
|
+
exit 1
|
152
|
+
end
|
153
|
+
|
154
|
+
appid = `(cd #{workdir} && rake --silent install:appid[#{CONFIG['erlang_root']}])`.strip
|
155
|
+
install_dir = File.join(CONFIG['site_dir'], appid)
|
156
|
+
|
157
|
+
# Check that the target directory doesn't already exist -- bail if it does
|
158
|
+
if File.directory?(install_dir)
|
159
|
+
puts "#{appid} is already installed...skipping"
|
160
|
+
cleanup(workdir, is_temp)
|
161
|
+
return
|
162
|
+
end
|
163
|
+
|
164
|
+
install_deps(workdir, appname, stack)
|
165
|
+
|
166
|
+
# Tell the app to build itself and install in the provided site directory
|
167
|
+
# TODO: Handle downloads of pre-built stuff
|
168
|
+
|
169
|
+
# Run the prepare task in a separate rake process so that computed
|
170
|
+
# dependencies will work out right
|
171
|
+
system "(cd #{workdir} && rake --silent install:prepare)"
|
172
|
+
system "(cd #{workdir} && rake --silent install:build)"
|
173
|
+
|
174
|
+
if $? == 0
|
175
|
+
puts "Installing to #{install_dir}..."
|
176
|
+
FileUtils.mkdir install_dir
|
177
|
+
FileUtils.cp_r "#{workdir}/ebin", install_dir
|
178
|
+
FileUtils.cp_r "#{workdir}/src", install_dir
|
179
|
+
FileUtils.cp_r "#{workdir}/include", install_dir if File.exist?("#{workdir}/include")
|
180
|
+
FileUtils.cp_r "#{workdir}/priv", install_dir if File.exist?("#{workdir}/priv")
|
181
|
+
FileUtils.cp_r "#{workdir}/mibs", install_dir if File.exist?("#{workdir}/mibs")
|
182
|
+
|
183
|
+
puts "Install successful..."
|
184
|
+
cleanup(workdir, is_temp)
|
185
|
+
else
|
186
|
+
puts "Rake failed! Build files are in '#{workdir}'."
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
CONFIG = load_config()
|
191
|
+
|
192
|
+
action = ARGV[0]
|
193
|
+
case action
|
194
|
+
when 'install'
|
195
|
+
install_app(ARGV[1])
|
196
|
+
when 'cleanup'
|
197
|
+
FileUtils.rm_rf Dir.glob("/tmp/erlbox_*")
|
198
|
+
when 'ensure'
|
199
|
+
install_deps(Dir.getwd())
|
200
|
+
else
|
201
|
+
puts "Usage: erlbox install ..."
|
202
|
+
end
|
data/erlbox.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{erlbox}
|
5
|
+
s.version = "1.5.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Phillip Toland"]
|
9
|
+
s.date = %q{2009-06-22}
|
10
|
+
s.default_executable = %q{erlbox}
|
11
|
+
s.description = %q{Rake tasks and helper scripts for building Erlang applications.}
|
12
|
+
s.email = %q{phil.toland@gmail.com}
|
13
|
+
s.executables = ["erlbox"]
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.txt"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"LICENSE",
|
21
|
+
"README.txt",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION.yml",
|
24
|
+
"bin/erlbox",
|
25
|
+
"erlbox.gemspec",
|
26
|
+
"lib/erlbox.rb",
|
27
|
+
"lib/erlbox/build.rb",
|
28
|
+
"lib/erlbox/dialyzer.rb",
|
29
|
+
"lib/erlbox/driver.rb",
|
30
|
+
"lib/erlbox/edoc.rb",
|
31
|
+
"lib/erlbox/eunit",
|
32
|
+
"lib/erlbox/eunit",
|
33
|
+
"lib/erlbox/eunit.rb",
|
34
|
+
"lib/erlbox/faxien.rb",
|
35
|
+
"lib/erlbox/install.rb",
|
36
|
+
"lib/erlbox/recurse.rb",
|
37
|
+
"lib/erlbox/release.rb",
|
38
|
+
"lib/erlbox/snmp.rb",
|
39
|
+
"lib/erlbox/test.rb",
|
40
|
+
"lib/erlbox/utils.rb"
|
41
|
+
]
|
42
|
+
s.homepage = %q{http://github.com/toland/erlbox}
|
43
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubyforge_project = %q{erlbox}
|
46
|
+
s.rubygems_version = %q{1.3.2}
|
47
|
+
s.summary = %q{Erlang Toolbox}
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<rake>, [">= 0.8.4"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<rake>, [">= 0.8.4"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<rake>, [">= 0.8.4"])
|
60
|
+
end
|
61
|
+
end
|
data/lib/erlbox/build.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
## -------------------------------------------------------------------
|
2
|
+
##
|
3
|
+
## Erlang Toolbox: Included tasks for building Erlang sources
|
4
|
+
## Copyright (c) 2008 The Hive http://www.thehive.com/
|
5
|
+
##
|
6
|
+
## Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
## of this software and associated documentation files (the "Software"), to deal
|
8
|
+
## in the Software without restriction, including without limitation the rights
|
9
|
+
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
## copies of the Software, and to permit persons to whom the Software is
|
11
|
+
## furnished to do so, subject to the following conditions:
|
12
|
+
##
|
13
|
+
## The above copyright notice and this permission notice shall be included in
|
14
|
+
## all copies or substantial portions of the Software.
|
15
|
+
##
|
16
|
+
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
## THE SOFTWARE.
|
23
|
+
##
|
24
|
+
## -------------------------------------------------------------------
|
25
|
+
|
26
|
+
puts "WARNING: Debugging is enabled." if debug?
|
27
|
+
|
28
|
+
## -------------------------------------------------------------------
|
29
|
+
## Constants
|
30
|
+
|
31
|
+
PWD = Dir.getwd
|
32
|
+
|
33
|
+
ERL_SRC = FileList['src/**/*.erl']
|
34
|
+
ERL_BEAM = ERL_SRC.pathmap("%{src,ebin}X.beam")
|
35
|
+
ERL_PATH = FileList.new
|
36
|
+
APP_FILE = FileList["#{PWD}/ebin/*.app"][0]
|
37
|
+
APP_NAME = File.basename(APP_FILE, ".app")
|
38
|
+
|
39
|
+
unless APP_FILE && File.exists?(APP_FILE)
|
40
|
+
fail "ERROR: No app file found."
|
41
|
+
end
|
42
|
+
|
43
|
+
ERL_INCLUDE = "./include"
|
44
|
+
ERLC_FLAGS = %W( -I#{ERL_INCLUDE} -W )
|
45
|
+
ERLC_FLAGS << '+debug_info' if debug?
|
46
|
+
|
47
|
+
CLEAN.include %w( **/*.beam **/erl_crash.dump )
|
48
|
+
|
49
|
+
## -------------------------------------------------------------------
|
50
|
+
## Rules
|
51
|
+
|
52
|
+
directory 'ebin'
|
53
|
+
|
54
|
+
rule(%r(^ebin/.*\.beam$) => ["%{ebin,src}X.erl"]) do |t|
|
55
|
+
puts "compiling #{t.source}..."
|
56
|
+
sh "erlc #{print_flags(ERLC_FLAGS)} #{expand_path(ERL_PATH)} -o ebin #{t.source}"
|
57
|
+
end
|
58
|
+
|
59
|
+
## -------------------------------------------------------------------
|
60
|
+
## Tasks
|
61
|
+
|
62
|
+
namespace :build do
|
63
|
+
|
64
|
+
desc "Verify that all application modules are listed in the app file"
|
65
|
+
task :validate_app do
|
66
|
+
# Setup app name and build sets of modules from the .app as well as
|
67
|
+
# beams that got compiled
|
68
|
+
modules = Set.new(erl_app_modules(APP_NAME))
|
69
|
+
beams = Set.new(ERL_BEAM.pathmap("%n").to_a)
|
70
|
+
|
71
|
+
puts "validating #{APP_NAME}.app..."
|
72
|
+
|
73
|
+
# Identify .beam files which are listed in the .app, but not present in ebin/
|
74
|
+
missing_beams = (modules - beams)
|
75
|
+
if not missing_beams.empty?
|
76
|
+
msg = "One or more modules listed in #{APP_NAME}.app do not exist as .beam:\n"
|
77
|
+
missing_beams.each { |m| msg << " * #{m}\n" }
|
78
|
+
fail msg
|
79
|
+
end
|
80
|
+
|
81
|
+
# Identify modules which are not listed in the .app, but are present in ebin/
|
82
|
+
missing_modules = (beams - modules)
|
83
|
+
if not missing_modules.empty?
|
84
|
+
msg = "One or more .beam files exist that are not listed in #{APP_NAME}.app:\n"
|
85
|
+
missing_modules.each { |m| msg << " * #{m}\n" }
|
86
|
+
fail msg
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "Compile Erlang sources to .beam files"
|
91
|
+
task :compile => ['ebin'] + ERL_BEAM + [:validate_app]
|
92
|
+
|
93
|
+
desc "Do a fresh build from scratch"
|
94
|
+
task :rebuild => [:clean, :compile]
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
task :compile => 'build:compile'
|
99
|
+
task :default => [:compile]
|
@@ -0,0 +1,81 @@
|
|
1
|
+
## -------------------------------------------------------------------
|
2
|
+
##
|
3
|
+
## Erlang Toolbox: Included tasks for running Dialyzer
|
4
|
+
## Copyright (c) 2008 The Hive http://www.thehive.com/
|
5
|
+
##
|
6
|
+
## Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
## of this software and associated documentation files (the "Software"), to deal
|
8
|
+
## in the Software without restriction, including without limitation the rights
|
9
|
+
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
## copies of the Software, and to permit persons to whom the Software is
|
11
|
+
## furnished to do so, subject to the following conditions:
|
12
|
+
##
|
13
|
+
## The above copyright notice and this permission notice shall be included in
|
14
|
+
## all copies or substantial portions of the Software.
|
15
|
+
##
|
16
|
+
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
## THE SOFTWARE.
|
23
|
+
##
|
24
|
+
## -------------------------------------------------------------------
|
25
|
+
require 'pathname'
|
26
|
+
|
27
|
+
## -------------------------------------------------------------------
|
28
|
+
## Constants
|
29
|
+
|
30
|
+
PLT_LIBS = %w( kernel stdlib )
|
31
|
+
PLT_FILE = "#{ENV['HOME']}/.dialyzer_plt"
|
32
|
+
|
33
|
+
CLEAN.include 'dialyzer.log'
|
34
|
+
|
35
|
+
## -------------------------------------------------------------------
|
36
|
+
## Rules
|
37
|
+
|
38
|
+
rule PLT_FILE do
|
39
|
+
puts "generating base PLT file..."
|
40
|
+
`dialyzer --build_plt -r #{erl_where('kernel', 'ebin')} --plt #{PLT_FILE}`
|
41
|
+
end
|
42
|
+
|
43
|
+
## -------------------------------------------------------------------
|
44
|
+
## Tasks
|
45
|
+
|
46
|
+
namespace :dialyzer do
|
47
|
+
|
48
|
+
desc "Update your PLT file with the libraries required by this application"
|
49
|
+
task :update_plt => PLT_FILE do
|
50
|
+
PLT_LIBS.each do |lib|
|
51
|
+
puts "adding #{lib} to plt..."
|
52
|
+
`dialyzer --add_to_plt -r #{erl_where(lib, 'ebin')} --plt #{PLT_FILE}`
|
53
|
+
end
|
54
|
+
|
55
|
+
ERL_PATH.each do |app_path|
|
56
|
+
path = abspath(app_path)
|
57
|
+
puts "adding #{path} to plt..."
|
58
|
+
`dialyzer --add_to_plt -r #{path} --plt #{PLT_FILE}`
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
task :prepare do
|
63
|
+
ERLC_FLAGS << '+debug_info'
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Run Dialyzer on the compiled beam files"
|
67
|
+
task :run => [:prepare] + ERL_BEAM do
|
68
|
+
warnings = ENV['WARN']
|
69
|
+
if !warnings.nil? && !warnings.empty?
|
70
|
+
warn_opts = ' -W' + warnings.split(',').join(' -W')
|
71
|
+
else
|
72
|
+
warn_opts = ''
|
73
|
+
end
|
74
|
+
|
75
|
+
sh "dialyzer -Iinclude -r ebin --plt #{PLT_FILE}\
|
76
|
+
-Werror_handling -Wunmatched_returns #{warn_opts} | tee dialyzer.log"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
task :dialyzer => 'dialyzer:run'
|
@@ -0,0 +1,98 @@
|
|
1
|
+
## -------------------------------------------------------------------
|
2
|
+
##
|
3
|
+
## Erlang Toolbox: Optional tasks for building C extensions
|
4
|
+
## Copyright (c) 2008 The Hive http://www.thehive.com/
|
5
|
+
##
|
6
|
+
## Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
## of this software and associated documentation files (the "Software"), to deal
|
8
|
+
## in the Software without restriction, including without limitation the rights
|
9
|
+
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
## copies of the Software, and to permit persons to whom the Software is
|
11
|
+
## furnished to do so, subject to the following conditions:
|
12
|
+
##
|
13
|
+
## The above copyright notice and this permission notice shall be included in
|
14
|
+
## all copies or substantial portions of the Software.
|
15
|
+
##
|
16
|
+
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
## THE SOFTWARE.
|
23
|
+
##
|
24
|
+
## -------------------------------------------------------------------
|
25
|
+
|
26
|
+
if !defined?(APP_NAME)
|
27
|
+
fail "You must require 'erlbox' before requiring this file"
|
28
|
+
end
|
29
|
+
|
30
|
+
## -------------------------------------------------------------------
|
31
|
+
## Helpers
|
32
|
+
|
33
|
+
def dflag()
|
34
|
+
debug? ? "-DDEBUG" : ""
|
35
|
+
end
|
36
|
+
|
37
|
+
def erts_dir()
|
38
|
+
script = <<-ERL
|
39
|
+
io:format("~s\n", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version)])])
|
40
|
+
ERL
|
41
|
+
erl_run(script)
|
42
|
+
end
|
43
|
+
|
44
|
+
def ei_dir()
|
45
|
+
script = <<-ERL
|
46
|
+
io:format("~s\n", [code:lib_dir(erl_interface)])
|
47
|
+
ERL
|
48
|
+
erl_run(script)
|
49
|
+
end
|
50
|
+
|
51
|
+
def erts_link_cflags()
|
52
|
+
if darwin?
|
53
|
+
%w(-bundle -flat_namespace -undefined suppress)
|
54
|
+
else
|
55
|
+
%w(-shared)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
## -------------------------------------------------------------------
|
60
|
+
## Constants
|
61
|
+
|
62
|
+
SRC_DIR = 'c_src'
|
63
|
+
C_SRCS = FileList["#{SRC_DIR}/*.c"]
|
64
|
+
C_OBJS = C_SRCS.pathmap("%X.o")
|
65
|
+
|
66
|
+
DRV_DIR = 'priv'
|
67
|
+
DRIVER = "#{DRV_DIR}/#{APP_NAME}_drv.so"
|
68
|
+
|
69
|
+
CC_FLAGS = %W(-g -c -Wall -fPIC -fno-common #{dflag()} -I#{SRC_DIR} -I#{erts_dir()}/include -I#{ei_dir()}/include)
|
70
|
+
LD_FLAGS = erts_link_cflags()
|
71
|
+
EI_LIBS = %W(-L#{ei_dir()}/lib -lerl_interface -lei)
|
72
|
+
LD_LIBS = EI_LIBS
|
73
|
+
|
74
|
+
CLEAN.include %W( #{SRC_DIR}/*.o #{DRV_DIR}/*.so )
|
75
|
+
|
76
|
+
## -------------------------------------------------------------------
|
77
|
+
## Rules
|
78
|
+
|
79
|
+
directory SRC_DIR
|
80
|
+
directory DRV_DIR
|
81
|
+
|
82
|
+
rule '.o' => ['.c'] do |t|
|
83
|
+
puts "compiling #{t.source}..."
|
84
|
+
sh "gcc #{print_flags(CC_FLAGS)} #{t.source} -o #{t.name}", :verbose => verbose?
|
85
|
+
end
|
86
|
+
|
87
|
+
file DRIVER => [SRC_DIR, DRV_DIR] + C_OBJS do
|
88
|
+
puts "linking #{DRIVER}..."
|
89
|
+
sh "gcc -g #{print_flags(LD_FLAGS)} #{C_OBJS.join(' ')} #{print_flags(LD_LIBS)} -o #{DRIVER}", :verbose => verbose?
|
90
|
+
end
|
91
|
+
|
92
|
+
## -------------------------------------------------------------------
|
93
|
+
## Tasks
|
94
|
+
|
95
|
+
desc "Compile and link the C port driver"
|
96
|
+
task :driver => DRIVER
|
97
|
+
|
98
|
+
task :compile => :driver
|
data/lib/erlbox/edoc.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
## -------------------------------------------------------------------
|
2
|
+
##
|
3
|
+
## Erlang Toolbox: Included tasks for building edoc documentation
|
4
|
+
## Copyright (c) 2008 The Hive http://www.thehive.com/
|
5
|
+
##
|
6
|
+
## Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
## of this software and associated documentation files (the "Software"), to deal
|
8
|
+
## in the Software without restriction, including without limitation the rights
|
9
|
+
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
## copies of the Software, and to permit persons to whom the Software is
|
11
|
+
## furnished to do so, subject to the following conditions:
|
12
|
+
##
|
13
|
+
## The above copyright notice and this permission notice shall be included in
|
14
|
+
## all copies or substantial portions of the Software.
|
15
|
+
##
|
16
|
+
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
## THE SOFTWARE.
|
23
|
+
##
|
24
|
+
## -------------------------------------------------------------------
|
25
|
+
|
26
|
+
## -------------------------------------------------------------------
|
27
|
+
## Constants
|
28
|
+
|
29
|
+
CLOBBER.include 'doc'
|
30
|
+
|
31
|
+
## -------------------------------------------------------------------
|
32
|
+
## Tasks
|
33
|
+
|
34
|
+
namespace :edoc do
|
35
|
+
|
36
|
+
desc "Generate Edoc documentation"
|
37
|
+
task :run do
|
38
|
+
sh %Q(erl -noshell -run edoc_run application #{APP_NAME} '"."' "[]" -s init stop)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
task :edoc => 'edoc:run'
|