Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:choptastic/nitrogen

  • Loading branch information...
commit b9367ccd44ae3fe3694c4a438002acbcc91eeb36 2 parents 7dd2398 + df55827
@choptastic choptastic authored
View
2  Makefile
@@ -86,7 +86,7 @@ package_yaws: rel_yaws
# SHARED
rel_inner:
- @(cd rel; ./rebar generate)
+ @(cd rel; ./rebar generate; escript copy_erl_interface.escript)
@(cd rel/nitrogen; make)
@printf "Nitrogen Version:\n${NITROGEN_VERSION}\n\n" > rel/nitrogen/BuildInfo.txt
@echo "Built On (uname -v):" >> rel/nitrogen/BuildInfo.txt
View
BIN  rebar
Binary file not shown
View
188 rel/copy_erl_interface.escript
@@ -0,0 +1,188 @@
+#!/usr/bin/env escript
+%% -*- erlang -*-
+%%! -smp enable -sname copy_erl_interface
+%%
+%% Coyright 2012 - Jesse Gumm
+%% MIT License
+%%
+%% The purpoose of this file is due to a behavior or bug in Erlang's reltool
+%% functionality, where the erl_interface directory is not copied using reltool.
+%% This is a workaround for that shortcoming particularly for building Yaws
+%% with Nitrogen, as Yaws requires erl_interface to compile.
+%%
+%% Much of this file has been straight up copied from rebar, most of it is
+%% overkill for what it's doing, and can probably be stripped to its bare bones,
+%% especially for whenever that shortcoming gets fixed.
+%%
+%% So for now, this serves a simple purpose which will likely be rendered
+%% unnecessary in the future.
+
+-define(CONSOLE(Str,Args), io:format(Str,Args)).
+-define(FMT(Str,Args), lists:flatten(io_lib:format(Str,Args))).
+
+main([]) ->
+ Path = code:lib_dir(erl_interface),
+ To = filename:join([get_cwd(), "nitrogen", "lib", filename:basename(Path)]),
+
+ ?CONSOLE("~s~n",["Copying " ++ Path]),
+ cp_r([Path],To),
+ ok.
+
+
+%% Copied from Rebar
+cp_r(Sources, Dest) ->
+ case os:type() of
+ {unix, _} ->
+ EscSources = [escape_spaces(Src) || Src <- Sources],
+ SourceStr = string:join(EscSources, " "),
+ {ok, []} = sh(?FMT("cp -R ~s \"~s\"",
+ [SourceStr, Dest]),
+ [{use_stdout, false}, return_on_error]),
+ ok;
+ {win32, _} ->
+ lists:foreach(fun(Src) -> ok = cp_r_win32(Src,Dest) end, Sources),
+ ok
+ end.
+
+
+%% Windows stuff
+xcopy_win32(Source,Dest)->
+ {ok, R} = sh(
+ ?FMT("xcopy \"~s\" \"~s\" /q /y /e 2> nul",
+ [filename:nativename(Source), filename:nativename(Dest)]),
+ [{use_stdout, false}, return_on_error]),
+ case length(R) > 0 of
+ %% when xcopy fails, stdout is empty and and error message is printed
+ %% to stderr (which is redirected to nul)
+ true -> ok;
+ false ->
+ {error, lists:flatten(
+ io_lib:format("Failed to xcopy from ~s to ~s~n",
+ [Source, Dest]))}
+ end.
+
+cp_r_win32({true, SourceDir}, {true, DestDir}) ->
+ %% from directory to directory
+ SourceBase = filename:basename(SourceDir),
+ ok = case file:make_dir(filename:join(DestDir, SourceBase)) of
+ {error, eexist} -> ok;
+ Other -> Other
+ end,
+ ok = xcopy_win32(SourceDir, filename:join(DestDir, SourceBase));
+cp_r_win32({false, Source} = S,{true, DestDir}) ->
+ %% from file to directory
+ cp_r_win32(S, {false, filename:join(DestDir, filename:basename(Source))});
+cp_r_win32({false, Source},{false, Dest}) ->
+ %% from file to file
+ {ok,_} = file:copy(Source, Dest),
+ ok;
+cp_r_win32(Source,Dest) ->
+ Dst = {filelib:is_dir(Dest), Dest},
+ lists:foreach(fun(Src) ->
+ ok = cp_r_win32({filelib:is_dir(Src), Src}, Dst)
+ end, filelib:wildcard(Source)),
+ ok.
+
+%% Shell Command Stuff (from rebar_utils)
+sh(Command0, Options0) ->
+ % ?CONSOLE("sh info:\n\tcwd: ~p\n\tcmd: ~s\n", [get_cwd(), Command0]),
+ % ?DEBUG("\topts: ~p\n", [Options0]),
+
+ DefaultOptions = [use_stdout, abort_on_error],
+ Options = [expand_sh_flag(V)
+ || V <- proplists:compact(Options0 ++ DefaultOptions)],
+
+ ErrorHandler = proplists:get_value(error_handler, Options),
+ OutputHandler = proplists:get_value(output_handler, Options),
+
+ Command = patch_on_windows(Command0, proplists:get_value(env, Options, [])),
+ PortSettings = proplists:get_all_values(port_settings, Options) ++
+ [exit_status, {line, 16384}, use_stdio, stderr_to_stdout, hide],
+ Port = open_port({spawn, Command}, PortSettings),
+
+ case sh_loop(Port, OutputHandler, []) of
+ {ok, _Output} = Ok ->
+ Ok;
+ {error, {_Rc, _Output}=Err} ->
+ ErrorHandler(Command, Err)
+ end.
+
+get_cwd() ->
+ {ok,Dir} = file:get_cwd(),
+ Dir.
+
+patch_on_windows(Cmd, Env) ->
+ case os:type() of
+ {win32,nt} ->
+ "cmd /q /c "
+ ++ lists:foldl(fun({Key, Value}, Acc) ->
+ expand_env_variable(Acc, Key, Value)
+ end, Cmd, Env);
+ _ ->
+ Cmd
+ end.
+
+expand_env_variable(InStr, VarName, RawVarValue) ->
+ case string:chr(InStr, $$) of
+ 0 ->
+ %% No variables to expand
+ InStr;
+ _ ->
+ VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", [global]),
+ %% Use a regex to match/replace:
+ %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO}
+ RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]),
+ ReOpts = [global, {return, list}],
+ re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts)
+ end.
+
+sh_loop(Port, Fun, Acc) ->
+ receive
+ {Port, {data, {eol, Line}}} ->
+ sh_loop(Port, Fun, Fun(Line ++ "\n", Acc));
+ {Port, {data, {noeol, Line}}} ->
+ sh_loop(Port, Fun, Fun(Line, Acc));
+ {Port, {exit_status, 0}} ->
+ {ok, lists:flatten(lists:reverse(Acc))};
+ {Port, {exit_status, Rc}} ->
+ {error, {Rc, lists:flatten(lists:reverse(Acc))}}
+ end.
+
+escape_spaces(Str) ->
+ re:replace(Str, " ", "\\\\ ", [global, {return, list}]).
+
+
+log_and_abort(Message) ->
+ ?CONSOLE("Aborting: ~s ~n",[Message]).
+
+
+
+expand_sh_flag(return_on_error) ->
+ {error_handler,
+ fun(_Command, Err) ->
+ {error, Err}
+ end};
+expand_sh_flag({abort_on_error, Message}) ->
+ {error_handler,
+ fun(Cmd,Err) ->
+ log_and_abort({Message,{Cmd,Err}})
+ end};
+expand_sh_flag(abort_on_error) ->
+ expand_sh_flag({abort_on_error, error});
+expand_sh_flag(use_stdout) ->
+ {output_handler,
+ fun(Line, Acc) ->
+ ?CONSOLE("~s", [Line]),
+ [Line | Acc]
+ end};
+expand_sh_flag({use_stdout, false}) ->
+ {output_handler,
+ fun(Line, Acc) ->
+ [Line | Acc]
+ end};
+expand_sh_flag({cd, _CdArg} = Cd) ->
+ {port_settings, Cd};
+expand_sh_flag({env, _EnvArg} = Env) ->
+ {port_settings, Env}.
+
+
View
BIN  rel/overlay/common/rebar
Binary file not shown
View
2  rel/overlay/inets/rebar.config
@@ -3,7 +3,7 @@
"deps"
]}.
-{require_otp_vsn, "R13B04|R14"}.
+{require_otp_vsn, "R13B04|R14|R15"}.
{cover_enabled, true}.
View
4 rel/overlay/mochiweb/rebar.config
@@ -3,7 +3,7 @@
"deps"
]}.
-{require_otp_vsn, "R13B04|R14"}.
+{require_otp_vsn, "R13B04|R14|R15"}.
{cover_enabled, true}.
@@ -12,7 +12,7 @@
{deps_dir, ["lib"]}.
{deps, [
- {mochiweb, "1.5.*", {git, "git://github.com/mochi/mochiweb.git", {tag, "1.5.0"}}},
+ {mochiweb, "2.3.*", {git, "git://github.com/mochi/mochiweb.git", {tag, "v2.3.0"}}},
{nitrogen_core, "2.1.*", {git, "git://github.com/nitrogen/nitrogen_core", "HEAD"}},
{nprocreg, "0.2.*", {git, "git://github.com/nitrogen/nprocreg", "HEAD"}},
View
4 rel/overlay/webmachine/rebar.config
@@ -3,7 +3,7 @@
"deps"
]}.
-{require_otp_vsn, "R13B04|R14"}.
+{require_otp_vsn, "R13B04|R14|R15"}.
{cover_enabled, true}.
@@ -12,7 +12,7 @@
{deps_dir, ["lib"]}.
{deps, [
- {webmachine, "1.8.*", {git, "git://github.com/basho/webmachine.git", {tag, "webmachine-1.8.0"}}},
+ {webmachine, "1.8.*", {git, "git://github.com/basho/webmachine.git", {tag, "webmachine-1.8.1"}}},
{nitrogen_core, "2.1.*", {git, "git://github.com/nitrogen/nitrogen_core", "HEAD"}},
{nprocreg, "0.2.*", {git, "git://github.com/nitrogen/nprocreg", "HEAD"}},
View
4 rel/overlay/yaws/rebar.config
@@ -3,7 +3,7 @@
"deps"
]}.
-{require_otp_vsn, "R13B04|R14"}.
+{require_otp_vsn, "R13B04|R14|R15"}.
{cover_enabled, true}.
@@ -12,7 +12,7 @@
{deps_dir, ["lib"]}.
{deps, [
- {yaws, "1.*", {git, "git://github.com/klacke/yaws",{tag, "yaws-1.91"}}},
+ {yaws, "1.*", {git, "git://github.com/klacke/yaws",{tag, "yaws-1.92"}}},
{nitrogen_core, "2.1.*", {git, "git://github.com/nitrogen/nitrogen_core", "HEAD"}},
{nprocreg, "0.2.*", {git, "git://github.com/nitrogen/nprocreg", "HEAD"}},
View
BIN  rel/rebar
Binary file not shown
View
1  rel/reltool_inets.config
@@ -33,7 +33,6 @@
{copy, "../deps/simple_bridge", "lib/simple_bridge"},
{copy, "../deps/nprocreg", "lib/nprocreg"},
{copy, "../deps/sync", "lib/sync"},
- {copy_absolute, "{{core_lib_dir}}/erl_interface-*","lib"},
%% Copy Inets-specific files...
{copy, "overlay/inets/*"}
View
1  rel/reltool_mochiweb.config
@@ -34,7 +34,6 @@
{copy, "../deps/simple_bridge", "lib/simple_bridge"},
{copy, "../deps/nprocreg", "lib/nprocreg"},
{copy, "../deps/sync", "lib/sync"},
- {copy_absolute, "{{core_lib_dir}}/erl_interface-*","lib"},
%% Copy Mochiweb files...
{copy, "overlay/mochiweb/*"}
View
1  rel/reltool_webmachine.config
@@ -33,7 +33,6 @@
{copy, "../deps/simple_bridge", "lib/simple_bridge"},
{copy, "../deps/nprocreg", "lib/nprocreg"},
{copy, "../deps/sync", "lib/sync"},
- {copy_absolute, "{{core_lib_dir}}/erl_interface-*","lib"},
%% Copy Webmachine files...
{copy, "overlay/webmachine/*"}
View
1  rel/reltool_yaws.config
@@ -33,7 +33,6 @@
{copy, "../deps/simple_bridge", "lib/simple_bridge"},
{copy, "../deps/nprocreg", "lib/nprocreg"},
{copy, "../deps/sync", "lib/sync"},
- {copy_absolute, "{{core_lib_dir}}/erl_interface-*","lib"},
%% Copy Yaws files...
{copy, "overlay/yaws/*"}
Please sign in to comment.
Something went wrong with that request. Please try again.