From 7b419bd55cf5b81abd58f1ae8fcc66560ab77782 Mon Sep 17 00:00:00 2001 From: Nick Vatamaniuc Date: Tue, 22 Feb 2022 11:28:17 -0500 Subject: Try using rebar3 * Use 3.15.2 version which is compatible with Erlang 20 * Fauxton and docs converted to be used as rebar3 deps * Use get-deps only instead of update-deps --- .gitignore | 3 ++- Makefile | 33 ++++++++++++++++----------------- configure | 43 ++++--------------------------------------- rebar.config.script | 15 ++++++--------- src/couch/rebar.config.script | 31 +++++++++++++++++++++++-------- src/docs | 1 + src/fauxton | 1 + 7 files changed, 53 insertions(+), 74 deletions(-) create mode 120000 src/docs create mode 120000 src/fauxton diff --git a/.gitignore b/.gitignore index fe3e5acaa..8d27dbc15 100644 --- a/.gitignore +++ b/.gitignore @@ -128,7 +128,8 @@ src/mango/venv/ src/jwtf/.rebar3/ test/javascript/junit.xml -/_build/ +_build/ +rebar.lock /src/bunt /src/credo/ /src/httpotion/ diff --git a/Makefile b/Makefile index eed3a8dfe..35db22205 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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 ################################################################################ @@ -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 @@ -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 @@ -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 ################################################################################ diff --git a/configure b/configure index 0bcbfaef3..495fa806d 100755 --- a/configure +++ b/configure @@ -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" @@ -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 @@ -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 @@ -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 @@ -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, diff --git a/rebar.config.script b/rebar.config.script index da3fc58a1..6d1b5cf17 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -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"}} @@ -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}, diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script index ba907b0a2..c2bf0ee8f 100644 --- a/src/couch/rebar.config.script +++ b/src/couch/rebar.config.script @@ -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). @@ -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"]; @@ -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 = [ @@ -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 @@ -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}, diff --git a/src/docs b/src/docs new file mode 120000 index 000000000..a148f3341 --- /dev/null +++ b/src/docs @@ -0,0 +1 @@ +../_build/default/lib/docs \ No newline at end of file diff --git a/src/fauxton b/src/fauxton new file mode 120000 index 000000000..624d7e4d3 --- /dev/null +++ b/src/fauxton @@ -0,0 +1 @@ +../_build/default/lib/fauxton \ No newline at end of file -- cgit v1.2.1