Skip to content

Commit

Permalink
Add support for different Erlang/OTP releases
Browse files Browse the repository at this point in the history
  • Loading branch information
alavrik committed Feb 5, 2012
1 parent c4fb53e commit a1e2790
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,9 @@
ebin ebin
.eunit .eunit


erlson_erlc/src/erl_parse.yrl
erlson_shell/src/erl_parse.yrl

*.beam *.beam
*.P *.P
erl_parse.erl erl_parse.erl
Expand Down
11 changes: 11 additions & 0 deletions erlson_erlc/rebar.config
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,11 @@
{pre_hooks, [
{compile, "ln -sf ../../`../otp_release.sh`/erl_parse_erlc.yrl src/erl_parse.yrl"}
]}.


{post_hooks, [
{clean, "rm -f src/erl_parse.yrl"}
]}.


% vim:ft=erlang
11 changes: 11 additions & 0 deletions erlson_shell/rebar.config
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,11 @@
{pre_hooks, [
{compile, "ln -sf ../../`../otp_release.sh`/erl_parse_shell.yrl src/erl_parse.yrl"}
]}.


{post_hooks, [
{clean, "rm -f src/erl_parse.yrl"}
]}.


% vim:ft=erlang
19 changes: 19 additions & 0 deletions otp_release.sh
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

OTP_VERSION=`erl -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().'`

case "$OTP_VERSION" in
R13*)
echo "r13"
;;
R14*)
echo "r14"
;;
R15*)
echo "r15"
;;
*)
echo "error: unknown Erlang/OTP version: $OTP_VERSION" >&2
exit 1
esac

File renamed without changes.
File renamed without changes.
17 changes: 11 additions & 6 deletions rebar.config
Original file line number Original file line Diff line number Diff line change
@@ -1,17 +1,23 @@
{require_otp_vsn, "R13B04|R14|R15"}.


% this will allow us to load the Erlson rebar plugin during this build (e.g. for % this will allow us to load the Erlson rebar plugin during this build (e.g. for
% running EUnit) % running EUnit)
{lib_dirs, [".."]}. {lib_dirs, [".."]}.



{plugins, [erlson_rebar_plugin]}. % newest rebar {plugins, [erlson_rebar_plugin]}. % newest rebar
{rebar_plugins, [erlson_rebar_plugin]}. % older rebar {rebar_plugins, [erlson_rebar_plugin]}. % older rebar



% version of the extended Erlang parser that generates Erlson at parse time % version of the extended Erlang parser that generates Erlson at parse time
{sub_dirs, ["erlson_erlc", "erlson_shell"]}. {sub_dirs, ["erlson_erlc", "erlson_shell"]}.



{post_hooks, [ {post_hooks, [
{compile, "cp erlson_erlc/ebin/erl_parse.beam ebin/erl_parse_erlc.beam"}, {compile, "cp erlson_erlc/ebin/erl_parse.beam ebin/erl_parse_erlc.beam"},
{compile, "cp erlson_shell/ebin/erl_parse.beam ebin/erl_parse_shell.beam"} {compile, "cp erlson_shell/ebin/erl_parse.beam ebin/erl_parse_shell.beam"}
]}. ]}.




{erl_opts, [fail_on_warning, debug_info]}. {erl_opts, [fail_on_warning, debug_info]}.
Expand All @@ -24,11 +30,10 @@
{cover_enabled, false}. {cover_enabled, false}.




%{deps, %{deps, [
% [
% % we need Mochiweb for mochijson2 % % we need Mochiweb for mochijson2
% {mochiweb, "", {git, "https://github.com/mochi/mochiweb.git", {branch, "master"}}} % {mochiweb, "", {git, "https://github.com/mochi/mochiweb.git", {branch, "master"}}}
% ]}. %]}.




% vim:ft=erlang % vim:ft=erlang
7 changes: 5 additions & 2 deletions src/Makefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ ERLC_FLAGS = -pa $(EBIN_DIR)
ERL_OBJECTS = $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.beam) ERL_OBJECTS = $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.beam)
ERL_TEST_OBJECTS = $(ERL_TESTS:%.erl=$(EBIN_DIR)/%.beam) ERL_TEST_OBJECTS = $(ERL_TESTS:%.erl=$(EBIN_DIR)/%.beam)


OTP_RELEASE := $(shell ../otp_release.sh)


.PHONY: all test .PHONY: all test




Expand All @@ -25,11 +28,11 @@ erlson_tests.erl: $(ERL_SOURCES)




erl_parse_shell.yrl: erl_parse_shell.yrl:
test -s $@ || ln -s ../erlson_shell/src/erl_parse.yrl $@ test -s $@ || ln -s ../$(OTP_RELEASE)/erl_parse_shell.yrl $@




erl_parse.yrl: erl_parse.yrl:
test -s $@ || ln -s ../erlson_erlc/src/erl_parse.yrl $@ test -s $@ || ln -s ../$(OTP_RELEASE)/erl_parse_erlc.yrl $@




$(ERL_OBJECTS) $(ERL_TEST_OBJECTS): %.beam: %.erl $(ERL_OBJECTS) $(ERL_TEST_OBJECTS): %.beam: %.erl
Expand Down

0 comments on commit a1e2790

Please sign in to comment.