Skip to content

Commit

Permalink
Rebar3: Makefile make
Browse files Browse the repository at this point in the history
1. Use `couch/rebar.config.script` to get dependencies to avoid
dependency cycle errors.
2. Modify Makefile to pass `make all`
  • Loading branch information
jiahuili430 committed Jul 19, 2022
1 parent 6ca1839 commit 0902bf6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 53 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

include version.mk

REBAR?=$(shell echo `pwd`/bin/rebar)
REBAR3?=$(shell echo `pwd`/bin/rebar3)
ERLFMT?=$(shell echo `pwd`/bin/erlfmt)

# Handle the following scenarios:
Expand Down Expand Up @@ -120,7 +120,7 @@ help:
.PHONY: couch
# target: couch - Build CouchDB core, use ERL_COMPILER_OPTIONS to provide custom compiler's options
couch: config.erl
@COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) compile $(COMPILE_OPTS)
@[ -e bin/couchjs ] || COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR3) compile $(COMPILE_OPTS)
@cp apps/couch/priv/couchjs bin/


Expand All @@ -140,8 +140,8 @@ fauxton: share/www
.PHONY: escriptize
# target: escriptize - Build CLI tools
escriptize: couch
@$(REBAR) -r escriptize apps=weatherreport
@cp apps/weatherreport/weatherreport bin/weatherreport
@[ -e bin/weatherreport ] ||$(REBAR3) escriptize -a weatherreport
@cp _build/default/bin/weatherreport bin/weatherreport


################################################################################
Expand Down Expand Up @@ -488,7 +488,7 @@ config.erl:

apps/docs/build:
ifeq ($(with_docs), 1)
@cd apps/docs; $(MAKE)
@cd _build/default/lib/docs; $(MAKE)
endif


Expand Down
52 changes: 49 additions & 3 deletions apps/couch/rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

Rebar3MixPath =
case erlang:function_exported(rebar3, main, 1) of
true -> "apps/couch/"; % rebar3
false -> "" % mix
true -> "apps/couch/"; % rebar3
false -> "" % mix
end.

CopyIfDifferent = fun(Path, Contents) ->
Expand Down Expand Up @@ -237,8 +237,54 @@ end.
PlatformDefines = [
{platform_define, "win32", 'WINDOWS'}
].

DepDescs = [
%% Independent Apps
{config, {url, "https://github.com/jiahuili430/couchdb-config.git"}, {branch, "82-rebar3"}},
{b64url, "b64url", {tag, "1.0.3"}},
{ets_lru, "ets-lru", {tag, "1.1.0"}},
{khash, {url, "https://github.com/jiahuili430/couchdb-khash"}, {branch, "82-rebar3"}},
{snappy, {url, "https://github.com/jiahuili430/couchdb-snappy"}, {branch, "82-rebar3"}},

%% Non-Erlang deps
{docs, {url, "https://github.com/apache/couchdb-documentation"}, {branch, "main"}},

%% Third party deps
{folsom, {url, "https://github.com/jiahuili430/couchdb-folsom"}, {branch, "82-rebar3"}},
{hyper, {url, "https://github.com/jiahuili430/couchdb-hyper"}, {branch, "82-rebar3"}},
{ibrowse, "ibrowse", {tag, "CouchDB-4.4.2-5"}},
{jiffy, "jiffy", {tag, "1.1.1"}},
{mochiweb, "mochiweb", {tag, "v3.0.0"}},
{recon, "recon", {tag, "2.5.2"}}
].

WithProper = lists:keyfind(with_proper, 1, CouchConfig) == {with_proper, true}.

OptionalDeps = case WithProper of
true ->
[{proper, {url, "https://github.com/proper-testing/proper"}, {tag, "v1.4"}}];
false ->
[]
end.

BaseUrl = "https://github.com/apache/".

MakeDep = fun
({AppName, {url, Url}, Version}) ->
{AppName, {git, Url, Version}};
({AppName, {url, Url}, Version, Options}) ->
{AppName, {git, Url, Version}, Options};
({AppName, RepoName, Version}) ->
Url = BaseUrl ++ "couchdb-" ++ RepoName ++ ".git",
{AppName, {git, Url, Version}};
({AppName, RepoName, Version, Options}) ->
Url = BaseUrl ++ "couchdb-" ++ RepoName ++ ".git",
{AppName, {git, Url, Version}, Options}
end.

AddConfig = [
{plugins, [{pc, "~> 1.0"}]},
{deps, lists:map(MakeDep, DepDescs ++ OptionalDeps)},
{plugins, [{pc, "~> 1.0"}]},
{artifacts, [
"priv/couch_ejson_compare.so",
"priv/couchjs",
Expand Down
45 changes: 0 additions & 45 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -104,53 +104,8 @@ end.

os:putenv("COUCHDB_APPS_CONFIG_DIR", filename:join([COUCHDB_ROOT, "rel/apps"])).

DepDescs = [
%% Independent Apps
{config, {url, "https://github.com/jiahuili430/couchdb-config.git"}, {branch, "82-rebar3"}},
{b64url, "b64url", {tag, "1.0.3"}},
{ets_lru, "ets-lru", {tag, "1.1.0"}},
{khash, {url, "https://github.com/jiahuili430/couchdb-khash"}, {branch, "82-rebar3"}},
{snappy, {url, "https://github.com/jiahuili430/couchdb-snappy"}, {branch, "82-rebar3"}},

%% Non-Erlang deps
{docs, {url, "https://github.com/apache/couchdb-documentation"}, {branch, "main"}},

%% Third party deps
{folsom, {url, "https://github.com/jiahuili430/couchdb-folsom"}, {branch, "82-rebar3"}},
{hyper, {url, "https://github.com/jiahuili430/couchdb-hyper"}, {branch, "82-rebar3"}},
{ibrowse, "ibrowse", {tag, "CouchDB-4.4.2-5"}},
{jiffy, "jiffy", {tag, "1.1.1"}},
{mochiweb, "mochiweb", {tag, "v3.0.0"}},
{recon, "recon", {tag, "2.5.2"}}
].

WithProper = lists:keyfind(with_proper, 1, CouchConfig) == {with_proper, true}.

OptionalDeps = case WithProper of
true ->
[{proper, {url, "https://github.com/proper-testing/proper"}, {tag, "v1.4"}}];
false ->
[]
end.

BaseUrl = "https://github.com/apache/".

MakeDep = fun
({AppName, {url, Url}, Version}) ->
{AppName, {git, Url, Version}};
({AppName, {url, Url}, Version, Options}) ->
{AppName, {git, Url, Version}, Options};
({AppName, RepoName, Version}) ->
Url = BaseUrl ++ "couchdb-" ++ RepoName ++ ".git",
{AppName, {git, Url, Version}};
({AppName, RepoName, Version, Options}) ->
Url = BaseUrl ++ "couchdb-" ++ RepoName ++ ".git",
{AppName, {git, Url, Version}, Options}
end.

AddConfig = [
{require_otp_vsn, "23|24|25"},
{deps, lists:map(MakeDep, DepDescs ++ OptionalDeps)},
{erl_opts, [{i, "../"}, {d, 'COUCHDB_ERLANG_VERSION', VerString}]},
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]},
{dialyzer, [
Expand Down

0 comments on commit 0902bf6

Please sign in to comment.