Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ src/mango/venv/
src/jwtf/.rebar3/
test/javascript/junit.xml

/_build/
_build/
rebar.lock
/src/bunt
/src/credo/
/src/httpotion/
Expand Down
33 changes: 16 additions & 17 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)
REBAR?=$(shell echo `pwd`/bin/rebar3)
ERLFMT?=$(shell echo `pwd`/bin/erlfmt)

# Handle the following scenarios:
Expand Down Expand Up @@ -140,8 +140,8 @@ fauxton: share/www
.PHONY: escriptize
# target: escriptize - Build CLI tools
escriptize: couch
@$(REBAR) -r escriptize apps=weatherreport
@cp src/weatherreport/weatherreport bin/weatherreport
@$(REBAR) escriptize apps=weatherreport
@cp _build/default/bin/weatherreport bin/weatherreport


################################################################################
Expand Down Expand Up @@ -171,10 +171,9 @@ eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
eunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell pwd)/bin/couchjs $(shell pwd)/share/server/main.js
eunit: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
eunit: couch
@COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) setup_eunit 2> /dev/null
@for dir in $(subdirs); do \
COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) -r eunit $(EUNIT_OPTS) apps=$$dir || exit 1; \
done
COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) eunit $(EUNIT_OPTS) --application=$$dir || exit 1; \
done


.PHONY: exunit
Expand All @@ -185,25 +184,25 @@ exunit: export ERL_LIBS = $(shell pwd)/src
exunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
exunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell pwd)/bin/couchjs $(shell pwd)/share/server/main.js
exunit: export COUCHDB_TEST_ADMIN_PARTY_OVERRIDE=1
exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo
exunit: couch elixir-init elixir-check-formatted elixir-credo
@mix test --trace $(EXUNIT_OPTS)

setup-eunit: export BUILDDIR = $(shell pwd)
setup-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
setup-eunit:
@$(REBAR) setup_eunit 2> /dev/null
# setup-eunit: export BUILDDIR = $(shell pwd)
# setup-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
# setup-eunit:
# @$(REBAR) setup_eunit 2> /dev/null

just-eunit: export BUILDDIR = $(shell pwd)
just-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
just-eunit:
@$(REBAR) -r eunit $(EUNIT_OPTS)
@$(REBAR) eunit $(EUNIT_OPTS)

.PHONY: soak-eunit
soak-eunit: export BUILDDIR = $(shell pwd)
soak-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config
soak-eunit: couch
@$(REBAR) setup_eunit 2> /dev/null
while [ $$? -eq 0 ] ; do $(REBAR) -r eunit $(EUNIT_OPTS) ; done
while [ $$? -eq 0 ] ; do $(REBAR) eunit $(EUNIT_OPTS) ; done

erlfmt-check:
ERLFMT_PATH=$(ERLFMT) python3 dev/format_check.py
Expand Down Expand Up @@ -339,25 +338,25 @@ weatherreport-test: devclean escriptize
.PHONY: build-plt
# target: build-plt - Build project-specific PLT
build-plt:
@$(REBAR) -r build-plt $(DIALYZE_OPTS)
@$(REBAR) build-plt $(DIALYZE_OPTS)


.PHONY: check-plt
# target: check-plt - Check the PLT for consistency and rebuild it if it is not up-to-date
check-plt:
@$(REBAR) -r check-plt $(DIALYZE_OPTS)
@$(REBAR) check-plt $(DIALYZE_OPTS)


.PHONY: dialyze
# target: dialyze - Analyze the code for discrepancies
dialyze: .rebar
@$(REBAR) -r dialyze $(DIALYZE_OPTS)
@$(REBAR) dialyze $(DIALYZE_OPTS)


.PHONY: introspect
# target: introspect - Check for commits difference between rebar.config and repository
introspect:
@$(REBAR) -r update-deps
@$(REBAR) get-deps
@build-aux/introspect

################################################################################
Expand Down
43 changes: 4 additions & 39 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ basename=`basename $0`

PACKAGE_AUTHOR_NAME="The Apache Software Foundation"

REBAR3_BRANCH="main"
REBAR3_BRANCH="3.15.2"

# TEST=0
WITH_PROPER="true"
Expand Down Expand Up @@ -126,22 +126,6 @@ parse_opts() {
continue
;;

--rebar)
if [ -x "$2" ]; then
version=`$2 --version 2> /dev/null | grep -o "2\.[6-9]\.[0-9]"`
if [ $? -ne 0 ]; then
printf 'Rebar >=2.6.0 and <3.0.0 required' >&2
exit 1
fi
eval REBAR=$2
shift 2
continue
else
printf 'ERROR: "--rebar" requires valid path to executable.\n' >&2
exit 1
fi
;;

--rebar3)
if [ -x "$2" ]; then
eval REBAR3=$2
Expand Down Expand Up @@ -290,18 +274,6 @@ cat > $rootdir/config.erl << EOF
{spidermonkey_version, "$SM_VSN"}.
EOF

install_local_rebar() {
if [ ! -x "${rootdir}/bin/rebar" ]; then
if [ ! -d "${rootdir}/src/rebar" ]; then
# git clone --depth 1 https://github.com/apache/couchdb-rebar.git ${rootdir}/src/rebar
git clone https://github.com/apache/couchdb-rebar.git ${rootdir}/src/rebar
fi
make -C ${rootdir}/src/rebar
mv ${rootdir}/src/rebar/rebar ${rootdir}/bin/rebar
make -C ${rootdir}/src/rebar clean
fi
}

install_local_rebar3() {
if [ ! -x "${rootdir}/bin/rebar3" ]; then
if [ ! -d "${rootdir}/src/rebar3" ]; then
Expand All @@ -327,15 +299,8 @@ install_local_erlfmt() {
fi
}

if [ -z "${REBAR}" ]; then
install_local_rebar
REBAR=${rootdir}/bin/rebar
fi

if [ -z "${REBAR3}" ] && [ "${ERLANG_VER}" != "20" ]; then
install_local_rebar3
REBAR3=${rootdir}/bin/rebar3
fi
install_local_rebar3
REBAR3=${rootdir}/bin/rebar3

if [ -z "${ERLFMT}" ] && [ "${ERLANG_VER}" != "20" ]; then
install_local_erlfmt
Expand All @@ -345,7 +310,7 @@ fi
# only update dependencies, when we are not in a release tarball
if [ -d .git -a $SKIP_DEPS -ne 1 ]; then
echo "==> updating dependencies"
${REBAR} get-deps update-deps
${REBAR3} get-deps
fi

# External repos frequently become integrated with the primary repo,
Expand Down
15 changes: 6 additions & 9 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,14 @@ DepDescs = [
{snappy, "snappy", {tag, "CouchDB-1.0.7"}},

%% Non-Erlang deps
{docs, {url, "https://github.com/apache/couchdb-documentation"},
{tag, "3.2.1-1"}, [raw]},
{fauxton, {url, "https://github.com/apache/couchdb-fauxton"},
{tag, "v1.2.8"}, [raw]},
{docs, "documentation", {tag, "rebar3-bogus-app"}},
{fauxton, "fauxton", {tag, "rebar3-bogus-app"}},

%% Third party deps
{folsom, "folsom", {tag, "CouchDB-0.8.4"}},
{hyper, "hyper", {tag, "CouchDB-2.2.0-7"}},
{ibrowse, "ibrowse", {tag, "CouchDB-4.4.2-5"}},
{jiffy, "jiffy", {tag, "CouchDB-1.0.9-1"}},
{jiffy, "jiffy", {tag, "1.1.1"}},
{mochiweb, "mochiweb", {tag, "CouchDB-v2.21.0-1"}},
{meck, "meck", {tag, "0.9.2"}},
{recon, "recon", {tag, "2.5.2"}}
Expand Down Expand Up @@ -193,13 +192,11 @@ end.

AddConfig = [
{require_otp_vsn, "20|21|22|23|24"},
{deps_dir, "src"},
{deps, lists:map(MakeDep, DepDescs ++ OptionalDeps)},
{sub_dirs, SubDirs},
{lib_dirs, ["src"]},
{project_app_dirs, SubDirs},
{erl_opts, [{i, "../"}, {d, 'COUCHDB_ERLANG_VERSION', VerString}]},
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]},
{plugins, [eunit_plugin]},
{escript_main_app, weatherreport}, % a hack for rebar3 support
{dialyzer, [
{plt_location, local},
{plt_location, COUCHDB_ROOT},
Expand Down
31 changes: 23 additions & 8 deletions src/couch/rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ ConfigH = [

CouchJSConfig = case SMVsn of
"78" ->
"priv/couch_js/86/config.h";
"src/couch/priv/couch_js/86/config.h";
"91" ->
"priv/couch_js/86/config.h";
"src/couch/priv/couch_js/86/config.h";
_ ->
"priv/couch_js/" ++ SMVsn ++ "/config.h"
"src/couch/priv/couch_js/" ++ SMVsn ++ "/config.h"
end.
ConfigSrc = [["#define ", K, " ", V, $\n] || {K, V} <- ConfigH].
ConfigBin = iolist_to_binary(ConfigSrc).
Expand Down Expand Up @@ -165,6 +165,8 @@ end.
}
end.



CouchJSSrc = case SMVsn of
"1.8.5" -> ["priv/couch_js/1.8.5/*.c"];
"60" -> ["priv/couch_js/60/*.cpp"];
Expand Down Expand Up @@ -196,7 +198,7 @@ IcuBsdEnv = [{"CFLAGS", "-DXP_UNIX -I/usr/local/include"},
IcuWinEnv = [{"CFLAGS", "$DRV_CFLAGS /DXP_WIN"},
{"LDFLAGS", "$LDFLAGS icuin.lib icudt.lib icuuc.lib"}].

ComparePath = "priv/couch_ejson_compare.so".
ComparePath = "src/couch/priv/couch_ejson_compare.so".
CompareSrc = ["priv/couch_ejson_compare/*.c"].

BaseSpecs = [
Expand All @@ -210,7 +212,7 @@ BaseSpecs = [
].

SpawnSpec = [
{"priv/couchspawnkillable", ["priv/spawnkillable/*.c"]}
{"src/couch/priv/couchspawnkillable", ["src/couch/priv/spawnkillable/*.c"]}
].

%% hack required until switch to enc/rebar3
Expand All @@ -223,15 +225,28 @@ PortSpecs = case os:type() of
{win32, _} ->
BaseSpecs ++ SpawnSpec;
_ ->
{ok, CSK} = file:read_file("priv/spawnkillable/couchspawnkillable.sh"),
ok = CopyIfDifferent("priv/couchspawnkillable", CSK),
os:cmd("chmod +x priv/couchspawnkillable"),
{ok, CSK} = file:read_file("src/couch/priv/spawnkillable/couchspawnkillable.sh"),
ok = CopyIfDifferent("src/couch/priv/couchspawnkillable", CSK),
os:cmd("chmod +x src/couch/priv/couchspawnkillable"),
BaseSpecs
end.

PlatformDefines = [
{platform_define, "win32", 'WINDOWS'}
].
AddConfig = [
{plugins, [{pc, "~> 1.0"}]},
{artifacts, [
"priv/couchjs",
"src/couch/priv/couch_ejson_compare.so",
"priv/couchspawnkillable"
]},
{provider_hooks, [
{post, [
{compile, {pc, compile}},
{clean, {pc, clean}}
]}
]},
{port_specs, PortSpecs},
{erl_opts, PlatformDefines ++ [
{d, 'COUCHDB_VERSION', Version},
Expand Down
1 change: 1 addition & 0 deletions src/docs
1 change: 1 addition & 0 deletions src/fauxton