Skip to content

Commit

Permalink
Support Rebar3 and Rebar2
Browse files Browse the repository at this point in the history
Configure rebar.config for Rebar3, but with rebar.config.script changes to allow
rebar2.x to work.
Add some Hex-centric properties to the .app.src
Configure Makefile to handle the differences appropriately
Add a test axis to Travis to run both rebar2 and rebar3
  • Loading branch information
Nathaniel Waisbrot committed Mar 24, 2016
1 parent 49012c5 commit 62f1b88
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 13 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ otp_release:
- R16B03-1
- 17.5
- 18.1
env:
- FORCE_REBAR2=true
- FORCE_REBAR2=false PATH=$PATH:$PWD
branches:
only:
- master
script: make eunit
install:
- make travis-install
script: make eunit
51 changes: 48 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
.PHONY: all get-deps clean compile run eunit check check-eunit doc

REBAR=$(shell which rebar || echo ./rebar)
# determine which Rebar we want to be running
REBAR2=$(shell which rebar || echo ./rebar)
REBAR3=$(shell which rebar3)
ifeq ($(FORCE_REBAR2),true)
REBAR=$(REBAR2)
REBAR_VSN=2
else ifeq ($(REBAR3),)
REBAR=$(REBAR2)
REBAR_VSN=2
else
REBAR=$(REBAR3)
REBAR_VSN=3
endif

# eventually this should be just ebin/*.beam, but there are a number
# of warnings in other files. Just check the clean files for now.
Expand Down Expand Up @@ -30,10 +42,13 @@ CHECK_EUNIT_FILES=\
.eunit/erlcloud_ec2_tests.beam \
.eunit/erlcloud_s3_tests.beam


all: get-deps compile

get-deps:
ifeq ($(REBAR_VSN),2)
@$(REBAR) get-deps
endif

clean:
@$(REBAR) clean
Expand All @@ -42,23 +57,53 @@ compile:
@$(REBAR) compile

run:
ifeq ($(REBAR_VSN),2)
erl -pa deps/*/ebin -pa ./ebin
else
$(REBAR) shell
endif

eunit: compile
eunit:
ifeq ($(REBAR_VSN),2)
@$(REBAR) compile
@$(REBAR) eunit skip_deps=true
else
@$(REBAR) eunit
endif

check: compile
check:
ifeq ($(REBAR_VSN),2)
@$(REBAR) compile
dialyzer --verbose --no_check_plt --no_native --fullpath \
$(CHECK_FILES) \
-Wunmatched_returns \
-Werror_handling
else
@$(REBAR) dialyzer
endif

check-eunit: eunit
ifeq ($(REBAR_VSN),2)
dialyzer --verbose --no_check_plt --no_native --fullpath \
$(CHECK_EUNIT_FILES) \
-Wunmatched_returns \
-Werror_handling
else
@$(REBAR) dialyzer
endif

doc:
ifeq ($(REBAR_VSN),2)
@$(REBAR) doc skip_deps=true
else
@$(REBAR) edoc
endif

# The "install" step for Travis
travis-install:
ifeq ($(FORCE_REBAR2),true)
rebar get-deps
else
wget https://s3.amazonaws.com/rebar3/rebar3
chmod a+x rebar3
endif
6 changes: 3 additions & 3 deletions package.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Expm.Package.new(name: "erlcloud", description: "Cloud Computing library for Erlang (Amazon EC2, S3, SQS, SimpleDB, Mechanical Turk, ELB) ",
version: "0.8.0", keywords: ["cloud", "api", "amazon", "ec2", "s3", "sqs"],
maintainers: [[name: "Gleb Peregud",
version: "0.13.1", keywords: ["cloud", "api", "amazon", "ec2", "s3", "sqs"],
maintainers: [[name: "Gleb Peregud",
email: "[email protected]"]],
repositories: [[github: "gleber/erlcloud"]])
repositories: [[github: "gleber/erlcloud"]])
11 changes: 7 additions & 4 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
warn_unused_record,
warn_unused_vars]}.

{deps, [{meck, ".*", {git, "https://github.com/eproxus/meck.git", {tag, "0.8.4"}}},
{jsx, ".*", {git, "git://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}},
%% {hackney, ".*", {git, "git://github.com/benoitc/hackney.git", {tag, "1.2.0"}}},
{lhttpc, ".*", {git, "git://github.com/erlcloud/lhttpc", {tag, "1.4.0"}}}
{deps, [
{jsx, "2.8.0"},
{lhttpc, "1.4.0"}
]}.

{profiles, [
{test, [{deps, [{meck, "0.8.4"}]}]}
]}.
15 changes: 14 additions & 1 deletion rebar.config.script
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
case erlang:system_info(otp_release) =< "R15B01" of
%% -*- mode: erlang; -*-
Config1 = case erlang:system_info(otp_release) =< "R15B01" of
true ->
HashDefine = [{d,old_hash}],
case lists:keysearch(erl_opts, 1, CONFIG) of
Expand All @@ -8,4 +9,16 @@ case erlang:system_info(otp_release) =< "R15B01" of
CONFIG ++ [{erl_opts, HashDefine}]
end;
false -> CONFIG
end,
case erlang:function_exported(rebar3, main, 1) of
true -> % rebar3
Config1;
false -> % rebar 2.x or older
%% Use git-based deps
%% profiles
[{deps, [{meck, ".*",{git, "https://github.com/eproxus/meck.git", {tag, "0.8.4"}}},
{jsx, ".*", {git, "git://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}},
%% {hackney, ".*", {git, "git://github.com/benoitc/hackney.git", {tag, "1.2.0"}}},
{lhttpc, ".*", {git, "git://github.com/talko/lhttpc", {tag, "1.4.0"}}}]}
| lists:keydelete(deps, 1, Config1)]
end.
2 changes: 2 additions & 0 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[{<<"jsx">>,{pkg,<<"jsx">>,<<"2.8.0">>},0},
{<<"lhttpc">>,{pkg,<<"lhttpc">>,<<"1.4.0">>},0}].
5 changes: 4 additions & 1 deletion src/erlcloud.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
%% hackney,
lhttpc]},
{modules, []},
{env, []}
{env, []},
{licenses, ["MIT"]},
{links, [{"Github", "https://github.com/erlcloud/erlcloud"}]},
{maintainers, []}
]
}.

0 comments on commit 62f1b88

Please sign in to comment.