Permalink
Browse files

Use a REIA_HOME environment variable to allow Reia to function outsid…

…e of the Erlang lib dir (i.e. when you clone a development copy)
  • Loading branch information...
1 parent 2f85224 commit 91c4281cf4f010c5e40f5631d599935a58bfd016 Tony Arcieri committed Jul 9, 2010
Showing with 19 additions and 21 deletions.
  1. +7 −11 Rakefile
  2. +1 −0 bin/ire
  3. +1 −0 bin/reia
  4. +10 −10 src/core/reia_internal.erl
View
18 Rakefile
@@ -3,7 +3,7 @@ require 'rake/clean'
# Path on the local filesystem to install reia/ire scripts to
BIN_INSTALL_DIR = "/usr/local/bin"
-task :default => %w(check_erl_version check_previous_install build test)
+task :default => %w(check_erl_version build test)
# Returns the installed Erlang version
def erlang_version
@@ -38,16 +38,6 @@ task :check_erl_version do
end
end
-# Ensure Reia was not previously installed
-task :check_previous_install do
- if File.exists?(reia_install_dir)
- puts "*** WARNING: Previous installation of Reia detected"
- puts "*** This will clash with the development copy. Please run"
- puts "*** 'rake uninstall' before proceeding."
- exit 1
- end
-end
-
# Generate an output path for the given input file
def output_file(input_file, dir = 'ebin/', ext = '.beam')
dir + File.basename(input_file).sub(/\.\w+$/, ext)
@@ -125,12 +115,18 @@ end
def munge_script(src, dest)
str = File.read(src)
+ # Remove REIA_HOME declaration
+ str.gsub!(/^export REIA_HOME=.*$/, '')
+
# Remove EXTRA_PATHS declaration
str.gsub!(/^EXTRA_PATHS=.*$/, '')
# Remove $EXTRA_PATHS variables
str.gsub!(/\$EXTRA_PATHS/, '')
+ # Strip all the extraneous newlines
+ str.gsub!(/\n\n+/m, "\n\n")
+
File.open(dest, "w", 0755) { |file| file << str }
end
View
1 bin/ire
@@ -1,4 +1,5 @@
#!/bin/sh
+export REIA_HOME=.
EXTRA_PATHS="-pz ebin -pz ../ebin"
erl $EXTRA_PATHS -noshell -noinput +K true -s ire init -extra $*
View
1 bin/reia
@@ -10,5 +10,6 @@ fi
PROGRAM=$1
shift
+export REIA_HOME=.
EXTRA_PATHS="-pz ebin -pz ../ebin"
erl $EXTRA_PATHS -noshell +K true -s reia init -s reia_internal execute_file $PROGRAM -s init stop -extra $*
View
20 src/core/reia_internal.erl
@@ -90,16 +90,16 @@ load_stdlib() ->
% Base directory of the Reia distribution
base_directory() ->
- % Look for the Reia distribution under the Erlang lib directory
- Dir = code:lib_dir() ++ "/reia",
- case filelib:is_dir(Dir) of
- true -> Dir;
- false ->
- % If it's not there, look for it relative to cwd
- {ok, Dir2} = file:get_cwd(),
- case filelib:is_dir(Dir2 ++ "/ebin") of
- true -> Dir2;
- false -> throw({error, "can't locate the Reia distribution"})
+ % Look for a REIA_HOME environment variable, which takes precedence
+ case [Home || "REIA_HOME=" ++ Home <- os:getenv()] of
+ [Dir] -> Dir;
+ _ ->
+ % Look for the Reia distribution under the Erlang lib directory
+ Dir = code:lib_dir() ++ "/reia",
+ case filelib:is_dir(Dir) of
+ true -> Dir;
+ false ->
+ throw({error, "can't locate the Reia distribution"})
end
end.

0 comments on commit 91c4281

Please sign in to comment.