Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Numerous always-ignore extensions
###################
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~

*.sass-cache
# Folders to ignore
###################
.hg
.svn
.CVS
# OS or Editor folders
###################
.DS_Store
Icon?
Thumbs.db
ehthumbs.db
nbproject
.cache
.project
.settings
.tmproj
*.esproj
*.sublime-project
*.sublime-workspace
# Dreamweaver added files
###################
_notes
dwsync.xml
# Komodo
###################
*.komodoproject
.komodotools
10 changes: 5 additions & 5 deletions README
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Sample erlang application to demonstrate the use of rake tasks dedicated to erlang.

= Installation =
= Installation =

Put in your project the directory 'rakelib' it contains all '.rake'
files and some escript needed by tasks.

= Usage =
= Usage =
rake --tasks : to know all tasks

You'll need a configuration in which you'll have to put things specific to your installation.
Expand All @@ -14,7 +14,7 @@ A template of file is generated the first time you launch 'rake'
Here is some useful tasks:
rake erlang:modules: Compile all erlang source files (test included)
rake erlang:releases: Build a tarball for each rel file found in the directory tree
rake erlang:tests[name]: Run the eunit test for the application "name". If no name is given,
rake erlang:tests[name]: Run the eunit test for the application "name". If no name is given,
all applications are tested. If a file test.desc is find in the "app_name/test" directory, eunit will
use it as eunit test description.
rake erlang:edoc[name]: Build the document for an application or all if 'name' is omitted
Expand All @@ -25,12 +25,12 @@ rake otp:initial_targer[name,version]: Create a tarball with a 'ready' to deploy
an erlang system running the release. To use the system, you have to provide
2 startup files in a directory named 'release_config'. Look at the sample in the
application sample_rake.
= Author =
= Author =
Nicolas Charpentier <open_source@charpi.net>

= Quick Start =

Create the a default erlang_config.rb file
Create the a default erlang_config.rb file
% rake

Edit the erlang_config.rb and add the path to your erlang installation
Expand Down
16 changes: 8 additions & 8 deletions lib/sample_rake/mibs/EX1-MIB.mib
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
EX1-MIB DEFINITIONS ::= BEGIN

IMPORTS
experimental FROM RFC1155-SMI
RowStatus FROM STANDARD-MIB
DisplayString FROM RFC1213-MIB
OBJECT-TYPE FROM RFC-1212
;

example1 OBJECT IDENTIFIER ::= { experimental 7 }


myName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
Expand All @@ -17,15 +17,15 @@
DESCRIPTION
"My own name"
::= { example1 1 }

friendsTable OBJECT-TYPE
SYNTAX SEQUENCE OF FriendsEntry
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"A list of friends."
::= { example1 4 }

friendsEntry OBJECT-TYPE
SYNTAX FriendsEntry
ACCESS not-accessible
Expand All @@ -34,7 +34,7 @@
""
INDEX { fIndex }
::= { friendsTable 1 }

FriendsEntry ::=
SEQUENCE {
fIndex
Expand All @@ -45,15 +45,15 @@
DisplayString,
fStatus
RowStatus }

fIndex OBJECT-TYPE
SYNTAX INTEGER
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"number of friend"
::= { friendsEntry 1 }

fName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
Expand Down
2 changes: 1 addition & 1 deletion lib/sample_rake/src/sample.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-export([atoms/0]).
-export([breaks_xref/0]).

atoms() ->
atoms() ->
lists:foldl(fun(X,Acc) -> [X|Acc] end,
[],
[foobar, bar, baz]).
Expand Down
2 changes: 1 addition & 1 deletion lib/sample_rake/src/sample_rake.rel.src
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%% -*-erlang-*- ;
%% -*-erlang-*- ;
{release,
{"sample_rake", ""},
{erts, "_"},
Expand Down
2 changes: 1 addition & 1 deletion lib/sample_rake/src/sample_rake_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

start(_Type, _StartArgs) ->
case sample_rake_sup:start_link() of
{ok, Pid} ->
{ok, Pid} ->
{ok, Pid};
Error ->
Error
Expand Down
52 changes: 26 additions & 26 deletions rakelib/erlang.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Distributed under BSD licence


if File.file?('erlang_config.rb')
require 'erlang_config'
if File.file?('erlang_config.rb')
require 'erlang_config'
else
puts "erlang_config.rb file is missing."
puts "You need to fill it with your local configuration."
Expand All @@ -25,7 +25,7 @@ require 'rake/loaders/makefile'
import '.depend_erlang.mf'

namespace :erlang do

def handle_test(mode, args)
directories = ERL_DIRECTORIES + ERL_DIRECTORIES.pathmap("%{ebin,test}X")
if args.name
Expand All @@ -46,7 +46,7 @@ namespace :erlang do
end
end
end

def collect_boot_files(releases)
releases.collect { |elt|
if elt =~ /^release/
Expand All @@ -60,40 +60,40 @@ namespace :erlang do
end
}
end

def collect_release_files(rel_sources)
rel_sources.inject({}) do |acc,d|
config_file = d.pathmap("%d/../vsn.config")
vsn = extract_version_information(config_file,"release_name").gsub(/\"/,"")
directory "release_local"
map_expression = "%{src,ebin}X-" + vsn + ".rel"
rel_file = d.ext("").pathmap(map_expression)
rel_file = d.ext("").pathmap(map_expression)
acc[rel_file] = d
acc[rel_file.pathmap("release_local/%f")] = d
acc
end
end

def collect_generated_archives(releases)
tmp = releases.delete_if { |elt| elt =~ /^release_local/ }
tmp = tmp.pathmap("releases/%f").ext(".tar.gz")
tmp
end

def extract_version_information(file, type)
informations = []
IO.foreach(file) { |line|
informations << $1 if line =~ /\{#{type},(.*)\}/
}
informations[0]
end

def application_modules(app_file)
modules = FileList.new(app_file.pathmap("%d/*.beam")).pathmap("%f").ext("")
modules = modules.map {|item| item.gsub(/^([A-Z].*)/, '\'\1\'')}
modules = modules.join(', ')
end

def check_dependencies (file)
dependencies = []
IO.foreach(file) { |line|
Expand All @@ -107,14 +107,14 @@ namespace :erlang do
end
end
end
if header
if header
dependencies << "#{header}"
dependencies << check_dependencies(header)
end
} if File.file?(file)
dependencies.flatten
end

def erlang_include_dependencies
erlang_source_dependencies + erlang_test_dependencies
end
Expand Down Expand Up @@ -143,7 +143,7 @@ namespace :erlang do
end
run_script("make_script",[style, source, output] + ERL_DIRECTORIES)
end

ERL_SOURCES = FileList['lib/*/src/*.erl']
ERL_BEAM = ERL_SOURCES.pathmap("%{src,ebin}X.beam")

Expand Down Expand Up @@ -174,59 +174,59 @@ namespace :erlang do
directory "applications"
CLEAN.include "release_local"

ERL_DIRECTORIES.each do |d|
ERL_DIRECTORIES.each do |d|
directory d
CLEAN.include d
end

CLEAN.include("lib/*/test/*.beam")
CLEAN.include("lib/*/cover")

def beam_dependencies_with_emake(beam, file)
def beam_dependencies_with_emake(beam, file)
dependencies = check_dependencies(file).uniq
dependencies.collect { |dependency|
["#{beam}: #{dependency}", "Emakefile: #{dependency}"]
} + ["#{beam} : #{file}", "#{beam}: Emakefile"]
end

def beam_dependencies(beam, file)
def beam_dependencies(beam, file)
dependencies = check_dependencies(file).uniq
dependencies.collect { |dependency|
["#{beam}: #{dependency}"]
} + ["#{beam} : #{file}"]
end

if USE_EMAKE
if USE_EMAKE
def erlang_test_dependencies
FileList['lib/*/test/*.erl'].collect { |file|
beam = file.pathmap("%X.beam")
beam_dependencies_with_emake(beam, file)
beam_dependencies_with_emake(beam, file)
}.flatten
end

def erlang_source_dependencies
FileList['lib/*/src/*.erl'].collect { |file|
beam = file.pathmap("%{src,ebin}X.beam")
beam_dependencies_with_emake(beam, file)
}.flatten
end

file "Emakefile" => ERL_SOURCES + ERL_TESTS do |t|
source_directories = t.prerequisites.collect { |elt| elt.pathmap("%d")}
File.open("Emakefile",'w') do |file|

source_directories.uniq.each do |elt|
target_directory = elt.pathmap("%{src,ebin}X")
options = ["{outdir,\"#{target_directory}\"}",
"{i, \"lib\"}",
"{i,\"lib/*/include\"}"] + EMAKE_COMPILE_OPTIONS
option_string = "[#{options.join(',')}]"
option_string = "[#{options.join(',')}]"
file.write("{\"#{elt}/*\",#{option_string}}.\n")
end
end
end
CLEAN.include "Emakefile"

desc "Compile Erlang sources"
task :modules => ERL_DIRECTORIES + ERL_BEAM + ERL_BEAM_TESTS do
sh "#{ERL_TOP}/bin/erl -noinput -s make all -s erlang halt "
Expand All @@ -239,14 +239,14 @@ namespace :erlang do
beam_dependencies(beam, file)
}.flatten
end

def erlang_source_dependencies
FileList['lib/*/src/*.erl'].collect { |file|
beam = file.pathmap("%{src,ebin}X.beam")
beam_dependencies(beam, file)
}.flatten
end

rule ".beam" => ["%{ebin,src}X.erl"] do |t|
output = t.name.pathmap("%d")
sh "#{ERL_TOP}/bin/erlc -Ilib #{ERLC_FLAGS} -o #{output} #{t.source}"
Expand All @@ -273,7 +273,7 @@ namespace :erlang do
def release_to_src(a)
if a =~ /^release/
[ERL_RELEASE_FILES_DEP[a], a.pathmap("%d") ]
else
else
[ERL_RELEASE_FILES_DEP[a], a.pathmap("%d") ]
end

Expand Down
2 changes: 1 addition & 1 deletion rakelib/escripts/make_doc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ main([Application| Paths]) ->
end;
main(_) ->
usage().

usage() ->
io:format("usage: make_doc <application_name> <application_path>\n"),
halt(1).
Expand Down
2 changes: 1 addition & 1 deletion rakelib/escripts/make_release
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ main([Script, Output | Paths]) ->
end;
main(_) ->
usage().

usage() ->
io:format("usage: make_release <release_name> [<additional_code_path>]\n"),
halt(1).
Loading