summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2013-12-18 14:04:59 +0000
committerRobert Newson <rnewson@apache.org>2014-02-03 12:53:55 +0000
commitf84eb4fc50ef8e6d26508bbc55c5dbd270f9d408 (patch)
tree0646f26fd4a38efe051aae4cfae41bcbb873ef38
parent938fc0116e289d86e48e3454920e51e37d6308e1 (diff)
downloadcouchdb-f84eb4fc50ef8e6d26508bbc55c5dbd270f9d408.tar.gz
Build with rebar
-rw-r--r--.gitignore149
-rw-r--r--Makefile50
-rw-r--r--Makefile.am172
-rw-r--r--bin/Makefile.am154
-rwxr-xr-xbootstrap151
-rwxr-xr-xconfigure82
-rw-r--r--configure.ac789
-rw-r--r--etc/Makefile.am117
-rw-r--r--etc/couchdb/Makefile.am93
-rw-r--r--etc/default/Makefile.am13
-rw-r--r--etc/init/Makefile.am13
-rw-r--r--etc/launchd/Makefile.am13
-rw-r--r--etc/logrotate.d/Makefile.am13
-rw-r--r--etc/windows/Makefile.am13
-rw-r--r--rebar.config38
-rw-r--r--rel/files/README4
-rw-r--r--rel/files/sys.config1
-rw-r--r--rel/files/vm.args0
-rwxr-xr-xrel/overlay/bin/couchdb28
-rw-r--r--rel/overlay/etc/default.ini122
-rw-r--r--rel/overlay/etc/local.ini1
-rw-r--r--rel/overlay/etc/vm.args23
-rw-r--r--rel/reltool.config70
-rw-r--r--share/Makefile.am219
-rw-r--r--share/doc/Makefile.am14
-rw-r--r--share/doc/build/Makefile.am354
-rw-r--r--src/Makefile.am30
-rw-r--r--src/chttpd/.gitignore1
-rw-r--r--src/chttpd/Makefile.am56
-rw-r--r--src/chttpd/README.md16
-rw-r--r--src/chttpd/src/chttpd.app.src2
-rw-r--r--src/chttpd/src/chttpd_view.erl71
-rw-r--r--src/config/.gitignore5
-rw-r--r--src/config/Makefile.am44
-rw-r--r--src/config/src/config.app.src2
-rw-r--r--src/couch/Makefile.am204
-rw-r--r--src/couch/priv/Makefile.am159
-rw-r--r--src/couch/priv/stat_descriptions.cfg (renamed from src/couch/priv/stat_descriptions.cfg.in)0
-rw-r--r--src/couch/rebar.config11
-rw-r--r--src/couch/src/couch.app.src (renamed from src/couch/src/couch.app.tpl.in)14
-rw-r--r--src/couch_index/Makefile.am38
-rw-r--r--src/couch_index/src/couch_index.app.src2
-rw-r--r--src/couch_mrview/Makefile.am72
-rw-r--r--src/couch_mrview/include/couch_mrview.hrl2
-rw-r--r--src/couch_mrview/src/couch_mrview.app.src2
-rw-r--r--src/couch_replicator/.gitignore4
-rw-r--r--src/couch_replicator/Makefile.am76
-rw-r--r--src/couch_replicator/src/couch_replicator.app.src2
-rw-r--r--src/ddoc_cache/.gitignore1
-rw-r--r--src/ddoc_cache/Makefile.am42
-rw-r--r--src/ddoc_cache/src/ddoc_cache.app.src2
-rw-r--r--src/ejson/Makefile.am91
-rw-r--r--src/ejson/src/ejson.app.src (renamed from src/ejson/src/ejson.app.in)2
-rw-r--r--src/ets_lru/.gitignore5
-rw-r--r--src/ets_lru/Makefile.am34
-rw-r--r--src/ets_lru/src/ets_lru.app.src2
-rw-r--r--src/fabric/.gitignore4
-rw-r--r--src/fabric/Makefile.am77
-rw-r--r--src/fabric/src/fabric.app.src2
-rw-r--r--src/fabric/src/fabric_rpc.erl17
-rw-r--r--src/fabric/src/fabric_view.erl13
-rw-r--r--src/fabric/src/fabric_view_reduce.erl7
-rw-r--r--src/ibrowse/Makefile.am51
-rw-r--r--src/ibrowse/src/ibrowse.app.src (renamed from src/ibrowse/src/ibrowse.app.in)2
-rw-r--r--src/mem3/.gitignore4
-rw-r--r--src/mem3/Makefile.am60
-rw-r--r--src/mem3/src/mem3.app.src2
-rw-r--r--src/mochiweb/Makefile.am113
-rw-r--r--src/mochiweb/src/mochiweb.app.in32
-rw-r--r--src/mochiweb/src/mochiweb.app.src3
-rw-r--r--src/oauth/Makefile.am41
-rw-r--r--src/oauth/src/oauth.app.src (renamed from src/oauth/src/oauth.app.in)0
-rw-r--r--src/rebar/.gitignore12
-rw-r--r--src/rebar/.travis.yml8
-rw-r--r--src/rebar/CONTRIBUTING.md94
-rw-r--r--src/rebar/LICENSE178
-rw-r--r--src/rebar/Makefile44
-rw-r--r--src/rebar/NOTES.org28
-rw-r--r--src/rebar/README.md79
-rw-r--r--src/rebar/THANKS122
-rwxr-xr-xsrc/rebar/bootstrap118
-rw-r--r--src/rebar/bootstrap.bat2
-rw-r--r--src/rebar/dialyzer_reference3
-rw-r--r--src/rebar/ebin/rebar.app93
-rw-r--r--src/rebar/include/rebar.hrl14
-rw-r--r--src/rebar/inttest/bug_5_rt.erl29
-rw-r--r--src/rebar/inttest/ct1/ct1_rt.erl28
-rw-r--r--src/rebar/inttest/ct1/rebar.config1
-rw-r--r--src/rebar/inttest/ct1/test_SUITE.erl11
-rw-r--r--src/rebar/inttest/ct2/ct2_rt.erl26
-rw-r--r--src/rebar/inttest/ct2/foo.test.spec1
-rw-r--r--src/rebar/inttest/ct2/foo_SUITE.erl10
-rw-r--r--src/rebar/inttest/depplugins/depplugins_rt.erl50
-rw-r--r--src/rebar/inttest/depplugins/rebar.config1
-rw-r--r--src/rebar/inttest/depplugins/rebar_dependsonplugin.config2
-rw-r--r--src/rebar/inttest/depplugins/testplugin_mod.erl6
-rw-r--r--src/rebar/inttest/rgen1/reltool.config31
-rw-r--r--src/rebar/inttest/rgen1/retest.config1
-rw-r--r--src/rebar/inttest/rgen1/rgen1_rt.erl18
-rw-r--r--src/rebar/inttest/rgen1/test.config1
-rw-r--r--src/rebar/inttest/rgen1/vars.config1
-rw-r--r--src/rebar/inttest/t_custom_config/custom.config4
-rw-r--r--src/rebar/inttest/t_custom_config/custom_config.erl6
-rw-r--r--src/rebar/inttest/t_custom_config/t_custom_config_rt.erl39
-rw-r--r--src/rebar/inttest/tdeps1/a.erl8
-rw-r--r--src/rebar/inttest/tdeps1/a.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps1/b.hrl1
-rw-r--r--src/rebar/inttest/tdeps1/b.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps1/c.hrl1
-rw-r--r--src/rebar/inttest/tdeps1/tdeps1_rt.erl59
-rw-r--r--src/rebar/inttest/tdeps2/a.erl3
-rw-r--r--src/rebar/inttest/tdeps2/a.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps2/b.hrl1
-rw-r--r--src/rebar/inttest/tdeps2/b.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps2/c.hrl1
-rw-r--r--src/rebar/inttest/tdeps2/root.rebar.config2
-rw-r--r--src/rebar/inttest/tdeps2/tdeps2_rt.erl65
-rw-r--r--src/rebar/inttest/tdeps3/a.erl3
-rw-r--r--src/rebar/inttest/tdeps3/a.rebar.config4
-rw-r--r--src/rebar/inttest/tdeps3/b.hrl1
-rw-r--r--src/rebar/inttest/tdeps3/b.rebar.config5
-rw-r--r--src/rebar/inttest/tdeps3/c.hrl1
-rw-r--r--src/rebar/inttest/tdeps3/c.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps3/d.hrl1
-rw-r--r--src/rebar/inttest/tdeps3/d.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps3/e.hrl1
-rw-r--r--src/rebar/inttest/tdeps3/f.hrl1
-rw-r--r--src/rebar/inttest/tdeps3/root.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps3/tdeps3_rt.erl89
-rw-r--r--src/rebar/inttest/tdeps_update/a.erl3
-rw-r--r--src/rebar/inttest/tdeps_update/a.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/a2.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/a3.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/a4.rebar.config4
-rw-r--r--src/rebar/inttest/tdeps_update/b.hrl1
-rw-r--r--src/rebar/inttest/tdeps_update/b.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/b2.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/b3.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/b4.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/c.hrl1
-rw-r--r--src/rebar/inttest/tdeps_update/c.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/c2.hrl1
-rw-r--r--src/rebar/inttest/tdeps_update/c2.rebar.config4
-rw-r--r--src/rebar/inttest/tdeps_update/c3.rebar.config4
-rw-r--r--src/rebar/inttest/tdeps_update/d.hrl1
-rw-r--r--src/rebar/inttest/tdeps_update/root.rebar.config1
-rw-r--r--src/rebar/inttest/tdeps_update/tdeps_update_rt.erl147
-rw-r--r--src/rebar/inttest/thooks/fish.erl5
-rw-r--r--src/rebar/inttest/thooks/rebar.config7
-rw-r--r--src/rebar/inttest/thooks/thooks_rt.erl40
-rw-r--r--src/rebar/inttest/tplugins/bad.config2
-rw-r--r--src/rebar/inttest/tplugins/bad_plugin.erl7
-rw-r--r--src/rebar/inttest/tplugins/fish.erl5
-rw-r--r--src/rebar/inttest/tplugins/rebar.config1
-rw-r--r--src/rebar/inttest/tplugins/test_plugin.erl8
-rw-r--r--src/rebar/inttest/tplugins/tplugins_rt.erl40
-rw-r--r--src/rebar/priv/shell-completion/bash/rebar85
-rw-r--r--src/rebar/priv/shell-completion/zsh/_rebar83
-rw-r--r--src/rebar/priv/templates/basicnif.c59
-rw-r--r--src/rebar/priv/templates/basicnif.erl42
-rw-r--r--src/rebar/priv/templates/basicnif.template3
-rw-r--r--src/rebar/priv/templates/ctsuite.erl167
-rw-r--r--src/rebar/priv/templates/ctsuite.template2
-rw-r--r--src/rebar/priv/templates/simpleapp.app.src12
-rw-r--r--src/rebar/priv/templates/simpleapp.template4
-rw-r--r--src/rebar/priv/templates/simpleapp_app.erl16
-rw-r--r--src/rebar/priv/templates/simpleapp_sup.erl27
-rw-r--r--src/rebar/priv/templates/simplefsm.erl57
-rw-r--r--src/rebar/priv/templates/simplefsm.template2
-rw-r--r--src/rebar/priv/templates/simplemod.erl6
-rw-r--r--src/rebar/priv/templates/simplemod.template3
-rw-r--r--src/rebar/priv/templates/simplemod_tests.erl3
-rw-r--r--src/rebar/priv/templates/simplenode.erl.script44
-rw-r--r--src/rebar/priv/templates/simplenode.install_upgrade.escript44
-rwxr-xr-xsrc/rebar/priv/templates/simplenode.nodetool182
-rw-r--r--src/rebar/priv/templates/simplenode.reltool.config44
-rwxr-xr-xsrc/rebar/priv/templates/simplenode.runner348
-rw-r--r--src/rebar/priv/templates/simplenode.sys.config11
-rw-r--r--src/rebar/priv/templates/simplenode.template13
-rw-r--r--src/rebar/priv/templates/simplenode.vm.args19
-rw-r--r--src/rebar/priv/templates/simplenode.windows.runner.cmd103
-rw-r--r--src/rebar/priv/templates/simplenode.windows.start_erl.cmd40
-rw-r--r--src/rebar/priv/templates/simplesrv.erl50
-rw-r--r--src/rebar/priv/templates/simplesrv.template2
-rw-r--r--src/rebar/rebar.config21
-rw-r--r--src/rebar/rebar.config.sample236
-rw-r--r--src/rebar/rebar.config.script20
-rw-r--r--src/rebar/src/getopt.erl842
-rw-r--r--src/rebar/src/mustache.erl228
-rw-r--r--src/rebar/src/rebar.erl501
-rw-r--r--src/rebar/src/rebar_abnfc_compiler.erl123
-rw-r--r--src/rebar/src/rebar_app_utils.erl208
-rw-r--r--src/rebar/src/rebar_appups.erl210
-rw-r--r--src/rebar/src/rebar_asn1_compiler.erl100
-rw-r--r--src/rebar/src/rebar_base_compiler.erl260
-rw-r--r--src/rebar/src/rebar_cleaner.erl56
-rw-r--r--src/rebar/src/rebar_config.erl249
-rw-r--r--src/rebar/src/rebar_core.erl608
-rw-r--r--src/rebar/src/rebar_ct.erl350
-rw-r--r--src/rebar/src/rebar_deps.erl774
-rw-r--r--src/rebar/src/rebar_dia_compiler.erl106
-rw-r--r--src/rebar/src/rebar_edoc.erl130
-rw-r--r--src/rebar/src/rebar_erlc_compiler.erl511
-rw-r--r--src/rebar/src/rebar_erlydtl_compiler.erl265
-rw-r--r--src/rebar/src/rebar_escripter.erl197
-rw-r--r--src/rebar/src/rebar_eunit.erl812
-rw-r--r--src/rebar/src/rebar_file_utils.erl194
-rw-r--r--src/rebar/src/rebar_lfe_compiler.erl84
-rw-r--r--src/rebar/src/rebar_log.erl83
-rw-r--r--src/rebar/src/rebar_neotoma_compiler.erl163
-rw-r--r--src/rebar/src/rebar_otp_app.erl220
-rw-r--r--src/rebar/src/rebar_port_compiler.erl607
-rw-r--r--src/rebar/src/rebar_protobuffs_compiler.erl153
-rw-r--r--src/rebar/src/rebar_qc.erl187
-rw-r--r--src/rebar/src/rebar_rel_utils.erl238
-rw-r--r--src/rebar/src/rebar_reltool.erl408
-rw-r--r--src/rebar/src/rebar_require_vsn.erl121
-rw-r--r--src/rebar/src/rebar_shell.erl56
-rw-r--r--src/rebar/src/rebar_subdirs.erl84
-rw-r--r--src/rebar/src/rebar_templater.erl462
-rw-r--r--src/rebar/src/rebar_upgrade.erl268
-rw-r--r--src/rebar/src/rebar_utils.erl510
-rw-r--r--src/rebar/src/rebar_xref.erl287
-rw-r--r--src/rebar/test/rebar_eunit_tests.erl434
-rw-r--r--src/rebar/test/rebar_file_utils_tests.erl278
-rw-r--r--src/rebar/test/rebar_xref_eunit.erl203
-rw-r--r--src/rebar/test/upgrade_project/README.md40
-rw-r--r--src/rebar/test/upgrade_project/apps/dummy/src/dummy.app.src9
-rw-r--r--src/rebar/test/upgrade_project/apps/dummy/src/dummy_app.erl9
-rw-r--r--src/rebar/test/upgrade_project/apps/dummy/src/dummy_server.erl56
-rw-r--r--src/rebar/test/upgrade_project/apps/dummy/src/dummy_sup.erl15
-rw-r--r--src/rebar/test/upgrade_project/rebar.config4
-rwxr-xr-xsrc/rebar/test/upgrade_project/rel/files/dummy347
-rwxr-xr-xsrc/rebar/test/upgrade_project/rel/files/erl44
-rw-r--r--src/rebar/test/upgrade_project/rel/files/nodetool182
-rw-r--r--src/rebar/test/upgrade_project/rel/files/sys.config11
-rw-r--r--src/rebar/test/upgrade_project/rel/files/vm.args19
-rw-r--r--src/rebar/test/upgrade_project/rel/reltool.config27
-rw-r--r--src/rexi/.gitignore8
-rw-r--r--src/rexi/Makefile.am48
-rw-r--r--src/rexi/src/rexi.app.src2
-rw-r--r--src/snappy/Makefile.am40
-rw-r--r--src/snappy/c_src/Makefile.am58
-rw-r--r--src/snappy/src/snappy.app.src (renamed from src/snappy/src/snappy.app.in)2
-rw-r--r--src/twig/.gitignore3
-rw-r--r--src/twig/Makefile.am49
-rw-r--r--test/Makefile.am15
-rw-r--r--test/bench/Makefile.am22
-rw-r--r--test/etap/Makefile.am96
-rw-r--r--test/javascript/Makefile.am26
-rw-r--r--test/view_server/Makefile.am15
-rw-r--r--utils/Makefile.am38
-rw-r--r--var/Makefile.am23
253 files changed, 548 insertions, 19699 deletions
diff --git a/.gitignore b/.gitignore
index 3391f7a5d..e15b2108e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,112 +1,45 @@
-!.gitignore
-!.mailmap
-*.beam
-*.diff
-*.gz
-*.la
-*.lo
*.o
-*.orig
-*.rej
-*.stamp
-*.sw*
-*.tpl
-*~
-.*
-INSTALL
-Makefile
-Makefile.in
-THANKS
-acinclude.m4
-aclocal.m4
-apache-couchdb-*
-autom4te.cache
-bin/.deps/
-bin/couch-config
-bin/couch-config_dev
-bin/couchdb
-bin/couchdb.1
-bin/couchjs_dev
-bin/couchpw
-build-aux/config.*
-build-aux/depcomp
-build-aux/install-sh
-build-aux/ltmain.sh
-build-aux/missing
-build-aux/texinfo.tex
-config.h
-config.h.in
-config.log
-config.status
-configure
-couchdb.log
-couchdb.stderr
-couchdb.stdout
-cover/*
+*.so
+*.Tpo
+*.beam
erl_crash.dump
-etc/couchdb/default.ini
-etc/couchdb/default_dev.ini
-etc/couchdb/local_dev.ini
-etc/init/couchdb
-etc/launchd/org.apache.couchdb.plist
-etc/logrotate.d/couchdb
-libtool
-m4
-share/doc/build/CouchDB.log
-share/doc/build/doctrees
-share/doc/build/html
-share/doc/build/latex
-share/doc/build/texinfo
-share/server/main-coffee.js
-share/server/main.js
-src/couch_mrview/ebin/
-src/couch_replicator/ebin/
-src/couch/.deps/*
-src/couch/.libs/*
-src/couch/ebin/
-src/couch/couch.app
-src/couch/couchjs
-src/couch/edoc-info
-src/couch/erlang.png
-src/couch/priv/.deps/
-src/couch/priv/.libs/
-src/couch/priv/couch_icu_driver.la
-src/couch/priv/couch_icu_driver.*
-src/couch/priv/couchjs
-src/couch/priv/couchjs.1
-src/couch/priv/couchspawnkillable
-src/couch/priv/stat_descriptions.cfg
-src/couch/priv/stat_descriptions.cfg
-src/couch/stylesheet.css
-src/ejson/.deps/
-src/ejson/.libs/
-src/ejson/ebin
-src/ejson/priv
-src/erlang-oauth/oauth.app
-src/erlang-oauth/oauth.app
-src/ibrowse/ebin/
-src/mochiweb/ebin/
-src/oauth/ebin/
-src/snappy/.deps/
-src/snappy/.libs/
-src/snappy/ebin/
-src/snappy/priv/
-src/snappy/c_src/google-snappy/.deps/
-src/snappy/c_src/google-snappy/snappy-stubs-public.h
-src/snappy/c_src/google-snappy/stamp-h2
+wiki/
+
+# building
+src/*/ebin/
+rel/couchdb
+rel/couchdb.config
+rel/overlay.config
+install.mk
+rebar
+deps/
+# scons building
+couchjs/.sconf_temp/
+couchjs/.sconsign.dblite
+couchjs/build/
+couchjs/config.log
+*.pyc
+
+# testing
+.eunit
+@abs_top_builddir@/
+src/couch/test/etap/temp*
+.dialyzer_filter
+.dialyzer_out
+*.plt
+
+# dev
+dev/lib
+dev/logs
+rel/dev*
+rel/tmpdata
+rel/logs
+
+# vim
+*.swp
+*~
-stamp-h1
-test/.deps/
-test/bench/run
-test/etap/.deps/
-test/etap/run
-test/etap/run
-test/etap/temp.*
-test/etap/test_cfg_register
-test/etap/test_util.erl
-test/javascript/run
-test/javascript/run_js_tests.sh
-test/local.ini
-tmp
-utils/run
+# eclipse
+.project
+/.pydevproject
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..b90d957a6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,50 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+all: compile
+
+compile:
+ @echo "==> couchjs (compile)"
+# @cd couchjs && python scons/scons.py $(couchjsflags)
+ @rebar compile
+
+clean:
+ @echo "==> couchjs (clean)"
+# @cd couchjs && python scons/scons.py --clean
+ @rebar clean
+
+dist: compile
+ @rm -rf rel/couchdb
+ @rebar generate
+
+distclean: clean
+ @rm -rf rel/couchdb
+
+dev: compile
+ @rm -rf rel/dev1 rel/dev2 rel/dev3
+ @echo "==> Building development node #1 (ports 15984/15986)"
+ @rebar generate target_dir=dev1 overlay_vars=dev1.config
+ @echo "==> Building development node #2 (ports 25984/25986)"
+ @rebar generate target_dir=dev2 overlay_vars=dev2.config
+ @echo "==> Building development node #3 (ports 35984/35986)"
+ @rebar generate target_dir=dev3 overlay_vars=dev3.config
+ @echo "\n\
+Development nodes are built, and can be started using ./rel/dev[123]/bin/couchdb.\n\
+Once the nodes are started, they must be joined together by editing the local\n\
+nodes DB. For example, executing\n\
+\n\
+ curl localhost:15986/nodes/dev2@127.0.0.1 -X PUT -d '{}'\n\
+ curl localhost:15986/nodes/dev3@127.0.0.1 -X PUT -d '{}'\n\
+\n\
+will cause node 1 to immediately connect to nodes 2 and 3 and form a cluster.\n\
+The content of the nodes database is continuously replicated throughout the\n\
+cluster, so this is a one-time operation.\n"
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 1b71e83f5..000000000
--- a/Makefile.am
+++ /dev/null
@@ -1,172 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-SUBDIRS = bin etc src share test var utils
-
-ACLOCAL_AMFLAGS = -I m4
-
-localdoc_DATA = \
- AUTHORS.gz \
- BUGS.gz \
- CHANGES.gz \
- DEVELOPERS.gz \
- INSTALL.gz \
- INSTALL.Unix.gz \
- INSTALL.Windows.gz \
- LICENSE.gz \
- NEWS.gz \
- NOTICE.gz \
- README.gz \
- THANKS.gz
-
-DISTCLEANFILES = $(localdoc_DATA)
-
-EXTRA_DIST = \
- AUTHORS \
- BUGS \
- CHANGES \
- DEVELOPERS \
- INSTALL \
- INSTALL.Unix \
- INSTALL.Windows \
- LICENSE \
- NEWS \
- NOTICE \
- README \
- THANKS \
- build-aux/sphinx-build \
- build-aux/sphinx-touch \
- license.skip
-
-AUTHORS.gz: AUTHORS
- gzip -9 < $< > $@
-
-BUGS.gz: BUGS
- gzip -9 < $< > $@
-
-CHANGES.gz: CHANGES
- gzip -9 < $< > $@
-
-DEVELOPERS.gz: DEVELOPERS
- gzip -9 < $< > $@
-
-INSTALL.gz: INSTALL
- gzip -9 < $< > $@
-
-INSTALL.Unix.gz: INSTALL.Unix
- gzip -9 < $< > $@
-
-INSTALL.Windows.gz: INSTALL.Windows
- gzip -9 < $< > $@
-
-LICENSE.gz: LICENSE
- gzip -9 < $< > $@
-
-NEWS.gz: NEWS
- gzip -9 < $< > $@
-
-NOTICE.gz: NOTICE
- gzip -9 < $< > $@
-
-README.gz: README
- gzip -9 < $< > $@
-
-THANKS.gz: THANKS
- gzip -9 < $< > $@
-
-check: dev check-js
-if TESTS
- $(top_builddir)/test/etap/run $(top_srcdir)/test/etap
-endif
-
-check-js: dev
-if TESTS
-if USE_CURL
- MAKE=$(MAKE) $(top_builddir)/test/javascript/run
-endif
-endif
-
-check-etap: dev
-if TESTS
- $(top_builddir)/test/etap/run $(top_srcdir)/test/etap
-endif
-
-cover: dev
-if TESTS
- rm -f cover/*.coverdata
- COVER=1 COVER_BIN=./src/couch/ebin $(top_builddir)/test/etap/run
- SRC=./src/couch/src \
- $(ERL) -noshell \
- -pa src/etap \
- -eval 'etap_report:create()' \
- -s init stop > /dev/null 2>&1
-endif
-
-dev: all
-if TESTS
- @echo "This command is intended for developers to use;"
- @echo "it creates development ini files as well as a"
- @echo "$(top_builddir)/tmp structure for development runtime files."
- @echo "Use ./utils/run to launch CouchDB from the source tree."
- mkdir -p $(top_builddir)/etc/couchdb/default.d
- mkdir -p $(top_builddir)/etc/couchdb/local.d
- mkdir -p $(top_builddir)/tmp/lib
- mkdir -p $(top_builddir)/tmp/log
- mkdir -p $(top_builddir)/tmp/run/couchdb
-endif
-
-install-data-hook:
- @echo
- @echo "You have installed Apache CouchDB, time to relax."
-
-distclean-local:
- rm -fr $(top_builddir)/etc/couchdb/default.d
- rm -fr $(top_builddir)/etc/couchdb/local.d
- rm -fr $(top_builddir)/tmp
- rm -f $(top_builddir)/couchdb.stdout
- rm -f $(top_builddir)/couchdb.stderr
-
-.PHONY: local-clean
-local-clean: maintainer-clean
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may need special tools to rebuild."
- rm -f $(top_srcdir)/INSTALL
- rm -f $(top_srcdir)/acinclude.m4
- rm -f $(top_srcdir)/aclocal.m4
- rm -f $(top_srcdir)/config.h.in
- rm -f $(top_srcdir)/configure
- rm -f $(top_srcdir)/test/etap/temp.*
- rm -f $(top_srcdir)/*.tar.gz
- rm -f $(top_srcdir)/*.tar.gz.*
- find $(top_srcdir) -name Makefile.in -exec rm -f {} \;
-
-dist-hook:
- find $(top_srcdir) -type f -name "._*" -exec rm -f {} \;
- find $(top_builddir) -type f -name "._*" -exec rm -f {} \;
-
-distcheck-hook:
- $(MAKE) -C bin distcheck-hook
- $(MAKE) -C src/couch/priv distcheck-hook
- $(MAKE) -C share/doc/build distcheck-hook
- grep -rL 'http://www.apache.org/licenses/LICENSE-2.0' * \
- | grep --include= -vEf license.skip; \
- test "$$?" -eq 1
-
-.PHONY: distsign
-distsign: distcheck check
- gpg --armor --detach-sig $(GPG_ARGS) \
- < $(top_srcdir)/$(distdir).tar.gz \
- > $(top_srcdir)/$(distdir).tar.gz.asc
- md5sum $(top_srcdir)/$(distdir).tar.gz \
- > $(top_srcdir)/$(distdir).tar.gz.md5
- sha1sum $(top_srcdir)/$(distdir).tar.gz \
- > $(top_srcdir)/$(distdir).tar.gz.sha
diff --git a/bin/Makefile.am b/bin/Makefile.am
deleted file mode 100644
index 95471eab8..000000000
--- a/bin/Makefile.am
+++ /dev/null
@@ -1,154 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-MAKE_SAFE = $(MAKE)
-
-if WINDOWS
-bin_SCRIPTS = couchdb.bat
-else
-bin_SCRIPTS = couchdb couch-config
-endif
-
-man1dir = $(mandir)/man1
-
-noinst_SCRIPTS = couchjs_dev couch-config_dev
-
-man_file = couchdb.1
-
-if BUILD_MAN
-man_file_build = $(man_file)
-else
-man_file_build =
-endif
-
-BUILT_SOURCES = $(man_file_build)
-
-EXTRA_DIST = $(man_file_build)
-
-CLEANFILES = $(bin_SCRIPTS) $(man_file_build) $(noinst_SCRIPTS)
-
-transform = @program_transform_name@
-couchdb_command_name = `echo couchdb | sed '$(transform)'`
-couchjs_command_name = `echo couchjs | sed '$(transform)'`
-
-couchdb: couchdb.tpl
- sed -e "s|%ERL%|$(ERL)|g" \
- -e "s|%ICU_CONFIG%|$(ICU_CONFIG)|g" \
- -e "s|%bindir%|@bindir@|g" \
- -e "s|%localerlanglibdir%|@localerlanglibdir@|g" \
- -e "s|%defaultini%|default.ini|g" \
- -e "s|%localini%|local.ini|g" \
- -e "s|%localconfdir%|@localconfdir@|g" \
- -e "s|%localstatelogdir%|@localstatelogdir@|g" \
- -e "s|%localstatelibdir%|@localstatelibdir@|g" \
- -e "s|%localstatedir%|@localstatedir@|g" \
- -e "s|%bug_uri%|@bug_uri@|g" \
- -e "s|%package_author_address%|@package_author_address@|g" \
- -e "s|%package_author_name%|@package_author_name@|g" \
- -e "s|%package_name%|@package_name@|g" \
- -e "s|%version%|@version@|g" \
- -e "s|%couchdb_command_name%|$(couchdb_command_name)|g" > \
- $@ < $<
- chmod +x $@
-
-if !WINDOWS
-install-exec-hook:
- $(LN_S) -f "$(locallibbindir)/$(couchjs_command_name)" \
- "$(DESTDIR)$(bindir)/$(couchjs_command_name)"
-endif
-
-couchjs_dev:
- $(LN_S) -f "$(abs_top_builddir)/src/couch/priv/couchjs" "$@"
-
-couchdb.bat: couchdb.bat.tpl
- sed -e "s|%ICU_CONFIG%|$(ICU_CONFIG)|g" \
- -e "s|%version%|@version@|g" \
- $< > $@
-
-couch-config: couch-config.tpl
- sed -e "s|%ERL%|$(ERL)|g" \
- -e "s|%bindir%|@bindir@|g" \
- -e "s|%localerlanglibdir%|@localerlanglibdir@|g" \
- -e "s|%localconfdir%|@localconfdir@|g" \
- -e "s|%localdatadir%|$(localdatadir)|g" \
- -e "s|%localbuilddatadir%|$(localdatadir)|g" \
- -e "s|%localstatelogdir%|@localstatelogdir@|g" \
- -e "s|%localstatelibdir%|@localstatelibdir@|g" \
- -e "s|%localstatedir%|@localstatedir@|g" \
- -e "s|%localstaterundir%|@localstaterundir@|g" \
- -e "s|%couchlibdir%|@localerlanglibdir@/couch-%version%|g"\
- -e "s|%couchincludedir%|@localerlanglibdir@/include|g"\
- -e "s|%couchebindir%|@localerlanglibdir@/ebin|g"\
- -e "s|%couchprivlibdir%|@localerlanglibdir@/couch-%version%/priv/lib|g"\
- -e "s|%bug_uri%|@bug_uri@|g" \
- -e "s|%package_author_address%|@package_author_address@|g" \
- -e "s|%package_author_name%|@package_author_name@|g" \
- -e "s|%package_name%|@package_name@|g" \
- -e "s|%version%|@version@|g" \
- -e "s|%couchdb_command_name%|$(couchdb_command_name)|g" > \
- $@ < $<
- chmod +x $@
-
-couch-config_dev: couch-config.tpl
- sed -e "s|%ERL%|$(ERL)|g" \
- -e "s|%bindir%|$(abs_top_builddir)/bin|g" \
- -e "s|%localerlanglibdir%|$(abs_top_builddir)\/src\/couchdb|g" \
- -e "s|%couchlibdir%|$(abs_top_builddir)\/src\/couchdb|g"\
- -e "s|%couchincludedir%|$(abs_top_builddir)\/src\/couchdb|g"\
- -e "s|%couchebindir%|$(abs_top_builddir)\/src\/couchdb|g"\
- -e "s|%couchprivlibdir%|$(abs_top_builddir)/src/couchdb/priv/.libs|g"\
- -e "s|%localdatadir%|$(abs_top_srcdir)/share|g" \
- -e "s|%localbuilddatadir%|$(abs_top_builddir)/share|g" \
- -e "s|%localstatelibdir%|$(abs_top_builddir)/tmp/lib|g" \
- -e "s|%localstatelogdir%|$(abs_top_builddir)/tmp/log|g" \
- -e "s|%localstatedir%|$(abs_top_builddir)/tmp|g" \
- -e "s|%localstaterundir%|$(abs_top_builddir)/tmp/run|g" \
- -e "s|%bug_uri%|@bug_uri@|g" \
- -e "s|%package_author_address%|@package_author_address@|g" \
- -e "s|%package_author_name%|@package_author_name@|g" \
- -e "s|%package_name%|@package_name@|g" \
- -e "s|%version%|@version@|g" \
- -e "s|%couchdb_command_name%|$(abs_top_builddir)/utils/run|g" > \
- $@ < $<
- chmod +x $@
-
-# Depend on source files so distributed man pages are not rebuilt for end user.
-
-$(man_file): couchdb.tpl.in
- $(MAKE_SAFE) -f Makefile couchdb; \
- $(top_srcdir)/build-aux/missing --run \
- help2man \
- --no-info \
- --help-option="-h" \
- --version-option="-V" \
- --name="$(package_name) database server" \
- ./couchdb --output $@
-
-install-data-local:
- if test -s $(man_file); then \
- if test `cat $(man_file) | wc -l` -gt 1; then \
- $(INSTALL) -d $(DESTDIR)$(man1dir); \
- $(INSTALL_DATA) $(man_file) $(DESTDIR)$(man1dir)/$(man_file); \
- fi \
- fi
-
-uninstall-local:
- rm -f $(DESTDIR)$(man1dir)/$(man_file)
-
-distcheck-hook:
- if test ! -s $(man_file); then \
- $(top_srcdir)/build-aux/dist-error $(man_file); \
- else \
- if test ! `cat $(man_file) | wc -l` -gt 1; then \
- $(top_srcdir)/build-aux/dist-error $(man_file); \
- fi \
- fi
diff --git a/bootstrap b/bootstrap
deleted file mode 100755
index 021275bad..000000000
--- a/bootstrap
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/bin/sh -e
-
-# Licensed under the Apache License, Version 2.0 (the "License"); you may not
-# use this file except in compliance with the License. You may obtain a copy of
-# the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations under
-# the License.
-
-cd `dirname $0`
-
-get () {
- variable_name=$1
- echo "changequote(\`[', \`]')" > acinclude.m4.tmp
- sed -e "s/m4_//" < acinclude.m4.in >> acinclude.m4.tmp
- echo $variable_name >> acinclude.m4.tmp
- if test -x "`which gm4 2> /dev/null || true`"; then
- gm4 acinclude.m4.tmp | grep -v "^$" || true
- else
- if test -x "`which m4 2> /dev/null || true`"; then
- m4 acinclude.m4.tmp | grep -v "^$" || true
- else
- echo unknown
- fi
- fi
- rm -f acinclude.m4.tmp
-}
-
-if test -z "$REVISION"; then
- if test -e .git; then
- REVISION=`git describe --always`-git
- fi
-fi
-
-if test -z "`get LOCAL_VERSION_STAGE`" -o -z "$REVISION"; then
- sed "s/%release%//" < acinclude.m4.in > acinclude.m4
-else
- sed "s/%release%/$REVISION/" < acinclude.m4.in > acinclude.m4
-fi
-
-if test -e .git; then
- OS=`uname -s`
- case "$OS" in
- Linux|CYGWIN*) # GNU sed
- SED_ERE_FLAG=-r
- ;;
- *) # BSD sed
- SED_ERE_FLAG=-E
- ;;
- esac
-
- sed -e "/^#.*/d" THANKS.in > THANKS
- CONTRIB_EMAIL_SED_COMMAND="s/^[[:blank:]]{5}[[:digit:]]+[[:blank:]]/ * /"
- git shortlog -se 6c976bd..HEAD \
- | grep -v @apache.org \
- | sed $SED_ERE_FLAG -e "$CONTRIB_EMAIL_SED_COMMAND" >> THANKS
- echo "" >> THANKS # simplest portable newline
- echo "For a list of authors see the \`AUTHORS\` file." >> THANKS
-fi
-
-find_program() {
- set +e
- for f in "$@"
- do
- file=`which ${f} 2>/dev/null | grep -v '^no '`
- if test -n "x${file}" -a -x "${file}"
- then
- echo ${file}
- set -e
- exit 0
- fi
- done
-
- echo "Unable to find any variant: $@" 1>&2
- echo 1>&2
- echo "Have you installed a version of this package?" 1>&2
- set -e
- exit 1
-}
-
-LIBTOOLIZE=`find_program glibtoolize libtoolize`
-ACLOCAL=`find_program aclocal-1.11 aclocal-1.10 aclocal-1.9 aclocal`
-AUTOHEADER=`find_program autoheader`
-AUTOMAKE=`find_program automake-1.11 automake-1.10 automake-1.9 automake`
-AUTOCONF=`find_program autoconf`
-
-get_aclocal_dir_list () {
- aclocal_dir=`$ACLOCAL --print-ac-dir`
- echo $aclocal_dir
- aclocal_dirlist="$aclocal_dir/dirlist"
- if test -e $aclocal_dirlist; then
- cat $aclocal_dirlist | while read dir; do
- if test -d "$dir"; then
- echo $dir
- fi
- done
- fi
-}
-
-aclocal_dir_list=`get_aclocal_dir_list`
-
-if test -z "`find $aclocal_dir_list -name ax_check_icu.m4`"; then
- echo "Unable to find the \`ax_check_icu.m4' file."
- echo
- echo "Have you installed GNU Autoconf Archive?"
- exit 1
-fi
-
-if test -z "`find $aclocal_dir_list -name ax_lib_curl.m4`"; then
- echo "Unable to find the \`ax_check_icu.m4' file."
- echo
- echo "Have you installed GNU Autoconf Archive?"
- exit 1
-fi
-
-if test -z "`find $aclocal_dir_list -name pkg.m4`"; then
- echo "Unable to find the \`pkg.m4' file."
- echo
- echo "Have you installed pkg-config?"
- exit 1
-fi
-
-
-mkdir -p build-aux
-mkdir -p m4
-
-${LIBTOOLIZE} -f -c --automake
-${ACLOCAL} -I m4 -Wall
-${AUTOHEADER} -f
-${AUTOMAKE} -f -a -Wall
-${AUTOCONF} -f -Wall
-
-rm -f INSTALL
-
-ln -f -s "`dirname \`readlink build-aux/missing\``/INSTALL"
-
-if test ! -s INSTALL; then
- echo "Broken INSTALL file."
- exit 1
-fi
-
-cat << EOF
-You have bootstrapped Apache CouchDB, time to relax.
-
-Run \`./configure' to configure the source before you install.
-EOF \ No newline at end of file
diff --git a/configure b/configure
new file mode 100755
index 000000000..4e59ca607
--- /dev/null
+++ b/configure
@@ -0,0 +1,82 @@
+#!/bin/sh
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+PREFIX="/opt/couchdb"
+COUCHDB_USER=`whoami`
+ABSPATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
+if test ! -n "$DIRPATH"; then DIRPATH=`dirname "$ABSPATH"`; fi
+
+while [ $# -gt 0 ]
+do
+ case $1
+ in
+ -p)
+ PREFIX=$2
+ shift 2
+ ;;
+ -t)
+ TEMPLATE=$2
+ shift 2
+ ;;
+ -d)
+ DATA=$2
+ shift 2
+ ;;
+ -v)
+ VIEW=$2
+ shift 2
+ ;;
+ -u)
+ COUCHDB_USER=$2
+ shift 2
+ ;;
+ *)
+ echo "usage: $0 [-p {prefix} -t {template} -d {data_dir} -v {view_dir} -u {user}]"
+ exit
+ ;;
+ esac
+done
+
+if test ! -n "$DATA"; then DATA="$PREFIX/var/lib"; fi
+if test ! -n "$VIEW"; then VIEW="$PREFIX/var/lib"; fi
+
+echo "==> configuring couchdb in rel/couchdb.config"
+cat > rel/couchdb.config << EOF
+{prefix, "$PREFIX"}.
+{data_dir, "$DATA"}.
+{view_dir, "$VIEW"}.
+{user, "$COUCHDB_USER"}.
+{node_name, "-name couchdb"}.
+{cluster_port, 5984}.
+{backend_port, 5986}.
+EOF
+
+cat > install.mk << EOF
+# The contents of this file are auto-generated by configure
+prefix = $PREFIX
+data_dir = $DATA
+view_dir = $VIEW
+user = $COUCHDB_USER
+EOF
+
+# finally, a few config files for local development nodes
+for i in 1 2 3; do
+cat > rel/dev$i.config << EOF
+{prefix, "$DIRPATH/rel/dev$i"}.
+{data_dir, "$DIRPATH/rel/tmpdata/dev$i"}.
+{view_dir, "$DIRPATH/rel/tmpdata/dev$i"}.
+{node_name, "-name dev$i@127.0.0.1"}.
+{cluster_port, `expr 10000 \* $i + 5984`}.
+{backend_port, `expr 10000 \* $i + 5986`}.
+EOF
+done
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 4a8edf6a6..000000000
--- a/configure.ac
+++ /dev/null
@@ -1,789 +0,0 @@
-dnl Licensed under the Apache License, Version 2.0 (the "License"); you may not
-dnl use this file except in compliance with the License. dnl You may obtain a
-dnl copy of the License at
-dnl
-dnl http://www.apache.org/licenses/LICENSE-2.0
-dnl
-dnl Unless required by applicable law or agreed to in writing, software
-dnl distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-dnl WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-dnl License for the specific language governing permissions and limitations
-dnl under the License.
-
-AC_INIT(
- [LOCAL_PACKAGE_NAME],
- [LOCAL_VERSION],
- [LOCAL_BUG_URI],
- [LOCAL_PACKAGE_TARNAME])
-
-AC_PREREQ([2.68])
-
-AC_CONFIG_SRCDIR([CHANGES])
-AC_CONFIG_AUX_DIR([build-aux])
-AC_CONFIG_MACRO_DIR([m4])
-
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_HEADERS([src/snappy/c_src/google-snappy/config.h])
-
-AM_INIT_AUTOMAKE([1.6.3 foreign])
-
-AC_USE_SYSTEM_EXTENSIONS
-AC_ENABLE_SHARED
-AC_DISABLE_STATIC
-
-AC_PROG_CC
-LT_INIT([win32-dll])
-LT_INIT
-AC_PROG_LN_S
-
-PKG_PROG_PKG_CONFIG
-
-dnl Config for google snappy
-m4_define([snappy_major], [1])
-m4_define([snappy_minor], [0])
-m4_define([snappy_patchlevel], [3])
-
-AC_PROG_CXX
-AC_LANG([C++])
-AC_C_BIGENDIAN
-AC_CHECK_HEADERS([stdint.h stddef.h sys/mman.h sys/resource.h])
-AC_CHECK_FUNC([mmap])
-
-AC_MSG_CHECKING([if the compiler supports __builtin_expect])
-
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
- return __builtin_expect(1, 1) ? 1 : 0
-]])],[
- snappy_have_builtin_expect=yes
- AC_MSG_RESULT([yes])
-],[
- snappy_have_builtin_expect=no
- AC_MSG_RESULT([no])
-])
-
-if test x$snappy_have_builtin_expect = xyes ; then
- AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
- [Define to 1 if the compiler supports __builtin_expect.])
-fi
-
-AC_MSG_CHECKING([if the compiler supports __builtin_ctzll])
-
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
- return (__builtin_ctzll(0x100000000LL) == 32) ? 1 : 0
-]])],[
- snappy_have_builtin_ctz=yes
- AC_MSG_RESULT([yes])
-],[
- snappy_have_builtin_ctz=no
- AC_MSG_RESULT([no])
-])
-
-if test x$snappy_have_builtin_ctz = xyes ; then
- AC_DEFINE([HAVE_BUILTIN_CTZ], [1],
- [Define to 1 if the compiler supports __builtin_ctz and friends.])
-fi
-
-if test "$ac_cv_header_stdint_h" = "yes"; then
- AC_SUBST([ac_cv_have_stdint_h], [1])
-else
- AC_SUBST([ac_cv_have_stdint_h], [0])
-fi
-if test "$ac_cv_header_stddef_h" = "yes"; then
- AC_SUBST([ac_cv_have_stddef_h], [1])
-else
- AC_SUBST([ac_cv_have_stddef_h], [0])
-fi
-
-SNAPPY_MAJOR="snappy_major"
-SNAPPY_MINOR="snappy_minor"
-SNAPPY_PATCHLEVEL="snappy_patchlevel"
-
-AC_SUBST([SNAPPY_MAJOR])
-AC_SUBST([SNAPPY_MINOR])
-AC_SUBST([SNAPPY_PATCHLEVEL])
-
-AC_MSG_CHECKING([for pthread_create in -lpthread])
-
-original_LIBS="$LIBS"
-LIBS="-lpthread $original_LIBS"
-
-AC_LINK_IFELSE([
- AC_LANG_PROGRAM(
- [[#include<pthread.h>]],
- [[pthread_create((void *)0, (void *)0, (void *)0, (void *)0)]])],
- [pthread=yes],
- [pthread=no])
-
-if test x${pthread} = xyes; then
- AC_MSG_RESULT([yes])
-else
- LIBS="$original_LIBS"
- AC_MSG_RESULT([no])
-fi
-
-AC_PATH_PROG([ERL], [erl])
-
-AS_IF([test x${ERL} = x], [
- AC_MSG_ERROR([Could not find the `erl' executable. Is Erlang installed?])
-])
-
-AC_ARG_WITH([erlang],
- [AS_HELP_STRING([--with-erlang=PATH],
- [set PATH to the Erlang include directory])
-], [
- ERLANG_FLAGS="-I$withval"
-], [
- realerl=`readlink -f $ERL 2>/dev/null`
- AS_IF([test $? -eq 0], [
- erlbase=`dirname $realerl`
- erlbase=`dirname $erlbase`
- ERLANG_FLAGS="-I${erlbase}/usr/include"
- ], [
- # Failed to figure out where erl is installed..
- # try to add some default directories to search
- ERLANG_FLAGS="-I${libdir}/erlang/usr/include"
- ERLANG_FLAGS="$ERLANG_FLAGS -I/usr/lib/erlang/usr/include"
- ERLANG_FLAGS="$ERLANG_FLAGS -I/usr/local/lib/erlang/usr/include"
- ERLANG_FLAGS="$ERLANG_FLAGS -I/opt/local/lib/erlang/usr/include"
- ])
-])
-
-AC_SUBST(ERLANG_FLAGS)
-
-PKG_CHECK_MODULES([JS], [mozjs185], [
- JS_LIB_DIR="$(${PKG_CONFIG} --variable=libdir mozjs185)"
-], [
- PKG_CHECK_MODULES([JS], [mozilla-js >= 1.7], [
- JS_LIB_DIR="$(${PKG_CONFIG} --variable=sdkdir mozilla-js)/lib"
- ], [
- JS_LIB_DIR="${libdir}"
- JS_CFLAGS="-I/usr/include"
- JS_CFLAGS="$JS_CFLAGS -I/usr/include/js"
- JS_CFLAGS="$JS_CFLAGS -I/usr/include/mozjs"
- JS_CFLAGS="$JS_CFLAGS -I/usr/local/include/js"
- JS_CFLAGS="$JS_CFLAGS -I/opt/local/include/js"
- ])
-])
-
-AC_ARG_WITH([js-include],
- [AS_HELP_STRING([--with-js-include=PATH],
- [set PATH to the SpiderMonkey include directory])
-], [
- JS_INCLUDE="$withval"
- JS_CFLAGS="-I$JS_INCLUDE"
-], [])
-
-AC_ARG_WITH([js-lib],
- [AS_HELP_STRING([--with-js-lib=PATH],
- [set PATH to the SpiderMonkey library directory])
-], [
- JS_LIB_DIR=$withval
- JS_LIBS="-L$withval"
-], [])
-
-use_js_trunk=no
-
-AC_ARG_ENABLE([js-trunk],
- [AS_HELP_STRING([--enable-js-trunk],
- [allow use of SpiderMonkey versions newer than js185-1.0.0])
-], [
- use_js_trunk=$enableval
-], [])
-
-AC_ARG_VAR([ERLC_FLAGS], [general flags to prepend to ERLC_FLAGS])
-AC_ARG_VAR([FLAGS], [general flags to prepend to LDFLAGS and CPPFLAGS])
-
-AS_CASE([$(uname -s)], [CYGWIN*], [] , [*], [
- CPPFLAGS="$CPPFLAGS -I/opt/local/include"
- CPPFLAGS="$CPPFLAGS -I/opt/local/include/js"
- CPPFLAGS="$CPPFLAGS -I/usr/local/include"
- CPPFLAGS="$CPPFLAGS -I/usr/local/include/js"
- CPPFLAGS="$CPPFLAGS -I/usr/include"
- CPPFLAGS="$CPPFLAGS -I/usr/include/js"
- LDFLAGS="$LDFLAGS -L/opt/local/lib"
- LDFLAGS="$LDFLAGS -L/usr/local/lib"
-])
-
-CPPFLAGS="$CPPFLAGS $FLAGS"
-LDFLAGS="$LDFLAGS $FLAGS"
-
-# The erlang cc.sh/ld.sh scripts will convert a -O option
-# into the same optimization flags erlang itself uses.
-CFLAGS="-O2 $CFLAGS"
-
-LIBS="$LIBS $LDFLAGS"
-
-AS_CASE([$(uname -s)], [CYGWIN*], [
- JS_CFLAGS="-DXP_WIN $JS_CFLAGS"
- IS_WINDOWS="TRUE"
-], [*], [
- # XP_UNIX required for jsapi.h, tested on Linux and Darwin.
- JS_CFLAGS="-DXP_UNIX $JS_CFLAGS"
-])
-
-AM_CONDITIONAL([WINDOWS], [test x$IS_WINDOWS = xTRUE])
-
-OLD_LIBS="$LIBS"
-LIBS="$JS_LIBS $LIBS"
-
-OLD_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$JS_CFLAGS $CPPFLAGS"
-
-AC_CHECK_HEADER([jsapi.h], [], [
- AC_CHECK_HEADER([js/jsapi.h], [
- CPPFLAGS="$CPPFLAGS -I$JS_INCLUDE/js"
- ], [
- AC_MSG_ERROR([Could not find the jsapi header.
-
-Are the Mozilla SpiderMonkey headers installed?])
- ])
-])
-
-AC_CHECK_LIB([mozjs185], [JS_NewContext], [JS_LIB_BASE=mozjs185], [
- AC_CHECK_LIB([mozjs185-1.0], [JS_NewContext], [JS_LIB_BASE=mozjs185-1.0], [
- AC_CHECK_LIB([mozjs], [JS_NewContext], [JS_LIB_BASE=mozjs], [
- AC_CHECK_LIB([js], [JS_NewContext], [JS_LIB_BASE=js], [
- AC_CHECK_LIB([js3250], [JS_NewContext], [JS_LIB_BASE=js3250], [
- AC_CHECK_LIB([js32], [JS_NewContext], [JS_LIB_BASE=js32], [
- AC_MSG_ERROR([Could not find the js library.
-
-Is the Mozilla SpiderMonkey library installed?])
- ])
- ])
- ])
- ])
- ])
-])
-
-# Figure out what version of SpiderMonkey to use
-
-AC_CHECK_LIB([$JS_LIB_BASE], [JS_NewCompartmentAndGlobalObject],
- # Prevent people from accidentally using SpiderMonkey's that are too new
- if test "$use_js_trunk" = "no"; then
- AC_CHECK_DECL([JSOPTION_ANONFUNFIX], [], [
- AC_MSG_ERROR([Your SpiderMonkey library is too new.
-
-Versions of SpiderMonkey after the js185-1.0.0 release remove the optional
-enforcement of preventing anonymous functions in a statement context. This
-will most likely break your existing JavaScript code as well as render all
-example code invalid.
-
-If you wish to ignore this error pass --enable-js-trunk to ./configure.])
- ], [
- [#include <jsapi.h>]
- ])
- fi
- AC_DEFINE([SM185], [1], [Use SpiderMonkey 1.8.5])
-)
-
-AC_CHECK_LIB([$JS_LIB_BASE], [JS_ThrowStopIteration],
- AC_DEFINE([SM180], [1],
- [Use SpiderMonkey 1.8.0])
-)
-
-AC_CHECK_LIB([$JS_LIB_BASE], [JS_GetStringCharsAndLength],
- AC_DEFINE([HAVE_JS_GET_STRING_CHARS_AND_LENGTH], [1],
- [Use newer JS_GetCharsAndLength function.])
-)
-
-# Else, hope that 1.7.0 works
-
-# Deal with JSScript to JSObject to JSScript switcheroo
-
-AC_CHECK_TYPE([JSScript*],
- [AC_DEFINE([JSSCRIPT_TYPE], [JSScript*], [Use JSObject* for scripts])],
- [AC_DEFINE([JSSCRIPT_TYPE], [JSObject*], [Use JSScript* for scripts])],
- [[#include <jsapi.h>]]
-)
-
-AC_DEFINE([COUCHJS_NAME], ["couchjs"], ["CouchJS executable name."])
-
-if test x${IS_WINDOWS} = xTRUE; then
- AC_DEFINE([COUCHJS_NAME], ["couchjs.exe"], ["CouchJS executable name."])
- if test -f "$JS_LIB_DIR/$JS_LIB_BASE.dll"; then
- # seamonkey 1.7- build layout on Windows
- JS_LIB_BINARY="$JS_LIB_DIR/$JS_LIB_BASE.dll"
- else
- # seamonkey 1.8+ build layout on Windows
- if test -f "$JS_LIB_DIR/../bin/$JS_LIB_BASE.dll"; then
- JS_LIB_BINARY="$JS_LIB_DIR/../bin/$JS_LIB_BASE.dll"
- else
- AC_MSG_ERROR([Could not find $JS_LIB_BASE.dll.])
- fi
- fi
- AC_SUBST(JS_LIB_BINARY)
- # On windows we need to know the path to the openssl binaries.
- AC_ARG_WITH([openssl-bin-dir],
- [AS_HELP_STRING([--with-openssl-bin-dir=PATH],
- [path to the open ssl binaries for distribution on Windows])
- ], [
- openssl_bin_dir=`cygpath -m "$withval"`
- AC_SUBST(openssl_bin_dir)
- ], [])
- # Windows uses Inno setup - look for its compiler.
- AC_PATH_PROG([INNO_COMPILER_EXECUTABLE], [iscc])
- if test x${INNO_COMPILER_EXECUTABLE} = x; then
- AC_MSG_WARN([You will be unable to build the Windows installer.])
- fi
- # We need the msvc redistributables for this platform too
- # (in theory we could just install the assembly locally - but
- # there are at least 4 directories with binaries, meaning 4 copies;
- # so using the redist .exe means it ends up installed globally...)
- AC_ARG_WITH([msvc-redist-dir],
- [AS_HELP_STRING([--with-msvc-redist-dir=PATH],
- [path to the msvc redistributables for the Windows platform])
- ], [
- msvc_redist_dir=`cygpath -m "$withval"`
- msvc_redist_name="vcredist_x86.exe"
- AC_SUBST(msvc_redist_dir)
- AC_SUBST(msvc_redist_name)
- ], [])
- if test ! -f ${msvc_redist_dir}/${msvc_redist_name}; then
- AC_MSG_WARN([Installer may fail due to missing MSVC redistributable.])
- fi
-fi
-
-JS_LIBS="-l$JS_LIB_BASE -lm $JS_LIBS"
-
-AC_SUBST(JS_LIBS)
-
-LIBS="$OLD_LIBS"
-CPPFLAGS="$OLD_CPPFLAGS"
-
-AC_ARG_WITH([win32-icu-binaries],
- [AS_HELP_STRING([--with-win32-icu-binaries=PATH],
- [set PATH to the Win32 native ICU binaries directory])
-], [
- ICU_CPPFLAGS="-I$withval/include"
- ICU_LIBS="-L$withval/lib -licuuc -licudt -licuin"
- ICU_BIN=$withval/bin
-], [
- AX_CHECK_ICU([3.4.1])
- ICU_BIN=
-])
-
-AC_SUBST(ICU_CFLAGS)
-AC_SUBST(ICU_CPPFLAGS)
-AC_SUBST(ICU_LIBS)
-AC_SUBST(ICU_BIN)
-
-use_curl=yes
-
-AC_ARG_WITH([win32-curl],
- [AS_HELP_STRING([--with-win32-curl=PATH],
- [set PATH to the Win32 native curl directory])
-], [
- # default build on windows is a static lib, and that's what we want too
- CURL_CFLAGS="-I$withval/include -DCURL_STATICLIB"
- CURL_LIBS="-L$withval/lib -llibcurl -lWs2_32 -lkernel32 -luser32 -ladvapi32 -lWldap32"
- # OpenSSL libraries may be pulled in via libcurl if it was built with SSL
- # these are libeay32 ssleay32 instead of crypto ssl on unix
-], [
- AX_LIB_CURL([7.18.0],[
- AC_DEFINE([HAVE_CURL], [1], ["Provide HTTP support to couchjs"])
- ],[
- AC_MSG_WARN([You will be unable to run some JavaScript unit tests.])
- use_curl=no
- CURL_LIBS=
- ])
-])
-
-AC_SUBST(CURL_CFLAGS)
-AC_SUBST(CURL_LIBS)
-
-case "$(uname -s)" in
- Linux)
- LIBS="$LIBS -lcrypt"
- CPPFLAGS="-D_XOPEN_SOURCE $CPPFLAGS"
- ;;
- FreeBSD)
- LIBS="$LIBS -lcrypt"
- ;;
- OpenBSD)
- LIBS="$LIBS -lcrypto"
- ;;
-esac
-
-
-erlang_version_error="The installed Erlang version is less than 5.7.4 (R13B04)."
-
-version="`${ERL} -version 2>&1 | ${SED} 's/[[^0-9]]/ /g'`"
-
-if test `echo $version | ${AWK} "{print \\$1}"` -lt 5; then
- AC_MSG_ERROR([$erlang_version_error])
-fi
-
-if test `echo $version | ${AWK} "{print \\$2}"` -lt 7; then
- AC_MSG_ERROR([$erlang_version_error])
-fi
-
-if test `echo $version | ${AWK} "{print \\$2}"` -eq 7; then
- if test `echo $version | ${AWK} "{print \\$3}"` -lt 4; then
- AC_MSG_ERROR([$erlang_version_error])
- fi
-fi
-
-otp_release="`\
- ${ERL} -noshell \
- -eval 'io:put_chars(erlang:system_info(otp_release)).' \
- -s erlang halt`"
-
-AC_SUBST(otp_release)
-
-AM_CONDITIONAL([USE_OTP_NIFS], [test x$otp_release \> xR13B03])
-AM_CONDITIONAL([USE_EJSON_COMPARE_NIF], [test x$otp_release \> xR14B03])
-
-has_crypto=`\
- ${ERL} -eval "\
- case application:load(crypto) of ok -> ok; _ -> exit(no_crypto) end. \
- " -noshell -s init stop`
-
-if test -n "$has_crypto"; then
- AC_MSG_ERROR([Could not find the Erlang crypto library.
-
-Has Erlang been compiled with OpenSSL support?])
-fi
-
-AC_PATH_PROG([ERLC], [erlc])
-
-if test x${ERLC} = x; then
- AC_MSG_ERROR([Could not find the `erlc' executable.
-
-Is Erlang installed?])
-fi
-
-OLD_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$ERLANG_FLAGS $CPPFLAGS"
-
-AC_CHECK_HEADER([erl_driver.h], [], [
- AC_MSG_ERROR([Could not find the `erl_driver.h' header.
-
-Are the Erlang headers installed?
-
-Use the `--with-erlang' option to specify the Erlang include directory.])
-])
-
-CPPFLAGS="$OLD_CPPFLAGS"
-
-use_init=yes
-use_launchd=yes
-native_mochijson_enabled=no
-tests_enabled=yes
-docs_enabled=yes
-strictness_enabled=no
-
-AC_ARG_ENABLE([init],
- [AS_HELP_STRING([--disable-init],
- [don't install init script where applicable])
-], [
- use_init=$enableval
-], [])
-
-AC_ARG_ENABLE([launchd],
- [AS_HELP_STRING([--disable-launchd],
- [don't install launchd configuration where applicable])
-], [
- use_launchd=$enableval
-], [])
-
-AC_ARG_ENABLE([native-mochijson],
- [AS_HELP_STRING([--enable-native-mochijson],
- [compile mochijson to native code (EXPERIMENTAL)])
-], [
- native_mochijson_enabled=$enableval
-], [])
-
-AC_ARG_ENABLE([tests],
- [AS_HELP_STRING([--disable-tests],
- [skip tests during build])
-], [
- tests_enabled=$enableval
-], [])
-
-AC_ARG_ENABLE([docs],
- [AS_HELP_STRING([--disable-docs],
- [skip docs during build])
-], [
- docs_enabled=$enableval
-], [])
-
-AC_ARG_ENABLE([strictness],
- [AS_HELP_STRING([--enable-strictness],
- [exit when optional checks fail])
-], [
- strictness_enabled=$enableval
-], [])
-
-init_enabled=false
-launchd_enabled=false
-
-if test "$use_init" = "yes"; then
- AC_MSG_CHECKING(location of init directory)
- if test -d /etc/rc.d; then
- init_enabled=true
- AC_SUBST([initdir], ['${sysconfdir}/rc.d'])
- AC_MSG_RESULT(${initdir})
- else
- if test -d /etc/init.d; then
- init_enabled=true
- AC_SUBST([initdir], ['${sysconfdir}/init.d'])
- AC_MSG_RESULT(${initdir})
- else
- AC_MSG_RESULT(not found)
- fi
- fi
-fi
-
-if test "$use_launchd" = "yes"; then
- AC_MSG_CHECKING(location of launchd directory)
- if test -d /Library/LaunchDaemons; then
- init_enabled=false
- launchd_enabled=true
- AC_SUBST([launchddir], ['${prefix}/Library/LaunchDaemons'])
- AC_MSG_RESULT(${launchddir})
- else
- AC_MSG_RESULT(not found)
- fi
-fi
-
-AC_CHECK_PROG([HAS_HELP2MAN], [help2man], [yes])
-
-if test x${HAS_HELP2MAN} = x; then
- if test x${strictness_enabled} = xyes; then
- AC_MSG_ERROR([Could not find the `help2man' executable.])
- else
- AC_MSG_WARN([You will be unable to regenerate man pages.])
- fi
-fi
-
-AC_CHECK_PROG([HAS_PDFLATEX], [pdflatex], [yes])
-
-if test x${HAS_PDFLATEX} = x; then
- if test x${strictness_enabled} = xyes; then
- AC_MSG_ERROR([Could not find the `pdflatex' executable.
-
-Is LaTeX installed?])
- else
- AC_MSG_WARN([You will be unable to regenerate PDF documentation.])
- fi
-fi
-
-AC_CHECK_PROG([HAS_MAKEINFO], [makeinfo], [yes])
-
-if test x${HAS_MAKEINFO} = x; then
- if test x${strictness_enabled} = xyes; then
- AC_MSG_ERROR([Could not find the `makeinfo' executable.
-
-Is GNU Texinfo installed?])
- else
- AC_MSG_WARN([You will be unable to regenerate info documentation.])
- fi
-fi
-
-AC_CHECK_PROG([HAS_INSTALLINFO], [install-info], [yes])
-
-if test x${HAS_INSTALLINFO} = x; then
- if test x${strictness_enabled} = xyes; then
- AC_MSG_ERROR([Could not find the `install-info' executable.
-
-Is GNU Texinfo installed?])
- else
- AC_MSG_WARN([You will be unable to install info documentation.])
- fi
-fi
-
-AC_CHECK_PROG([HAS_SPHINX_BUILD], [sphinx-build], [yes])
-
-if test x${HAS_SPHINX_BUILD} = x; then
- if test x${strictness_enabled} = xyes; then
- AC_MSG_ERROR([Could not find the `sphinx-build' executable.])
- else
- AC_MSG_WARN([You will be unable to regenerate documentation.])
- fi
-fi
-
-if test x${docs_enabled} = xyes; then
- if test x${HAS_HELP2MAN} = xyes; then
- build_man=yes
- fi
- if test x${HAS_SPHINX_BUILD} = xyes; then
- build_html=yes
- if test x${HAS_MAKEINFO} = xyes; then
- build_info=yes
- fi
- if test x${HAS_PDFLATEX} = xyes; then
- build_pdf=yes
- fi
- fi
-fi
-
-if test x${strictness_enabled} = xyes; then
- AX_PYTHON_MODULE([pygments], [fatal])
-else
- AX_PYTHON_MODULE([pygments])
-fi
-
-AC_MSG_CHECKING(pygments version >= 1.5)
-
-python 2> /dev/null << EOF
-import sys
-import pygments
-
-if float(pygments.__version__) >= 1.5:
- sys.exit(0)
-else:
- sys.exit(1)
-EOF
-
-if test $? -eq 0; then
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
- if test x${strictness_enabled} = xyes; then
- AC_MSG_ERROR([Your copy of pygments is out of date.], 1)
- else
- AC_MSG_WARN([Syntax highlighting may not work.])
- fi
-fi
-
-AC_ARG_VAR([ERL], [path to the `erl' executable])
-AC_ARG_VAR([ERLC], [path to the `erlc' executable])
-
-AM_CONDITIONAL([INIT], [test x${init_enabled} = xtrue])
-AM_CONDITIONAL([LAUNCHD], [test x${launchd_enabled} = xtrue])
-AM_CONDITIONAL([USE_NATIVE_MOCHIJSON], [test x${native_mochijson_enabled} = xyes])
-AM_CONDITIONAL([USE_CURL], [test x${use_curl} = xyes])
-
-AM_CONDITIONAL([BUILD_MAN], [test x${build_man} = xyes])
-AM_CONDITIONAL([BUILD_INFO], [test x${build_info} = xyes])
-AM_CONDITIONAL([BUILD_PDF], [test x${build_pdf} = xyes])
-AM_CONDITIONAL([BUILD_HTML], [test x${build_html} = xyes])
-
-AM_CONDITIONAL([TESTS], [test x${tests_enabled} = xyes])
-AM_CONDITIONAL([STRICTNESS], [test x${strictness_enabled} = xyes])
-
-AC_SUBST([package_author_name], ["LOCAL_PACKAGE_AUTHOR_NAME"])
-AC_SUBST([package_author_address], ["LOCAL_PACKAGE_AUTHOR_ADDRESS"])
-AC_SUBST([package_identifier], ["LOCAL_PACKAGE_IDENTIFIER"])
-AC_SUBST([package_tarname], ["LOCAL_PACKAGE_TARNAME"])
-AC_SUBST([package_name], ["LOCAL_PACKAGE_NAME"])
-
-AC_SUBST([version], ["LOCAL_VERSION"])
-AC_SUBST([version_major], ["LOCAL_VERSION_MAJOR"])
-AC_SUBST([version_minor], ["LOCAL_VERSION_MINOR"])
-AC_SUBST([version_revision], ["LOCAL_VERSION_REVISION"])
-AC_SUBST([version_stage], ["LOCAL_VERSION_STAGE"])
-AC_SUBST([version_release], ["LOCAL_VERSION_RELEASE"])
-
-AC_SUBST([bug_uri], ["LOCAL_BUG_URI"])
-
-AC_SUBST([localconfdir], [${sysconfdir}/${package_identifier}])
-AC_SUBST([localdatadir], [${datadir}/${package_identifier}])
-AC_SUBST([localdocdir], [${datadir}/doc/${package_identifier}])
-AC_SUBST([locallibdir], [${libdir}/${package_identifier}])
-AC_SUBST([localstatelibdir], [${localstatedir}/lib/${package_identifier}])
-AC_SUBST([localstatelogdir], [${localstatedir}/log/${package_identifier}])
-AC_SUBST([localstaterundir], [${localstatedir}/run/${package_identifier}])
-
-# On Windows we install directly into our erlang distribution.
-if test x${IS_WINDOWS} = xTRUE; then
- AC_SUBST([locallibbindir], [${prefix}/bin])
- AC_SUBST([localerlanglibdir], [${libdir}])
-else
- AC_SUBST([locallibbindir], [${locallibdir}/bin])
- AC_SUBST([localerlanglibdir], [${locallibdir}/erlang/lib])
-fi
-
-# fix for older autotools that don't define "abs_top_YYY" by default
-AC_SUBST(abs_top_srcdir)
-AC_SUBST(abs_top_builddir)
-
-AC_REVISION([LOCAL_VERSION])
-
-AC_CONFIG_FILES([Makefile])
-AC_CONFIG_FILES([bin/couch-config.tpl])
-AC_CONFIG_FILES([bin/couchdb.tpl])
-AC_CONFIG_FILES([bin/couchdb.bat.tpl])
-AC_CONFIG_FILES([bin/Makefile])
-AC_CONFIG_FILES([etc/couchdb/Makefile])
-AC_CONFIG_FILES([etc/couchdb/default.ini.tpl])
-AC_CONFIG_FILES([etc/default/Makefile])
-AC_CONFIG_FILES([etc/init/couchdb.tpl])
-AC_CONFIG_FILES([etc/init/Makefile])
-AC_CONFIG_FILES([etc/launchd/org.apache.couchdb.plist.tpl])
-AC_CONFIG_FILES([etc/launchd/Makefile])
-AC_CONFIG_FILES([etc/logrotate.d/couchdb.tpl])
-AC_CONFIG_FILES([etc/logrotate.d/Makefile])
-AC_CONFIG_FILES([etc/windows/Makefile])
-AC_CONFIG_FILES([etc/Makefile])
-AC_CONFIG_FILES([share/Makefile])
-AC_CONFIG_FILES([share/doc/Makefile])
-AC_CONFIG_FILES([share/doc/build/Makefile])
-AC_CONFIG_FILES([src/Makefile])
-AC_CONFIG_FILES([src/chttpd/Makefile])
-AC_CONFIG_FILES([src/config/Makefile])
-AC_CONFIG_FILES([src/couch_index/Makefile])
-AC_CONFIG_FILES([src/couch_mrview/Makefile])
-AC_CONFIG_FILES([src/couch_replicator/Makefile])
-AC_CONFIG_FILES([src/couch/src/couch.app.tpl])
-AC_CONFIG_FILES([src/couch/Makefile])
-AC_CONFIG_FILES([src/couch/priv/Makefile])
-AC_CONFIG_FILES([src/mem3/Makefile])
-AC_CONFIG_FILES([src/fabric/Makefile])
-AC_CONFIG_FILES([src/ets_lru/Makefile])
-AC_CONFIG_FILES([src/ddoc_cache/Makefile])
-AC_CONFIG_FILES([src/oauth/Makefile])
-AC_CONFIG_FILES([src/ibrowse/Makefile])
-AC_CONFIG_FILES([src/mochiweb/Makefile])
-AC_CONFIG_FILES([src/rexi/Makefile])
-AC_CONFIG_FILES([src/snappy/Makefile])
-AC_CONFIG_FILES([src/snappy/c_src/Makefile])
-AC_CONFIG_FILES([src/snappy/c_src/google-snappy/snappy-stubs-public.h])
-AC_CONFIG_FILES([src/twig/Makefile])
-AC_CONFIG_FILES([src/ejson/Makefile])
-AC_CONFIG_FILES([test/Makefile])
-AC_CONFIG_FILES([test/bench/Makefile])
-AC_CONFIG_FILES([test/etap/Makefile])
-AC_CONFIG_FILES([test/etap/test_util.erl])
-AC_CONFIG_FILES([test/javascript/Makefile])
-AC_CONFIG_FILES([test/view_server/Makefile])
-AC_CONFIG_FILES([utils/Makefile])
-AC_CONFIG_FILES([var/Makefile])
-
-AC_OUTPUT
-
-# Windows Erlang build tools wrap Microsoft's linker and compiler just enough
-# to be able to build Erlang/OTP successfully, but not enough for full
-# compatibility with GNU AutoTools. The MS VC compiler and linker are
-# hidden from autotools in Erlang's cc.sh and ld.sh wrappers. GNU autoconf
-# identifies this dastardly mix as a unix variant, and libtool kindly
-# passes incorrect flags and names through to the MS linker. The simplest fix
-# is to modify libtool via sed to remove those options.
-#
-# As this is only done once at first configure, and subsequent config or source
-# changes may trigger a silent reversion to the non-functioning original.
-#
-# Changes are;
-#
-# 1. replace LIB$name with $name in libname_spec (e.g. libicu -> icu) to ensure
-# correct windows versions of .lib and .dlls are found or generated.
-# 2. remove incompatible \w-link\w from archive_cmds
-# 3. remove GNU-style directives to be passed through to the linker
-# 4. swap GNU-style shared library flags with MS -dll variant
-#
-# This obscene hackery is tracked under COUCHDB-440 and COUCHDB-1197.
-
-if test x${IS_WINDOWS} = xTRUE; then
- mv libtool libtool.dist
- /bin/sed -E -e 's,^libname_spec="lib,libname_spec=",' \
- -e 's,( -link ), ,' \
- -e 's,-Xlinker --out-implib -Xlinker \\\$lib,,' \
- -e 's,(-shared -nostdlib), -dll ,' \
- < libtool.dist > libtool
- # probably would chmod +x if we weren't on windows...
-fi
-
-echo
-echo "You have configured Apache CouchDB, time to relax."
-echo
-echo "Run \`make && sudo make install' to install."
diff --git a/etc/Makefile.am b/etc/Makefile.am
deleted file mode 100644
index 148f70157..000000000
--- a/etc/Makefile.am
+++ /dev/null
@@ -1,117 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-SUBDIRS = couchdb default init launchd logrotate.d windows
-
-default_sysconf_data = logrotate.d/couchdb
-
-if INIT
-init_sysconf_data = default/couchdb
-init_DATA = init/couchdb
-endif
-
-if LAUNCHD
-launchd_DATA = launchd/org.apache.couchdb.plist
-endif
-
-nobase_sysconf_DATA = $(default_sysconf_data) $(init_sysconf_data)
-
-EXTRA_DIST = \
- default/couchdb \
- windows/couchdb.iss.tpl \
- windows/README.txt.tpl
-
-if WINDOWS
-EXTRA_DIST += \
- windows/setup-couchdb-@version@.exe.md5 \
- windows/setup-couchdb-@version@.exe.sha
-endif
-
-CLEANFILES = $(init_DATA) $(default_sysconf_data) $(launchd_DATA)
-
-transform = @program_transform_name@
-couchdb_command_name = `echo couchdb | sed '$(transform)'`
-
-init/couchdb: init/couchdb.tpl
- if test "$(mkdir_p)"; then \
- $(mkdir_p) init; \
- else \
- if test ! -d init; then \
- mkdir init; \
- fi \
- fi
- sed -e "s|%configure_input%|$@. Generated from $< by configure.|" \
- -e "s|%bindir%|$(bindir)|" \
- -e "s|%sysconfdir%|$(sysconfdir)|" \
- -e "s|%localstaterundir%|$(localstaterundir)|" \
- -e "s|%couchdb_command_name%|$(couchdb_command_name)|" \
- < $< > $@
-
-logrotate.d/couchdb: logrotate.d/couchdb.tpl
- sed -e "s|%localstatelogdir%|@localstatelogdir@|g" < $< > $@
-
-launchd/org.apache.couchdb.plist: launchd/org.apache.couchdb.plist.tpl
- if test "$(mkdir_p)"; then \
- $(mkdir_p) launchd; \
- else \
- if test ! -d launchd; then \
- mkdir launchd; \
- fi \
- fi
- sed -e "s|%configure_input%|$@. Generated from $< by configure.|" \
- -e "s|%bindir%|$(bindir)|" \
- -e "s|%couchdb_command_name%|$(couchdb_command_name)|" \
- < $< > $@
-
-if WINDOWS
-
-# README.txt has \n line endings in the repo and must have \r\n
-# when installed as notepad is used to view it.
-# Also: the targets below don't seem to update after an svn-up (which
-# changes the version string in the generated files) so we trick make
-# into always building it with the FORCE pattern...
-windows/README.txt: windows/README.txt.tpl FORCE
- sed -e "s|%package_name%|@package_name@|g" \
- -e "s|%version%|@version@|g" \
- < $< | unix2dos > $@
-
-windows/couchdb.iss: windows/couchdb.iss.tpl FORCE
- sed -e "s|%configure_input%|$@. Generated from $< by configure.|" \
- -e "s|%package_name%|@package_name@|g" \
- -e "s|%locallibbindir%|`cygpath -m @locallibbindir@`|g" \
- -e "s|%version%|@version@|g" \
- -e "s|%erts_version%|`$(ERL) -version 2>&1 | $(SED) 's/[^0-9\.]//g'`|g" \
- -e "s|%openssl_bin_dir%|@openssl_bin_dir@|g" \
- -e "s|%msvc_redist_dir%|@msvc_redist_dir@|g" \
- -e "s|%msvc_redist_name%|@msvc_redist_name@|g" \
- < $< > $@
-
-# The installer depends on all files, not just the source .iss file,
-# so we trick make into always building it with the FORCE pattern...
-windows/setup-couchdb-@version@.exe: windows/couchdb.iss windows/README.txt FORCE
- "$(INNO_COMPILER_EXECUTABLE)" /q $<
- @echo Windows Installer is at: `cygpath -a -w windows/setup-couchdb-@version@.exe`
-
-windows/setup-couchdb-@version@.exe.md5: windows/setup-couchdb-@version@.exe
- cd windows && md5sum ./$(<F) > $(@F)
-
-windows/setup-couchdb-@version@.exe.sha: windows/setup-couchdb-@version@.exe
- cd windows && sha1sum ./$(<F) > $(@F)
-
-FORCE:
-
-endif
-
-install-data-hook:
- if test -n "$(init_DATA)"; then \
- chmod +x "$(DESTDIR)$(initdir)/couchdb"; \
- fi
diff --git a/etc/couchdb/Makefile.am b/etc/couchdb/Makefile.am
deleted file mode 100644
index 3c15f9962..000000000
--- a/etc/couchdb/Makefile.am
+++ /dev/null
@@ -1,93 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-couchprivlibdir = $(localerlanglibdir)/couch-$(version)/priv/lib
-devcouchprivlibdir = $(abs_top_builddir)/src/couch/priv/.libs
-
-localconf_DATA = default.ini
-noinst_DATA = default_dev.ini local_dev.ini
-
-EXTRA_DIST = local.ini
-
-CLEANFILES = $(localconf_DATA) $(noinst_DATA)
-
-transform = @program_transform_name@
-couchjs_command_name = `echo couchjs | sed '$(transform)'`
-couchjs_dev_command_name = `echo couchjs_dev | sed '$(transform)'`
-
-if WINDOWS
-default.ini: default.ini.tpl
- sed -e "s|%bindir%|.|g" \
- -e "s|%localconfdir%|$(localconfdir)|g" \
- -e "s|%localdatadir%|../share/couchdb|g" \
- -e "s|%localbuilddatadir%|../share/couchdb|g" \
- -e "s|%localstatelibdir%|../var/lib/couchdb|g" \
- -e "s|%localstatelogdir%|../var/log/couchdb|g" \
- -e "s|%localstaterundir%|../var/run/couchdb|g" \
- -e "s|%couchprivlibdir%|../lib/couch-$(version)/priv/lib|g" \
- -e "s|%couchjs_command_name%|couchjs.exe|g" \
- -e "s|%package_author_name%|$(package_author_name)|g" \
- -e "s|%version%|$(version)|g" \
- < $< > $@
-else
-default.ini: default.ini.tpl
- sed -e "s|%bindir%|$(bindir)|g" \
- -e "s|%localconfdir%|$(localconfdir)|g" \
- -e "s|%localdatadir%|$(localdatadir)|g" \
- -e "s|%localbuilddatadir%|$(localdatadir)|g" \
- -e "s|%localstatelibdir%|$(localstatelibdir)|g" \
- -e "s|%localstatelogdir%|$(localstatelogdir)|g" \
- -e "s|%localstaterundir%|$(localstaterundir)|g" \
- -e "s|%couchprivlibdir%|$(couchprivlibdir)|g" \
- -e "s|%couchjs_command_name%|$(couchjs_command_name)|g" \
- -e "s|%package_author_name%|$(package_author_name)|g" \
- -e "s|%version%|$(version)|g" \
- < $< > $@
-endif
-
-default_dev.ini: default.ini.tpl
- sed -e "s|%bindir%|$(abs_top_builddir)/bin|g" \
- -e "s|%localconfdir%|$(abs_top_builddir)/etc/couchdb|g" \
- -e "s|%localdatadir%|$(abs_top_srcdir)/share|g" \
- -e "s|%localbuilddatadir%|$(abs_top_builddir)/share|g" \
- -e "s|%localstatelibdir%|$(abs_top_builddir)/tmp/lib|g" \
- -e "s|%localstatelogdir%|$(abs_top_builddir)/tmp/log|g" \
- -e "s|%localstaterundir%|$(abs_top_builddir)/tmp/run|g" \
- -e "s|%couchprivlibdir%|$(devcouchprivlibdir)|g" \
- -e "s|%couchjs_command_name%|$(couchjs_dev_command_name)|g" \
- -e "s|%package_author_name%|$(package_author_name)|g" \
- -e "s|%version%|$(version)|g" \
- < $< > $@
-
-# Noah said to not specify local.ini but it borks
-# VPATH builds that make distcheck uses.
-local_dev.ini: local.ini
- if test ! -f "$@"; then \
- cp $< $@; \
- chmod +w $@; \
- fi
-
-install-data-hook:
- if test ! -f "$(DESTDIR)$(localconfdir)/local.ini"; then \
- cp $(srcdir)/local.ini "$(DESTDIR)$(localconfdir)/local.ini"; \
- fi
- if test ! "$(mkdir_p)" = ""; then \
- $(mkdir_p) "$(DESTDIR)$(localconfdir)/default.d"; \
- $(mkdir_p) "$(DESTDIR)$(localconfdir)/local.d"; \
- else \
- echo "WARNING: You may have to create these directories by hand."; \
- mkdir -p "$(DESTDIR)$(localconfdir)/default.d"; \
- mkdir -p "$(DESTDIR)$(localconfdir)/local.d"; \
- fi
-
-uninstall-local:
- rm -f "$(DESTDIR)/$(localconfdir)/local.ini"
diff --git a/etc/default/Makefile.am b/etc/default/Makefile.am
deleted file mode 100644
index 5b4faae06..000000000
--- a/etc/default/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-## This file intentionally left blank.
diff --git a/etc/init/Makefile.am b/etc/init/Makefile.am
deleted file mode 100644
index 5b4faae06..000000000
--- a/etc/init/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-## This file intentionally left blank.
diff --git a/etc/launchd/Makefile.am b/etc/launchd/Makefile.am
deleted file mode 100644
index 5b4faae06..000000000
--- a/etc/launchd/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-## This file intentionally left blank.
diff --git a/etc/logrotate.d/Makefile.am b/etc/logrotate.d/Makefile.am
deleted file mode 100644
index 5b4faae06..000000000
--- a/etc/logrotate.d/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-## This file intentionally left blank.
diff --git a/etc/windows/Makefile.am b/etc/windows/Makefile.am
deleted file mode 100644
index 5b4faae06..000000000
--- a/etc/windows/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-## This file intentionally left blank.
diff --git a/rebar.config b/rebar.config
new file mode 100644
index 000000000..1ae51fde0
--- /dev/null
+++ b/rebar.config
@@ -0,0 +1,38 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+{sub_dirs, [
+ "src/ibrowse",
+ "src/config",
+ "src/couch",
+ "src/couch_index",
+ "src/couch_mrview",
+ "src/mem3",
+
+ "src/chttpd",
+ "src/couch_replicator",
+ "src/ddoc_cache",
+ "src/ejson",
+ "src/ets_lru",
+ "src/fabric",
+ "src/mochiweb",
+ "src/oauth",
+ "src/rexi",
+ "src/snappy",
+ "src/twig",
+
+ "rel"
+]}.
+
+{lib_dirs, ["src/"]}.
+
+{erl_opts, [debug_info]}.
diff --git a/rel/files/README b/rel/files/README
new file mode 100644
index 000000000..5ee938657
--- /dev/null
+++ b/rel/files/README
@@ -0,0 +1,4 @@
+Ignore these files for now.
+
+This is to pacify newer rebar that insists on having a sys.config and
+a vm.args in releases/$VSN/.
diff --git a/rel/files/sys.config b/rel/files/sys.config
new file mode 100644
index 000000000..57afcca04
--- /dev/null
+++ b/rel/files/sys.config
@@ -0,0 +1 @@
+[].
diff --git a/rel/files/vm.args b/rel/files/vm.args
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/rel/files/vm.args
diff --git a/rel/overlay/bin/couchdb b/rel/overlay/bin/couchdb
new file mode 100755
index 000000000..b2dc76b83
--- /dev/null
+++ b/rel/overlay/bin/couchdb
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+ERTS_BIN_DIR=$(cd ${0%/*} && pwd)
+
+export ROOTDIR=${ERTS_BIN_DIR%/*}
+
+START_ERL=`cat $ROOTDIR/releases/start_erl.data`
+ERTS_VSN=${START_ERL% *}
+APP_VSN=${START_ERL#* }
+
+export BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
+export EMU=beam
+export PROGNAME=`echo $0 | sed 's/.*\///'`
+
+exec $BINDIR/erlexec -boot $ROOTDIR/releases/$APP_VSN/couchdb \
+ -args_file $ROOTDIR/etc/vm.args
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
new file mode 100644
index 000000000..f10ac3377
--- /dev/null
+++ b/rel/overlay/etc/default.ini
@@ -0,0 +1,122 @@
+[couchdb]
+database_dir = {{data_dir}}
+view_index_dir = {{view_dir}}
+max_document_size = 67108864
+os_process_timeout = 5000
+max_dbs_open = 500
+delayed_commits = false
+
+[cluster]
+q=8
+r=2
+w=2
+n=3
+
+[chttpd]
+port = {{cluster_port}}
+backlog = 512
+docroot = {{prefix}}/share/www
+
+[httpd]
+port = {{backend_port}}
+bind_address = 127.0.0.1
+max_connections = 2048
+authentication_handlers = {couch_httpd_oauth, oauth_authentication_handler}, {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}
+default_handler = {couch_httpd_db, handle_request}
+secure_rewrites = true
+vhost_global_handlers = _utils, _uuids, _session, _oauth, _users
+allow_jsonp = false
+
+[log]
+file = {{prefix}}/var/log/bigcouch.log
+level = info
+include_sasl = true
+
+[couch_httpd_auth]
+authentication_db = _users
+authentication_redirect = /_utils/session.html
+secret = somethingveryverysecret
+require_valid_user = false
+timeout = 600 ; number of seconds before automatic logout
+auth_cache_size = 50 ; size is number of cache entries
+
+[query_servers]
+javascript = {{prefix}}/bin/couchjs {{prefix}}/share/couchjs/main.js
+
+[query_server_config]
+reduce_limit = true
+
+[daemons]
+external_manager={couch_external_manager, start_link, []}
+query_servers={couch_proc_manager, start_link, []}
+httpd={couch_httpd, start_link, []}
+stats_collector={couch_stats_collector, start, []}
+uuids={couch_uuids, start, []}
+auth_cache={couch_auth_cache, start_link, []}
+
+[httpd_global_handlers]
+/ = {couch_httpd_misc_handlers, handle_welcome_req, <<"Welcome">>}
+favicon.ico = {couch_httpd_misc_handlers, handle_favicon_req, "{{prefix}}/share/www"}
+
+_utils = {couch_httpd_misc_handlers, handle_utils_dir_req, "{{prefix}}/share/www"}
+_all_dbs = {couch_httpd_misc_handlers, handle_all_dbs_req}
+_active_tasks = {couch_httpd_misc_handlers, handle_task_status_req}
+_config = {couch_httpd_misc_handlers, handle_config_req}
+_replicate = {couch_httpd_misc_handlers, handle_replicate_req}
+_uuids = {couch_httpd_misc_handlers, handle_uuids_req}
+_restart = {couch_httpd_misc_handlers, handle_restart_req}
+_stats = {couch_httpd_stats_handlers, handle_stats_req}
+_log = {couch_httpd_misc_handlers, handle_log_req}
+_session = {couch_httpd_auth, handle_session_req}
+_oauth = {couch_httpd_oauth, handle_oauth_req}
+_system = {chttpd_misc, handle_system_req}
+
+[httpd_db_handlers]
+_view_cleanup = {couch_httpd_db, handle_view_cleanup_req}
+_compact = {couch_httpd_db, handle_compact_req}
+_design = {couch_httpd_db, handle_design_req}
+_temp_view = {couch_httpd_view, handle_temp_view_req}
+_changes = {couch_httpd_db, handle_changes_req}
+
+[httpd_design_handlers]
+_view = {couch_httpd_view, handle_view_req}
+_show = {couch_httpd_show, handle_doc_show_req}
+_list = {couch_httpd_show, handle_view_list_req}
+_info = {couch_httpd_db, handle_design_info_req}
+_rewrite = {couch_httpd_rewrite, handle_rewrite_req}
+_update = {couch_httpd_show, handle_doc_update_req}
+
+[uuids]
+; Known algorithms:
+; random - 128 bits of random awesome
+; All awesome, all the time.
+; sequential - monotonically increasing ids with random increments
+; First 26 hex characters are random. Last 6 increment in
+; random amounts until an overflow occurs. On overflow, the
+; random prefix is regenerated and the process starts over.
+; utc_random - Time since Jan 1, 1970 UTC with microseconds
+; First 14 characters are the time in hex. Last 18 are random.
+algorithm = sequential
+
+[stats]
+; rate is in milliseconds
+rate = 1000
+; sample intervals are in seconds
+samples = [0, 60, 300, 900]
+
+[attachments]
+compression_level = 8 ; from 1 (lowest, fastest) to 9 (highest, slowest), 0 to disable compression
+compressible_types = text/*, application/javascript, application/json, application/xml
+
+[replicator]
+max_http_sessions = 20
+max_http_pipeline_size = 50
+; set to true to validate peer certificates
+verify_ssl_certificates = false
+; file containing a list of peer trusted certificates (PEM format)
+; ssl_trusted_certificates_file = /etc/ssl/certs/ca-certificates.crt
+; maximum peer certificate depth (must be set even if certificate validation is off)
+ssl_certificate_max_depth = 3
+
+[dreyfus]
+name={{clouseau_name}}
diff --git a/rel/overlay/etc/local.ini b/rel/overlay/etc/local.ini
new file mode 100644
index 000000000..3146ea257
--- /dev/null
+++ b/rel/overlay/etc/local.ini
@@ -0,0 +1 @@
+; local customizations are stored here
diff --git a/rel/overlay/etc/vm.args b/rel/overlay/etc/vm.args
new file mode 100644
index 000000000..d112f455d
--- /dev/null
+++ b/rel/overlay/etc/vm.args
@@ -0,0 +1,23 @@
+# Each node in the system must have a unique name. A name can be short
+# (specified using -sname) or it can by fully qualified (-name). There can be
+# no communication between nodes running with the -sname flag and those running
+# with the -name flag.
+{{node_name}}
+
+# All nodes must share the same magic cookie for distributed Erlang to work.
+# Comment out this line if you synchronized the cookies by other means (using
+# the ~/.erlang.cookie file, for example).
+-setcookie monster
+
+# Tell kernel and SASL not to log anything
+-kernel error_logger silent
+-sasl sasl_error_logger false
+
+# Use kernel poll functionality if supported by emulator
++K true
+
+# Start a pool of asynchronous IO threads
++A 16
+
+# Comment this line out to enable the interactive Erlang shell on startup
++Bd -noinput
diff --git a/rel/reltool.config b/rel/reltool.config
new file mode 100644
index 000000000..049531c81
--- /dev/null
+++ b/rel/reltool.config
@@ -0,0 +1,70 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+{sys, [
+ {lib_dirs, ["../src"]},
+ {rel, "couchdb", "2.0.0a", [
+ chttpd,
+ config,
+ couch,
+ couch_replicator,
+ crypto,
+ ddoc_cache,
+ ets_lru,
+ fabric,
+ ibrowse,
+ inets,
+ kernel,
+ mem3,
+ mochiweb,
+ oauth,
+ rexi,
+ runtime_tools,
+ sasl,
+ snappy,
+ ssl,
+ stdlib,
+ twig,
+ xmerl
+ ]},
+ {rel, "start_clean", "", [kernel, stdlib]},
+ {boot_rel, "couchdb"},
+ {profile, embedded},
+ {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)"]},
+ {excl_archive_filters, [".*"]},
+
+ % It's sufficient to list 'chttpd' here, as reltool will pull in all
+ % dependencies. But we'll be explicit and list everything actively
+ % developed in this repository.
+ {app, chttpd, [{incl_cond, include}]},
+ {app, config, [{incl_cond, include}]},
+ {app, couch, [{incl_cond, include}]},
+ {app, couch_replicator, [{incl_cond, include}]},
+ {app, ddoc_cache, [{incl_cond, include}]},
+ {app, ets_lru, [{incl_cond, include}]},
+ {app, fabric, [{incl_cond, include}]},
+ {app, mem3, [{incl_cond, include}]},
+ {app, rexi, [{incl_cond, include}]},
+ {app, snappy, [{incl_cond, include}]},
+ {app, twig, [{incl_cond, include}]}
+]}.
+
+{overlay_vars, "couchdb.config"}.
+{overlay, [
+ {mkdir, "var/log"},
+ {copy, "overlay/bin"},
+ {copy, "overlay/etc"},
+ {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
+ {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"},
+ {template, "overlay/etc/default.ini", "etc/default.ini"},
+ {template, "overlay/etc/vm.args", "etc/vm.args"}
+]}.
diff --git a/share/Makefile.am b/share/Makefile.am
deleted file mode 100644
index 31373ee2a..000000000
--- a/share/Makefile.am
+++ /dev/null
@@ -1,219 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-SUBDIRS = doc
-
-JS_FILE = server/main.js
-
-JS_FILE_COMPONENTS = \
- server/json2.js \
- server/filter.js \
- server/mimeparse.js \
- server/render.js \
- server/state.js \
- server/util.js \
- server/validate.js \
- server/views.js
-
-JS_FILE_COMPONENTS_LAST = server/loop.js
-
-$(JS_FILE): $(JS_FILE_COMPONENTS) $(JS_FILE_COMPONENTS_LAST)
- mkdir -p `dirname $(JS_FILE)`
- echo "// DO NOT EDIT THIS FILE BY HAND" > $@
- echo >> $@
- cat $^ >> $@
-
-COFFEE_FILE = server/main-coffee.js
-
-COFFEE_FILE_COMPONENTS_LAST = server/coffee-script.js server/loop.js
-
-$(COFFEE_FILE): $(JS_FILE_COMPONENTS) $(COFFEE_FILE_COMPONENTS_LAST)
- mkdir -p `dirname $(COFFEE_FILE)`
- echo "// DO NOT EDIT THIS FILE BY HAND" > $@
- echo >> $@
- cat $^ >> $@
-
-CLEANFILES = $(JS_FILE) $(COFFEE_FILE)
-
-EXTRA_DIST = $(JS_FILE_COMPONENTS) $(JS_FILE_COMPONENTS_LAST) $(COFFEE_FILE_COMPONENTS_LAST)
-
-nobase_localdata_SCRIPTS = \
- $(JS_FILE) \
- $(COFFEE_FILE)
-
-nobase_dist_localdata_DATA = \
- www/config.html \
- www/couch_tests.html \
- www/custom_test.html \
- www/database.html \
- www/session.html \
- www/dialog/_admin_party.html \
- www/dialog/_change_password.html \
- www/dialog/_compact_cleanup.html \
- www/dialog/_create_admin.html \
- www/dialog/_login.html \
- www/dialog/_signup.html \
- www/dialog/_create_database.html \
- www/dialog/_create_config.html \
- www/dialog/_delete_database.html \
- www/dialog/_delete_document.html \
- www/dialog/_database_security.html \
- www/dialog/_share_test_reports.html \
- www/dialog/_save_view_as.html \
- www/dialog/_upload_attachment.html \
- www/document.html \
- www/favicon.ico \
- www/image/add.png \
- www/image/apply.gif \
- www/image/bg.png \
- www/image/cancel.gif \
- www/image/compact.png \
- www/image/delete-mini.png \
- www/image/delete.png \
- www/image/grippie.gif \
- www/image/hgrad.gif \
- www/image/key.png \
- www/image/load.png \
- www/image/logo.png \
- www/image/order-asc.gif \
- www/image/order-desc.gif \
- www/image/path.gif \
- www/image/progress.gif \
- www/image/rarrow.png \
- www/image/run-mini.png \
- www/image/run.png \
- www/image/running.png \
- www/image/save.png \
- www/image/sidebar-toggle.png \
- www/image/spinner.gif \
- www/image/spinner_33.gif \
- www/image/spinner_6b.gif \
- www/image/test_failure.gif \
- www/image/test_success.gif \
- www/image/thead-key.gif \
- www/image/thead.gif \
- www/image/toggle-collapse.gif \
- www/image/toggle-expand.gif \
- www/image/twisty.gif \
- www/index.html \
- www/replicator.html \
- www/script/couch.js \
- www/script/couch_tests.js \
- www/script/couch_test_runner.js \
- www/script/futon.browse.js \
- www/script/futon.format.js \
- www/script/futon.js \
- www/script/jquery.couch.js \
- www/script/jquery.dialog.js \
- www/script/jquery.editinline.js \
- www/script/jquery.form.js \
- www/script/jquery.js \
- www/script/jquery-ui-1.8.11.custom.min.js \
- www/script/jquery.resizer.js \
- www/script/jquery.suggest.js \
- www/script/json2.js \
- www/script/jspec/jspec.css \
- www/script/jspec/jspec.jquery.js \
- www/script/jspec/jspec.js \
- www/script/jspec/jspec.xhr.js \
- www/script/oauth.js \
- www/script/sha1.js \
- www/script/base64.js \
- www/script/test/all_docs.js \
- www/script/test/attachments.js \
- www/script/test/attachments_multipart.js \
- www/script/test/attachment_names.js \
- www/script/test/attachment_paths.js \
- www/script/test/attachment_ranges.js \
- www/script/test/attachment_views.js \
- www/script/test/auth_cache.js \
- www/script/test/basics.js \
- www/script/test/batch_save.js \
- www/script/test/bulk_docs.js \
- www/script/test/changes.js \
- www/script/test/coffee.js \
- www/script/test/compact.js \
- www/script/test/config.js \
- www/script/test/conflicts.js \
- www/script/test/content_negotiation.js \
- www/script/test/cookie_auth.js \
- www/script/test/copy_doc.js \
- www/script/test/delayed_commits.js \
- www/script/test/design_docs.js \
- www/script/test/design_options.js \
- www/script/test/design_paths.js \
- www/script/test/erlang_views.js \
- www/script/test/etags_head.js \
- www/script/test/etags_views.js \
- www/script/test/form_submit.js \
- www/script/test/http.js \
- www/script/test/invalid_docids.js \
- www/script/test/jsonp.js \
- www/script/test/large_docs.js \
- www/script/test/list_views.js \
- www/script/test/lorem.txt \
- www/script/test/lorem_b64.txt \
- www/script/test/lots_of_docs.js \
- www/script/test/method_override.js \
- www/script/test/multiple_rows.js \
- www/script/test/oauth.js \
- www/script/test/oauth_users_db.js \
- www/script/test/proxyauth.js \
- www/script/test/purge.js \
- www/script/test/reader_acl.js \
- www/script/test/recreate_doc.js \
- www/script/test/reduce.js \
- www/script/test/reduce_builtin.js \
- www/script/test/reduce_false.js \
- www/script/test/reduce_false_temp.js \
- www/script/test/replication.js \
- www/script/test/replicator_db.js \
- www/script/test/replicator_db_security.js \
- www/script/test/rev_stemming.js \
- www/script/test/rewrite.js \
- www/script/test/security_validation.js \
- www/script/test/show_documents.js \
- www/script/test/stats.js \
- www/script/test/update_documents.js \
- www/script/test/users_db.js \
- www/script/test/users_db_security.js \
- www/script/test/utf8.js \
- www/script/test/uuids.js \
- www/script/test/view_collation.js \
- www/script/test/view_collation_raw.js \
- www/script/test/view_conflicts.js \
- www/script/test/view_compaction.js \
- www/script/test/view_errors.js \
- www/script/test/view_include_docs.js \
- www/script/test/view_multi_key_all_docs.js \
- www/script/test/view_multi_key_design.js \
- www/script/test/view_multi_key_temp.js \
- www/script/test/view_offsets.js \
- www/script/test/view_update_seq.js \
- www/script/test/view_pagination.js \
- www/script/test/view_sandboxing.js \
- www/script/test/view_xml.js \
- www/spec/couch_js_class_methods_spec.js \
- www/spec/couch_js_instance_methods_1_spec.js \
- www/spec/couch_js_instance_methods_2_spec.js \
- www/spec/couch_js_instance_methods_3_spec.js \
- www/spec/custom_helpers.js \
- www/spec/jquery_couch_js_class_methods_spec.js \
- www/spec/jquery_couch_js_instance_methods_1_spec.js \
- www/spec/jquery_couch_js_instance_methods_2_spec.js \
- www/spec/jquery_couch_js_instance_methods_3_spec.js \
- www/spec/run.html \
- www/status.html \
- www/style/jquery-ui-1.8.11.custom.css \
- www/style/layout.css \
- www/verify_install.html \
- www/_sidebar.html
diff --git a/share/doc/Makefile.am b/share/doc/Makefile.am
deleted file mode 100644
index 34b41a03f..000000000
--- a/share/doc/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-SUBDIRS = build
-
diff --git a/share/doc/build/Makefile.am b/share/doc/build/Makefile.am
deleted file mode 100644
index 3db9689c7..000000000
--- a/share/doc/build/Makefile.am
+++ /dev/null
@@ -1,354 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-MAKE_SAFE = $(MAKE)
-
-SPHINXOPTS = \
- -n -c $(srcdir)/../src \
- -A local=1 \
- $(srcdir)/../src
-
-info_file_dist = texinfo/CouchDB.info
-
-info_file_inst = CouchDB
-
-if BUILD_INFO
-info_file_build = $(info_file_dist)
-else
-info_file_build =
-endif
-
-pdf_file_dist = latex/CouchDB.pdf.gz
-
-pdf_file_inst = CouchDB.pdf.gz
-
-if BUILD_PDF
-pdf_file_build = $(pdf_file_dist)
-else
-pdf_file_build =
-endif
-
-# Please keep lists of rst and related generated files sorted
-
-html_files = \
- html/_images/futon-createdb.png \
- html/_images/futon-editdoc.png \
- html/_images/futon-editeddoc.png \
- html/_images/futon-overview.png \
- html/_images/futon-replform.png \
- html/_sources/api/authn.txt \
- html/_sources/api/configuration.txt \
- html/_sources/api/database.txt \
- html/_sources/api/dbmaint.txt \
- html/_sources/api/design.txt \
- html/_sources/api/documents.txt \
- html/_sources/api/local.txt \
- html/_sources/api/misc.txt \
- html/_sources/api/reference.txt \
- html/_sources/api-basics.txt \
- html/_sources/changelog.txt \
- html/_sources/changes.txt \
- html/_sources/commonjs.txt \
- html/_sources/cors.txt \
- html/_sources/config_reference.txt \
- html/_sources/configuring.txt \
- html/_sources/ddocs.txt \
- html/_sources/errors.txt \
- html/_sources/http-proxying.txt \
- html/_sources/index.txt \
- html/_sources/intro.txt \
- html/_sources/json-structure.txt \
- html/_sources/os-daemons.txt \
- html/_sources/pretty_urls.txt \
- html/_sources/query-servers.txt \
- html/_sources/range.txt \
- html/_sources/release.txt \
- html/_sources/replication.txt \
- html/_sources/ssl.txt \
- html/_static/ajax-loader.gif \
- html/_static/basic.css \
- html/_static/comment-bright.png \
- html/_static/comment-close.png \
- html/_static/comment.png \
- html/_static/default.css \
- html/_static/doctools.js \
- html/_static/down-pressed.png \
- html/_static/down.png \
- html/_static/favicon.ico \
- html/_static/file.png \
- html/_static/jquery.js \
- html/_static/logo.png \
- html/_static/minus.png \
- html/_static/plus.png \
- html/_static/pygments.css \
- html/_static/rtd.css \
- html/_static/searchtools.js \
- html/_static/sidebar.js \
- html/_static/underscore.js \
- html/_static/up-pressed.png \
- html/_static/up.png \
- html/_static/websupport.js \
- html/api/authn.html \
- html/api/configuration.html \
- html/api/database.html \
- html/api/dbmaint.html \
- html/api/design.html \
- html/api/documents.html \
- html/api/local.html \
- html/api/misc.html \
- html/api/reference.html \
- html/api-basics.html \
- html/changelog.html \
- html/changes.html \
- html/commonjs.html \
- html/cors.html \
- html/config_reference.html \
- html/configuring.html \
- html/ddocs.html \
- html/errors.html \
- html/http-proxying.html \
- html/index.html \
- html/intro.html \
- html/json-structure.html \
- html/os-daemons.html \
- html/pretty_urls.html \
- html/query-servers.html \
- html/range.html \
- html/release.html \
- html/replication.html \
- html/ssl.html \
- html/objects.inv \
- html/genindex.html \
- html/search.html \
- html/searchindex.js
-
-if BUILD_HTML
-html_files_build = $(html_files)
-else
-html_files_build =
-endif
-
-image_files = \
- ../images/epub-icon.png \
- ../images/favicon.ico \
- ../images/futon-createdb.png \
- ../images/futon-editdoc.png \
- ../images/futon-editeddoc.png \
- ../images/futon-overview.png \
- ../images/futon-replform.png \
- ../images/logo.png
-
-src_files = \
- ../src/api/authn.rst \
- ../src/api/configuration.rst \
- ../src/api/database.rst \
- ../src/api/dbmaint.rst \
- ../src/api/design.rst \
- ../src/api/documents.rst \
- ../src/api/local.rst \
- ../src/api/misc.rst \
- ../src/api/reference.rst \
- ../src/api-basics.rst \
- ../src/changelog.rst \
- ../src/changes.rst \
- ../src/commonjs.rst \
- ../src/cors.rst \
- ../src/config_reference.rst \
- ../src/configuring.rst \
- ../src/ddocs.rst \
- ../src/errors.rst \
- ../src/http-proxying.rst \
- ../src/index.rst \
- ../src/intro.rst \
- ../src/json-structure.rst \
- ../src/os-daemons.rst \
- ../src/pretty_urls.rst \
- ../src/query-servers.rst \
- ../src/range.rst \
- ../src/release.rst \
- ../src/replication.rst \
- ../src/ssl.rst \
- ../src/conf.py
-
-src_files_html = \
- ../static/rtd.css \
- ../templates/help.html \
- ../templates/searchbox.html \
- ../templates/utilities.html
-
-EXTRA_DIST = \
- $(image_files) \
- $(src_files) \
- $(src_files_html) \
- $(info_file_build) \
- $(pdf_file_build) \
- $(html_files_build)
-
-BUILT_SOURCES = \
- $(info_file_build) \
- $(pdf_file_build) \
- $(html_files_build)
-
-$(pdf_file_dist): pdf
-
-$(html_files): html
-
-$(info_file_dist): info.stamp
- @if test -f $@; then :; else \
- rm -f info.stamp; \
- $(MAKE_SAFE) $(AM_MAKEFLAGS) info.stamp; \
- fi
-
-info.stamp: $(image_files) $(src_files)
- trap "rm -rf info.lock info.stamp" 1 2 13 15; \
- if mkdir info.lock 2>/dev/null; then \
- rm -f info.tmp; \
- touch info.tmp; \
- $(top_srcdir)/build-aux/sphinx-build \
- -b texinfo $(SPHINXOPTS) $(builddir)/texinfo; \
- $(MAKE_SAFE) -C texinfo info; \
- $(top_srcdir)/build-aux/sphinx-touch $(info_file_dist); \
- mv -f info.tmp $@; \
- rmdir info.lock; \
- else \
- while test -d info.lock; do \
- sleep 1; \
- done; \
- test -f info.stamp; \
- fi
-
-$(pdf_file_dist): pdf.stamp
- @if test -f $@; then :; else \
- rm -f pdf.stamp; \
- $(MAKE_SAFE) $(AM_MAKEFLAGS) pdf.stamp; \
- fi
-
-pdf.stamp: $(image_files) $(src_files)
- trap "rm -rf pdf.lock pdf.stamp" 1 2 13 15; \
- if mkdir pdf.lock 2>/dev/null; then \
- rm -f pdf.tmp; \
- touch pdf.tmp; \
- $(top_srcdir)/build-aux/sphinx-build \
- -b latex $(SPHINXOPTS) $(builddir)/latex; \
- $(MAKE_SAFE) -C latex all-pdf; \
- $(top_srcdir)/build-aux/sphinx-touch latex/CouchDB.pdf; \
- gzip -9 < latex/CouchDB.pdf > $(pdf_file_dist); \
- mv -f pdf.tmp $@; \
- rmdir pdf.lock; \
- else \
- while test -d pdf.lock; do \
- sleep 1; \
- done; \
- test -f pdf.stamp; \
- fi
-
-$(html_files): html.stamp
- @if test -f $@; then :; else \
- rm -f html.stamp; \
- $(MAKE_SAFE) $(AM_MAKEFLAGS) html.stamp; \
- fi
-
-html.stamp: $(image_files) $(src_files) $(src_files_html)
- trap "rm -rf html.lock html.stamp" 1 2 13 15; \
- if mkdir html.lock 2>/dev/null; then \
- rm -f html.tmp; \
- touch html.tmp; \
- $(top_srcdir)/build-aux/sphinx-build \
- -b html $(SPHINXOPTS) $(builddir)/html; \
- $(top_srcdir)/build-aux/sphinx-touch $(html_files); \
- mv -f html.tmp $@; \
- rmdir html.lock; \
- else \
- while test -d html.lock; do \
- sleep 1; \
- done; \
- test -f html.stamp; \
- fi
-
-pdf-local:
- $(MAKE) $(AM_MAKEFLAGS) pdf.stamp
-
-html-local:
- $(MAKE) $(AM_MAKEFLAGS) html.stamp
-
-install-data-local:
- if test -s $(info_file_dist); then \
- $(INSTALL) -d $(DESTDIR)$(infodir); \
- $(INSTALL_DATA) \
- $(info_file_dist) $(DESTDIR)$(infodir)/$(info_file_inst); \
- if test -n "`which install-info`"; then \
- install-info \
- $(DESTDIR)$(infodir)/$(info_file_inst) \
- $(DESTDIR)$(infodir)/dir \
- || true; \
- fi \
- fi
- if test -s $(pdf_file_dist); then \
- $(INSTALL) -d $(DESTDIR)$(localdocdir); \
- $(INSTALL_DATA) \
- $(pdf_file_dist) $(DESTDIR)$(localdocdir)/$(pdf_file_inst); \
- fi
- for dist_file in $(html_files); do \
- if test -s $$dist_file; then \
- inst_file=`echo $$dist_file | sed s,^html,docs,`; \
- $(INSTALL) -d `dirname $(DESTDIR)$(localdatadir)/www/$$inst_file`; \
- $(INSTALL_DATA) \
- $$dist_file $(DESTDIR)$(localdatadir)/www/$$inst_file; \
- fi \
- done
-
-uninstall-local:
- rm -f $(DESTDIR)$(infodir)/$(info_file_inst)
- if test -d $(DESTDIR)$(infodir); then \
- if test -n "`which install-info`"; then\
- install-info \
- --delete \
- $(DESTDIR)$(infodir)/$(info_file_inst) \
- $(DESTDIR)$(infodir)/dir \
- || true; \
- fi \
- fi
- rm -f $(DESTDIR)$(localdocdir)/$(pdf_file_inst)
- for dist_file in $(html_files); do \
- if test -s $$dist_file; then \
- inst_file=`echo $$dist_file | sed s,^html,docs,`; \
- rm -f $(DESTDIR)$(localdatadir)/www/$$inst_file; \
- fi \
- done
-
-DISTCLEANFILES = \
- info.stamp \
- pdf.stamp \
- html.stamp
-
-distclean-local:
- rm -fr doctrees
- rm -fr html
- rm -fr latex
- rm -fr texinfo
-
-# We handle exit code manually. Please fix if there is a better way.
-distcheck-hook:
- if test ! -s $(info_file_dist); then \
- $(top_srcdir)/build-aux/dist-error $(info_file_dist); \
- fi
- if test ! -s $(pdf_file_dist); then \
- $(top_srcdir)/build-aux/dist-error $(pdf_file_dist); \
- fi
- exit_code=0; \
- for file in $(html_files); do \
- if test ! -s $$file; then \
- exit_code=1; \
- $(top_srcdir)/build-aux/dist-error $$file || break; \
- fi \
- done; \
- exit $$exit_code;
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index 2b05fbdd3..000000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,30 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-SUBDIRS = \
- snappy \
- ejson \
- ibrowse \
- mochiweb \
- oauth \
- config \
- couch_index \
- couch_mrview \
- couch_replicator \
- couch \
- twig \
- rexi \
- mem3 \
- fabric \
- ets_lru \
- ddoc_cache \
- chttpd
diff --git a/src/chttpd/.gitignore b/src/chttpd/.gitignore
deleted file mode 100644
index ba4df8d20..000000000
--- a/src/chttpd/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-ebin/* \ No newline at end of file
diff --git a/src/chttpd/Makefile.am b/src/chttpd/Makefile.am
deleted file mode 100644
index c785968c0..000000000
--- a/src/chttpd/Makefile.am
+++ /dev/null
@@ -1,56 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-chttpdebindir = $(localerlanglibdir)/chttpd/ebin
-
-chttpdebin_DATA = $(compiled_files)
-
-source_files = \
- src/chttpd.app.src \
- src/chttpd.erl \
- src/chttpd_app.erl \
- src/chttpd_config_listener.erl \
- src/chttpd_db.erl \
- src/chttpd_external.erl \
- src/chttpd_misc.erl \
- src/chttpd_rewrite.erl \
- src/chttpd_show.erl \
- src/chttpd_sup.erl \
- src/chttpd_view.erl
-
-compiled_files = \
- ebin/chttpd.app \
- ebin/chttpd.beam \
- ebin/chttpd_app.beam \
- ebin/chttpd_config_listener.beam \
- ebin/chttpd_db.beam \
- ebin/chttpd_external.beam \
- ebin/chttpd_misc.beam \
- ebin/chttpd_rewrite.beam \
- ebin/chttpd_show.beam \
- ebin/chttpd_sup.beam
-
-# Conflicts in couch_db.hrl prevent us from building these
-# until after we merge the couch application
-# ebin/chttpd_view.beam
-
-
-EXTRA_DIST = $(source_files)
-CLEANFILES = $(compiled_files)
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" < $< > $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/chttpd/README.md b/src/chttpd/README.md
deleted file mode 100644
index 784bedd72..000000000
--- a/src/chttpd/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-## chttpd
-
-chttpd is a cluster-aware http layer for [CouchDB][1]. It is used in [BigCouch][2] as the http front-end.
-
-### License
-[Apache 2.0][3]
-
-### Contact
- * [http://cloudant.com][4]
- * [info@cloudant.com][5]
-
-[1]: http://couchdb.apache.org
-[2]: http://github.com/cloudant/bigcouch
-[3]: http://www.apache.org/licenses/LICENSE-2.0.html
-[4]: http://cloudant.com
-[5]: mailto:info@cloudant.com
diff --git a/src/chttpd/src/chttpd.app.src b/src/chttpd/src/chttpd.app.src
index d841f6ce1..9ab91c879 100644
--- a/src/chttpd/src/chttpd.app.src
+++ b/src/chttpd/src/chttpd.app.src
@@ -12,7 +12,7 @@
{application, chttpd, [
{description, "HTTP interface for CouchDB cluster"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
chttpd,
chttpd_app,
diff --git a/src/chttpd/src/chttpd_view.erl b/src/chttpd/src/chttpd_view.erl
index 2c64dda13..85b88a3fa 100644
--- a/src/chttpd/src/chttpd_view.erl
+++ b/src/chttpd/src/chttpd_view.erl
@@ -12,6 +12,7 @@
-module(chttpd_view).
-include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
-export([handle_view_req/3, handle_temp_view_req/2, get_reduce_type/1,
parse_view_params/3, view_group_etag/2, view_group_etag/3,
@@ -91,11 +92,11 @@ view_callback({error, Reason}, {_, Resp}) ->
extract_view_type(_ViewName, [], _IsReduce) ->
throw({not_found, missing_named_view});
extract_view_type(ViewName, [View|Rest], IsReduce) ->
- case lists:member(ViewName, [Name || {Name, _} <- View#view.reduce_funs]) of
+ case lists:member(ViewName, [Name || {Name, _} <- View#mrview.reduce_funs]) of
true ->
if IsReduce -> reduce; true -> red_map end;
false ->
- case lists:member(ViewName, View#view.map_names) of
+ case lists:member(ViewName, View#mrview.map_names) of
true -> map;
false -> extract_view_type(ViewName, Rest, IsReduce)
end
@@ -153,7 +154,7 @@ parse_view_params(Req, Keys, ViewType) when not is_list(Req) ->
parse_view_params(QueryParams, Keys, ViewType);
parse_view_params(QueryParams, Keys, ViewType) ->
IsMultiGet = (Keys =/= nil),
- Args = #view_query_args{
+ Args = #mrargs{
view_type=ViewType,
multi_get=IsMultiGet,
keys=Keys
@@ -162,7 +163,7 @@ parse_view_params(QueryParams, Keys, ViewType) ->
validate_view_query(K, V, Args2)
end, Args, QueryParams),
- GroupLevel = QueryArgs#view_query_args.group_level,
+ GroupLevel = QueryArgs#mrargs.group_level,
case {ViewType, GroupLevel, IsMultiGet} of
{reduce, exact, true} ->
QueryArgs;
@@ -180,9 +181,9 @@ parse_view_params(QueryParams, Keys, ViewType) ->
parse_json_view_param({<<"key">>, V}) ->
[{start_key, V}, {end_key, V}];
parse_json_view_param({<<"startkey_docid">>, V}) ->
- [{start_docid, V}];
+ [{start_key_docid, V}];
parse_json_view_param({<<"endkey_docid">>, V}) ->
- [{end_docid, V}];
+ [{end_key_docid, V}];
parse_json_view_param({<<"startkey">>, V}) ->
[{start_key, V}];
parse_json_view_param({<<"endkey">>, V}) ->
@@ -224,9 +225,9 @@ parse_view_param("key", Value) ->
JsonKey = ?JSON_DECODE(Value),
[{start_key, JsonKey}, {end_key, JsonKey}];
parse_view_param("startkey_docid", Value) ->
- [{start_docid, ?l2b(Value)}];
+ [{start_key_docid, ?l2b(Value)}];
parse_view_param("endkey_docid", Value) ->
- [{end_docid, ?l2b(Value)}];
+ [{end_key_docid, ?l2b(Value)}];
parse_view_param("startkey", Value) ->
[{start_key, ?JSON_DECODE(Value)}];
parse_view_param("endkey", Value) ->
@@ -273,64 +274,64 @@ parse_view_param(Key, Value) ->
[{extra, {Key, Value}}].
validate_view_query(start_key, Value, Args) ->
- case Args#view_query_args.multi_get of
+ case Args#mrargs.multi_get of
true ->
Msg = <<"Query parameter `start_key` is "
"not compatiible with multi-get">>,
throw({query_parse_error, Msg});
_ ->
- Args#view_query_args{start_key=Value}
+ Args#mrargs{start_key=Value}
end;
-validate_view_query(start_docid, Value, Args) ->
- Args#view_query_args{start_docid=Value};
+validate_view_query(start_key_docid, Value, Args) ->
+ Args#mrargs{start_key_docid=Value};
validate_view_query(end_key, Value, Args) ->
- case Args#view_query_args.multi_get of
+ case Args#mrargs.multi_get of
true->
Msg = <<"Query paramter `end_key` is "
"not compatibile with multi-get">>,
throw({query_parse_error, Msg});
_ ->
- Args#view_query_args{end_key=Value}
+ Args#mrargs{end_key=Value}
end;
-validate_view_query(end_docid, Value, Args) ->
- Args#view_query_args{end_docid=Value};
+validate_view_query(end_key_docid, Value, Args) ->
+ Args#mrargs{end_key_docid=Value};
validate_view_query(limit, Value, Args) ->
- Args#view_query_args{limit=Value};
+ Args#mrargs{limit=Value};
validate_view_query(list, Value, Args) ->
- Args#view_query_args{list=Value};
+ Args#mrargs{list=Value};
validate_view_query(stale, Value, Args) ->
- Args#view_query_args{stale=Value};
+ Args#mrargs{stale=Value};
validate_view_query(descending, true, Args) ->
- case Args#view_query_args.direction of
+ case Args#mrargs.direction of
rev -> Args; % Already reversed
fwd ->
- Args#view_query_args{
+ Args#mrargs{
direction = rev,
- start_docid =
- reverse_key_default(Args#view_query_args.start_docid),
- end_docid =
- reverse_key_default(Args#view_query_args.end_docid)
+ start_key_docid =
+ reverse_key_default(Args#mrargs.start_key_docid),
+ end_key_docid =
+ reverse_key_default(Args#mrargs.end_key_docid)
}
end;
validate_view_query(descending, false, Args) ->
Args; % Ignore default condition
validate_view_query(skip, Value, Args) ->
- Args#view_query_args{skip=Value};
+ Args#mrargs{skip=Value};
validate_view_query(group_level, Value, Args) ->
- case Args#view_query_args.view_type of
+ case Args#mrargs.view_type of
reduce ->
- Args#view_query_args{group_level=Value};
+ Args#mrargs{group_level=Value};
_ ->
Msg = <<"Invalid URL parameter 'group' or "
" 'group_level' for non-reduce view.">>,
throw({query_parse_error, Msg})
end;
validate_view_query(inclusive_end, Value, Args) ->
- Args#view_query_args{inclusive_end=Value};
+ Args#mrargs{inclusive_end=Value};
validate_view_query(reduce, false, Args) ->
Args;
validate_view_query(reduce, _, Args) ->
- case Args#view_query_args.view_type of
+ case Args#mrargs.view_type of
map ->
Msg = <<"Invalid URL parameter `reduce` for map view.">>,
throw({query_parse_error, Msg});
@@ -338,29 +339,29 @@ validate_view_query(reduce, _, Args) ->
Args
end;
validate_view_query(include_docs, true, Args) ->
- case Args#view_query_args.view_type of
+ case Args#mrargs.view_type of
reduce ->
Msg = <<"Query paramter `include_docs` "
"is invalid for reduce views.">>,
throw({query_parse_error, Msg});
_ ->
- Args#view_query_args{include_docs=true}
+ Args#mrargs{include_docs=true}
end;
validate_view_query(include_docs, _Value, Args) ->
Args;
validate_view_query(conflicts, true, Args) ->
- case Args#view_query_args.view_type of
+ case Args#mrargs.view_type of
reduce ->
Msg = <<"Query parameter `conflicts` "
"is invalid for reduce views.">>,
throw({query_parse_error, Msg});
_ ->
- Args#view_query_args{extra = [conflicts|Args#view_query_args.extra]}
+ Args#mrargs{extra = [conflicts|Args#mrargs.extra]}
end;
validate_view_query(conflicts, _Value, Args) ->
Args;
validate_view_query(sorted, false, Args) ->
- Args#view_query_args{sorted=false};
+ Args#mrargs{sorted=false};
validate_view_query(sorted, _Value, Args) ->
Args;
validate_view_query(extra, _Value, Args) ->
diff --git a/src/config/.gitignore b/src/config/.gitignore
deleted file mode 100644
index c57e7cfcb..000000000
--- a/src/config/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-ebin
-deps
-.eunit
-*~
-*.swp
diff --git a/src/config/Makefile.am b/src/config/Makefile.am
deleted file mode 100644
index 86731a2cf..000000000
--- a/src/config/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-configebindir = $(localerlanglibdir)/config/ebin
-
-configebin_DATA = $(compiled_files)
-
-source_files = \
- src/config.app.src \
- src/config.erl \
- src/config_app.erl \
- src/config_listener.erl \
- src/config_sup.erl \
- src/config_util.erl \
- src/config_writer.erl
-
-compiled_files = \
- ebin/config.app \
- ebin/config.beam \
- ebin/config_app.beam \
- ebin/config_listener.beam \
- ebin/config_sup.beam \
- ebin/config_util.beam \
- ebin/config_writer.beam
-
-EXTRA_DIST = $(source_files)
-CLEANFILES = $(compiled_files)
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" < $< > $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/config/src/config.app.src b/src/config/src/config.app.src
index 9b0f5f069..6eea351ff 100644
--- a/src/config/src/config.app.src
+++ b/src/config/src/config.app.src
@@ -12,7 +12,7 @@
{application, config, [
{description, "INI file configuration system for Apache CouchDB"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
config,
config_app,
diff --git a/src/couch/Makefile.am b/src/couch/Makefile.am
deleted file mode 100644
index 5f47bcdc3..000000000
--- a/src/couch/Makefile.am
+++ /dev/null
@@ -1,204 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-SUBDIRS = priv
-
-# devdocdir = $(localdocdir)/developer/couchdb
-couchlibdir = $(localerlanglibdir)/couch-$(version)
-couchincludedir = $(couchlibdir)/include
-couchebindir = $(couchlibdir)/ebin
-
-couchinclude_DATA = include/couch_db.hrl
-couchebin_DATA = $(compiled_files)
-
-# dist_devdoc_DATA = $(doc_base) $(doc_modules)
-
-CLEANFILES = $(compiled_files) $(doc_base)
-
-# CLEANFILES = $(doc_modules) edoc-info
-
-source_files = \
- src/couch.erl \
- src/couch_app.erl \
- src/couch_auth_cache.erl \
- src/couch_btree.erl \
- src/couch_changes.erl \
- src/couch_compaction_daemon.erl \
- src/couch_compress.erl \
- src/couch_config.erl \
- src/couch_config_writer.erl \
- src/couch_db.erl \
- src/couch_db_update_notifier.erl \
- src/couch_db_update_notifier_sup.erl \
- src/couch_doc.erl \
- src/couch_drv.erl \
- src/couch_ejson_compare.erl \
- src/couch_emsort.erl \
- src/couch_event_sup.erl \
- src/couch_external_manager.erl \
- src/couch_external_server.erl \
- src/couch_file.erl \
- src/couch_httpd.erl \
- src/couch_httpd_db.erl \
- src/couch_httpd_auth.erl \
- src/couch_httpd_cors.erl \
- src/couch_httpd_oauth.erl \
- src/couch_httpd_external.erl \
- src/couch_httpd_misc_handlers.erl \
- src/couch_httpd_proxy.erl \
- src/couch_httpd_rewrite.erl \
- src/couch_httpd_stats_handlers.erl \
- src/couch_httpd_vhost.erl \
- src/couch_key_tree.erl \
- src/couch_log.erl \
- src/couch_lru.erl \
- src/couch_native_process.erl \
- src/couch_os_daemons.erl \
- src/couch_os_process.erl \
- src/couch_passwords.erl \
- src/couch_primary_sup.erl \
- src/couch_proc_manager.erl \
- src/couch_query_servers.erl \
- src/couch_secondary_sup.erl \
- src/couch_server.erl \
- src/couch_stats_aggregator.erl \
- src/couch_stats_collector.erl \
- src/couch_stream.erl \
- src/couch_sup.erl \
- src/couch_task_status.erl \
- src/couch_users_db.erl \
- src/couch_util.erl \
- src/couch_uuids.erl \
- src/couch_db_updater.erl \
- src/couch_work_queue.erl
-
-EXTRA_DIST = \
- $(source_files) \
- include/couch_db.hrl \
- src/couch_js_functions.hrl
-
-compiled_files = \
- ebin/couch.app \
- ebin/couch.beam \
- ebin/couch_app.beam \
- ebin/couch_auth_cache.beam \
- ebin/couch_btree.beam \
- ebin/couch_changes.beam \
- ebin/couch_compaction_daemon.beam \
- ebin/couch_compress.beam \
- ebin/couch_config.beam \
- ebin/couch_config_writer.beam \
- ebin/couch_db.beam \
- ebin/couch_db_update_notifier.beam \
- ebin/couch_db_update_notifier_sup.beam \
- ebin/couch_doc.beam \
- ebin/couch_drv.beam \
- ebin/couch_ejson_compare.beam \
- ebin/couch_emsort.beam \
- ebin/couch_event_sup.beam \
- ebin/couch_external_manager.beam \
- ebin/couch_external_server.beam \
- ebin/couch_file.beam \
- ebin/couch_httpd.beam \
- ebin/couch_httpd_db.beam \
- ebin/couch_httpd_auth.beam \
- ebin/couch_httpd_oauth.beam \
- ebin/couch_httpd_cors.beam \
- ebin/couch_httpd_proxy.beam \
- ebin/couch_httpd_external.beam \
- ebin/couch_httpd_misc_handlers.beam \
- ebin/couch_httpd_rewrite.beam \
- ebin/couch_httpd_stats_handlers.beam \
- ebin/couch_httpd_vhost.beam \
- ebin/couch_key_tree.beam \
- ebin/couch_log.beam \
- ebin/couch_lru.beam \
- ebin/couch_native_process.beam \
- ebin/couch_os_daemons.beam \
- ebin/couch_os_process.beam \
- ebin/couch_passwords.beam \
- ebin/couch_primary_sup.beam \
- ebin/couch_proc_manager.beam \
- ebin/couch_query_servers.beam \
- ebin/couch_secondary_sup.beam \
- ebin/couch_server.beam \
- ebin/couch_stats_aggregator.beam \
- ebin/couch_stats_collector.beam \
- ebin/couch_stream.beam \
- ebin/couch_sup.beam \
- ebin/couch_task_status.beam \
- ebin/couch_users_db.beam \
- ebin/couch_util.beam \
- ebin/couch_uuids.beam \
- ebin/couch_db_updater.beam \
- ebin/couch_work_queue.beam
-
-# doc_base = \
-# erlang.png \
-# index.html \
-# modules-frame.html \
-# overview-summary.html \
-# packages-frame.html \
-# stylesheet.css
-
-# doc_modules = \
-# couch_btree.html \
-# couch_config.html \
-# couch_config_writer.html \
-# couch_db.html \
-# couch_db_update_notifier.html \
-# couch_db_update_notifier_sup.html \
-# couch_doc.html \
-# couch_event_sup.html \
-# couch_file.html \
-# couch_httpd.html \
-# couch_key_tree.html \
-# couch_log.html \
-# couch_query_servers.html \
-# couch_rep.html \
-# couch_rep_sup.html \
-# couch_server.html \
-# couch_stream.html \
-# couch_util.html
-
-if WINDOWS
-ebin/couch.app: src/couch.app.tpl
- @mkdir -p ebin/
- modules=`find ./src -name "*.erl" \! -name ".*" -exec basename {} .erl \; | tr '\n' ',' | sed "s/,$$//"`; \
- sed -e "s|%package_name%|@package_name@|g" \
- -e "s|%version%|@version@|g" \
- -e "s|@modules@|$$modules|g" \
- -e "s|%localconfdir%|../etc/couchdb|g" \
- -e "s|@defaultini@|default.ini|g" \
- -e "s|@localini@|local.ini|g" > \
- $@ < $<
-else
-ebin/couch.app: src/couch.app.tpl
- @mkdir -p ebin/
- modules=`{ find ./src -name "*.erl" \! -name ".*" -exec basename {} .erl \; | tr '\n' ','; echo ''; } | sed "s/,$$//"`; \
- sed -e "s|%package_name%|@package_name@|g" \
- -e "s|%version%|@version@|g" \
- -e "s|@modules@|$$modules|g" \
- -e "s|%localconfdir%|@localconfdir@|g" \
- -e "s|@defaultini@|default.ini|g" \
- -e "s|@localini@|local.ini|g" > \
- $@ < $<
-endif
-
-# $(dist_devdoc_DATA): edoc-info
-
-# $(ERL) -noshell -run edoc_run files [\"$<\"]
-
-ebin/%.beam: src/%.erl include/couch_db.hrl src/couch_js_functions.hrl
- @mkdir -p ebin/
- $(ERLC) -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) ${TEST} $<;
-
diff --git a/src/couch/priv/Makefile.am b/src/couch/priv/Makefile.am
deleted file mode 100644
index ced9bec22..000000000
--- a/src/couch/priv/Makefile.am
+++ /dev/null
@@ -1,159 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-MAKE_SAFE = $(MAKE)
-
-couchlibdir = $(localerlanglibdir)/couch-$(version)
-couchprivdir = $(couchlibdir)/priv
-couchprivlibdir = $(couchlibdir)/priv/lib
-man1dir = $(mandir)/man1
-
-man_file = couchjs.1
-
-if BUILD_MAN
-man_file_build = $(man_file)
-else
-man_file_build =
-endif
-
-BUILT_SOURCES = $(man_file_build)
-
-EXTRA_DIST = \
- spawnkillable/couchspawnkillable.sh \
- stat_descriptions.cfg.in \
- couch_ejson_compare/erl_nif_compat.h \
- couch_js/sm170.c \
- couch_js/sm180.c \
- couch_js/sm185.c \
- $(man_file_build)
-
-CLEANFILES = $(man_file_build) stat_descriptions.cfg
-
-couchprivlib_LTLIBRARIES = couch_icu_driver.la
-if USE_EJSON_COMPARE_NIF
-couchprivlib_LTLIBRARIES += couch_ejson_compare.la
-couch_ejson_compare_la_SOURCES = couch_ejson_compare/couch_ejson_compare.c
-couch_ejson_compare_la_CPPFLAGS = -D_BSD_SOURCE $(ICU_CPPFLAGS) $(ERLANG_FLAGS)
-couch_ejson_compare_la_LDFLAGS = -module -avoid-version
-couch_ejson_compare_la_LIBADD = $(ICU_LIBS)
-if WINDOWS
-couch_ejson_compare_la_LDFLAGS += -no-undefined
-endif
-endif
-couch_icu_driver_la_SOURCES = icu_driver/couch_icu_driver.c
-couch_icu_driver_la_LDFLAGS = -module -avoid-version
-couch_icu_driver_la_CPPFLAGS = $(ICU_CPPFLAGS) $(ERLANG_FLAGS)
-couch_icu_driver_la_LIBADD = $(ICU_LIBS)
-
-if WINDOWS
-couch_icu_driver_la_LDFLAGS += -no-undefined
-couch_icu_driver_so_name = couch_icu_driver.dll
-else
-couch_icu_driver_so_name = couch_icu_driver.so
-endif
-
-$(couch_icu_driver_so_name): couch_icu_driver.la
- cp .libs/$(couch_icu_driver_so_name) $@
-
-all: $(couch_icu_driver_so_name)
-
-COUCHJS_SRCS = \
- couch_js/help.h \
- couch_js/http.c \
- couch_js/http.h \
- couch_js/main.c \
- couch_js/utf8.c \
- couch_js/utf8.h \
- couch_js/util.h \
- couch_js/util.c
-
-locallibbin_PROGRAMS = couchjs
-couchjs_SOURCES = $(COUCHJS_SRCS)
-couchjs_CFLAGS = -g -Wall -Werror -D_BSD_SOURCE $(CURL_CFLAGS) $(JS_CFLAGS)
-couchjs_LDADD = $(CURL_LIBS) $(JS_LIBS)
-
-couchpriv_DATA = stat_descriptions.cfg
-couchpriv_PROGRAMS = couchspawnkillable
-
-# Depend on source files so distributed man pages are not rebuilt for end user.
-
-$(man_file): $(COUCHJS_SRCS)
- $(MAKE_SAFE) -f Makefile couchjs; \
- $(top_srcdir)/build-aux/missing --run \
- help2man \
- --no-info \
- --help-option="-h" \
- --version-option="-V" \
- --name="$(package_name) JavaScript interpreter" \
- ./couchjs --output $@
-
-install-data-local:
- if test -s $(man_file); then \
- if test `cat $(man_file) | wc -l` -gt 1; then \
- $(INSTALL) -d $(DESTDIR)$(man1dir); \
- $(INSTALL_DATA) $(man_file) $(DESTDIR)$(man1dir)/$(man_file); \
- fi \
- fi
-
-%.cfg: %.cfg.in
- cp $< $@
-
-if WINDOWS
-couchspawnkillable_SOURCES = spawnkillable/couchspawnkillable_win.c
-endif
-
-if !WINDOWS
-couchspawnkillable: spawnkillable/couchspawnkillable.sh
- cp $< $@
- chmod +x $@
-endif
-
-# libtool and automake have defeated markh. For each of our executables
-# we end up with 2 copies - one directly in the 'target' folder (eg, 'priv')
-# and another - the correct one - in .libs. The former doesn't work but is
-# what gets installed for 'couchspawnkillable' - but the correct one for
-# couchjs.exe *does* get copied. *shrug* So just clobber it with the
-# correct one as the last step. See bug COUCHDB-439
-install-data-hook:
- if test -f "$(DESTDIR)$(couchprivlibdir)/couch_icu_driver"; then \
- rm -f "$(DESTDIR)$(couchprivlibdir)/couch_icu_driver.so"; \
- cd "$(DESTDIR)$(couchprivlibdir)" && \
- $(LN_S) couch_icu_driver couch_icu_driver.so; \
- fi
- if test -f "$(DESTDIR)$(couchprivlibdir)/couch_ejson_compare_nif"; then \
- rm -f "$(DESTDIR)$(couchprivlibdir)/couch_ejson_compare_nif.so"; \
- cd "$(DESTDIR)$(couchprivlibdir)" && \
- $(LN_S) couch_ejson_compare_nif couch_ejson_compare_nif.so; \
- fi
-if WINDOWS
- $(INSTALL) $(ICU_BIN)/icuuc*.dll $(bindir)
- $(INSTALL) $(ICU_BIN)/icudt*.dll $(bindir)
- $(INSTALL) $(ICU_BIN)/icuin*.dll $(bindir)
- $(INSTALL) $(JS_LIB_BINARY) $(bindir)
- $(INSTALL) .libs/couchspawnkillable.exe \
- "$(DESTDIR)$(couchprivdir)/couchspawnkillable.exe"
-endif
-
-uninstall-local:
- rm -f $(DESTDIR)$(man1dir)/$(man_file)
- if test -f "$(DESTDIR)$(couchprivlibdir)/couch_erl_driver"; then \
- rm -f "$(DESTDIR)$(couchprivlibdir)/couch_erl_driver.so"; \
- fi
-
-distcheck-hook:
- if test ! -s $(man_file); then \
- $(top_srcdir)/build-aux/dist-error $(man_file); \
- else \
- if test ! `cat $(man_file) | wc -l` -gt 1; then \
- $(top_srcdir)/build-aux/dist-error $(man_file); \
- fi \
- fi
diff --git a/src/couch/priv/stat_descriptions.cfg.in b/src/couch/priv/stat_descriptions.cfg
index b80d76844..b80d76844 100644
--- a/src/couch/priv/stat_descriptions.cfg.in
+++ b/src/couch/priv/stat_descriptions.cfg
diff --git a/src/couch/rebar.config b/src/couch/rebar.config
new file mode 100644
index 000000000..def6879d8
--- /dev/null
+++ b/src/couch/rebar.config
@@ -0,0 +1,11 @@
+{port_specs, [{"priv/couch_icu_driver.so", ["priv/icu_driver/couch_icu_driver.c"]}]}.
+
+{port_env, [
+ {"DRV_CFLAGS", "$DRV_CFLAGS -DPIC -O2 -fno-common"},
+ {"DRV_LDFLAGS", "$DRV_LDFLAGS -lm -licuuc -licudata -licui18n -lpthread"},
+ {"linux", "DRV_LDFLAGS", "$DRV_LDFLAGS -lcrypt"},
+ {"freebsd", "DRV_CFLAGS", "$DRV_CFLAGS -I/usr/local/include"},
+ {"freebsd", "DRV_LDFLAGS", "$DRV_LDFLAGS -L/usr/local/lib"},
+ {"solaris", "DRV_CFLAGS", "$DRV_CFLAGS -I/opt/local/include"},
+ {"solaris", "DRV_LDFLAGS", "$DRV_LDFLAGS -L/opt/local/lib"}
+]}.
diff --git a/src/couch/src/couch.app.tpl.in b/src/couch/src/couch.app.src
index 9b7536b99..bb1e52739 100644
--- a/src/couch/src/couch.app.tpl.in
+++ b/src/couch/src/couch.app.src
@@ -1,7 +1,6 @@
{application, couch, [
- {description, "@package_name@"},
- {vsn, "@version@"},
- {modules, [@modules@]},
+ {description, "Apache CouchDB"},
+ {vsn, git},
{registered, [
couch_db_update,
couch_db_update_notifier_sup,
@@ -17,10 +16,7 @@
couch_stats_collector,
couch_task_status
]},
- {mod, {couch_app, [
- "%localconfdir%/@defaultini@",
- "%localconfdir%/@localini@"
- ]}},
- {applications, [kernel, stdlib, twig, config]},
- {included_applications, [crypto, sasl, inets, oauth, ibrowse, mochiweb, os_mon]}
+ {mod, {couch_app, []}},
+ {applications, [kernel, stdlib, crypto, sasl, inets, oauth, ibrowse,
+ mochiweb, ssl, twig]}
]}.
diff --git a/src/couch_index/Makefile.am b/src/couch_index/Makefile.am
deleted file mode 100644
index 945623acc..000000000
--- a/src/couch_index/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-couch_indexlibdir = $(localerlanglibdir)/couch_index-0.1
-couch_indexebindir = $(couch_indexlibdir)/ebin
-
-couch_indexebin_DATA = $(compiled_files)
-
-EXTRA_DIST = $(source_files)
-CLEANFILES = $(compiled_files)
-
-source_files = \
- src/couch_index.erl \
- src/couch_index_compactor.erl \
- src/couch_index_server.erl \
- src/couch_index_updater.erl \
- src/couch_index_util.erl
-
-compiled_files = \
- ebin/couch_index.beam \
- ebin/couch_index_compactor.beam \
- ebin/couch_index_server.beam \
- ebin/couch_index_updater.beam \
- ebin/couch_index_util.beam
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) ${TEST} $<;
-
diff --git a/src/couch_index/src/couch_index.app.src b/src/couch_index/src/couch_index.app.src
index 141ed9d35..594589d5e 100644
--- a/src/couch_index/src/couch_index.app.src
+++ b/src/couch_index/src/couch_index.app.src
@@ -12,7 +12,7 @@
{application, couch_index, [
{description, "CouchDB Secondary Index Manager"},
- {vsn, "@version@"},
+ {vsn, git},
{modules, [
couch_index,
couch_index_server
diff --git a/src/couch_mrview/Makefile.am b/src/couch_mrview/Makefile.am
deleted file mode 100644
index fa7d83b9c..000000000
--- a/src/couch_mrview/Makefile.am
+++ /dev/null
@@ -1,72 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-couch_mrviewlibdir = $(localerlanglibdir)/couch_mrview-0.1
-couch_mrviewincludedir = $(couch_mrviewlibdir)/include
-couch_mrviewebindir = $(couch_mrviewlibdir)/ebin
-
-couch_mrviewinclude_DATA = $(include_files)
-couch_mrviewebin_DATA = $(compiled_files)
-
-include_files = \
- include/couch_mrview.hrl
-
-source_files = \
- src/couch_mrview.app.src \
- src/couch_mrview.erl \
- src/couch_mrview_cleanup.erl \
- src/couch_mrview_compactor.erl \
- src/couch_mrview_http.erl \
- src/couch_mrview_index.erl \
- src/couch_mrview_show.erl \
- src/couch_mrview_test_util.erl \
- src/couch_mrview_updater.erl \
- src/couch_mrview_util.erl
-
-test_files = \
- test/01-load.t \
- test/02-map-views.t \
- test/03-red-views.t \
- test/04-index-info.t \
- test/05-collation.t \
- test/06-all-docs.t \
- test/07-compact-swap.t
-
-compiled_files = \
- ebin/couch_mrview.app \
- ebin/couch_mrview.beam \
- ebin/couch_mrview_cleanup.beam \
- ebin/couch_mrview_compactor.beam \
- ebin/couch_mrview_http.beam \
- ebin/couch_mrview_index.beam \
- ebin/couch_mrview_show.beam \
- ebin/couch_mrview_test_util.beam \
- ebin/couch_mrview_updater.beam \
- ebin/couch_mrview_util.beam
-
-EXTRA_DIST = $(include_files) $(source_files) $(test_files)
-CLEANFILES = $(compiled_files)
-
-check:
-if TESTS
- $(abs_top_builddir)/test/etap/run $(abs_top_srcdir)/src/couch_mrview/test
-endif
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" \
- < $< > $@
-
-ebin/%.beam: src/%.erl $(include_files)
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) ${TEST} $<;
-
diff --git a/src/couch_mrview/include/couch_mrview.hrl b/src/couch_mrview/include/couch_mrview.hrl
index 0d590665d..6a0dfd023 100644
--- a/src/couch_mrview/include/couch_mrview.hrl
+++ b/src/couch_mrview/include/couch_mrview.hrl
@@ -70,11 +70,13 @@
skip = 0,
group_level = 0,
stale = false,
+ multi_get = false,
inclusive_end = true,
include_docs = false,
update_seq=false,
conflicts,
callback,
list,
+ sorted = true,
extra = []
}).
diff --git a/src/couch_mrview/src/couch_mrview.app.src b/src/couch_mrview/src/couch_mrview.app.src
index 52898a659..99c52f063 100644
--- a/src/couch_mrview/src/couch_mrview.app.src
+++ b/src/couch_mrview/src/couch_mrview.app.src
@@ -12,7 +12,7 @@
{application, couch_mrview, [
{description, "CouchDB Map/Reduce Views"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
couch_mrview,
couch_mrview_compactor,
diff --git a/src/couch_replicator/.gitignore b/src/couch_replicator/.gitignore
deleted file mode 100644
index b3099f518..000000000
--- a/src/couch_replicator/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.beam
-.eunit
-ebin/replicator.app
-.DS_Store \ No newline at end of file
diff --git a/src/couch_replicator/Makefile.am b/src/couch_replicator/Makefile.am
deleted file mode 100644
index ea5d117fe..000000000
--- a/src/couch_replicator/Makefile.am
+++ /dev/null
@@ -1,76 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-couch_replicatorlibdir = $(localerlanglibdir)/couch_replicator-0.1
-couch_replicatorincludedir = $(couch_replicatorlibdir)/include
-couch_replicatorebindir = $(couch_replicatorlibdir)/ebin
-
-couch_replicatorinclude_DATA = $(include_files)
-couch_replicatorebin_DATA = $(compiled_files)
-
-include_files = \
- src/couch_replicator_api_wrap.hrl \
- src/couch_replicator.hrl \
- src/couch_replicator_js_functions.hrl
-
-source_files = \
- src/couch_replicator_api_wrap.erl \
- src/couch_replicator_httpc_pool.erl \
- src/couch_replicator_httpc.erl \
- src/couch_replicator_httpd.erl \
- src/couch_replicator_job_sup.erl \
- src/couch_replicator_notifier.erl \
- src/couch_replicator_manager.erl \
- src/couch_replicator_utils.erl \
- src/couch_replicator_worker.erl \
- src/couch_replicator.app.src \
- src/couch_replicator.erl
-
-test_files = \
- test/01-load.t \
- test/02-httpc-pool.t \
- test/03-replication-compact.t \
- test/04-replication-large-atts.t \
- test/05-replication-many-leaves.t \
- test/06-doc-missing-stubs.t
-
-compiled_files = \
- ebin/couch_replicator_api_wrap.beam \
- ebin/couch_replicator_httpc_pool.beam \
- ebin/couch_replicator_httpc.beam \
- ebin/couch_replicator_httpd.beam \
- ebin/couch_replicator_job_sup.beam \
- ebin/couch_replicator_notifier.beam \
- ebin/couch_replicator_manager.beam \
- ebin/couch_replicator_utils.beam \
- ebin/couch_replicator_worker.beam \
- ebin/couch_replicator.app \
- ebin/couch_replicator.beam
-
-EXTRA_DIST = $(include_files) $(source_files) $(test_files)
-CLEANFILES = $(compiled_files)
-
-check:
-if TESTS
- $(abs_top_builddir)/test/etap/run $(abs_top_srcdir)/src/couch_replicator/test
-endif
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" \
- < $< > $@
-
-ebin/%.beam: src/%.erl $(include_files)
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) ${TEST} $<;
-
-
diff --git a/src/couch_replicator/src/couch_replicator.app.src b/src/couch_replicator/src/couch_replicator.app.src
index bd6b3e357..2da0d4a43 100644
--- a/src/couch_replicator/src/couch_replicator.app.src
+++ b/src/couch_replicator/src/couch_replicator.app.src
@@ -12,7 +12,7 @@
{application, couch_replicator, [
{description, "CouchDB replicator"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
couch_replicator,
couch_replicator_api_wrap,
diff --git a/src/ddoc_cache/.gitignore b/src/ddoc_cache/.gitignore
deleted file mode 100644
index fc83a9a22..000000000
--- a/src/ddoc_cache/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-ebin/
diff --git a/src/ddoc_cache/Makefile.am b/src/ddoc_cache/Makefile.am
deleted file mode 100644
index 6936545b8..000000000
--- a/src/ddoc_cache/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-ddoc_cacheebindir = $(localerlanglibdir)/ddoc_cache/ebin
-
-ddoc_cacheebin_DATA = $(compiled_files)
-
-source_files = \
- src/ddoc_cache.app.src \
- src/ddoc_cache.erl \
- src/ddoc_cache_app.erl \
- src/ddoc_cache_opener.erl \
- src/ddoc_cache_sup.erl \
- src/ddoc_cache_util.erl
-
-compiled_files = \
- ebin/ddoc_cache.app \
- ebin/ddoc_cache.beam \
- ebin/ddoc_cache_app.beam \
- ebin/ddoc_cache_opener.beam \
- ebin/ddoc_cache_sup.beam \
- ebin/ddoc_cache_util.beam
-
-EXTRA_DIST = $(source_files)
-CLEANFILES = $(compiled_files)
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" < $< > $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/ddoc_cache/src/ddoc_cache.app.src b/src/ddoc_cache/src/ddoc_cache.app.src
index 78f45de85..a183dbdb6 100644
--- a/src/ddoc_cache/src/ddoc_cache.app.src
+++ b/src/ddoc_cache/src/ddoc_cache.app.src
@@ -12,7 +12,7 @@
{application, ddoc_cache, [
{description, "Design Document Cache"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
ddoc_cache,
ddoc_cache_app,
diff --git a/src/ejson/Makefile.am b/src/ejson/Makefile.am
deleted file mode 100644
index 21136fba2..000000000
--- a/src/ejson/Makefile.am
+++ /dev/null
@@ -1,91 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-ejsonebindir = $(localerlanglibdir)/ejson-0.1.0/ebin
-ejsonprivdir = $(localerlanglibdir)/ejson-0.1.0/priv
-
-CLEANFILES = \
- $(ejsonebin_make_generated_file_list) \
- $(ejsonpriv_make_generated_file_list) \
- priv/ejson.so
-
-EJSON_C_SRCS = \
- c_src/ejson.c \
- c_src/decode.c \
- c_src/encode.c \
- c_src/yajl/yajl_alloc.c \
- c_src/yajl/yajl_buf.c \
- c_src/yajl/yajl.c \
- c_src/yajl/yajl_encode.c \
- c_src/yajl/yajl_gen.c \
- c_src/yajl/yajl_lex.c \
- c_src/yajl/yajl_parser.c
-
-EJSON_C_HDRS = \
- c_src/erl_nif_compat.h \
- c_src/yajl/yajl_alloc.h \
- c_src/yajl/yajl_buf.h \
- c_src/yajl/yajl_bytestack.h \
- c_src/yajl/yajl_common.h \
- c_src/yajl/yajl_encode.h \
- c_src/yajl/yajl_gen.h \
- c_src/yajl/yajl_lex.h \
- c_src/yajl/yajl_parse.h \
- c_src/yajl/yajl_parser.h
-
-ejson_file_collection = \
- src/ejson.app.in \
- src/ejson.erl \
- src/mochijson2.erl \
- src/mochinum.erl
-
-ejsonebin_make_generated_file_list = \
- ebin/ejson.app \
- ebin/ejson.beam \
- ebin/mochijson2.beam \
- ebin/mochinum.beam
-
-EXTRA_DIST = \
- $(EJSON_C_HDRS) \
- $(ejson_file_collection)
-
-ejsonebin_DATA = \
- $(ejsonebin_make_generated_file_list)
-
-if USE_OTP_NIFS
-ejsonpriv_LTLIBRARIES = ejson.la
-
-ejson_la_SOURCES = $(EJSON_C_SRCS)
-ejson_la_CFLAGS = $(ERLANG_FLAGS)
-ejson_la_LDFLAGS = -module -avoid-version
-
-if WINDOWS
-ejson_la_LDFLAGS += -no-undefined
-EJSON_SO_NAME = ejson.dll
-else
-EJSON_SO_NAME = ejson.so
-endif
-
-priv/$(EJSON_SO_NAME): ejson.la
- @mkdir -p ./priv
- cp .libs/$(EJSON_SO_NAME) $@
-
-all: priv/$(EJSON_SO_NAME)
-endif
-
-ebin/%.app: src/%.app.in
- @mkdir -p ebin/
- cp $< $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) $(ERLC_FLAGS) -o ebin/ $<
diff --git a/src/ejson/src/ejson.app.in b/src/ejson/src/ejson.app.src
index c2920e9c4..7180b81cf 100644
--- a/src/ejson/src/ejson.app.in
+++ b/src/ejson/src/ejson.app.src
@@ -1,6 +1,6 @@
{application, ejson, [
{description, "EJSON - decode and encode JSON into/from Erlang terms"},
- {vsn, "0.1.0"},
+ {vsn, git},
{modules, [ejson]},
{registered, []},
{applications, [kernel, stdlib]},
diff --git a/src/ets_lru/.gitignore b/src/ets_lru/.gitignore
deleted file mode 100644
index 90bd4cbf4..000000000
--- a/src/ets_lru/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-erl_crash.dump
-
-.eunit/
-ebin/
-test/*.beam
diff --git a/src/ets_lru/Makefile.am b/src/ets_lru/Makefile.am
deleted file mode 100644
index 5fd6c7bb2..000000000
--- a/src/ets_lru/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-ets_lruebindir = $(localerlanglibdir)/ets_lru/ebin
-
-ets_lruebin_DATA = $(compiled_files)
-
-source_files = \
- src/ets_lru.app.src \
- src/ets_lru.erl
-
-compiled_files = \
- ebin/ets_lru.app \
- ebin/ets_lru.beam
-
-EXTRA_DIST = $(source_files)
-CLEANFILES = $(compiled_files)
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" < $< > $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/ets_lru/src/ets_lru.app.src b/src/ets_lru/src/ets_lru.app.src
index 603c5d6b4..2573a0f1a 100644
--- a/src/ets_lru/src/ets_lru.app.src
+++ b/src/ets_lru/src/ets_lru.app.src
@@ -12,7 +12,7 @@
{application, ets_lru, [
{description, "ETS Base LRU Cache"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
ets_lru
]},
diff --git a/src/fabric/.gitignore b/src/fabric/.gitignore
deleted file mode 100644
index 37bfdb0ee..000000000
--- a/src/fabric/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.beam
-.eunit
-ebin/fabric.app
-.DS_Store \ No newline at end of file
diff --git a/src/fabric/Makefile.am b/src/fabric/Makefile.am
deleted file mode 100644
index 64ca93573..000000000
--- a/src/fabric/Makefile.am
+++ /dev/null
@@ -1,77 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-fabricebindir = $(localerlanglibdir)/fabric/ebin
-
-fabricebin_DATA = $(compiled_files)
-
-source_files = \
- src/fabric.app.src \
- src/fabric.erl \
- src/fabric_db_create.erl \
- src/fabric_db_delete.erl \
- src/fabric_db_doc_count.erl \
- src/fabric_db_info.erl \
- src/fabric_db_meta.erl \
- src/fabric_db_update_listener.erl \
- src/fabric_dict.erl \
- src/fabric_doc_attachments.erl \
- src/fabric_doc_missing_revs.erl \
- src/fabric_doc_open.erl \
- src/fabric_doc_open_revs.erl \
- src/fabric_doc_update.erl \
- src/fabric_group_info.erl \
- src/fabric_rpc.erl \
- src/fabric_util.erl \
- src/fabric_view.erl \
- src/fabric_view_all_docs.erl \
- src/fabric_view_changes.erl \
- src/fabric_view_map.erl \
- src/fabric_view_reduce.erl
-
-compiled_files = \
- ebin/fabric.app \
- ebin/fabric.beam \
- ebin/fabric_db_create.beam \
- ebin/fabric_db_delete.beam \
- ebin/fabric_db_doc_count.beam \
- ebin/fabric_db_info.beam \
- ebin/fabric_db_meta.beam \
- ebin/fabric_db_update_listener.beam \
- ebin/fabric_dict.beam \
- ebin/fabric_doc_attachments.beam \
- ebin/fabric_doc_missing_revs.beam \
- ebin/fabric_doc_open.beam \
- ebin/fabric_doc_open_revs.beam \
- ebin/fabric_doc_update.beam \
- ebin/fabric_group_info.beam \
- ebin/fabric_util.beam
-
-# Conflicts in couch_db.hrl prevent us from building these
-# until after we merge the couch application
-# ebin/fabric_rpc.beam
-# ebin/fabric_view.beam
-# ebin/fabric_view_all_docs.beam
-# ebin/fabric_view_changes.beam
-# ebin/fabric_view_map.beam
-# ebin/fabric_view_reduce.beam
-
-EXTRA_DIST = $(source_files)
-CLEANFILES = $(compiled_files)
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" < $< > $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/fabric/src/fabric.app.src b/src/fabric/src/fabric.app.src
index a3022e6f8..5ac86efd1 100644
--- a/src/fabric/src/fabric.app.src
+++ b/src/fabric/src/fabric.app.src
@@ -12,7 +12,7 @@
{application, fabric, [
{description, "Routing and proxying layer for CouchDB cluster"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
fabric,
fabric_db_create,
diff --git a/src/fabric/src/fabric_rpc.erl b/src/fabric/src/fabric_rpc.erl
index 49266098f..2685cd79a 100644
--- a/src/fabric/src/fabric_rpc.erl
+++ b/src/fabric/src/fabric_rpc.erl
@@ -22,6 +22,7 @@
-include_lib("fabric/include/fabric.hrl").
-include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
-record (view_acc, {
db,
@@ -38,13 +39,13 @@
%% rpc endpoints
%% call to with_db will supply your M:F with a #db{} and then remaining args
-all_docs(DbName, #view_query_args{keys=nil} = QueryArgs) ->
+all_docs(DbName, #mrargs{keys=nil} = QueryArgs) ->
{ok, Db} = get_or_create_db(DbName, []),
- #view_query_args{
+ #mrargs{
start_key = StartKey,
- start_docid = StartDocId,
+ start_key_docid = StartDocId,
end_key = EndKey,
- end_docid = EndDocId,
+ end_key_docid = EndDocId,
limit = Limit,
skip = Skip,
include_docs = IncludeDocs,
@@ -93,7 +94,7 @@ changes(DbName, Options, StartSeq) ->
map_view(DbName, DDoc, ViewName, QueryArgs) ->
{ok, Db} = get_or_create_db(DbName, []),
- #view_query_args{
+ #mrargs{
limit = Limit,
skip = Skip,
keys = Keys,
@@ -126,7 +127,7 @@ map_view(DbName, DDoc, ViewName, QueryArgs) ->
{ok, _, Acc} = couch_view:fold(View, fun view_fold/3, Acc0, Options);
_ ->
Acc = lists:foldl(fun(Key, AccIn) ->
- KeyArgs = QueryArgs#view_query_args{start_key=Key, end_key=Key},
+ KeyArgs = QueryArgs#mrargs{start_key=Key, end_key=Key},
Options = couch_httpd_view:make_key_options(KeyArgs),
{_Go, _, Out} = couch_view:fold(View, fun view_fold/3, AccIn,
Options),
@@ -141,7 +142,7 @@ reduce_view(DbName, #doc{} = DDoc, ViewName, QueryArgs) ->
reduce_view(DbName, Group0, ViewName, QueryArgs) ->
erlang:put(io_priority, {interactive, DbName}),
{ok, Db} = get_or_create_db(DbName, []),
- #view_query_args{
+ #mrargs{
group_level = GroupLevel,
limit = Limit,
skip = Skip,
@@ -168,7 +169,7 @@ reduce_view(DbName, Group0, ViewName, QueryArgs) ->
couch_view:fold_reduce(ReduceView, fun reduce_fold/3, Acc0, Options);
_ ->
lists:map(fun(Key) ->
- KeyArgs = QueryArgs#view_query_args{start_key=Key, end_key=Key},
+ KeyArgs = QueryArgs#mrargs{start_key=Key, end_key=Key},
Options0 = couch_httpd_view:make_key_options(KeyArgs),
Options = [{key_group_fun, GroupFun} | Options0],
couch_view:fold_reduce(ReduceView, fun reduce_fold/3, Acc0, Options)
diff --git a/src/fabric/src/fabric_view.erl b/src/fabric/src/fabric_view.erl
index a42582b39..9cb4b03c1 100644
--- a/src/fabric/src/fabric_view.erl
+++ b/src/fabric/src/fabric_view.erl
@@ -19,6 +19,7 @@
-include_lib("fabric/include/fabric.hrl").
-include_lib("mem3/include/mem3.hrl").
-include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
-spec remove_down_shards(#collector{}, node()) ->
{ok, #collector{}} | {error, any()}.
@@ -139,7 +140,7 @@ possibly_embed_doc(_State,
Row;
possibly_embed_doc(#collector{db_name=DbName, query_args=Args},
#view_row{key=_Key, id=_Id, value=Value, doc=_Doc}=Row) ->
- #view_query_args{include_docs=IncludeDocs} = Args,
+ #mrargs{include_docs=IncludeDocs} = Args,
case IncludeDocs andalso is_tuple(Value) of
true ->
{Props} = Value,
@@ -190,7 +191,7 @@ get_next_row(#collector{rows = []}) ->
throw(complete);
get_next_row(#collector{reducer = RedSrc} = St) when RedSrc =/= undefined ->
#collector{
- query_args = #view_query_args{direction=Dir},
+ query_args = #mrargs{direction=Dir},
keys = Keys,
rows = RowDict,
os_proc = Proc,
@@ -269,9 +270,9 @@ extract_view(Pid, ViewName, [View|Rest], ViewType) ->
end.
view_names(View, Type) when Type == red_map; Type == reduce ->
- [Name || {Name, _} <- View#view.reduce_funs];
+ [Name || {Name, _} <- View#mrview.reduce_funs];
view_names(View, map) ->
- View#view.map_names.
+ View#mrview.map_names.
index_of(X, List) ->
index_of(X, List, 1).
@@ -283,10 +284,10 @@ index_of(X, [X|_Rest], I) ->
index_of(X, [_|Rest], I) ->
index_of(X, Rest, I+1).
-get_shards(DbName, #view_query_args{stale=Stale})
+get_shards(DbName, #mrargs{stale=Stale})
when Stale == ok orelse Stale == update_after ->
mem3:ushards(DbName);
-get_shards(DbName, #view_query_args{stale=false}) ->
+get_shards(DbName, #mrargs{stale=false}) ->
mem3:shards(DbName).
% unit test
diff --git a/src/fabric/src/fabric_view_reduce.erl b/src/fabric/src/fabric_view_reduce.erl
index 54dcdf550..c922a7f51 100644
--- a/src/fabric/src/fabric_view_reduce.erl
+++ b/src/fabric/src/fabric_view_reduce.erl
@@ -17,6 +17,7 @@
-include_lib("fabric/include/fabric.hrl").
-include_lib("mem3/include/mem3.hrl").
-include_lib("couch/include/couch_db.hrl").
+-include_lib("couch_mrview/include/couch_mrview.hrl").
go(DbName, GroupId, View, Args, Callback, Acc0) when is_binary(GroupId) ->
{ok, DDoc} = fabric:open_doc(DbName, <<"_design/", GroupId/binary>>, []),
@@ -27,13 +28,13 @@ go(DbName, DDoc, VName, Args, Callback, Acc0) ->
Lang = couch_view_group:get_language(Group),
Views = couch_view_group:get_views(Group),
{NthRed, View} = fabric_view:extract_view(nil, VName, Views, reduce),
- {VName, RedSrc} = lists:nth(NthRed, View#view.reduce_funs),
+ {VName, RedSrc} = lists:nth(NthRed, View#mrview.reduce_funs),
Workers = lists:map(fun(#shard{name=Name, node=N} = Shard) ->
Ref = rexi:cast(N, {fabric_rpc, reduce_view, [Name,DDoc,VName,Args]}),
Shard#shard{ref = Ref}
end, fabric_view:get_shards(DbName, Args)),
RexiMon = fabric_util:create_monitors(Workers),
- #view_query_args{limit = Limit, skip = Skip} = Args,
+ #mrargs{limit = Limit, skip = Skip} = Args,
OsProc = case os_proc_needed(RedSrc) of
true -> couch_query_servers:get_os_process(Lang);
_ -> nil
@@ -43,7 +44,7 @@ go(DbName, DDoc, VName, Args, Callback, Acc0) ->
query_args = Args,
callback = Callback,
counters = fabric_dict:init(Workers, 0),
- keys = Args#view_query_args.keys,
+ keys = Args#mrargs.keys,
skip = Skip,
limit = Limit,
lang = Lang,
diff --git a/src/ibrowse/Makefile.am b/src/ibrowse/Makefile.am
deleted file mode 100644
index 533a27fb8..000000000
--- a/src/ibrowse/Makefile.am
+++ /dev/null
@@ -1,51 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-ibrowseebindir = $(localerlanglibdir)/ibrowse-2.2.0/ebin
-
-ibrowse_file_collection = \
- src/ibrowse.app.in \
- src/ibrowse.erl \
- src/ibrowse_app.erl \
- src/ibrowse_http_client.erl \
- src/ibrowse_lb.erl \
- src/ibrowse_lib.erl \
- src/ibrowse_sup.erl \
- src/ibrowse_test.erl
-
-ibrowseebin_make_generated_file_list = \
- ebin/ibrowse.app \
- ebin/ibrowse.beam \
- ebin/ibrowse_app.beam \
- ebin/ibrowse_http_client.beam \
- ebin/ibrowse_lb.beam \
- ebin/ibrowse_lib.beam \
- ebin/ibrowse_sup.beam \
- ebin/ibrowse_test.beam
-
-ibrowseebin_DATA = \
- $(ibrowseebin_make_generated_file_list)
-
-EXTRA_DIST = \
- $(ibrowse_file_collection) \
- include/ibrowse.hrl
-
-CLEANFILES = \
- $(ibrowseebin_make_generated_file_list)
-
-ebin/%.app: src/%.app.in
- @mkdir -p ebin/
- cp $< $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -o ebin/ -I$(top_srcdir)/src $(ERLC_FLAGS) $<
diff --git a/src/ibrowse/src/ibrowse.app.in b/src/ibrowse/src/ibrowse.app.src
index 1d88084e3..f65ba44ab 100644
--- a/src/ibrowse/src/ibrowse.app.in
+++ b/src/ibrowse/src/ibrowse.app.src
@@ -1,6 +1,6 @@
{application, ibrowse,
[{description, "Erlang HTTP client application"},
- {vsn, "4.0.1"},
+ {vsn, git},
{registered, [ibrowse_sup, ibrowse]},
{applications, [kernel,stdlib]},
{env, []},
diff --git a/src/mem3/.gitignore b/src/mem3/.gitignore
deleted file mode 100644
index e16ee2984..000000000
--- a/src/mem3/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-ebin/*.beam
-ebin/*.app
-TEST-*
-.eunit
diff --git a/src/mem3/Makefile.am b/src/mem3/Makefile.am
deleted file mode 100644
index cf732abb5..000000000
--- a/src/mem3/Makefile.am
+++ /dev/null
@@ -1,60 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-mem3ebindir = $(localerlanglibdir)/mem3/ebin
-
-mem3ebin_DATA = $(compiled_files)
-
-source_files = \
- src/mem3.app.src \
- src/mem3.erl \
- src/mem3_app.erl \
- src/mem3_httpd.erl \
- src/mem3_nodes.erl \
- src/mem3_rep.erl \
- src/mem3_shards.erl \
- src/mem3_sup.erl \
- src/mem3_sync.erl \
- src/mem3_sync_event.erl \
- src/mem3_sync_nodes.erl \
- src/mem3_sync_security.erl \
- src/mem3_util.erl
-
-compiled_files = \
- ebin/mem3.app \
- ebin/mem3.beam \
- ebin/mem3_app.beam \
- ebin/mem3_httpd.beam \
- ebin/mem3_shards.beam \
- ebin/mem3_sup.beam \
- ebin/mem3_sync.beam \
- ebin/mem3_sync_event.beam \
- ebin/mem3_sync_nodes.beam \
- ebin/mem3_sync_security.beam \
- ebin/mem3_util.beam
-
-# Conflicts in couch_db.hrl prevent us from building these
-# until after we merge the couch application
-# ebin/mem3_nodes.beam
-# ebin/mem3_rep.beam
-
-
-EXTRA_DIST = $(source_files)
-CLEANFILES = $(compiled_files)
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" < $< > $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/mem3/src/mem3.app.src b/src/mem3/src/mem3.app.src
index 612a7fb80..616e4bd95 100644
--- a/src/mem3/src/mem3.app.src
+++ b/src/mem3/src/mem3.app.src
@@ -12,7 +12,7 @@
{application, mem3, [
{description, "CouchDB Cluster Membership"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
mem3,
mem3_app,
diff --git a/src/mochiweb/Makefile.am b/src/mochiweb/Makefile.am
deleted file mode 100644
index 655f0ab00..000000000
--- a/src/mochiweb/Makefile.am
+++ /dev/null
@@ -1,113 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-if USE_NATIVE_MOCHIJSON
-MOCHIJSON_ERLC_FLAGS=+native
-endif
-
-mochiwebebindir = $(localerlanglibdir)/mochiweb-1.4.1/ebin
-
-mochiweb_file_collection = \
- src/mochifmt.erl \
- src/mochifmt_records.erl \
- src/mochifmt_std.erl \
- src/mochiglobal.erl \
- src/mochihex.erl \
- src/mochijson.erl \
- src/mochijson2.erl \
- src/mochilists.erl \
- src/mochilogfile2.erl \
- src/mochinum.erl \
- src/mochitemp.erl \
- src/mochiutf8.erl \
- src/mochiweb.app.in \
- src/mochiweb.app.src \
- src/mochiweb.erl \
- src/mochiweb_acceptor.erl \
- src/mochiweb_app.erl \
- src/mochiweb_charref.erl \
- src/mochiweb_cookies.erl \
- src/mochiweb_cover.erl \
- src/mochiweb_echo.erl \
- src/mochiweb_headers.erl \
- src/mochiweb_html.erl \
- src/mochiweb_http.erl \
- src/mochiweb_io.erl \
- src/mochiweb_mime.erl \
- src/mochiweb_multipart.erl \
- src/mochiweb_request.erl \
- src/mochiweb_request_tests.erl \
- src/mochiweb_response.erl \
- src/mochiweb_skel.erl \
- src/mochiweb_socket.erl \
- src/mochiweb_socket_server.erl \
- src/mochiweb_sup.erl \
- src/mochiweb_util.erl \
- src/reloader.erl
-
-mochiwebebin_make_generated_file_list = \
- ebin/mochifmt.beam \
- ebin/mochifmt_records.beam \
- ebin/mochifmt_std.beam \
- ebin/mochiglobal.beam \
- ebin/mochihex.beam \
- ebin/mochijson.beam \
- ebin/mochijson2.beam \
- ebin/mochilists.beam \
- ebin/mochilogfile2.beam \
- ebin/mochinum.beam \
- ebin/mochitemp.beam \
- ebin/mochiutf8.beam \
- ebin/mochiweb.app \
- ebin/mochiweb.beam \
- ebin/mochiweb_acceptor.beam \
- ebin/mochiweb_app.beam \
- ebin/mochiweb_charref.beam \
- ebin/mochiweb_cookies.beam \
- ebin/mochiweb_cover.beam \
- ebin/mochiweb_echo.beam \
- ebin/mochiweb_headers.beam \
- ebin/mochiweb_html.beam \
- ebin/mochiweb_http.beam \
- ebin/mochiweb_io.beam \
- ebin/mochiweb_mime.beam \
- ebin/mochiweb_multipart.beam \
- ebin/mochiweb_request.beam \
- ebin/mochiweb_response.beam \
- ebin/mochiweb_skel.beam \
- ebin/mochiweb_socket.beam \
- ebin/mochiweb_socket_server.beam \
- ebin/mochiweb_sup.beam \
- ebin/mochiweb_util.beam \
- ebin/reloader.beam
-
-mochiwebebin_DATA = \
- $(mochiwebebin_make_generated_file_list)
-
-EXTRA_DIST = \
- $(mochiweb_file_collection) \
- src/internal.hrl
-
-CLEANFILES = \
- $(mochiwebebin_make_generated_file_list)
-
-ebin/%.app: src/%.app.in
- @mkdir -p ebin/
- cp $< $@
-
-ebin/mochijson2.beam: src/mochijson2.erl
- @mkdir -p ebin/
- $(ERLC) -o ebin/ $(ERLC_FLAGS) $(MOCHIJSON_ERLC_FLAGS) $<
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/mochiweb/src/mochiweb.app.in b/src/mochiweb/src/mochiweb.app.in
deleted file mode 100644
index 6a4a314d8..000000000
--- a/src/mochiweb/src/mochiweb.app.in
+++ /dev/null
@@ -1,32 +0,0 @@
-{application, mochiweb,
- [{description, "MochiMedia Web Server"},
- {vsn, "1.4.1"},
- {modules, [
- mochihex,
- mochijson,
- mochijson2,
- mochinum,
- mochiweb,
- mochiweb_app,
- mochiweb_charref,
- mochiweb_cookies,
- mochiweb_echo,
- mochiweb_headers,
- mochiweb_html,
- mochiweb_http,
- mochiweb_multipart,
- mochiweb_request,
- mochiweb_response,
- mochiweb_skel,
- mochiweb_socket_server,
- mochiweb_sup,
- mochiweb_util,
- reloader,
- mochifmt,
- mochifmt_std,
- mochifmt_records
- ]},
- {registered, []},
- {mod, {mochiweb_app, []}},
- {env, []},
- {applications, [kernel, stdlib]}]}.
diff --git a/src/mochiweb/src/mochiweb.app.src b/src/mochiweb/src/mochiweb.app.src
index 37a21fbf0..c240102dc 100644
--- a/src/mochiweb/src/mochiweb.app.src
+++ b/src/mochiweb/src/mochiweb.app.src
@@ -1,7 +1,6 @@
-%% This is generated from src/mochiweb.app.src
{application, mochiweb,
[{description, "MochiMedia Web Server"},
- {vsn, "1.4.1"},
+ {vsn, git},
{modules, []},
{registered, []},
{mod, {mochiweb_app, []}},
diff --git a/src/oauth/Makefile.am b/src/oauth/Makefile.am
deleted file mode 100644
index 1636d98ca..000000000
--- a/src/oauth/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-oauthebindir = $(localerlanglibdir)/oauth/ebin
-
-oauth_file_collection = \
- src/oauth.app.in \
- src/oauth.erl
-
-# Removed oauth_rsa_sha1.beam until we require R12B5 or
-# we add a ./configure option to enable it.
-
-oauthebin_make_generated_file_list = \
- ebin/oauth.app \
- ebin/oauth.beam
-
-oauthebin_DATA = \
- $(oauthebin_make_generated_file_list)
-
-EXTRA_DIST = \
- $(oauth_file_collection)
-
-CLEANFILES = \
- $(oauthebin_make_generated_file_list)
-
-ebin/%.app: src/%.app.in
- @mkdir -p ebin/
- cp $< $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/oauth/src/oauth.app.in b/src/oauth/src/oauth.app.src
index a8ec17c44..a8ec17c44 100644
--- a/src/oauth/src/oauth.app.in
+++ b/src/oauth/src/oauth.app.src
diff --git a/src/rebar/.gitignore b/src/rebar/.gitignore
deleted file mode 100644
index ef672fe40..000000000
--- a/src/rebar/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-*.beam
-rebar
-*~
-*.orig
-.*.swp
-rt.work
-.hgignore
-.test
-dialyzer_warnings
-rebar.cmd
-.eunit
-deps
diff --git a/src/rebar/.travis.yml b/src/rebar/.travis.yml
deleted file mode 100644
index 191d3374c..000000000
--- a/src/rebar/.travis.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-language: erlang
-otp_release:
- - R16B
- - R15B01
- - R15B
- - R14B04
- - R14B03
-script: "make travis"
diff --git a/src/rebar/CONTRIBUTING.md b/src/rebar/CONTRIBUTING.md
deleted file mode 100644
index 30693d89e..000000000
--- a/src/rebar/CONTRIBUTING.md
+++ /dev/null
@@ -1,94 +0,0 @@
-Contributing to rebar
----------------------
-
-Before implementing a new feature, please submit a ticket to discuss your plans.
-The feature might have been rejected already, or the implementation might already be decided.
-
-See [Community and Resources](README.md#community-and-resources).
-
-Code style
-----------
-
-The following rules must be followed:
- * Do not introduce trailing whitespace
- * Do not mix spaces and tabs
- * Do not introduce lines longer than 80 characters
-
-The following rules should be followed:
- * Write small functions whenever possible
- * Avoid having too many clauses containing clauses containing clauses.
- Basically, avoid deeply nested functions.
-
-[erlang-mode (emacs)](http://www.erlang.org/doc/man/erlang.el.html)
-indentation is preferred. This will keep the code base consistent.
-vi users are encouraged to give [Vim emulation](http://emacswiki.org/emacs/Evil) ([more
-info](https://gitorious.org/evil/pages/Home)) a try.
-
-Pull requests and branching
----------------------------
-
-Use one topic branch per pull request. If you do that, you can add extra commits or fix up
-buggy commits via `git rebase -i`, and update the branch. The updated branch will be
-visible in the same pull request. Therefore, you should not open a new pull request when
-you have to fix your changes.
-
-Do not commit to master in your fork.
-
-Provide a clean branch without merge commits.
-
-Committing your changes
------------------------
-
-Please ensure that all commits pass all tests, and do not have extra Dialyzer warnings.
-To do that run `make check`. If you didn't build via `make debug` at first, the beam files in
-`ebin/` might be missing debug_info required for [xref](http://www.erlang.org/doc/man/xref.html)
-and [Dialyzer](http://www.erlang.org/doc/man/dialyzer.html), causing a test
-failure.
-If that happens, running `make clean` before running `make check` could solve the problem.
-If you change any of the files with known but safe to ignore Dialyzer warnings, you may
-have to adapt the line number(s) in [dialyzer_reference](dialyzer_reference). If you do that,
-do not remove the
-leading blank line.
-
-#### Structuring your commits
-
-Fixing a bug is one commit.
-Adding a feature is one commit.
-Adding two features is two commits.
-Two unrelated changes is two commits.
-
-If you fix a (buggy) commit, squash (`git rebase -i`) the changes as a fixup commit into
-the original commit.
-
-#### Writing Commit Messages
-
-It's important to write a proper commit title and description. The commit title must be
-at most 50 characters; it is the first line of the commit text. The second line of the
-commit text must be left blank. The third line and beyond is the commit message. You
-should write a commit message. If you do, wrap all lines at 72 characters. You should
-explain what the commit does, what references you used, and any other information
-that helps understanding your changes.
-
-Basically, structure your commit message like this:
-
-<pre>
-One line summary (at most 50 characters)
-
-Longer description (wrap at 72 characters)
-</pre>
-
-##### Commit title/summary
-
-* At most 50 characters
-* What was changed
-* Imperative present tense (Fix, Add, Change)
- * `Fix bug 123`
- * `Add 'foobar' command`
- * `Change default timeout to 123`
-* No period
-
-##### Commit description
-
-* Wrap at 72 characters
-* Why, explain intention and implementation approach
-* Present tense
diff --git a/src/rebar/LICENSE b/src/rebar/LICENSE
deleted file mode 100644
index e454a5258..000000000
--- a/src/rebar/LICENSE
+++ /dev/null
@@ -1,178 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/src/rebar/Makefile b/src/rebar/Makefile
deleted file mode 100644
index 1aeb6ad45..000000000
--- a/src/rebar/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-.PHONY: clean dialyzer_warnings xref_warnings deps test
-
-REBAR=$(PWD)/rebar
-RETEST=$(PWD)/deps/retest/retest
-
-all:
- ./bootstrap
-
-clean:
- @rm -rf rebar ebin/*.beam inttest/rt.work rt.work .eunit
-
-distclean: clean
- @rm -f dialyzer_warnings
- @rm -rf deps
-
-debug:
- @./bootstrap debug
-
-check: debug xref dialyzer deps test
-
-xref:
- @./rebar xref
-
-dialyzer: dialyzer_warnings
- @diff -U0 dialyzer_reference dialyzer_warnings
-
-dialyzer_warnings:
- -@dialyzer -q -nn -n ebin -Wunmatched_returns -Werror_handling \
- -Wrace_conditions > dialyzer_warnings
-
-binary: VSN = $(shell ./rebar -V)
-binary: clean all
- @cp rebar ../rebar.wiki/rebar
- (cd ../rebar.wiki && git commit -m "Update $(VSN)" rebar)
-
-deps:
- @REBAR_EXTRA_DEPS=1 ./rebar get-deps
- @(cd deps/retest && $(REBAR) compile escriptize)
-
-test:
- @$(REBAR) eunit
- @$(RETEST) -v inttest
-
-travis: clean debug xref clean all deps test
diff --git a/src/rebar/NOTES.org b/src/rebar/NOTES.org
deleted file mode 100644
index 798cf4dda..000000000
--- a/src/rebar/NOTES.org
+++ /dev/null
@@ -1,28 +0,0 @@
-
-* Major operations
-** Compile
-*** Code generation
-*** Compilation/linking
-*** App validation
-** Clean
-** ct testing
-** eunit testing
-** Installation
-** Doc generation
-
-* Modes/File types
-** Erlang
-** Port driver
-** NIF driver
-** SNMP MIBs
-** ASN.1 files
-
-* Misc. Notes
-** Port/NIF driver compilation needs pre/post hook
-** Need to support code generation for things like protobuf
-** Need to support compilation flags
-
-* Contexts
-** Application
-** General
-** Release ?!
diff --git a/src/rebar/README.md b/src/rebar/README.md
deleted file mode 100644
index 3ec4a3a5a..000000000
--- a/src/rebar/README.md
+++ /dev/null
@@ -1,79 +0,0 @@
-rebar
-=====
-
-rebar is an Erlang build tool that makes it easy to compile and test Erlang
-applications, port drivers and releases.
-
-[![Build Status](https://secure.travis-ci.org/rebar/rebar.png?branch=master)](http://travis-ci.org/rebar/rebar)
-
-rebar is a self-contained Erlang script, so it's easy to distribute or even
-embed directly in a project. Where possible, rebar uses standard Erlang/OTP
-conventions for project structures, thus minimizing the amount of build
-configuration work. rebar also provides dependency management, enabling
-application writers to easily re-use common libraries from a variety of
-locations (git, hg, etc).
-
-Building
---------
-
-Information on building and installing [Erlang/OTP](http://www.erlang.org) can
-be found [here](https://github.com/erlang/otp/wiki/Installation) ([more
-info](https://github.com/erlang/otp/blob/master/INSTALL.md)).
-
-### Dependencies
-
-To build rebar you will need a working installation of Erlang R13B03 (or later).
-
-Should you want to clone the rebar repository, you will also require git.
-
-#### Downloading
-
-You can download a pre-built binary version of rebar from:
-
-https://github.com/rebar/rebar/wiki/rebar
-
-#### Building rebar
-
-```sh
-$ git clone git://github.com/rebar/rebar.git
-$ cd rebar
-$ ./bootstrap
-Recompile: src/getopt
-...
-Recompile: src/rebar_utils
-==> rebar (compile)
-Congratulations! You now have a self-contained script called "rebar" in
-your current working directory. Place this script anywhere in your path
-and you can use rebar to build OTP-compliant apps.
-```
-
-
-Contributing to rebar
-=====================
-
-Please refer to [CONTRIBUTING](CONTRIBUTING.md).
-
-Community and Resources
------------------------
-
-In case of problems that cannot be solved through documentation or examples, you
-may want to try to contact members of the community for help. The community is
-also where you want to go for questions about how to extend rebar, fill in bug
-reports, and so on.
-
-The main place to go for questions is the [rebar mailing
-list](http://lists.basho.com/pipermail/rebar_lists.basho.com/). If you need
-quick feedback, you can try the #rebar channel on
-[irc.freenode.net](http://freenode.net). Be sure to check the
-[wiki](https://github.com/rebar/rebar/wiki) first, just to be sure you're not
-asking about things with well known answers.
-
-For bug reports, roadmaps, and issues, visit the [github issues
-page](https://github.com/rebar/rebar/issues).
-
-General rebar community resources and links:
-
-- [Rebar Mailing List](http://lists.basho.com/pipermail/rebar_lists.basho.com/)
-- #rebar on [irc.freenode.net](http://freenode.net/)
-- [wiki](https://github.com/rebar/rebar/wiki)
-- [issues](https://github.com/rebar/rebar/issues)
diff --git a/src/rebar/THANKS b/src/rebar/THANKS
deleted file mode 100644
index 95cc493cd..000000000
--- a/src/rebar/THANKS
+++ /dev/null
@@ -1,122 +0,0 @@
-The following people have contributed to rebar:
-
-Dave Smith
-Jon Meredith
-Tim Dysinger
-Bryan Fink
-Tuncer Ayaz
-Ian Wilkinson
-Juan Jose Comellas
-Tom Preston-Werner
-OJ Reeves
-Ruslan Babayev
-Ryan Tilder
-Kevin Smith
-David Reid
-Cliff Moon
-Chris Bernard
-Jeremy Raymond
-Bob Ippolito
-Alex Songe
-Andrew Thompson
-Russell Brown
-Chris Chew
-Klas Johansson
-Geoff Cant
-Kostis Sagonas
-Essien Ita Essien
-Manuel Duran Aguete
-Daniel Neri
-Misha Gorodnitzky
-Adam Kocoloski
-Joseph Wayne Norton
-Mihai Balea
-Matthew Batema
-Alexey Romanov
-Benjamin Nortier
-Magnus Klaar
-Anthony Ramine
-Charles McKnight
-Andrew Tunnell-Jones
-Joe Williams
-Daniel Reverri
-Jesper Louis Andersen
-Richard Jones
-Tim Watson
-Anders 'andekar'
-Christopher Brown
-Jordi Chacon
-Shunichi Shinohara
-Mickael Remond
-Evax Software
-Piotr Usewicz
-Anthony Molinaro
-Andrew Gopienko
-Steve Vinoski
-Evan Miller
-Jared Morrow
-Jan Kloetzke
-Mathias Meyer
-Steven Gravell
-Alexis Sellier
-Mattias Holmlund
-Tino Breddin
-David Nonnenmacher
-Anders Nygren
-Scott Lystig Fritchie
-Uwe Dauernheim
-Yurii Rashkovskii
-Alfonso De Gregorio
-Matt Campbell
-Benjamin Plee
-Ben Ellis
-Ignas Vysniauskas
-Anton Lavrik
-Jan Vincent Liwanag
-Przemyslaw Dabek
-Fabian Linzberger
-Smith Winston
-Jesse Gumm
-Torbjorn Tornkvist
-Ali Sabil
-Tomas Abrahamsson
-Francis Joanis
-fisher@yun.io
-Slava Yurin
-Phillip Toland
-Mike Lazar
-Loic Hoguin
-Ali Yakout
-Adam Schepis
-Amit Kapoor
-Ulf Wiger
-Nick Vatamaniuc
-Daniel Luna
-Motiejus Jakstys
-Eric B Merritt
-Fred Hebert
-Kresten Krab Thorup
-David Aaberg
-Pedram Nimreezi
-Edwin Fine
-Lev Walkin
-Roberto Ostinelli
-Joe DeVivo
-Markus Nasman
-Dmitriy Kargapolov
-Ryan Zezeski
-Daniel White
-Martin Schut
-Serge Aleynikov
-Magnus Henoch
-Artem Teslenko
-Jeremie Lasalle Ratelle
-Jose Valim
-Krzysztof Rutka
-Mats Cronqvist
-Matthew Conway
-Giacomo Olgeni
-Pedram Nimreezi
-Sylvain Benner
-Oliver Ferrigni
-Dave Thomas
diff --git a/src/rebar/bootstrap b/src/rebar/bootstrap
deleted file mode 100755
index 70d8da13e..000000000
--- a/src/rebar/bootstrap
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/env escript
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ft=erlang ts=4 sw=4 et
-
-main(Args) ->
- %% Get a string repr of build time
- Built = build_time(),
-
- %% Get a string repr of first matching VCS changeset
- VcsInfo = vcs_info([{hg, ".hg", "hg identify -i", "hg status"},
- {git, ".git", "git describe --always --tags",
- "git status -s"}]),
-
- %% Check for force=1 flag to force a rebuild
- case lists:member("force=1", Args) of
- true ->
- rm("ebin/*.beam");
- false ->
- rm("ebin/rebar.beam")
- end,
-
- %% Add check for debug flag
- DebugFlag = case lists:member("debug", Args) of
- true -> debug_info;
- false -> undefined
- end,
-
- %% Extract the system info of the version of OTP we use to compile rebar
- OtpInfo = string:strip(erlang:system_info(otp_release), both, $\n),
-
- %% Compile all src/*.erl to ebin
- case make:files(filelib:wildcard("src/*.erl"),
- [{outdir, "ebin"}, {i, "include"},
- DebugFlag,
- {d, 'BUILD_TIME', Built},
- {d, 'VCS_INFO', VcsInfo},
- {d, 'OTP_INFO', OtpInfo}]) of
- up_to_date ->
- ok;
- error ->
- io:format("Failed to compile rebar files!\n"),
- halt(1)
- end,
-
- %% Make sure file:consult can parse the .app file
- case file:consult("ebin/rebar.app") of
- {ok, _} ->
- ok;
- {error, Reason} ->
- io:format("Invalid syntax in ebin/rebar.app: ~p\n", [Reason]),
- halt(1)
- end,
-
- %% Add ebin/ to our path
- true = code:add_path("ebin"),
-
- %% Run rebar compile to do proper .app validation etc.
- %% and rebar escriptize to create the rebar script
- rebar:main(["compile", "escriptize"] ++ Args),
-
- %% Finally, update executable perms for our script on *nix,
- %% or write out script files on win32.
- case os:type() of
- {unix,_} ->
- [] = os:cmd("chmod u+x rebar"),
- ok;
- {win32,_} ->
- write_windows_scripts(),
- ok;
- _ ->
- ok
- end,
-
- %% Add a helpful message
- io:format("Congratulations! You now have a self-contained script called"
- " \"rebar\" in\n"
- "your current working directory. "
- "Place this script anywhere in your path\n"
- "and you can use rebar to build OTP-compliant apps.\n").
-
-rm(Path) ->
- NativePath = filename:nativename(Path),
- Cmd = case os:type() of
- {unix,_} -> "rm -f ";
- {win32,_} -> "del /q "
- end,
- [] = os:cmd(Cmd ++ NativePath),
- ok.
-
-build_time() ->
- {{Y, M, D}, {H, Min, S}} = calendar:now_to_universal_time(now()),
- lists:flatten(io_lib:format("~4..0w~2..0w~2..0w_~2..0w~2..0w~2..0w",
- [Y, M, D, H, Min, S])).
-
-vcs_info([]) ->
- "No VCS info available.";
-vcs_info([{Id, Dir, VsnCmd, StatusCmd} | Rest]) ->
- case filelib:is_dir(Dir) of
- true ->
- Vsn = string:strip(os:cmd(VsnCmd), both, $\n),
- Status = case string:strip(os:cmd(StatusCmd), both, $\n) of
- [] ->
- "";
- _ ->
- "-dirty"
- end,
- lists:concat([Id, " ", Vsn, Status]);
- false ->
- vcs_info(Rest)
- end.
-
-write_windows_scripts() ->
- CmdScript=
- "@echo off\r\n"
- "setlocal\r\n"
- "set rebarscript=%~f0\r\n"
- "escript.exe \"%rebarscript:.cmd=%\" %*\r\n",
- ok = file:write_file("rebar.cmd", CmdScript).
diff --git a/src/rebar/bootstrap.bat b/src/rebar/bootstrap.bat
deleted file mode 100644
index b646a7db9..000000000
--- a/src/rebar/bootstrap.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-@echo off
-escript.exe bootstrap %*
diff --git a/src/rebar/dialyzer_reference b/src/rebar/dialyzer_reference
deleted file mode 100644
index e26d8dd2e..000000000
--- a/src/rebar/dialyzer_reference
+++ /dev/null
@@ -1,3 +0,0 @@
-
-rebar_eunit.erl:388: Call to missing or unexported function eunit_test:function_wrapper/2
-rebar_utils.erl:163: Call to missing or unexported function escript:foldl/3
diff --git a/src/rebar/ebin/rebar.app b/src/rebar/ebin/rebar.app
deleted file mode 100644
index e64a51f8e..000000000
--- a/src/rebar/ebin/rebar.app
+++ /dev/null
@@ -1,93 +0,0 @@
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 ft=erlang et
-
-{application, rebar,
- [{description, "Rebar: Erlang Build Tool"},
- {vsn, "2.1.0"},
- {modules, [ rebar,
- rebar_abnfc_compiler,
- rebar_app_utils,
- rebar_appups,
- rebar_asn1_compiler,
- rebar_dia_compiler,
- rebar_base_compiler,
- rebar_cleaner,
- rebar_config,
- rebar_core,
- rebar_ct,
- rebar_deps,
- rebar_edoc,
- rebar_erlc_compiler,
- rebar_erlydtl_compiler,
- rebar_escripter,
- rebar_eunit,
- rebar_file_utils,
- rebar_lfe_compiler,
- rebar_log,
- rebar_neotoma_compiler,
- rebar_otp_app,
- rebar_port_compiler,
- rebar_protobuffs_compiler,
- rebar_qc,
- rebar_rel_utils,
- rebar_reltool,
- rebar_require_vsn,
- rebar_shell,
- rebar_subdirs,
- rebar_templater,
- rebar_upgrade,
- rebar_utils,
- rebar_xref,
- getopt,
- mustache ]},
- {registered, []},
- {applications, [kernel,
- stdlib,
- sasl,
- compiler,
- crypto,
- syntax_tools,
- tools]},
- {env, [
- %% Default log level
- {log_level, error},
-
- %% any_dir processing modules
- {any_dir_modules, [
- rebar_require_vsn,
- rebar_deps,
- rebar_subdirs,
- rebar_templater,
- rebar_cleaner
- ]},
-
- %% Dir specific processing modules
- {modules, [
- {app_dir, [
- rebar_abnfc_compiler,
- rebar_protobuffs_compiler,
- rebar_neotoma_compiler,
- rebar_asn1_compiler,
- rebar_dia_compiler,
- rebar_erlc_compiler,
- rebar_lfe_compiler,
- rebar_erlydtl_compiler,
- rebar_port_compiler,
- rebar_otp_app,
- rebar_ct,
- rebar_eunit,
- rebar_qc,
- rebar_escripter,
- rebar_edoc,
- rebar_shell,
- rebar_xref
- ]},
-
- {rel_dir, [
- rebar_appups,
- rebar_reltool,
- rebar_upgrade
- ]}
- ]}
- ]}
- ]}.
diff --git a/src/rebar/include/rebar.hrl b/src/rebar/include/rebar.hrl
deleted file mode 100644
index 58debfcb2..000000000
--- a/src/rebar/include/rebar.hrl
+++ /dev/null
@@ -1,14 +0,0 @@
-%% TODO: rename FAIL to ABORT once we require at least R13B04 for
-%% building rebar. Macros with different arity were not supported by the
-%% compiler before 13B04.
--define(FAIL, rebar_utils:abort()).
--define(ABORT(Str, Args), rebar_utils:abort(Str, Args)).
-
--define(CONSOLE(Str, Args), io:format(Str, Args)).
-
--define(DEBUG(Str, Args), rebar_log:log(debug, Str, Args)).
--define(INFO(Str, Args), rebar_log:log(info, Str, Args)).
--define(WARN(Str, Args), rebar_log:log(warn, Str, Args)).
--define(ERROR(Str, Args), rebar_log:log(error, Str, Args)).
-
--define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))).
diff --git a/src/rebar/inttest/bug_5_rt.erl b/src/rebar/inttest/bug_5_rt.erl
deleted file mode 100644
index a06b69331..000000000
--- a/src/rebar/inttest/bug_5_rt.erl
+++ /dev/null
@@ -1,29 +0,0 @@
--module(bug_5_rt).
-
--compile(export_all).
-
-
-files() ->
- [{create, "ebin/a1.app", app(a1)},
- {create, "deps/d1/src/d1.app.src", app(d1)},
- {create, "rebar.config",
- <<"{deps, [{d1, \"1\", {hg, \"http://example.com\", \"tip\"}}]}.\n">>},
- {copy, "../rebar", "rebar"}].
-
-run(_Dir) ->
- {ok, _} = retest:sh("./rebar compile"),
- ok.
-
-
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, []},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/ct1/ct1_rt.erl b/src/rebar/inttest/ct1/ct1_rt.erl
deleted file mode 100644
index f173d3f8f..000000000
--- a/src/rebar/inttest/ct1/ct1_rt.erl
+++ /dev/null
@@ -1,28 +0,0 @@
--module(ct1_rt).
-
--compile(export_all).
-
-
-files() ->
- [{create, "ebin/a1.app", app(a1)},
- {copy, "../../rebar", "rebar"},
- {copy, "rebar.config", "rebar.config"},
- {copy, "test_SUITE.erl", "itest/test_SUITE.erl"}].
-
-run(_Dir) ->
- {ok, _} = retest:sh("./rebar compile ct"),
- ok.
-
-
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, []},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/ct1/rebar.config b/src/rebar/inttest/ct1/rebar.config
deleted file mode 100644
index a4b528405..000000000
--- a/src/rebar/inttest/ct1/rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{ct_dir, "itest"}.
diff --git a/src/rebar/inttest/ct1/test_SUITE.erl b/src/rebar/inttest/ct1/test_SUITE.erl
deleted file mode 100644
index 92f2b2e3c..000000000
--- a/src/rebar/inttest/ct1/test_SUITE.erl
+++ /dev/null
@@ -1,11 +0,0 @@
--module(test_SUITE).
-
--compile(export_all).
-
--include_lib("ct.hrl").
-
-all() ->
- [simple_test].
-
-simple_test(Config) ->
- io:format("Test: ~p\n", [Config]).
diff --git a/src/rebar/inttest/ct2/ct2_rt.erl b/src/rebar/inttest/ct2/ct2_rt.erl
deleted file mode 100644
index ecab0e486..000000000
--- a/src/rebar/inttest/ct2/ct2_rt.erl
+++ /dev/null
@@ -1,26 +0,0 @@
--module(ct2_rt).
-
--compile(export_all).
-
-
-files() ->
- [{create, "ebin/foo.app", app(foo)},
- {copy, "../../rebar", "rebar"},
- {copy, "foo.test.spec", "foo.test.spec"},
- {copy, "foo_SUITE.erl", "test/foo_SUITE.erl"}].
-
-run(_Dir) ->
- {ok, _} = retest:sh("./rebar compile ct -vvv"),
- ok.
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, []},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/ct2/foo.test.spec b/src/rebar/inttest/ct2/foo.test.spec
deleted file mode 100644
index f3e4cb0ad..000000000
--- a/src/rebar/inttest/ct2/foo.test.spec
+++ /dev/null
@@ -1 +0,0 @@
-{suites, "test", all}.
diff --git a/src/rebar/inttest/ct2/foo_SUITE.erl b/src/rebar/inttest/ct2/foo_SUITE.erl
deleted file mode 100644
index d03aedf0b..000000000
--- a/src/rebar/inttest/ct2/foo_SUITE.erl
+++ /dev/null
@@ -1,10 +0,0 @@
--module(foo_SUITE).
-
--include_lib("common_test/include/ct.hrl").
-
--compile(export_all).
-
-all() -> [foo].
-
-foo(Config) ->
- io:format("Test: ~p\n", [Config]).
diff --git a/src/rebar/inttest/depplugins/depplugins_rt.erl b/src/rebar/inttest/depplugins/depplugins_rt.erl
deleted file mode 100644
index 7b106ebf2..000000000
--- a/src/rebar/inttest/depplugins/depplugins_rt.erl
+++ /dev/null
@@ -1,50 +0,0 @@
-%%% @doc Plugin handling test
-%%%
-%%% This test checks if plugins are loaded correctly.
-%%%
-%%% It has three applications:
-%%% <ol>
-%%% <li>fish. top-level module, has one dependency: `dependsonplugin'.</li>
-%%% <li>dependsonplugin. This depends on some pre-compile actions by the
-%%% plugin. In the test the plugin creates a file `pre.compile' in the
-%%% top-level folder of this application.</li>
-%%% <li>testplugin. This is a plugin application which creates the file.</li>
-%%% </ol>
-
--module(depplugins_rt).
--compile(export_all).
-
--include_lib("eunit/include/eunit.hrl").
-
-files() ->
- [
- {copy, "../../rebar", "rebar"},
- {copy, "rebar.config", "rebar.config"},
- {create, "ebin/fish.app", app(fish, [])},
-
- {create, "deps/dependsonplugin/ebin/dependsonplugin.app",
- app(dependsonplugin, [])},
- {copy, "rebar_dependsonplugin.config",
- "deps/dependsonplugin/rebar.config"},
- {copy, "testplugin_mod.erl",
- "deps/testplugin/plugins/testplugin_mod.erl"},
- {create, "deps/testplugin/ebin/testplugin.app",
- app(testplugin, [])}
- ].
-
-run(_Dir) ->
- ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])),
- ?assertEqual(true, filelib:is_regular("deps/dependsonplugin/pre.compile")),
- ok.
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name, Modules) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, Modules},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/depplugins/rebar.config b/src/rebar/inttest/depplugins/rebar.config
deleted file mode 100644
index 3a2e34ede..000000000
--- a/src/rebar/inttest/depplugins/rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [dependsonplugin]}.
diff --git a/src/rebar/inttest/depplugins/rebar_dependsonplugin.config b/src/rebar/inttest/depplugins/rebar_dependsonplugin.config
deleted file mode 100644
index df362133c..000000000
--- a/src/rebar/inttest/depplugins/rebar_dependsonplugin.config
+++ /dev/null
@@ -1,2 +0,0 @@
-{deps, [testplugin]}.
-{plugins, [testplugin_mod]}.
diff --git a/src/rebar/inttest/depplugins/testplugin_mod.erl b/src/rebar/inttest/depplugins/testplugin_mod.erl
deleted file mode 100644
index 055bbc791..000000000
--- a/src/rebar/inttest/depplugins/testplugin_mod.erl
+++ /dev/null
@@ -1,6 +0,0 @@
--module(testplugin_mod).
--compile(export_all).
-
-pre_compile(Config, _) ->
- ok = file:write_file("pre.compile", <<"Yadda!">>),
- rebar_log:log(info, "Wrote ~p/pre.compile~n", [rebar_utils:get_cwd()]).
diff --git a/src/rebar/inttest/rgen1/reltool.config b/src/rebar/inttest/rgen1/reltool.config
deleted file mode 100644
index 4c4713cad..000000000
--- a/src/rebar/inttest/rgen1/reltool.config
+++ /dev/null
@@ -1,31 +0,0 @@
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-{sys, [
- {rel, "rgen1", "0.1",
- [
- kernel,
- stdlib,
- sasl,
- crypto
- ]},
- {rel, "start_clean", "",
- [
- kernel,
- stdlib
- ]},
- {boot_rel, "rgen1"},
- {profile, embedded},
- {excl_sys_filters, ["^bin/.*",
- "^erts.*/bin/(dialyzer|typer)"]},
- {excl_archive_filters, [".*"]},
- {app, sasl, [{incl_cond, include}]}
- ]}.
-
-{target_dir, "mytarget"}.
-
-{overlay_vars, "vars.config"}.
-
-{overlay, [
- {mkdir, "data"},
- {template, "test.config", "etc/test.config"}
- ]}.
diff --git a/src/rebar/inttest/rgen1/retest.config b/src/rebar/inttest/rgen1/retest.config
deleted file mode 100644
index a04233c0d..000000000
--- a/src/rebar/inttest/rgen1/retest.config
+++ /dev/null
@@ -1 +0,0 @@
-{timeout, 60000}.
diff --git a/src/rebar/inttest/rgen1/rgen1_rt.erl b/src/rebar/inttest/rgen1/rgen1_rt.erl
deleted file mode 100644
index 68b6eaf8a..000000000
--- a/src/rebar/inttest/rgen1/rgen1_rt.erl
+++ /dev/null
@@ -1,18 +0,0 @@
--module(rgen1_rt).
-
--compile(export_all).
-
-%% Exercise release generation w/ templating
-
-files() ->
- [
- {copy, "reltool.config"},
- {copy, "test.config"},
- {copy, "vars.config"},
- {copy, "../../rebar"}
- ].
-
-run(_Dir) ->
- {ok, _} = retest_sh:run("./rebar -v generate", []),
- true = filelib:is_dir("mytarget"),
- ok.
diff --git a/src/rebar/inttest/rgen1/test.config b/src/rebar/inttest/rgen1/test.config
deleted file mode 100644
index 2fd13852b..000000000
--- a/src/rebar/inttest/rgen1/test.config
+++ /dev/null
@@ -1 +0,0 @@
-{web_port, {{web_port}} }.
diff --git a/src/rebar/inttest/rgen1/vars.config b/src/rebar/inttest/rgen1/vars.config
deleted file mode 100644
index 174c51e1e..000000000
--- a/src/rebar/inttest/rgen1/vars.config
+++ /dev/null
@@ -1 +0,0 @@
-{web_port, 1234}.
diff --git a/src/rebar/inttest/t_custom_config/custom.config b/src/rebar/inttest/t_custom_config/custom.config
deleted file mode 100644
index 711c27f98..000000000
--- a/src/rebar/inttest/t_custom_config/custom.config
+++ /dev/null
@@ -1,4 +0,0 @@
-{deps, [
- {boo, "."}
-]}.
-{erl_opts, [warnings_as_errors]}.
diff --git a/src/rebar/inttest/t_custom_config/custom_config.erl b/src/rebar/inttest/t_custom_config/custom_config.erl
deleted file mode 100644
index 865620149..000000000
--- a/src/rebar/inttest/t_custom_config/custom_config.erl
+++ /dev/null
@@ -1,6 +0,0 @@
--module(custom_config).
-
--compile(export_all).
-
-test() ->
- ok.
diff --git a/src/rebar/inttest/t_custom_config/t_custom_config_rt.erl b/src/rebar/inttest/t_custom_config/t_custom_config_rt.erl
deleted file mode 100644
index 864ce5e31..000000000
--- a/src/rebar/inttest/t_custom_config/t_custom_config_rt.erl
+++ /dev/null
@@ -1,39 +0,0 @@
--module(t_custom_config_rt).
-
--compile(export_all).
-
--include_lib("eunit/include/eunit.hrl").
-
-files() ->
- [{copy, "../../rebar", "rebar"},
- {copy, "custom.config", "custom.config"},
- {create, "ebin/custom_config.app", app(custom_config, [custom_config])}].
-
-run(Dir) ->
- retest_log:log(debug, "Running in Dir: ~s~n", [Dir]),
- Ref = retest:sh("./rebar -C custom.config check-deps -vvv",
- [{async, true}]),
- {ok, Captured} =
- retest:sh_expect(Ref,
- "DEBUG: Consult config file .*/custom.config.*",
- [{capture, all, list}]),
- {ok, Missing} =
- retest:sh_expect(Ref,
- "DEBUG: Missing deps : \\[\\{dep,bad_name,"
- "boo,\"\\.\",undefined,false\\}\\]",
- [{capture, all, list}]),
- retest_log:log(debug, "[CAPTURED]: ~s~n", [Captured]),
- retest_log:log(debug, "[Missing]: ~s~n", [Missing]),
- ok.
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name, Modules) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, Modules},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/tdeps1/a.erl b/src/rebar/inttest/tdeps1/a.erl
deleted file mode 100644
index 835522ac2..000000000
--- a/src/rebar/inttest/tdeps1/a.erl
+++ /dev/null
@@ -1,8 +0,0 @@
--module(a).
-
--compile(export_all).
-
--include_lib("b/include/b.hrl").
-
-hello() ->
- io:format("~s\n", [?HELLO]).
diff --git a/src/rebar/inttest/tdeps1/a.rebar.config b/src/rebar/inttest/tdeps1/a.rebar.config
deleted file mode 100644
index 991ea5acf..000000000
--- a/src/rebar/inttest/tdeps1/a.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{b, "1", {git, "../repo/b"}}]}.
diff --git a/src/rebar/inttest/tdeps1/b.hrl b/src/rebar/inttest/tdeps1/b.hrl
deleted file mode 100644
index efbeab184..000000000
--- a/src/rebar/inttest/tdeps1/b.hrl
+++ /dev/null
@@ -1 +0,0 @@
--include_lib("c/include/c.hrl").
diff --git a/src/rebar/inttest/tdeps1/b.rebar.config b/src/rebar/inttest/tdeps1/b.rebar.config
deleted file mode 100644
index ffbd0db7c..000000000
--- a/src/rebar/inttest/tdeps1/b.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{c, "1", {git, "../repo/c"}}]}.
diff --git a/src/rebar/inttest/tdeps1/c.hrl b/src/rebar/inttest/tdeps1/c.hrl
deleted file mode 100644
index 9f02fab5f..000000000
--- a/src/rebar/inttest/tdeps1/c.hrl
+++ /dev/null
@@ -1 +0,0 @@
--define(HELLO, hello).
diff --git a/src/rebar/inttest/tdeps1/tdeps1_rt.erl b/src/rebar/inttest/tdeps1/tdeps1_rt.erl
deleted file mode 100644
index 3de1a2bdc..000000000
--- a/src/rebar/inttest/tdeps1/tdeps1_rt.erl
+++ /dev/null
@@ -1,59 +0,0 @@
--module(tdeps1_rt).
-
--compile(export_all).
-
-%% Exercise transitive dependencies
-%% A -> B -> C, where A includes a .hrl from B which includes .hrl from C
-
-files() ->
- [
- %% A application
- {create, "ebin/a.app", app(a, [a])},
- {copy, "a.rebar.config", "rebar.config"},
- {copy, "a.erl", "src/a.erl"},
- {copy, "../../rebar", "rebar"},
-
- %% B application
- {create, "repo/b/ebin/b.app", app(b, [])},
- {copy, "b.rebar.config", "repo/b/rebar.config"},
- {copy, "b.hrl", "repo/b/include/b.hrl"},
-
- %% C application
- {create, "repo/c/ebin/c.app", app(c, [])},
- {copy, "c.hrl", "repo/c/include/c.hrl"}
- ].
-
-apply_cmds([], _Params) ->
- ok;
-apply_cmds([Cmd | Rest], Params) ->
- io:format("Running: ~s (~p)\n", [Cmd, Params]),
- {ok, _} = retest_sh:run(Cmd, Params),
- apply_cmds(Rest, Params).
-
-run(_Dir) ->
- %% Initialize the b/c apps as git repos so that dependencies pull
- %% properly
- GitCmds = ["git init",
- "git add -A",
- "git config user.email 'tdeps@example.com'",
- "git config user.name 'tdeps'",
- "git commit -a -m 'Initial Commit'"],
- apply_cmds(GitCmds, [{dir, "repo/b"}]),
- apply_cmds(GitCmds, [{dir, "repo/c"}]),
-
- {ok, _} = retest_sh:run("./rebar get-deps compile", []),
-
- true = filelib:is_regular("ebin/a.beam"),
- ok.
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name, Modules) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, Modules},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/tdeps2/a.erl b/src/rebar/inttest/tdeps2/a.erl
deleted file mode 100644
index 294ae210b..000000000
--- a/src/rebar/inttest/tdeps2/a.erl
+++ /dev/null
@@ -1,3 +0,0 @@
--module({{module}}).
-
--include_lib("b/include/b.hrl").
diff --git a/src/rebar/inttest/tdeps2/a.rebar.config b/src/rebar/inttest/tdeps2/a.rebar.config
deleted file mode 100644
index 991ea5acf..000000000
--- a/src/rebar/inttest/tdeps2/a.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{b, "1", {git, "../repo/b"}}]}.
diff --git a/src/rebar/inttest/tdeps2/b.hrl b/src/rebar/inttest/tdeps2/b.hrl
deleted file mode 100644
index efbeab184..000000000
--- a/src/rebar/inttest/tdeps2/b.hrl
+++ /dev/null
@@ -1 +0,0 @@
--include_lib("c/include/c.hrl").
diff --git a/src/rebar/inttest/tdeps2/b.rebar.config b/src/rebar/inttest/tdeps2/b.rebar.config
deleted file mode 100644
index ffbd0db7c..000000000
--- a/src/rebar/inttest/tdeps2/b.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{c, "1", {git, "../repo/c"}}]}.
diff --git a/src/rebar/inttest/tdeps2/c.hrl b/src/rebar/inttest/tdeps2/c.hrl
deleted file mode 100644
index 9f02fab5f..000000000
--- a/src/rebar/inttest/tdeps2/c.hrl
+++ /dev/null
@@ -1 +0,0 @@
--define(HELLO, hello).
diff --git a/src/rebar/inttest/tdeps2/root.rebar.config b/src/rebar/inttest/tdeps2/root.rebar.config
deleted file mode 100644
index 005adfe05..000000000
--- a/src/rebar/inttest/tdeps2/root.rebar.config
+++ /dev/null
@@ -1,2 +0,0 @@
-{sub_dirs, ["apps/a1",
- "apps/a2"]}.
diff --git a/src/rebar/inttest/tdeps2/tdeps2_rt.erl b/src/rebar/inttest/tdeps2/tdeps2_rt.erl
deleted file mode 100644
index 987567e15..000000000
--- a/src/rebar/inttest/tdeps2/tdeps2_rt.erl
+++ /dev/null
@@ -1,65 +0,0 @@
--module(tdeps2_rt).
-
--compile(export_all).
-
-%% Exercise transitive dependencies where there are multiple files
-%% depending on the same set of deps
-%% [A1, A2] -> B -> C ; A1 and A2 includes B.hrl which includes C.hrl
-
-files() ->
- [
- %% A1 application
- {create, "apps/a1/ebin/a1.app", app(a1, [a1])},
- {copy, "a.rebar.config", "apps/a1/rebar.config"},
- {template, "a.erl", "apps/a1/src/a1.erl", dict:from_list([{module, a1}])},
-
- %% A2 application
- {create, "apps/a2/ebin/a2.app", app(a2, [a2])},
- {copy, "a.rebar.config", "apps/a2/rebar.config"},
- {template, "a.erl", "apps/a2/src/a2.erl", dict:from_list([{module, a2}])},
-
- {copy, "root.rebar.config", "rebar.config"},
- {copy, "../../rebar", "rebar"},
-
- %% B application
- {create, "repo/b/ebin/b.app", app(b, [])},
- {copy, "b.rebar.config", "repo/b/rebar.config"},
- {copy, "b.hrl", "repo/b/include/b.hrl"},
-
- %% C application
- {create, "repo/c/ebin/c.app", app(c, [])},
- {copy, "c.hrl", "repo/c/include/c.hrl"}
- ].
-
-apply_cmds([], _Params) ->
- ok;
-apply_cmds([Cmd | Rest], Params) ->
- io:format("Running: ~s (~p)\n", [Cmd, Params]),
- {ok, _} = retest_sh:run(Cmd, Params),
- apply_cmds(Rest, Params).
-
-run(_Dir) ->
- %% Initialize the b/c apps as git repos so that dependencies pull
- %% properly
- GitCmds = ["git init",
- "git add -A",
- "git config user.email 'tdeps@example.com'",
- "git config user.name 'tdeps'",
- "git commit -a -m 'Initial Commit'"],
- ok = apply_cmds(GitCmds, [{dir, "repo/b"}]),
- ok = apply_cmds(GitCmds, [{dir, "repo/c"}]),
-
- {ok, _} = retest_sh:run("./rebar -v get-deps compile", []),
- ok.
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name, Modules) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, Modules},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/tdeps3/a.erl b/src/rebar/inttest/tdeps3/a.erl
deleted file mode 100644
index 5a387eb53..000000000
--- a/src/rebar/inttest/tdeps3/a.erl
+++ /dev/null
@@ -1,3 +0,0 @@
--module({{module}}).
-
--include_lib("{{dep}}/include/{{dep}}.hrl").
diff --git a/src/rebar/inttest/tdeps3/a.rebar.config b/src/rebar/inttest/tdeps3/a.rebar.config
deleted file mode 100644
index 19b8ef845..000000000
--- a/src/rebar/inttest/tdeps3/a.rebar.config
+++ /dev/null
@@ -1,4 +0,0 @@
-{deps, [
- {b, "1", {git, "../repo/b"}},
- {f, "1", {git, "../repo/f"}}
-]}.
diff --git a/src/rebar/inttest/tdeps3/b.hrl b/src/rebar/inttest/tdeps3/b.hrl
deleted file mode 100644
index efbeab184..000000000
--- a/src/rebar/inttest/tdeps3/b.hrl
+++ /dev/null
@@ -1 +0,0 @@
--include_lib("c/include/c.hrl").
diff --git a/src/rebar/inttest/tdeps3/b.rebar.config b/src/rebar/inttest/tdeps3/b.rebar.config
deleted file mode 100644
index d1ccae239..000000000
--- a/src/rebar/inttest/tdeps3/b.rebar.config
+++ /dev/null
@@ -1,5 +0,0 @@
-{deps, [
- {c, "1", {git, "../repo/c"}}
-]}.
-
-{lib_dirs, [apps]}.
diff --git a/src/rebar/inttest/tdeps3/c.hrl b/src/rebar/inttest/tdeps3/c.hrl
deleted file mode 100644
index cc87fffb5..000000000
--- a/src/rebar/inttest/tdeps3/c.hrl
+++ /dev/null
@@ -1 +0,0 @@
--include_lib("d/include/d.hrl").
diff --git a/src/rebar/inttest/tdeps3/c.rebar.config b/src/rebar/inttest/tdeps3/c.rebar.config
deleted file mode 100644
index b590771e9..000000000
--- a/src/rebar/inttest/tdeps3/c.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{d, "1", {git, "../repo/d"}}]}.
diff --git a/src/rebar/inttest/tdeps3/d.hrl b/src/rebar/inttest/tdeps3/d.hrl
deleted file mode 100644
index 02f808870..000000000
--- a/src/rebar/inttest/tdeps3/d.hrl
+++ /dev/null
@@ -1 +0,0 @@
--include_lib("e/include/e.hrl").
diff --git a/src/rebar/inttest/tdeps3/d.rebar.config b/src/rebar/inttest/tdeps3/d.rebar.config
deleted file mode 100644
index 4c7cd548f..000000000
--- a/src/rebar/inttest/tdeps3/d.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{e, "1", {git, "../repo/e"}}]}.
diff --git a/src/rebar/inttest/tdeps3/e.hrl b/src/rebar/inttest/tdeps3/e.hrl
deleted file mode 100644
index 9f02fab5f..000000000
--- a/src/rebar/inttest/tdeps3/e.hrl
+++ /dev/null
@@ -1 +0,0 @@
--define(HELLO, hello).
diff --git a/src/rebar/inttest/tdeps3/f.hrl b/src/rebar/inttest/tdeps3/f.hrl
deleted file mode 100644
index 02f808870..000000000
--- a/src/rebar/inttest/tdeps3/f.hrl
+++ /dev/null
@@ -1 +0,0 @@
--include_lib("e/include/e.hrl").
diff --git a/src/rebar/inttest/tdeps3/root.rebar.config b/src/rebar/inttest/tdeps3/root.rebar.config
deleted file mode 100644
index d1c379340..000000000
--- a/src/rebar/inttest/tdeps3/root.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{sub_dirs, ["apps/a"]}.
diff --git a/src/rebar/inttest/tdeps3/tdeps3_rt.erl b/src/rebar/inttest/tdeps3/tdeps3_rt.erl
deleted file mode 100644
index da87d439f..000000000
--- a/src/rebar/inttest/tdeps3/tdeps3_rt.erl
+++ /dev/null
@@ -1,89 +0,0 @@
--module(tdeps3_rt).
-
--compile(export_all).
-
-%% Exercise transitive dependencies where there are multiple files
-%% depending on the same set of deps as well as lib_dir directives
-%% A -> B -> C -> D -> E
-%% |--> G(via lib_dir)
-%% |--> F -> D -> E
-
-files() ->
- [
- %% A1 application
- {create, "ebin/a.app", app(a, [a])},
- {template, "a.erl", "src/a.erl", dict:from_list([{module, a}, {dep, b}])},
-
- {copy, "a.rebar.config", "rebar.config"},
- {copy, "../../rebar", "rebar"},
-
- %% B application
- {create, "repo/b/ebin/b.app", app(b, [b])},
- {template, "a.erl", "repo/b/src/b.erl", dict:from_list([{module, b}, {dep, b}])},
- {copy, "b.rebar.config", "repo/b/rebar.config"},
- {copy, "b.hrl", "repo/b/include/b.hrl"},
-
- %% C application
- {create, "repo/c/ebin/c.app", app(c, [c])},
- {template, "a.erl", "repo/c/src/c.erl", dict:from_list([{module, c}, {dep, d}])},
- {copy, "c.rebar.config", "repo/c/rebar.config"},
- {copy, "c.hrl", "repo/c/include/c.hrl"},
-
- %% D application
- {create, "repo/d/ebin/d.app", app(d, [d])},
- {template, "a.erl", "repo/d/src/d.erl", dict:from_list([{module, d}, {dep, e}])},
- {copy, "d.rebar.config", "repo/d/rebar.config"},
- {copy, "d.hrl", "repo/d/include/d.hrl"},
-
- %% E application
- {create, "repo/e/ebin/e.app", app(e, [])},
- {copy, "e.hrl", "repo/e/include/e.hrl"},
-
-
- %% F application
- {create, "repo/f/ebin/f.app", app(f, [f])},
- {template, "a.erl", "repo/f/src/f.erl", dict:from_list([{module, f}, {dep, d}])},
- {copy, "c.rebar.config", "repo/f/rebar.config"},
- {copy, "f.hrl", "repo/f/include/f.hrl"},
-
- %% G application, which is part of the B repo, in a lib_dir
- {create, "repo/b/apps/g/ebin/g.app", app(g, [])},
- {copy, "e.hrl", "repo/b/apps/g/include/g.hrl"}
-
- ].
-
-apply_cmds([], _Params) ->
- ok;
-apply_cmds([Cmd | Rest], Params) ->
- io:format("Running: ~s (~p)\n", [Cmd, Params]),
- {ok, _} = retest_sh:run(Cmd, Params),
- apply_cmds(Rest, Params).
-
-run(_Dir) ->
- %% Initialize the b/c apps as git repos so that dependencies pull
- %% properly
- GitCmds = ["git init",
- "git add -A",
- "git config user.email 'tdeps@example.com'",
- "git config user.name 'tdeps'",
- "git commit -a -m 'Initial Commit'"],
- ok = apply_cmds(GitCmds, [{dir, "repo/b"}]),
- ok = apply_cmds(GitCmds, [{dir, "repo/c"}]),
- ok = apply_cmds(GitCmds, [{dir, "repo/d"}]),
- ok = apply_cmds(GitCmds, [{dir, "repo/e"}]),
- ok = apply_cmds(GitCmds, [{dir, "repo/f"}]),
-
- {ok, _} = retest_sh:run("./rebar -v get-deps compile", []),
- ok.
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name, Modules) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, Modules},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/tdeps_update/a.erl b/src/rebar/inttest/tdeps_update/a.erl
deleted file mode 100644
index 294ae210b..000000000
--- a/src/rebar/inttest/tdeps_update/a.erl
+++ /dev/null
@@ -1,3 +0,0 @@
--module({{module}}).
-
--include_lib("b/include/b.hrl").
diff --git a/src/rebar/inttest/tdeps_update/a.rebar.config b/src/rebar/inttest/tdeps_update/a.rebar.config
deleted file mode 100644
index 3b721dc37..000000000
--- a/src/rebar/inttest/tdeps_update/a.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{b, "0.2.3", {git, "../repo/b", {tag, "0.2.3"}}}]}.
diff --git a/src/rebar/inttest/tdeps_update/a2.rebar.config b/src/rebar/inttest/tdeps_update/a2.rebar.config
deleted file mode 100644
index 5687349d2..000000000
--- a/src/rebar/inttest/tdeps_update/a2.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{b, "0.2.4", {git, "../repo/b", {tag, "0.2.4"}}}]}.
diff --git a/src/rebar/inttest/tdeps_update/a3.rebar.config b/src/rebar/inttest/tdeps_update/a3.rebar.config
deleted file mode 100644
index 86bf4627c..000000000
--- a/src/rebar/inttest/tdeps_update/a3.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{b, "0.2.5", {git, "../repo/b", {tag, "0.2.5"}}}]}.
diff --git a/src/rebar/inttest/tdeps_update/a4.rebar.config b/src/rebar/inttest/tdeps_update/a4.rebar.config
deleted file mode 100644
index bfba81346..000000000
--- a/src/rebar/inttest/tdeps_update/a4.rebar.config
+++ /dev/null
@@ -1,4 +0,0 @@
-{deps, [
- {b, "0.2.6", {git, "../repo/b", {tag, "0.2.6"}}},
- {f, "0.1", {git, "../repo/f", {tag, "0.1"}}}
- ]}.
diff --git a/src/rebar/inttest/tdeps_update/b.hrl b/src/rebar/inttest/tdeps_update/b.hrl
deleted file mode 100644
index efbeab184..000000000
--- a/src/rebar/inttest/tdeps_update/b.hrl
+++ /dev/null
@@ -1 +0,0 @@
--include_lib("c/include/c.hrl").
diff --git a/src/rebar/inttest/tdeps_update/b.rebar.config b/src/rebar/inttest/tdeps_update/b.rebar.config
deleted file mode 100644
index 536aaa9ba..000000000
--- a/src/rebar/inttest/tdeps_update/b.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{c, "1.0", {git, "../repo/c", {tag, "1.0"}}}]}.
diff --git a/src/rebar/inttest/tdeps_update/b2.rebar.config b/src/rebar/inttest/tdeps_update/b2.rebar.config
deleted file mode 100644
index b603277da..000000000
--- a/src/rebar/inttest/tdeps_update/b2.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{c, "1.1", {git, "../repo/c", {tag, "1.1"}}}]}.
diff --git a/src/rebar/inttest/tdeps_update/b3.rebar.config b/src/rebar/inttest/tdeps_update/b3.rebar.config
deleted file mode 100644
index 5f4e20aa5..000000000
--- a/src/rebar/inttest/tdeps_update/b3.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{c, "1.2", {git, "../repo/c", {tag, "1.2"}}}]}.
diff --git a/src/rebar/inttest/tdeps_update/b4.rebar.config b/src/rebar/inttest/tdeps_update/b4.rebar.config
deleted file mode 100644
index 5fd1dca03..000000000
--- a/src/rebar/inttest/tdeps_update/b4.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{c, "1.3", {git, "../repo/c", {tag, "1.3"}}}]}.
diff --git a/src/rebar/inttest/tdeps_update/c.hrl b/src/rebar/inttest/tdeps_update/c.hrl
deleted file mode 100644
index 9f02fab5f..000000000
--- a/src/rebar/inttest/tdeps_update/c.hrl
+++ /dev/null
@@ -1 +0,0 @@
--define(HELLO, hello).
diff --git a/src/rebar/inttest/tdeps_update/c.rebar.config b/src/rebar/inttest/tdeps_update/c.rebar.config
deleted file mode 100644
index d99b963cd..000000000
--- a/src/rebar/inttest/tdeps_update/c.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{deps, [{d, "0.7", {git, "../repo/d", {tag, "0.7"}}}]}.
diff --git a/src/rebar/inttest/tdeps_update/c2.hrl b/src/rebar/inttest/tdeps_update/c2.hrl
deleted file mode 100644
index cc87fffb5..000000000
--- a/src/rebar/inttest/tdeps_update/c2.hrl
+++ /dev/null
@@ -1 +0,0 @@
--include_lib("d/include/d.hrl").
diff --git a/src/rebar/inttest/tdeps_update/c2.rebar.config b/src/rebar/inttest/tdeps_update/c2.rebar.config
deleted file mode 100644
index 1297e0708..000000000
--- a/src/rebar/inttest/tdeps_update/c2.rebar.config
+++ /dev/null
@@ -1,4 +0,0 @@
-{deps, [
- {d, "0.7", {git, "../repo/d", {tag, "0.7"}}},
- {e, "2.0", {git, "../repo/e", {tag, "2.0"}}}
- ]}.
diff --git a/src/rebar/inttest/tdeps_update/c3.rebar.config b/src/rebar/inttest/tdeps_update/c3.rebar.config
deleted file mode 100644
index 40c93c576..000000000
--- a/src/rebar/inttest/tdeps_update/c3.rebar.config
+++ /dev/null
@@ -1,4 +0,0 @@
-{deps, [
- {d, "0.7", {git, "../repo/d", {tag, "0.7"}}},
- {e, "2.1", {git, "../repo/e", {tag, "2.1"}}}
- ]}.
diff --git a/src/rebar/inttest/tdeps_update/d.hrl b/src/rebar/inttest/tdeps_update/d.hrl
deleted file mode 100644
index 9f02fab5f..000000000
--- a/src/rebar/inttest/tdeps_update/d.hrl
+++ /dev/null
@@ -1 +0,0 @@
--define(HELLO, hello).
diff --git a/src/rebar/inttest/tdeps_update/root.rebar.config b/src/rebar/inttest/tdeps_update/root.rebar.config
deleted file mode 100644
index ea0343703..000000000
--- a/src/rebar/inttest/tdeps_update/root.rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{sub_dirs, ["apps/a1"]}.
diff --git a/src/rebar/inttest/tdeps_update/tdeps_update_rt.erl b/src/rebar/inttest/tdeps_update/tdeps_update_rt.erl
deleted file mode 100644
index 81bb7ef43..000000000
--- a/src/rebar/inttest/tdeps_update/tdeps_update_rt.erl
+++ /dev/null
@@ -1,147 +0,0 @@
--module(tdeps_update_rt).
-
--compile(export_all).
-
-%% Exercises update deps, with recursive dependency updates.
-%% Initially:
-%% A(v0.5) -> B(v0.2.3) -> C(v1.0)
-%% But after updating A to 0.6:
-%% A(v0.6) -> B(v0.2.4) -> C(v1.1)
-%% -> D(v0.7)
-%% And after updating A to 0.7:
-%% A(v0.7) -> B(v0.2.5) -> C(v1.2) -> E(v2.0)
-%% -> D(v0.7)
-%% And after updating A to 0.8:
-%% A(v0.8) -> B(v0.2.6) -> C(v1.3) -> E(v2.1)
-%% -> D(v0.7)
-%% -> F(v0.1) -> E(v2.1)
-files() ->
- [
- %% A1 application
- {create, "apps/a1/ebin/a1.app", app(a1, [a1], "0.5")},
- {copy, "a.rebar.config", "apps/a1/rebar.config"},
- {template, "a.erl", "apps/a1/src/a1.erl", dict:from_list([{module, a1}])},
-
- {copy, "root.rebar.config", "rebar.config"},
- {copy, "../../rebar", "rebar"},
-
- %% B application
- {create, "repo/b/ebin/b.app", app(b, [], "0.2.3")},
- {create, "b2.app", app(b, [], "0.2.4")},
- {create, "b3.app", app(b, [], "0.2.5")},
- {create, "b4.app", app(b, [], "0.2.6")},
- {copy, "b.rebar.config", "repo/b/rebar.config"},
- {copy, "b.hrl", "repo/b/include/b.hrl"},
-
- %% C application
- {create, "repo/c/ebin/c.app", app(c, [], "1.0")},
- {create, "c2.app", app(c, [], "1.1")},
- {create, "c3.app", app(c, [], "1.2")},
- {create, "c4.app", app(c, [], "1.3")},
- {copy, "c.hrl", "repo/c/include/c.hrl"},
-
- %% D application
- {create, "repo/d/ebin/d.app", app(d, [], "0.7")},
- {copy, "d.hrl", "repo/d/include/d.hrl"},
-
- %% E application
- {create, "repo/e/ebin/e.app", app(e, [], "2.0")},
- {create, "e2.app", app(e, [], "2.1")},
-
- %% F application
- {create, "repo/f/ebin/f.app", app(f, [], "0.1")},
-
- %% update files
- {copy, "a2.rebar.config", "a2.rebar.config"},
- {copy, "a3.rebar.config", "a3.rebar.config"},
- {copy, "a4.rebar.config", "a4.rebar.config"},
- {copy, "b2.rebar.config", "b2.rebar.config"},
- {copy, "b3.rebar.config", "b3.rebar.config"},
- {copy, "b4.rebar.config", "b4.rebar.config"},
- {copy, "c2.hrl", "c2.hrl"},
- {copy, "c.rebar.config", "c.rebar.config"},
- {copy, "c2.rebar.config", "c2.rebar.config"},
- {copy, "c3.rebar.config", "c3.rebar.config"}
- ].
-
-apply_cmds([], _Params) ->
- ok;
-apply_cmds([Cmd | Rest], Params) ->
- io:format("Running: ~s (~p)\n", [Cmd, Params]),
- {ok, _} = retest_sh:run(Cmd, Params),
- apply_cmds(Rest, Params).
-
-run(_Dir) ->
- %% Initialize the b/c/d apps as git repos so that dependencies pull
- %% properly
- GitCmds = ["git init",
- "git add -A",
- "git config user.email 'tdeps@example.com'",
- "git config user.name 'tdeps'",
- "git commit -a -m 'Initial Commit'"],
- BCmds = ["git tag 0.2.3",
- "cp ../../b2.rebar.config rebar.config",
- "cp ../../b2.app ebin/b.app",
- "git commit -a -m 'update to 0.2.4'",
- "git tag 0.2.4",
- "cp ../../b3.rebar.config rebar.config",
- "cp ../../b3.app ebin/b.app",
- "git commit -a -m 'update to 0.2.5'",
- "git tag 0.2.5",
- "cp ../../b4.rebar.config rebar.config",
- "cp ../../b4.app ebin/b.app",
- "git commit -a -m 'update to 0.2.6'",
- "git tag 0.2.6"],
- %"git checkout 0.2.3"],
- CCmds = ["git tag 1.0",
- "cp ../../c2.hrl include/c.hrl",
- "cp ../../c2.app ebin/c.app",
- "cp ../../c.rebar.config rebar.config",
- "git add rebar.config",
- "git commit -a -m 'update to 1.1'",
- "git tag 1.1",
- "cp ../../c3.app ebin/c.app",
- "cp ../../c2.rebar.config rebar.config",
- "git commit -a -m 'update to 1.2'",
- "git tag 1.2",
- "cp ../../c4.app ebin/c.app",
- "cp ../../c3.rebar.config rebar.config",
- "git commit -a -m 'update to 1.3'",
- "git tag 1.3"],
- %"git checkout 1.0"],
- DCmds = ["git tag 0.7"],
- ECmds = ["git tag 2.0",
- "cp ../../e2.app ebin/e.app",
- "git commit -a -m 'update to 2.1'",
- "git tag 2.1"],
- FCmds = ["git tag 0.1"],
-
- ok = apply_cmds(GitCmds++BCmds, [{dir, "repo/b"}]),
- ok = apply_cmds(GitCmds++CCmds, [{dir, "repo/c"}]),
- ok = apply_cmds(GitCmds++DCmds, [{dir, "repo/d"}]),
- ok = apply_cmds(GitCmds++ECmds, [{dir, "repo/e"}]),
- ok = apply_cmds(GitCmds++FCmds, [{dir, "repo/f"}]),
-
- {ok, _} = retest_sh:run("./rebar -v get-deps compile", []),
- os:cmd("cp a2.rebar.config apps/a1/rebar.config"),
- {ok, _} = retest_sh:run("./rebar -v update-deps", []),
- {ok, _} = retest_sh:run("./rebar -v compile", []),
- os:cmd("cp a3.rebar.config apps/a1/rebar.config"),
- {ok, _} = retest_sh:run("./rebar -v update-deps", []),
- {ok, _} = retest_sh:run("./rebar -v compile", []),
- os:cmd("cp a4.rebar.config apps/a1/rebar.config"),
- {ok, _} = retest_sh:run("./rebar -v update-deps", []),
- {ok, _} = retest_sh:run("./rebar -v compile", []),
- ok.
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name, Modules, Version) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, Version},
- {modules, Modules},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/thooks/fish.erl b/src/rebar/inttest/thooks/fish.erl
deleted file mode 100644
index 739cb94b7..000000000
--- a/src/rebar/inttest/thooks/fish.erl
+++ /dev/null
@@ -1,5 +0,0 @@
--module(fish).
-
--compile(export_all).
-
-fish() -> fish.
diff --git a/src/rebar/inttest/thooks/rebar.config b/src/rebar/inttest/thooks/rebar.config
deleted file mode 100644
index 651481852..000000000
--- a/src/rebar/inttest/thooks/rebar.config
+++ /dev/null
@@ -1,7 +0,0 @@
-%% pre-scripts
-{pre_hooks, [{clean, "echo preclean >> preclean.out"},
- {compile, "echo precompile >> precompile.out"}]}.
-
-%% post-scripts
-{post_hooks, [{clean, "echo postclean >> postclean.out"},
- {compile, "echo postcompile >> postcompile.out"}]}.
diff --git a/src/rebar/inttest/thooks/thooks_rt.erl b/src/rebar/inttest/thooks/thooks_rt.erl
deleted file mode 100644
index 52af9f5c3..000000000
--- a/src/rebar/inttest/thooks/thooks_rt.erl
+++ /dev/null
@@ -1,40 +0,0 @@
--module(thooks_rt).
-
--include_lib("eunit/include/eunit.hrl").
--compile(export_all).
-
-files() ->
- [
- %% dummy lfe files
- {copy, "../../rebar", "rebar"},
- {copy, "rebar.config", "rebar.config"},
- {copy, "fish.erl", "src/fish.erl"},
- {create, "ebin/fish.app", app(fish, [fish])}
- ].
-
-run(_Dir) ->
- ?assertMatch({ok, _}, retest_sh:run("./rebar -v clean compile", [])),
- ensure_command_ran_only_once("preclean"),
- ensure_command_ran_only_once("precompile"),
- ensure_command_ran_only_once("postclean"),
- ensure_command_ran_only_once("postcompile"),
- ok.
-
-ensure_command_ran_only_once(Command) ->
- File = Command ++ ".out",
- ?assert(filelib:is_regular(File)),
- %% ensure that this command only ran once (not for each module)
- {ok, Content} = file:read_file(File),
- ?assertEqual(Command ++ "\n", binary_to_list(Content)).
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name, Modules) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, Modules},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/inttest/tplugins/bad.config b/src/rebar/inttest/tplugins/bad.config
deleted file mode 100644
index 23069b8f9..000000000
--- a/src/rebar/inttest/tplugins/bad.config
+++ /dev/null
@@ -1,2 +0,0 @@
-{plugins, [bad_plugin]}.
-{plugin_dir, "bad_plugins"}.
diff --git a/src/rebar/inttest/tplugins/bad_plugin.erl b/src/rebar/inttest/tplugins/bad_plugin.erl
deleted file mode 100644
index 77ec01bbd..000000000
--- a/src/rebar/inttest/tplugins/bad_plugin.erl
+++ /dev/null
@@ -1,7 +0,0 @@
--module(bad_plugin).
--compile(export_all).
-
-%% this plugin contains numerous DELIBERATE syntax errors
-
-fwibble(Config, _) >
- file:delete("fwibble.test")
diff --git a/src/rebar/inttest/tplugins/fish.erl b/src/rebar/inttest/tplugins/fish.erl
deleted file mode 100644
index 739cb94b7..000000000
--- a/src/rebar/inttest/tplugins/fish.erl
+++ /dev/null
@@ -1,5 +0,0 @@
--module(fish).
-
--compile(export_all).
-
-fish() -> fish.
diff --git a/src/rebar/inttest/tplugins/rebar.config b/src/rebar/inttest/tplugins/rebar.config
deleted file mode 100644
index 0b9c88732..000000000
--- a/src/rebar/inttest/tplugins/rebar.config
+++ /dev/null
@@ -1 +0,0 @@
-{plugins, [test_plugin]}.
diff --git a/src/rebar/inttest/tplugins/test_plugin.erl b/src/rebar/inttest/tplugins/test_plugin.erl
deleted file mode 100644
index 461247cca..000000000
--- a/src/rebar/inttest/tplugins/test_plugin.erl
+++ /dev/null
@@ -1,8 +0,0 @@
--module(test_plugin).
--compile(export_all).
-
-fwibble(Config, _) ->
- Pwd = rebar_utils:get_cwd(),
- Ok = filelib:is_regular(filename:join(Pwd, "fwibble.test")),
- rebar_log:log(info, "~p:~p in ~s :: ~p~n", [test_plugin, clean, Pwd, Ok]),
- ok = file:delete("fwibble.test").
diff --git a/src/rebar/inttest/tplugins/tplugins_rt.erl b/src/rebar/inttest/tplugins/tplugins_rt.erl
deleted file mode 100644
index d6908ad71..000000000
--- a/src/rebar/inttest/tplugins/tplugins_rt.erl
+++ /dev/null
@@ -1,40 +0,0 @@
--module(tplugins_rt).
--compile(export_all).
-
--include_lib("eunit/include/eunit.hrl").
-
--define(COMPILE_ERROR,
- "ERROR: Plugin bad_plugin contains compilation errors:").
-
-files() ->
- [
- {copy, "../../rebar", "rebar"},
- {copy, "rebar.config", "rebar.config"},
- {copy, "bad.config", "bad.config"},
- {copy, "fish.erl", "src/fish.erl"},
- {copy, "test_plugin.erl", "plugins/test_plugin.erl"},
- {copy, "bad_plugin.erl", "bad_plugins/bad_plugin.erl"},
- {create, "fwibble.test", <<"fwibble">>},
- {create, "ebin/fish.app", app(fish, [fish])}
- ].
-
-run(_Dir) ->
- ?assertMatch({ok, _}, retest_sh:run("./rebar fwibble -v", [])),
- ?assertEqual(false, filelib:is_regular("fwibble.test")),
- Ref = retest:sh("./rebar -C bad.config -v clean", [{async, true}]),
- {ok, _} = retest:sh_expect(Ref, "ERROR: Plugin .*bad_plugin.erl "
- "contains compilation errors:.*",
- [{newline, any}]),
- ok.
-
-%%
-%% Generate the contents of a simple .app file
-%%
-app(Name, Modules) ->
- App = {application, Name,
- [{description, atom_to_list(Name)},
- {vsn, "1"},
- {modules, Modules},
- {registered, []},
- {applications, [kernel, stdlib]}]},
- io_lib:format("~p.\n", [App]).
diff --git a/src/rebar/priv/shell-completion/bash/rebar b/src/rebar/priv/shell-completion/bash/rebar
deleted file mode 100644
index d4a42dc69..000000000
--- a/src/rebar/priv/shell-completion/bash/rebar
+++ /dev/null
@@ -1,85 +0,0 @@
-# bash completion for rebar
-
-_rebar()
-{
- local cur prev sopts lopts cmdsnvars
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
- sopts="-h -c -v -V -f -D -j -C -p -k"
- lopts="--help \
- --commands \
- --verbose \
- --force \
- --jobs \
- --config \
- --profile \
- --keep-going \
- --version"
- cmdsnvars="check-deps \
- clean \
- compile \
- create \
- create-app \
- create-node \
- ct \
- doc \
- delete-deps \
- escriptize \
- eunit \
- get-deps \
- generate \
- generate-appups \
- generate-upgrade \
- help \
- list-deps \
- list-templates \
- qc \
- update-deps \
- version \
- xref \
- overlay \
- apps= \
- case= \
- dump_spec=1 \
- force=1 \
- jobs= \
- suites= \
- verbose=1 \
- appid= \
- overlay_vars= \
- previous_release= \
- nodeid= \
- root_dir= \
- skip_deps=true \
- skip_apps= \
- target_dir= \
- template= \
- template_dir= \
- tests="
-
- if [[ ${cur} == --* ]] ; then
- COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) )
- elif [[ ${cur} == -* ]] ; then
- COMPREPLY=( $(compgen -W "${sopts}" -- ${cur}) )
- else
- COMPREPLY=( $(compgen -W "${cmdsnvars}" -- ${cur}) )
- fi
-
- if [ -n "$COMPREPLY" ] ; then
- # append space if matched
- COMPREPLY="${COMPREPLY} "
- # remove trailing space after equal sign
- COMPREPLY=${COMPREPLY/%= /=}
- fi
- return 0
-}
-complete -o nospace -F _rebar rebar
-
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
-# ex: ts=4 sw=4 et filetype=sh
diff --git a/src/rebar/priv/shell-completion/zsh/_rebar b/src/rebar/priv/shell-completion/zsh/_rebar
deleted file mode 100644
index 3d04ba158..000000000
--- a/src/rebar/priv/shell-completion/zsh/_rebar
+++ /dev/null
@@ -1,83 +0,0 @@
-#compdef rebar
-
-local curcontext=$curcontext state ret=1
-typeset -ga _rebar_global_opts
-
-_rebar_global_opts=(
- '(--help -h)'{--help,-h}'[Show the program options]'
- '(--commands -c)'{--commands,-c}'[Show available commands]'
- '(--version -V)'{--version,-V}'[Show version information]'
- '(-vvv -vv -v)'--verbose+'[Verbosity level. Default: 0]:verbosity level:(0 1 2 3)'
- '(-vvv)-v[Slightly more verbose output]'
- '(-vvv)-vv[More verbose output]'
- '(-v -vv)-vvv[Most verbose output]'
- '(--force -f)'{--force,-f}'[Force]'
- '-D+[Define compiler macro]'
- '(--jobs -j)'{--jobs+,-j+}'[Number of concurrent workers a command may use. Default: 3]:workers:(1 2 3 4 5 6 7 8 9)'
- '(--config -C)'{--config,-C}'[Rebar config file to use]:files:_files'
- '(--profile -p)'{--profile,-p}'[Profile this run of rebar]'
- '(--keep-going -k)'{--keep-going,-k}'[Keep running after a command fails]'
-)
-
-_rebar () {
- _arguments -C $_rebar_global_opts \
- '*::command and variable:->cmd_and_var' \
- && return
-
- case $state in
- cmd_and_var)
- _values -S = 'variables' \
- 'clean[Clean]' \
- 'compile[Compile sources]' \
- 'create[Create skel based on template and vars]' \
- 'create-app[Create simple app skel]' \
- 'create-node[Create simple node skel]' \
- 'list-template[List avaiavle templates]' \
- 'doc[Generate Erlang program documentation]' \
- 'check-deps[Display to be fetched dependencies]' \
- 'get-deps[Fetch dependencies]' \
- 'update-deps[Update fetched dependencies]' \
- 'delete-deps[Delete fetched dependencies]' \
- 'list-deps[List dependencies]' \
- 'generate[Build release with reltool]' \
- 'overlay[Run reltool overlays only]' \
- 'generate-appups[Generate appup files]' \
- 'generate-upgrade[Build an upgrade package]' \
- 'escriptize[Create stand-alone escript executable]' \
- 'eunit[Run eunit tests]' \
- 'ct[Run common_test suites]' \
- 'qc[Test QuickCheck properties]' \
- 'xref[Run cross reference analysis]' \
- 'help[Show the program options]' \
- 'version[Show version information]' \
- 'apps[Application names to process]:' \
- 'case[Common Test case]:' \
- 'dump_spec[Dump reltool spec]::flag:(1)' \
- 'jobs[Number of workers]::workers:(0 1 2 3 4 5 6 7 8 9)' \
- 'suites[Common Test suites]::suite name:_path_files -W "(src test)" -g "*.erl(:r)"' \
- 'verbose[Verbosity level]::verbosity level:(0 1 2 3)' \
- 'appid[Application id]:' \
- 'overlay_vars[Overlay variables file]:' \
- 'previous_release[Previous release path]:' \
- 'nodeid[Node id]:' \
- 'root_dir[Reltool config root directory]::directory:_files -/' \
- 'skip_deps[Skip deps]::flag:(true false)' \
- 'skip_apps[Application names to not process]::flag:(true false)' \
- 'target_dir[Target directory]:' \
- 'template[Template name]:' \
- 'template_dir[Template directory]::directory:_files -/' \
- 'tests[Run eunit tests whose name starts with given string]:' \
- && ret=0
- ;;
- esac
-}
-
-_rebar
-
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 2
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
-# ex: sw=2 ts=2 et filetype=sh
diff --git a/src/rebar/priv/templates/basicnif.c b/src/rebar/priv/templates/basicnif.c
deleted file mode 100644
index a1aa9e918..000000000
--- a/src/rebar/priv/templates/basicnif.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "erl_nif.h"
-
-static ErlNifResourceType* {{module}}_RESOURCE = NULL;
-
-typedef struct
-{
-} {{module}}_handle;
-
-// Prototypes
-static ERL_NIF_TERM {{module}}_new(ErlNifEnv* env, int argc,
- const ERL_NIF_TERM argv[]);
-static ERL_NIF_TERM {{module}}_myfunction(ErlNifEnv* env, int argc,
- const ERL_NIF_TERM argv[]);
-
-static ErlNifFunc nif_funcs[] =
-{
- {"new", 0, {{module}}_new},
- {"myfunction", 1, {{module}}_myfunction}
-};
-
-static ERL_NIF_TERM {{module}}_new(ErlNifEnv* env, int argc,
- const ERL_NIF_TERM argv[])
-{
- {{module}}_handle* handle = enif_alloc_resource({{module}}_RESOURCE,
- sizeof({{module}}_handle));
- ERL_NIF_TERM result = enif_make_resource(env, handle);
- enif_release_resource(handle);
- return enif_make_tuple2(env, enif_make_atom(env, "ok"), result);
-}
-
-
-static ERL_NIF_TERM {{module}}_myfunction(ErlNifEnv* env, int argc,
- const ERL_NIF_TERM argv[])
-{
- return enif_make_atom(env, "ok");
-}
-
-static void {{module}}_resource_cleanup(ErlNifEnv* env, void* arg)
-{
- /* Delete any dynamically allocated memory stored in {{module}}_handle */
- /* {{module}}_handle* handle = ({{module}}_handle*)arg; */
-}
-
-static int on_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
-{
- ErlNifResourceFlags flags = ERL_NIF_RT_CREATE | ERL_NIF_RT_TAKEOVER;
- ErlNifResourceType* rt = enif_open_resource_type(env, NULL,
- "{{module}}_resource",
- &{{module}}_resource_cleanup,
- flags, NULL);
- if (rt == NULL)
- return -1;
-
- {{module}}_RESOURCE = rt;
-
- return 0;
-}
-
-ERL_NIF_INIT({{module}}, nif_funcs, &on_load, NULL, NULL, NULL);
diff --git a/src/rebar/priv/templates/basicnif.erl b/src/rebar/priv/templates/basicnif.erl
deleted file mode 100644
index e1f414399..000000000
--- a/src/rebar/priv/templates/basicnif.erl
+++ /dev/null
@@ -1,42 +0,0 @@
--module({{module}}).
-
--export([new/0,
- myfunction/1]).
-
--on_load(init/0).
-
--define(nif_stub, nif_stub_error(?LINE)).
-nif_stub_error(Line) ->
- erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).
-
--ifdef(TEST).
--include_lib("eunit/include/eunit.hrl").
--endif.
-
-init() ->
- PrivDir = case code:priv_dir(?MODULE) of
- {error, bad_name} ->
- EbinDir = filename:dirname(code:which(?MODULE)),
- AppPath = filename:dirname(EbinDir),
- filename:join(AppPath, "priv");
- Path ->
- Path
- end,
- erlang:load_nif(filename:join(PrivDir, ?MODULE), 0).
-
-new() ->
- ?nif_stub.
-
-myfunction(_Ref) ->
- ?nif_stub.
-
-%% ===================================================================
-%% EUnit tests
-%% ===================================================================
--ifdef(TEST).
-
-basic_test() ->
- {ok, Ref} = new(),
- ?assertEqual(ok, myfunction(Ref)).
-
--endif.
diff --git a/src/rebar/priv/templates/basicnif.template b/src/rebar/priv/templates/basicnif.template
deleted file mode 100644
index 6dde8bbb0..000000000
--- a/src/rebar/priv/templates/basicnif.template
+++ /dev/null
@@ -1,3 +0,0 @@
-{variables, [{module, "mymodule"}]}.
-{template, "basicnif.erl", "src/{{module}}.erl"}.
-{template, "basicnif.c", "c_src/{{module}}.c"}.
diff --git a/src/rebar/priv/templates/ctsuite.erl b/src/rebar/priv/templates/ctsuite.erl
deleted file mode 100644
index 33a8fac9d..000000000
--- a/src/rebar/priv/templates/ctsuite.erl
+++ /dev/null
@@ -1,167 +0,0 @@
-%% common_test suite for {{testmod}}
-
--module({{testmod}}_SUITE).
--include_lib("common_test/include/ct.hrl").
-
--compile(export_all).
-
-%%--------------------------------------------------------------------
-%% Function: suite() -> Info
-%%
-%% Info = [tuple()]
-%% List of key/value pairs.
-%%
-%% Description: Returns list of tuples to set default properties
-%% for the suite.
-%%
-%% Note: The suite/0 function is only meant to be used to return
-%% default data values, not perform any other operations.
-%%--------------------------------------------------------------------
-suite() -> [{timetrap, {seconds, 20}}].
-
-%%--------------------------------------------------------------------
-%% Function: groups() -> [Group]
-%%
-%% Group = {GroupName,Properties,GroupsAndTestCases}
-%% GroupName = atom()
-%% The name of the group.
-%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]
-%% Group properties that may be combined.
-%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]
-%% TestCase = atom()
-%% The name of a test case.
-%% Shuffle = shuffle | {shuffle,Seed}
-%% To get cases executed in random order.
-%% Seed = {integer(),integer(),integer()}
-%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |
-%% repeat_until_any_ok | repeat_until_any_fail
-%% To get execution of cases repeated.
-%% N = integer() | forever
-%%
-%% Description: Returns a list of test case group definitions.
-%%--------------------------------------------------------------------
-groups() -> [].
-
-%%--------------------------------------------------------------------
-%% Function: all() -> GroupsAndTestCases
-%%
-%% GroupsAndTestCases = [{group,GroupName} | TestCase]
-%% GroupName = atom()
-%% Name of a test case group.
-%% TestCase = atom()
-%% Name of a test case.
-%%
-%% Description: Returns the list of groups and test cases that
-%% are to be executed.
-%%
-%% NB: By default, we export all 1-arity user defined functions
-%%--------------------------------------------------------------------
-all() ->
- [ {exports, Functions} | _ ] = ?MODULE:module_info(),
- [ FName || {FName, _} <- lists:filter(
- fun ({module_info,_}) -> false;
- ({all,_}) -> false;
- ({init_per_suite,1}) -> false;
- ({end_per_suite,1}) -> false;
- ({_,1}) -> true;
- ({_,_}) -> false
- end, Functions)].
-
-%%--------------------------------------------------------------------
-%% Function: init_per_suite(Config0) ->
-%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
-%%
-%% Config0 = Config1 = [tuple()]
-%% A list of key/value pairs, holding the test case configuration.
-%% Reason = term()
-%% The reason for skipping the suite.
-%%
-%% Description: Initialization before the suite.
-%%
-%% Note: This function is free to add any key/value pairs to the Config
-%% variable, but should NOT alter/remove any existing entries.
-%%--------------------------------------------------------------------
-init_per_suite(Config) ->
- Config.
-
-%%--------------------------------------------------------------------
-%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
-%%
-%% Config0 = Config1 = [tuple()]
-%% A list of key/value pairs, holding the test case configuration.
-%%
-%% Description: Cleanup after the suite.
-%%--------------------------------------------------------------------
-end_per_suite(_Config) ->
- ok.
-
-%%--------------------------------------------------------------------
-%% Function: init_per_group(GroupName, Config0) ->
-%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
-%%
-%% GroupName = atom()
-%% Name of the test case group that is about to run.
-%% Config0 = Config1 = [tuple()]
-%% A list of key/value pairs, holding configuration data for the group.
-%% Reason = term()
-%% The reason for skipping all test cases and subgroups in the group.
-%%
-%% Description: Initialization before each test case group.
-%%--------------------------------------------------------------------
-init_per_group(_group, Config) ->
- Config.
-
-%%--------------------------------------------------------------------
-%% Function: end_per_group(GroupName, Config0) ->
-%% void() | {save_config,Config1}
-%%
-%% GroupName = atom()
-%% Name of the test case group that is finished.
-%% Config0 = Config1 = [tuple()]
-%% A list of key/value pairs, holding configuration data for the group.
-%%
-%% Description: Cleanup after each test case group.
-%%--------------------------------------------------------------------
-end_per_group(_group, Config) ->
- Config.
-
-%%--------------------------------------------------------------------
-%% Function: init_per_testcase(TestCase, Config0) ->
-%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
-%%
-%% TestCase = atom()
-%% Name of the test case that is about to run.
-%% Config0 = Config1 = [tuple()]
-%% A list of key/value pairs, holding the test case configuration.
-%% Reason = term()
-%% The reason for skipping the test case.
-%%
-%% Description: Initialization before each test case.
-%%
-%% Note: This function is free to add any key/value pairs to the Config
-%% variable, but should NOT alter/remove any existing entries.
-%%--------------------------------------------------------------------
-init_per_testcase(TestCase, Config) ->
- Config.
-
-%%--------------------------------------------------------------------
-%% Function: end_per_testcase(TestCase, Config0) ->
-%% void() | {save_config,Config1} | {fail,Reason}
-%%
-%% TestCase = atom()
-%% Name of the test case that is finished.
-%% Config0 = Config1 = [tuple()]
-%% A list of key/value pairs, holding the test case configuration.
-%% Reason = term()
-%% The reason for failing the test case.
-%%
-%% Description: Cleanup after each test case.
-%%--------------------------------------------------------------------
-end_per_testcase(TestCase, Config) ->
- Config.
-
-test_{{testmod}}() ->
- [{userdata,[{doc,"Testing the {{testmod}} module"}]}].
-
-test_{{testmod}}(_Config) ->
- {skip,"Not implemented."}.
diff --git a/src/rebar/priv/templates/ctsuite.template b/src/rebar/priv/templates/ctsuite.template
deleted file mode 100644
index b7de33796..000000000
--- a/src/rebar/priv/templates/ctsuite.template
+++ /dev/null
@@ -1,2 +0,0 @@
-{variables, [{testmod, "mymodule"}]}.
-{template, "ctsuite.erl", "test/{{testmod}}_SUITE.erl"}.
diff --git a/src/rebar/priv/templates/simpleapp.app.src b/src/rebar/priv/templates/simpleapp.app.src
deleted file mode 100644
index 803e1ffe3..000000000
--- a/src/rebar/priv/templates/simpleapp.app.src
+++ /dev/null
@@ -1,12 +0,0 @@
-{application, {{appid}},
- [
- {description, ""},
- {vsn, "1"},
- {registered, []},
- {applications, [
- kernel,
- stdlib
- ]},
- {mod, { {{appid}}_app, []}},
- {env, []}
- ]}.
diff --git a/src/rebar/priv/templates/simpleapp.template b/src/rebar/priv/templates/simpleapp.template
deleted file mode 100644
index 2419a00a1..000000000
--- a/src/rebar/priv/templates/simpleapp.template
+++ /dev/null
@@ -1,4 +0,0 @@
-{variables, [{appid, "myapp"}]}.
-{template, "simpleapp.app.src", "src/{{appid}}.app.src"}.
-{template, "simpleapp_app.erl", "src/{{appid}}_app.erl"}.
-{template, "simpleapp_sup.erl", "src/{{appid}}_sup.erl"}.
diff --git a/src/rebar/priv/templates/simpleapp_app.erl b/src/rebar/priv/templates/simpleapp_app.erl
deleted file mode 100644
index 1af863b47..000000000
--- a/src/rebar/priv/templates/simpleapp_app.erl
+++ /dev/null
@@ -1,16 +0,0 @@
--module({{appid}}_app).
-
--behaviour(application).
-
-%% Application callbacks
--export([start/2, stop/1]).
-
-%% ===================================================================
-%% Application callbacks
-%% ===================================================================
-
-start(_StartType, _StartArgs) ->
- {{appid}}_sup:start_link().
-
-stop(_State) ->
- ok.
diff --git a/src/rebar/priv/templates/simpleapp_sup.erl b/src/rebar/priv/templates/simpleapp_sup.erl
deleted file mode 100644
index 477479fbf..000000000
--- a/src/rebar/priv/templates/simpleapp_sup.erl
+++ /dev/null
@@ -1,27 +0,0 @@
--module({{appid}}_sup).
-
--behaviour(supervisor).
-
-%% API
--export([start_link/0]).
-
-%% Supervisor callbacks
--export([init/1]).
-
-%% Helper macro for declaring children of supervisor
--define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
-
-%% ===================================================================
-%% API functions
-%% ===================================================================
-
-start_link() ->
- supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-
-%% ===================================================================
-%% Supervisor callbacks
-%% ===================================================================
-
-init([]) ->
- {ok, { {one_for_one, 5, 10}, []} }.
-
diff --git a/src/rebar/priv/templates/simplefsm.erl b/src/rebar/priv/templates/simplefsm.erl
deleted file mode 100644
index 776081ef6..000000000
--- a/src/rebar/priv/templates/simplefsm.erl
+++ /dev/null
@@ -1,57 +0,0 @@
--module({{fsmid}}).
--behaviour(gen_fsm).
--define(SERVER, ?MODULE).
-
-%% ------------------------------------------------------------------
-%% API Function Exports
-%% ------------------------------------------------------------------
-
--export([start_link/0]).
-
-%% ------------------------------------------------------------------
-%% gen_fsm Function Exports
-%% ------------------------------------------------------------------
-
--export([init/1, state_name/2, state_name/3, handle_event/3,
- handle_sync_event/4, handle_info/3, terminate/3,
- code_change/4]).
-
-%% ------------------------------------------------------------------
-%% API Function Definitions
-%% ------------------------------------------------------------------
-
-start_link() ->
- gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], []).
-
-%% ------------------------------------------------------------------
-%% gen_fsm Function Definitions
-%% ------------------------------------------------------------------
-
-init(_Args) ->
- {ok, initial_state_name, initial_state}.
-
-state_name(_Event, State) ->
- {next_state, state_name, State}.
-
-state_name(_Event, _From, State) ->
- {reply, ok, state_name, State}.
-
-handle_event(_Event, StateName, State) ->
- {next_state, StateName, State}.
-
-handle_sync_event(_Event, _From, StateName, State) ->
- {reply, ok, StateName, State}.
-
-handle_info(_Info, StateName, State) ->
- {next_state, StateName, State}.
-
-terminate(_Reason, _StateName, _State) ->
- ok.
-
-code_change(_OldVsn, StateName, State, _Extra) ->
- {ok, StateName, State}.
-
-%% ------------------------------------------------------------------
-%% Internal Function Definitions
-%% ------------------------------------------------------------------
-
diff --git a/src/rebar/priv/templates/simplefsm.template b/src/rebar/priv/templates/simplefsm.template
deleted file mode 100644
index 179c739b4..000000000
--- a/src/rebar/priv/templates/simplefsm.template
+++ /dev/null
@@ -1,2 +0,0 @@
-{variables, [{fsmid, "myfsm"}]}.
-{template, "simplefsm.erl", "src/{{fsmid}}.erl"}.
diff --git a/src/rebar/priv/templates/simplemod.erl b/src/rebar/priv/templates/simplemod.erl
deleted file mode 100644
index 46597aefd..000000000
--- a/src/rebar/priv/templates/simplemod.erl
+++ /dev/null
@@ -1,6 +0,0 @@
--module({{modid}}).
-
--export([my_func/0]).
-
-my_func() ->
- ok.
diff --git a/src/rebar/priv/templates/simplemod.template b/src/rebar/priv/templates/simplemod.template
deleted file mode 100644
index 04d61f30b..000000000
--- a/src/rebar/priv/templates/simplemod.template
+++ /dev/null
@@ -1,3 +0,0 @@
-{variables, [{modid, "mymod"}]}.
-{template, "simplemod.erl", "src/{{modid}}.erl"}.
-{template, "simplemod_tests.erl", "test/{{modid}}_tests.erl"}.
diff --git a/src/rebar/priv/templates/simplemod_tests.erl b/src/rebar/priv/templates/simplemod_tests.erl
deleted file mode 100644
index c5ca0bbe6..000000000
--- a/src/rebar/priv/templates/simplemod_tests.erl
+++ /dev/null
@@ -1,3 +0,0 @@
--module({{modid}}_tests).
--include_lib("eunit/include/eunit.hrl").
-
diff --git a/src/rebar/priv/templates/simplenode.erl.script b/src/rebar/priv/templates/simplenode.erl.script
deleted file mode 100644
index f4c63afbb..000000000
--- a/src/rebar/priv/templates/simplenode.erl.script
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
-if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
- POSIX_SHELL="true"
- export POSIX_SHELL
- exec /usr/bin/ksh $0 "$@"
-fi
-
-# clear it so if we invoke other scripts, they run as ksh as well
-unset POSIX_SHELL
-
-## This script replaces the default "erl" in erts-VSN/bin. This is
-## necessary as escript depends on erl and in turn, erl depends on
-## having access to a bootscript (start.boot). Note that this script
-## is ONLY invoked as a side-effect of running escript -- the embedded
-## node bypasses erl and uses erlexec directly (as it should).
-##
-## Note that this script makes the assumption that there is a
-## start_clean.boot file available in $ROOTDIR/release/VSN.
-
-# Determine the abspath of where this script is executing from.
-ERTS_BIN_DIR=$(cd ${0%/*} && pwd -P)
-
-# Now determine the root directory -- this script runs from erts-VSN/bin,
-# so we simply need to strip off two dirs from the end of the ERTS_BIN_DIR
-# path.
-ROOTDIR=${ERTS_BIN_DIR%/*/*}
-
-# Parse out release and erts info
-START_ERL=`cat $ROOTDIR/releases/start_erl.data`
-ERTS_VSN=${START_ERL% *}
-APP_VSN=${START_ERL#* }
-
-BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
-EMU=beam
-PROGNAME=`echo $0 | sed 's/.*\\///'`
-CMD="$BINDIR/erlexec"
-export EMU
-export ROOTDIR
-export BINDIR
-export PROGNAME
-
-exec $CMD -boot $ROOTDIR/releases/$APP_VSN/start_clean ${1+"$@"}
diff --git a/src/rebar/priv/templates/simplenode.install_upgrade.escript b/src/rebar/priv/templates/simplenode.install_upgrade.escript
deleted file mode 100644
index 56cea1963..000000000
--- a/src/rebar/priv/templates/simplenode.install_upgrade.escript
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env escript
-%%! -noshell -noinput
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ft=erlang ts=4 sw=4 et
-
--define(TIMEOUT, 60000).
--define(INFO(Fmt,Args), io:format(Fmt,Args)).
-
-main([NodeName, Cookie, ReleasePackage]) ->
- TargetNode = start_distribution(NodeName, Cookie),
- {ok, Vsn} = rpc:call(TargetNode, release_handler, unpack_release,
- [ReleasePackage], ?TIMEOUT),
- ?INFO("Unpacked Release ~p~n", [Vsn]),
- {ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
- check_install_release, [Vsn], ?TIMEOUT),
- {ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
- install_release, [Vsn], ?TIMEOUT),
- ?INFO("Installed Release ~p~n", [Vsn]),
- ok = rpc:call(TargetNode, release_handler, make_permanent, [Vsn], ?TIMEOUT),
- ?INFO("Made Release ~p Permanent~n", [Vsn]);
-main(_) ->
- init:stop(1).
-
-start_distribution(NodeName, Cookie) ->
- MyNode = make_script_node(NodeName),
- {ok, _Pid} = net_kernel:start([MyNode, shortnames]),
- erlang:set_cookie(node(), list_to_atom(Cookie)),
- TargetNode = make_target_node(NodeName),
- case {net_kernel:hidden_connect_node(TargetNode),
- net_adm:ping(TargetNode)} of
- {true, pong} ->
- ok;
- {_, pang} ->
- io:format("Node ~p not responding to pings.\n", [TargetNode]),
- init:stop(1)
- end,
- TargetNode.
-
-make_target_node(Node) ->
- [_, Host] = string:tokens(atom_to_list(node()), "@"),
- list_to_atom(lists:concat([Node, "@", Host])).
-
-make_script_node(Node) ->
- list_to_atom(lists:concat([Node, "_upgrader_", os:getpid()])).
diff --git a/src/rebar/priv/templates/simplenode.nodetool b/src/rebar/priv/templates/simplenode.nodetool
deleted file mode 100755
index ce06c6a8d..000000000
--- a/src/rebar/priv/templates/simplenode.nodetool
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/usr/bin/env escript
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ft=erlang ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% nodetool: Helper Script for interacting with live nodes
-%%
-%% -------------------------------------------------------------------
-main(Args) ->
- ok = start_epmd(),
- %% Extract the args
- {RestArgs, TargetNode} = process_args(Args, [], undefined),
-
- %% any commands that don't need a running node
- case RestArgs of
- ["chkconfig", File] ->
- case file:consult(File) of
- {ok, _} ->
- io:format("ok\n"),
- halt(0);
- {error, {Line, Mod, Term}} ->
- io:format(standard_error, ["Error on line ",
- file:format_error({Line, Mod, Term}), "\n"], []),
- halt(1);
- {error, R} ->
- io:format(standard_error, ["Error reading config file: ",
- file:format_error(R), "\n"], []),
- halt(1)
- end;
- _ ->
- ok
- end,
-
- %% See if the node is currently running -- if it's not, we'll bail
- case {net_kernel:hidden_connect_node(TargetNode),
- net_adm:ping(TargetNode)} of
- {true, pong} ->
- ok;
- {false,pong} ->
- io:format("Failed to connect to node ~p .\n", [TargetNode]),
- halt(1);
- {_, pang} ->
- io:format("Node ~p not responding to pings.\n", [TargetNode]),
- halt(1)
- end,
-
- case RestArgs of
- ["getpid"] ->
- io:format("~p\n",
- [list_to_integer(rpc:call(TargetNode, os, getpid, []))]);
- ["ping"] ->
- %% If we got this far, the node already responsed to a
- %% ping, so just dump a "pong"
- io:format("pong\n");
- ["stop"] ->
- io:format("~p\n", [rpc:call(TargetNode, init, stop, [], 60000)]);
- ["restart"] ->
- io:format("~p\n", [rpc:call(TargetNode, init, restart, [], 60000)]);
- ["reboot"] ->
- io:format("~p\n", [rpc:call(TargetNode, init, reboot, [], 60000)]);
- ["rpc", Module, Function | RpcArgs] ->
- case rpc:call(TargetNode,
- list_to_atom(Module),
- list_to_atom(Function),
- [RpcArgs], 60000) of
- ok ->
- ok;
- {badrpc, Reason} ->
- io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
- halt(1);
- _ ->
- halt(1)
- end;
- ["rpc_infinity", Module, Function | RpcArgs] ->
- case rpc:call(TargetNode,
- list_to_atom(Module),
- list_to_atom(Function),
- [RpcArgs], infinity) of
- ok ->
- ok;
- {badrpc, Reason} ->
- io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
- halt(1);
- _ ->
- halt(1)
- end;
- ["rpcterms", Module, Function, ArgsAsString] ->
- case rpc:call(TargetNode,
- list_to_atom(Module),
- list_to_atom(Function),
- consult(ArgsAsString), 60000) of
- {badrpc, Reason} ->
- io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
- halt(1);
- Other ->
- io:format("~p\n", [Other])
- end;
- Other ->
- io:format("Other: ~p\n", [Other]),
- io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms}\n")
- end,
- net_kernel:stop().
-
-process_args([], Acc, TargetNode) ->
- {lists:reverse(Acc), TargetNode};
-process_args(["-setcookie", Cookie | Rest], Acc, TargetNode) ->
- erlang:set_cookie(node(), list_to_atom(Cookie)),
- process_args(Rest, Acc, TargetNode);
-process_args(["-name", TargetName | Rest], Acc, _) ->
- ThisNode = append_node_suffix(TargetName, "_maint_"),
- {ok, _} = net_kernel:start([ThisNode, longnames]),
- process_args(Rest, Acc, nodename(TargetName));
-process_args(["-sname", TargetName | Rest], Acc, _) ->
- ThisNode = append_node_suffix(TargetName, "_maint_"),
- {ok, _} = net_kernel:start([ThisNode, shortnames]),
- process_args(Rest, Acc, nodename(TargetName));
-process_args([Arg | Rest], Acc, Opts) ->
- process_args(Rest, [Arg | Acc], Opts).
-
-
-start_epmd() ->
- [] = os:cmd(epmd_path() ++ " -daemon"),
- ok.
-
-epmd_path() ->
- ErtsBinDir = filename:dirname(escript:script_name()),
- Name = "epmd",
- case os:find_executable(Name, ErtsBinDir) of
- false ->
- case os:find_executable(Name) of
- false ->
- io:format("Could not find epmd.~n"),
- halt(1);
- GlobalEpmd ->
- GlobalEpmd
- end;
- Epmd ->
- Epmd
- end.
-
-
-nodename(Name) ->
- case string:tokens(Name, "@") of
- [_Node, _Host] ->
- list_to_atom(Name);
- [Node] ->
- [_, Host] = string:tokens(atom_to_list(node()), "@"),
- list_to_atom(lists:concat([Node, "@", Host]))
- end.
-
-append_node_suffix(Name, Suffix) ->
- case string:tokens(Name, "@") of
- [Node, Host] ->
- list_to_atom(lists:concat([Node, Suffix, os:getpid(), "@", Host]));
- [Node] ->
- list_to_atom(lists:concat([Node, Suffix, os:getpid()]))
- end.
-
-
-%%
-%% Given a string or binary, parse it into a list of terms, ala file:consult/0
-%%
-consult(Str) when is_list(Str) ->
- consult([], Str, []);
-consult(Bin) when is_binary(Bin)->
- consult([], binary_to_list(Bin), []).
-
-consult(Cont, Str, Acc) ->
- case erl_scan:tokens(Cont, Str, 0) of
- {done, Result, Remaining} ->
- case Result of
- {ok, Tokens, _} ->
- {ok, Term} = erl_parse:parse_term(Tokens),
- consult([], Remaining, [Term | Acc]);
- {eof, _Other} ->
- lists:reverse(Acc);
- {error, Info, _} ->
- {error, Info}
- end;
- {more, Cont1} ->
- consult(Cont1, eof, Acc)
- end.
diff --git a/src/rebar/priv/templates/simplenode.reltool.config b/src/rebar/priv/templates/simplenode.reltool.config
deleted file mode 100644
index bac727077..000000000
--- a/src/rebar/priv/templates/simplenode.reltool.config
+++ /dev/null
@@ -1,44 +0,0 @@
-%% -*- mode: erlang -*-
-%% ex: ft=erlang
-{sys, [
- {lib_dirs, []},
- {erts, [{mod_cond, derived}, {app_file, strip}]},
- {app_file, strip},
- {rel, "{{nodeid}}", "1",
- [
- kernel,
- stdlib,
- sasl,
- {{nodeid}}
- ]},
- {rel, "start_clean", "",
- [
- kernel,
- stdlib
- ]},
- {boot_rel, "{{nodeid}}"},
- {profile, embedded},
- {incl_cond, derived},
- {excl_archive_filters, [".*"]}, %% Do not archive built libs
- {excl_sys_filters, ["^bin/(?!start_clean.boot)",
- "^erts.*/bin/(dialyzer|typer)",
- "^erts.*/(doc|info|include|lib|man|src)"]},
- {excl_app_filters, ["\.gitignore"]},
- {app, {{nodeid}}, [{mod_cond, app}, {incl_cond, include}]}
- ]}.
-
-{target_dir, "{{nodeid}}"}.
-
-{overlay, [
- {mkdir, "log/sasl"},
- {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
- {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"},
- {copy, "{{nodeid}}/bin/start_clean.boot",
- "\{\{erts_vsn\}\}/bin/start_clean.boot"},
- {copy, "files/{{nodeid}}", "bin/{{nodeid}}"},
- {copy, "files/{{nodeid}}.cmd", "bin/{{nodeid}}.cmd"},
- {copy, "files/start_erl.cmd", "bin/start_erl.cmd"},
- {copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"},
- {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
- {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"}
- ]}.
diff --git a/src/rebar/priv/templates/simplenode.runner b/src/rebar/priv/templates/simplenode.runner
deleted file mode 100755
index 2786e7298..000000000
--- a/src/rebar/priv/templates/simplenode.runner
+++ /dev/null
@@ -1,348 +0,0 @@
-#!/bin/sh
-# -*- tab-width:4;indent-tabs-mode:nil -*-
-# ex: ts=4 sw=4 et
-
-# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
-if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
- POSIX_SHELL="true"
- export POSIX_SHELL
- # To support 'whoami' add /usr/ucb to path
- PATH=/usr/ucb:$PATH
- export PATH
- exec /usr/bin/ksh $0 "$@"
-fi
-
-# clear it so if we invoke other scripts, they run as ksh
-unset POSIX_SHELL
-
-RUNNER_SCRIPT_DIR=$(cd ${0%/*} && pwd -P)
-RUNNER_SCRIPT=${0##*/}
-
-CALLER_DIR=$PWD
-
-RUNNER_BASE_DIR=${RUNNER_SCRIPT_DIR%/*}
-RUNNER_ETC_DIR=$RUNNER_BASE_DIR/etc
-# Note the trailing slash on $PIPE_DIR/
-PIPE_DIR=/tmp/$RUNNER_BASE_DIR/
-RUNNER_USER=
-WHOAMI=$(whoami)
-
-# Make sure this script is running as the appropriate user
-if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
- type sudo > /dev/null 2>&1
- if [ $? -ne 0 ]; then
- echo "sudo doesn't appear to be installed and your EUID isn't $RUNNER_USER" 1>&2
- exit 1
- fi
- echo "Attempting to restart script through sudo -H -u $RUNNER_USER" >&2
- exec sudo -H -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
-fi
-
-# Identify the script name
-SCRIPT=`basename $0`
-
-# Parse out release and erts info
-START_ERL=`cat $RUNNER_BASE_DIR/releases/start_erl.data`
-ERTS_VSN=${START_ERL% *}
-APP_VSN=${START_ERL#* }
-
-# Use $CWD/vm.args if exists, otherwise releases/APP_VSN/vm.args, or
-# else etc/vm.args
-if [ -e "$CALLER_DIR/vm.args" ]; then
- VMARGS_PATH=$CALLER_DIR/vm.args
- USE_DIR=$CALLER_DIR
-else
- USE_DIR=$RUNNER_BASE_DIR
- if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" ]; then
- VMARGS_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args"
- else
- VMARGS_PATH="$RUNNER_ETC_DIR/vm.args"
- fi
-fi
-
-RUNNER_LOG_DIR=$USE_DIR/log
-# Make sure log directory exists
-mkdir -p $RUNNER_LOG_DIR
-
-# Use releases/VSN/sys.config if it exists otherwise use etc/app.config
-if [ -e "$USE_DIR/sys.config" ]; then
- CONFIG_PATH="$USE_DIR/sys.config"
-else
- if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config" ]; then
- CONFIG_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config"
- else
- CONFIG_PATH="$RUNNER_ETC_DIR/app.config"
- fi
-fi
-
-# Extract the target node name from node.args
-NAME_ARG=`egrep '^\-s?name' $VMARGS_PATH`
-if [ -z "$NAME_ARG" ]; then
- echo "vm.args needs to have either -name or -sname parameter."
- exit 1
-fi
-
-# Extract the name type and name from the NAME_ARG for REMSH
-REMSH_TYPE=`echo $NAME_ARG | awk '{print $1}'`
-REMSH_NAME=`echo $NAME_ARG | awk '{print $2}'`
-
-# Note the `date +%s`, used to allow multiple remsh to the same node
-# transparently
-REMSH_NAME_ARG="$REMSH_TYPE remsh`date +%s`@`echo $REMSH_NAME | awk -F@ '{print $2}'`"
-REMSH_REMSH_ARG="-remsh $REMSH_NAME"
-
-# Extract the target cookie
-COOKIE_ARG=`grep '^\-setcookie' $VMARGS_PATH`
-if [ -z "$COOKIE_ARG" ]; then
- echo "vm.args needs to have a -setcookie parameter."
- exit 1
-fi
-
-# Make sure CWD is set to the right dir
-cd $USE_DIR
-
-# Make sure log directory exists
-mkdir -p $USE_DIR/log
-
-# Add ERTS bin dir to our path
-ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin
-
-# Setup command to control the node
-NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"
-
-# Setup remote shell command to control node
-REMSH="$ERTS_PATH/erl $REMSH_NAME_ARG $REMSH_REMSH_ARG $COOKIE_ARG"
-
-# Common functions
-
-# Ping node without allowing nodetool to take stdin
-ping_node() {
- $NODETOOL ping < /dev/null
-}
-
-# Set the PID global variable, return 1 on error
-get_pid() {
- PID=`$NODETOOL getpid < /dev/null`
- ES=$?
- if [ "$ES" -ne 0 ]; then
- echo "Node is not running!"
- return 1
- fi
-
- # don't allow empty or init pid's
- if [ -z $PID ] || [ "$PID" -le 1 ]; then
- return 1
- fi
-
- return 0
-}
-
-# Check the first argument for instructions
-case "$1" in
- start|start_boot)
- # Make sure there is not already a node running
- RES=`ping_node`
- if [ "$RES" = "pong" ]; then
- echo "Node is already running!"
- exit 1
- fi
- case "$1" in
- start)
- shift
- START_OPTION="console"
- HEART_OPTION="start"
- ;;
- start_boot)
- shift
- START_OPTION="console_boot"
- HEART_OPTION="start_boot"
- ;;
- esac
- RUN_PARAM=$(printf "\'%s\' " "$@")
- HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT $HEART_OPTION $RUN_PARAM"
- export HEART_COMMAND
- mkdir -p $PIPE_DIR
- $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT $START_OPTION $RUN_PARAM" 2>&1
- ;;
-
- stop)
- # Wait for the node to completely stop...
- case `uname -s` in
- Darwin)
- # Make sure we explicitly set this because iTerm.app doesn't for
- # some reason.
- COMMAND_MODE=unix2003
- esac
-
- # Get the PID from nodetool
- get_pid
- GPR=$?
- if [ "$GPR" -ne 0 ] || [ -z $PID ]; then
- exit $GPR
- fi
-
- # Tell nodetool to initiate a stop
- $NODETOOL stop
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
-
- # Wait for the node to completely stop...
- while `kill -s 0 $PID 2>/dev/null`
- do
- sleep 1
- done
- ;;
-
- restart)
- ## Restart the VM without exiting the process
- $NODETOOL restart
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
- ;;
-
- reboot)
- ## Restart the VM completely (uses heart to restart it)
- $NODETOOL reboot
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
- ;;
-
- ping)
- ## See if the VM is alive
- ping_node
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
- ;;
-
- attach)
- # Make sure a node is running
- ping_node
- ES=$?
- if [ "$ES" -ne 0 ]; then
- echo "Node is not running!"
- exit $ES
- fi
-
- shift
- exec $ERTS_PATH/to_erl $PIPE_DIR
- ;;
-
- remote_console)
- # Make sure a node is running
- ping_node
- ES=$?
- if [ "$ES" -ne 0 ]; then
- echo "Node is not running!"
- exit $ES
- fi
-
- shift
- exec $REMSH
- ;;
-
- upgrade)
- if [ -z "$2" ]; then
- echo "Missing upgrade package argument"
- echo "Usage: $SCRIPT upgrade {package base name}"
- echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
- exit 1
- fi
-
- # Make sure a node IS running
- ping_node
- ES=$?
- if [ "$ES" -ne 0 ]; then
- echo "Node is not running!"
- exit $ES
- fi
-
- node_name=`echo $NAME_ARG | awk '{print $2}'`
- erlang_cookie=`echo $COOKIE_ARG | awk '{print $2}'`
-
- $ERTS_PATH/escript $RUNNER_BASE_DIR/bin/install_upgrade.escript $node_name $erlang_cookie $2
- ;;
-
- console|console_clean|console_boot)
- # .boot file typically just $SCRIPT (ie, the app name)
- # however, for debugging, sometimes start_clean.boot is useful.
- # For e.g. 'setup', one may even want to name another boot script.
- case "$1" in
- console) BOOTFILE=$SCRIPT ;;
- console_clean) BOOTFILE=start_clean ;;
- console_boot)
- shift
- BOOTFILE="$1"
- shift
- ;;
- esac
- # Setup beam-required vars
- ROOTDIR=$RUNNER_BASE_DIR
- BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
- EMU=beam
- PROGNAME=`echo $0 | sed 's/.*\\///'`
- CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH"
- export EMU
- export ROOTDIR
- export BINDIR
- export PROGNAME
-
- # Dump environment info for logging purposes
- echo "Exec: $CMD" -- ${1+"$@"}
- echo "Root: $ROOTDIR"
-
- # Log the startup
- logger -t "$SCRIPT[$$]" "Starting up"
-
- # Start the VM
- exec $CMD -- ${1+"$@"}
- ;;
-
- foreground)
- # start up the release in the foreground for use by runit
- # or other supervision services
-
- BOOTFILE=$SCRIPT
- FOREGROUNDOPTIONS="-noinput +Bd"
-
- # Setup beam-required vars
- ROOTDIR=$RUNNER_BASE_DIR
- BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
- EMU=beam
- PROGNAME=`echo $0 | sed 's/.*\///'`
- CMD="$BINDIR/erlexec $FOREGROUNDOPTIONS -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -config $CONFIG_PATH -args_file $VMARGS_PATH"
- export EMU
- export ROOTDIR
- export BINDIR
- export PROGNAME
-
- # Dump environment info for logging purposes
- echo "Exec: $CMD" -- ${1+"$@"}
- echo "Root: $ROOTDIR"
-
- # Start the VM
- exec $CMD -- ${1+"$@"}
- ;;
- getpid)
- # Get the PID from nodetool
- get_pid
- ES=$?
- if [ "$ES" -ne 0 ] || [ -z $PID ]; then
- exit $ES
- fi
- echo $PID
- ;;
- *)
- echo "Usage: $SCRIPT {start|start_boot <file>|foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot <file>|attach|remote_console|upgrade}"
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/src/rebar/priv/templates/simplenode.sys.config b/src/rebar/priv/templates/simplenode.sys.config
deleted file mode 100644
index 3b7f6bd1d..000000000
--- a/src/rebar/priv/templates/simplenode.sys.config
+++ /dev/null
@@ -1,11 +0,0 @@
-[
- %% SASL config
- {sasl, [
- {sasl_error_logger, {file, "log/sasl-error.log"}},
- {errlog_type, error},
- {error_logger_mf_dir, "log/sasl"}, % Log directory
- {error_logger_mf_maxbytes, 10485760}, % 10 MB max file size
- {error_logger_mf_maxfiles, 5} % 5 files max
- ]}
-].
-
diff --git a/src/rebar/priv/templates/simplenode.template b/src/rebar/priv/templates/simplenode.template
deleted file mode 100644
index 5d2c49dc6..000000000
--- a/src/rebar/priv/templates/simplenode.template
+++ /dev/null
@@ -1,13 +0,0 @@
-{variables, [{nodeid, "mynode"}]}.
-{template, "simplenode.reltool.config", "reltool.config"}.
-{file, "simplenode.erl.script", "files/erl"}.
-{chmod, 8#744, "files/erl"}.
-{file, "simplenode.nodetool", "files/nodetool"}.
-{chmod, 8#744, "files/nodetool"}.
-{file, "simplenode.runner", "files/{{nodeid}}"}.
-{chmod, 8#744, "files/{{nodeid}}"}.
-{file, "simplenode.sys.config", "files/sys.config"}.
-{template, "simplenode.vm.args", "files/vm.args"}.
-{template, "simplenode.windows.runner.cmd", "files/{{nodeid}}.cmd"}.
-{file, "simplenode.windows.start_erl.cmd", "files/start_erl.cmd"}.
-{file, "simplenode.install_upgrade.escript", "files/install_upgrade.escript"}.
diff --git a/src/rebar/priv/templates/simplenode.vm.args b/src/rebar/priv/templates/simplenode.vm.args
deleted file mode 100644
index 700b15e76..000000000
--- a/src/rebar/priv/templates/simplenode.vm.args
+++ /dev/null
@@ -1,19 +0,0 @@
-## Name of the node
--name {{nodeid}}@127.0.0.1
-
-## Cookie for distributed erlang
--setcookie {{nodeid}}
-
-## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
-## (Disabled by default..use with caution!)
-##-heart
-
-## Enable kernel poll and a few async threads
-##+K true
-##+A 5
-
-## Increase number of concurrent ports/sockets
-##-env ERL_MAX_PORTS 4096
-
-## Tweak GC to run more often
-##-env ERL_FULLSWEEP_AFTER 10
diff --git a/src/rebar/priv/templates/simplenode.windows.runner.cmd b/src/rebar/priv/templates/simplenode.windows.runner.cmd
deleted file mode 100644
index d45f43882..000000000
--- a/src/rebar/priv/templates/simplenode.windows.runner.cmd
+++ /dev/null
@@ -1,103 +0,0 @@
-@setlocal
-
-@set node_name={{nodeid}}
-
-@rem Get the absolute path to the parent directory,
-@rem which is assumed to be the node root.
-@for /F "delims=" %%I in ("%~dp0..") do @set node_root=%%~fI
-
-@set releases_dir=%node_root%\releases
-
-@rem Parse ERTS version and release version from start_erl.data
-@for /F "usebackq tokens=1,2" %%I in ("%releases_dir%\start_erl.data") do @(
- @call :set_trim erts_version %%I
- @call :set_trim release_version %%J
-)
-
-@set vm_args=%releases_dir%\%release_version%\vm.args
-@set sys_config=%releases_dir%\%release_version%\sys.config
-@set node_boot_script=%releases_dir%\%release_version%\%node_name%
-@set clean_boot_script=%releases_dir%\%release_version%\start_clean
-
-@rem extract erlang cookie from vm.args
-@for /f "usebackq tokens=1-2" %%I in (`findstr /b \-setcookie "%vm_args%"`) do @set erlang_cookie=%%J
-
-@set erts_bin=%node_root%\erts-%erts_version%\bin
-
-@set service_name=%node_name%_%release_version%
-
-@set erlsrv="%erts_bin%\erlsrv.exe"
-@set epmd="%erts_bin%\epmd.exe"
-@set escript="%erts_bin%\escript.exe"
-@set werl="%erts_bin%\werl.exe"
-@set nodetool="%erts_bin%\nodetool"
-
-@if "%1"=="usage" @goto usage
-@if "%1"=="install" @goto install
-@if "%1"=="uninstall" @goto uninstall
-@if "%1"=="start" @goto start
-@if "%1"=="stop" @goto stop
-@if "%1"=="restart" @call :stop && @goto start
-@if "%1"=="console" @goto console
-@if "%1"=="ping" @goto ping
-@if "%1"=="query" @goto query
-@if "%1"=="attach" @goto attach
-@if "%1"=="upgrade" @goto upgrade
-@echo Unknown command: "%1"
-
-:usage
-@echo Usage: %~n0 [install^|uninstall^|start^|stop^|restart^|console^|ping^|query^|attach^|upgrade]
-@goto :EOF
-
-:install
-@set description=Erlang node %node_name% in %node_root%
-@set start_erl=%node_root%\bin\start_erl.cmd
-@set args= ++ %node_name% ++ %node_root%
-@%erlsrv% add %service_name% -c "%description%" -sname %node_name% -w "%node_root%" -m "%start_erl%" -args "%args%" -stopaction "init:stop()."
-@goto :EOF
-
-:uninstall
-@%erlsrv% remove %service_name%
-@%epmd% -kill
-@goto :EOF
-
-:start
-@%erlsrv% start %service_name%
-@goto :EOF
-
-:stop
-@%erlsrv% stop %service_name%
-@goto :EOF
-
-:console
-@start "%node_name% console" %werl% -boot "%node_boot_script%" -config "%sys_config%" -args_file "%vm_args%" -sname %node_name%
-@goto :EOF
-
-:ping
-@%escript% %nodetool% ping -sname "%node_name%" -setcookie "%erlang_cookie%"
-@exit %ERRORLEVEL%
-@goto :EOF
-
-:query
-@%erlsrv% list %service_name%
-@exit %ERRORLEVEL%
-@goto :EOF
-
-:attach
-@for /f "usebackq" %%I in (`hostname`) do @set hostname=%%I
-start "%node_name% attach" %werl% -boot "%clean_boot_script%" -remsh %node_name%@%hostname% -sname console -setcookie %erlang_cookie%
-@goto :EOF
-
-:upgrade
-@if "%2"=="" (
- @echo Missing upgrade package argument
- @echo Usage: %~n0 upgrade {package base name}
- @echo NOTE {package base name} MUST NOT include the .tar.gz suffix
- @goto :EOF
-)
-@%escript% %node_root%\bin\install_upgrade.escript %node_name% %erlang_cookie% %2
-@goto :EOF
-
-:set_trim
-@set %1=%2
-@goto :EOF
diff --git a/src/rebar/priv/templates/simplenode.windows.start_erl.cmd b/src/rebar/priv/templates/simplenode.windows.start_erl.cmd
deleted file mode 100644
index c0f20722e..000000000
--- a/src/rebar/priv/templates/simplenode.windows.start_erl.cmd
+++ /dev/null
@@ -1,40 +0,0 @@
-@setlocal
-
-@rem Parse arguments. erlsrv.exe prepends erl arguments prior to first ++.
-@rem Other args are position dependent.
-@set args="%*"
-@for /F "delims=++ tokens=1,2,3" %%I in (%args%) do @(
- @set erl_args=%%I
- @call :set_trim node_name %%J
- @rem Trim spaces from the left of %%K (node_root), which may have spaces inside
- @for /f "tokens=* delims= " %%a in ("%%K") do @set node_root=%%a
-)
-
-@set releases_dir=%node_root%\releases
-
-@rem parse ERTS version and release version from start_erl.dat
-@for /F "usebackq tokens=1,2" %%I in ("%releases_dir%\start_erl.data") do @(
- @call :set_trim erts_version %%I
- @call :set_trim release_version %%J
-)
-
-@set erl_exe="%node_root%\erts-%erts_version%\bin\erl.exe"
-@set boot_file="%releases_dir%\%release_version%\%node_name%"
-
-@if exist "%releases_dir%\%release_version%\sys.config" (
- @set app_config="%releases_dir%\%release_version%\sys.config"
-) else (
- @set app_config="%node_root%\etc\app.config"
-)
-
-@if exist "%releases_dir%\%release_version%\vm.args" (
- @set vm_args="%releases_dir%\%release_version%\vm.args"
-) else (
- @set vm_args="%node_root%\etc\vm.args"
-)
-
-@%erl_exe% %erl_args% -boot %boot_file% -config %app_config% -args_file %vm_args%
-
-:set_trim
-@set %1=%2
-@goto :EOF
diff --git a/src/rebar/priv/templates/simplesrv.erl b/src/rebar/priv/templates/simplesrv.erl
deleted file mode 100644
index af6ca508a..000000000
--- a/src/rebar/priv/templates/simplesrv.erl
+++ /dev/null
@@ -1,50 +0,0 @@
--module({{srvid}}).
--behaviour(gen_server).
--define(SERVER, ?MODULE).
-
-%% ------------------------------------------------------------------
-%% API Function Exports
-%% ------------------------------------------------------------------
-
--export([start_link/0]).
-
-%% ------------------------------------------------------------------
-%% gen_server Function Exports
-%% ------------------------------------------------------------------
-
--export([init/1, handle_call/3, handle_cast/2, handle_info/2,
- terminate/2, code_change/3]).
-
-%% ------------------------------------------------------------------
-%% API Function Definitions
-%% ------------------------------------------------------------------
-
-start_link() ->
- gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
-
-%% ------------------------------------------------------------------
-%% gen_server Function Definitions
-%% ------------------------------------------------------------------
-
-init(Args) ->
- {ok, Args}.
-
-handle_call(_Request, _From, State) ->
- {reply, ok, State}.
-
-handle_cast(_Msg, State) ->
- {noreply, State}.
-
-handle_info(_Info, State) ->
- {noreply, State}.
-
-terminate(_Reason, _State) ->
- ok.
-
-code_change(_OldVsn, State, _Extra) ->
- {ok, State}.
-
-%% ------------------------------------------------------------------
-%% Internal Function Definitions
-%% ------------------------------------------------------------------
-
diff --git a/src/rebar/priv/templates/simplesrv.template b/src/rebar/priv/templates/simplesrv.template
deleted file mode 100644
index 101844a81..000000000
--- a/src/rebar/priv/templates/simplesrv.template
+++ /dev/null
@@ -1,2 +0,0 @@
-{variables, [{srvid, "myserver"}]}.
-{template, "simplesrv.erl", "src/{{srvid}}.erl"}.
diff --git a/src/rebar/rebar.config b/src/rebar/rebar.config
deleted file mode 100644
index 902873729..000000000
--- a/src/rebar/rebar.config
+++ /dev/null
@@ -1,21 +0,0 @@
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 ft=erlang et
-
-%% escript_incl_extra is for internal rebar-private use only.
-%% Do not use outside rebar. Config interface is not stable.
-{escript_incl_extra, [{"priv/templates/*", "."}]}.
-{erl_opts, [warnings_as_errors]}.
-{xref_checks, []}.
-{xref_queries,
- [{"(XC - UC) || (XU - X - B
- - (\"escript\":\"foldl\"/\"3\")
- - (\"eunit_test\":\"function_wrapper\"/\"2\")
- - (\"abnfc\":\"file\"/\"2\")
- - (\"erlydtl\":\"compile\"/\"3\")
- - (\"lfe_comp\":\"file\"/\"2\")
- - (\"neotoma\":\"file\"/\"2\")
- - (\"protobuffs_compile\":\"scan_file\"/\"2\")
- - (\"diameter_codegen\":\"from_dict\"/\"4\")
- - (\"diameter_dict_util\":\"format_error\"/\"1\")
- - (\"diameter_dict_util\":\"parse\"/\"2\"))",
- []}]}.
diff --git a/src/rebar/rebar.config.sample b/src/rebar/rebar.config.sample
deleted file mode 100644
index e6071bdc5..000000000
--- a/src/rebar/rebar.config.sample
+++ /dev/null
@@ -1,236 +0,0 @@
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 ft=erlang et
-%% This is a sample rebar.conf file that shows examples of some of rebar's
-%% options.
-
-%% == Core ==
-
-%% Check required ERTS or OTP release version
-{require_erts_vsn, ".*"}.
-{require_otp_vsn, ".*"}.
-{require_min_otp_vsn, ".*"}.
-
-%% Additional library directories to add to the code path
-{lib_dirs, []}.
-
-%% == Erlang Compiler ==
-
-%% Erlang files to compile before the rest. Rebar automatically compiles
-%% parse_transforms and custom behaviours before anything other than the files
-%% in this list.
-{erl_first_files, ["mymib1", "mymib2"]}.
-
-%% Erlang compiler options
-{erl_opts, [no_debug_info,
- {i, "myinclude"},
- {src_dirs, ["src", "src2", "src3"]},
- {platform_define,
- "(linux|solaris|freebsd|darwin)", 'HAVE_SENDFILE'},
- {platform_define, "(linux|freebsd)", 'BACKLOG', 128},
- {platform_define, "R13", 'old_inets'}]}.
-
-%% MIB Options?
-{mib_opts, []}.
-
-%% SNMP mibs to compile first?
-{mib_first_files, []}.
-
-%% leex options
-{xrl_opts, []}.
-
-%% leex files to compile first
-{xrl_first_files, []}.
-
-%% yecc options
-{yrl_opts, []}.
-
-%% yecc files to compile first
-{yrl_first_files, []}.
-
-%% == EDoc ==
-
-%% EDoc options
-{edoc_opts, []}.
-
-%% == Port Compiler ==
-
-%% Port compilation environment variables. See rebar_port_compiler.erl for
-%% more info. Default is `[]'
-{port_env, [{"CFLAGS", "$CFLAGS -Ifoo"},
- {"freebsd", "LDFLAGS", "$LDFLAGS -lfoo"}]}.
-
-%% port_specs
-%% List of filenames or wildcards to be compiled. May also contain a tuple
-%% consisting of a regular expression to be applied against the system
-%% architecture as a filter.
-{port_specs, [{"priv/so_name.so", ["c_src/*.c"]},
- {"linux", "priv/hello_linux", ["c_src/hello_linux.c"]},
- {"linux", "priv/hello_linux", ["c_src/*.c"], [{env, []}]}]}.
-
-%% == escriptize ==
-{escript_name, "application"}.
-{escript_incl_apps, []}.
-{escript_shebang, "#!/usr/bin/env escript\n"}.
-{escript_comment, "%%\n"}.
-{escript_emu_args, "%%! -pa application/application/ebin\n"}.
-
-%% == LFE Compiler ==
-
-%% LFE files to compile before the rest
-{lfe_first_files, []}.
-
-%% Options for the LFE compiler: reuse {erl_opts, []}
-
-%% == ErlyDTL Compiler ==
-
-%% Options for the ErlyDTL compiler
-{erlydtl_opts, []}.
-
-%% == EUnit ==
-
-%% Options for eunit:test()
-{eunit_opts, []}.
-
-%% Additional compile options for eunit. erl_opts is also used
-{eunit_compile_opts, []}.
-
-%% Same as erl_first_files, but used only when running 'eunit'
-{eunit_first_files, []}.
-
-%% == Cover ==
-
-%% Whether to enable coverage reporting. Default is `false'
-{cover_enabled, false}.
-
-%% Whether to print coverage report to console. Default is `false'
-{cover_print_enabled, false}.
-
-%% Whether to export coverage report to file. Default is `false'
-{cover_export_enabled, false}.
-
-%% == Common Test ==
-
-%% Override the default "test" directory in which SUITEs are located
-{ct_dir, "itest"}.
-
-%% Override the default "logs" directory in which SUITEs are logged
-{ct_log_dir, "test/logs"}.
-
-%% Option to pass extra parameters when launching Common Test
-{ct_extra_params, "-boot start_sasl -s myapp"}.
-
-%% Option to use short names (i.e., -sname test) when starting ct
-{ct_use_short_names, true}.
-
-%% == QuickCheck ==
-
-%% If qc_mod is unspecified, rebar tries to detect Triq or EQC
-{qc_opts, [{qc_mod, module()}, Options]}.
-
-%% Additional compile options for qc. erl_opts is also used
-{qc_compile_opts, []}.
-
-%% Same as erl_first_files, but used only when running 'qc'
-{qc_first_files, []}.
-
-%% == Cleanup ==
-
-%% Which files to cleanup
-{clean_files, ["file", "file2"]}.
-
-%% == OTP Applications ==
-
-%% Enable validation of the OTP app module list. Default is 'true'
-{validate_app_modules, true}.
-
-%% == Dependencies ==
-
-%% Where to put any downloaded dependencies. Default is "deps"
-{deps_dir, "deps"}.
-
-%% What dependencies we have, dependencies can be of 3 forms, an application
-%% name as an atom, eg. mochiweb, a name and a version (from the .app file), or
-%% an application name, a version and the SCM details on how to fetch it (SCM
-%% type, location and revision).
-%% Rebar currently supports git, hg, bzr, svn, rsync, and fossil.
-{deps, [app_name,
- {rebar, "1.0.*"},
- {rebar, ".*",
- {git, "git://github.com/rebar/rebar.git"}},
- {rebar, ".*",
- {git, "git://github.com/rebar/rebar.git", "Rev"}},
- {rebar, "1.0.*",
- {git, "git://github.com/rebar/rebar.git", {branch, "master"}}},
- {rebar, "1.0.0",
- {git, "git://github.com/rebar/rebar.git", {tag, "1.0.0"}}},
- %% Dependencies can be marked as 'raw'. Rebar does not require
- %% such dependencies to have a standard Erlang/OTP layout
- %% which assumes the presence of either
- %% "src/dependency_name.app.src" or "ebin/dependency_name.app"
- %% files.
- %%
- %% 'raw' dependencies can still contain 'rebar.config' and
- %% even can have the proper OTP directory layout, but they
- %% won't be compiled.
- %%
- %% Only a subset of rebar commands will be executed on the
- %% 'raw' subdirectories: get-deps, update-deps, check-deps,
- %% list-deps and delete-deps.
- {rebar, "",
- {git, "git://github.com/rebar/rebar.git", {branch, "master"}},
- [raw]},
- {app_name, ".*", {hg, "https://www.example.org/url"}},
- {app_name, ".*", {rsync, "Url"}},
- {app_name, ".*", {svn, "https://www.example.org/url"}},
- {app_name, ".*", {svn, "svn://svn.example.org/url"}},
- {app_name, ".*", {bzr, "https://www.example.org/url", "Rev"}},
- {app_name, ".*", {fossil, "https://www.example.org/url"}},
- {app_name, ".*", {fossil, "https://www.example.org/url", "Vsn"}}]}.
-
-%% == Subdirectories ==
-
-%% Subdirectories?
-{sub_dirs, ["dir1", "dir2"]}.
-
-%% == Plugins ==
-
-%% Plugins you wish to include.
-%% These can include any module on the code path, including deps.
-%% Alternatively, plugins can be placed as source files in the plugin_dir, in
-%% which case they will be compiled and loaded dynamically at runtime.
-{plugins, [plugin1, plugin2]}.
-
-%% Override the directory in which plugin sources can be found.
-%% Defaults to ./plugins
-{plugin_dir, "some_other_directory"}.
-
-
-%% == Pre/Post Command Hooks ==
-
-{pre_hooks, [{clean, "./prepare_package_files.sh"},
- {"linux", compile, "c_src/build_linux.sh"},
- {compile, "escript generate_headers"},
- {compile, "escript check_headers"}]}.
-
-{post_hooks, [{clean, "touch file1.out"},
- {"freebsd", compile, "c_src/freebsd_tweaks.sh"},
- {eunit, "touch file2.out"},
- {compile, "touch postcompile.out"}]}.
-
-%% == xref ==
-
-{xref_warnings, false}.
-
-%% xref checks to run
-{xref_checks, [undefined_function_calls, undefined_functions,
- locals_not_used, exports_not_used,
- deprecated_function_calls, deprecated_functions]}.
-
-%% Optional custom xref queries (xref manual has details) specified as
-%% {xref_queries, [{query_string(), expected_query_result()},...]}
-%% The following for example removes all references to mod:*foo/4
-%% functions from undefined external function calls as those are in a
-%% generated module
-{xref_queries,
- [{"(XC - UC) || (XU - X - B"
- " - (\"mod\":\".*foo\"/\"4\"))",[]}]}.
diff --git a/src/rebar/rebar.config.script b/src/rebar/rebar.config.script
deleted file mode 100644
index be61b5e2c..000000000
--- a/src/rebar/rebar.config.script
+++ /dev/null
@@ -1,20 +0,0 @@
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 ft=erlang et
-
-%% TODO: Change temporary retest fork back to dizzyd/retest after merge
-%% ExtraDeps = [{retest, ".*", {git, "git://github.com/dizzyd/retest.git"}}],
-ExtraDeps = [{retest, ".*",
- {git, "git://github.com/dizzyd/retest.git"}}],
-
-case os:getenv("REBAR_EXTRA_DEPS") of
- false ->
- CONFIG;
- _ ->
- case lists:keysearch(deps, 1, CONFIG) of
- {value, {deps, Deps}} ->
- NDeps = Deps ++ ExtraDeps,
- lists:keyreplace(deps, 1, CONFIG, {deps, NDeps});
- false ->
- CONFIG ++ [{deps, ExtraDeps}]
- end
-end.
diff --git a/src/rebar/src/getopt.erl b/src/rebar/src/getopt.erl
deleted file mode 100644
index f9852fbf6..000000000
--- a/src/rebar/src/getopt.erl
+++ /dev/null
@@ -1,842 +0,0 @@
-%%%-------------------------------------------------------------------
-%%% @author Juan Jose Comellas <juanjo@comellas.org>
-%%% @copyright (C) 2009 Juan Jose Comellas
-%%% @doc Parses command line options with a format similar to that of GNU getopt.
-%%% @end
-%%%
-%%% This source file is subject to the New BSD License. You should have received
-%%% a copy of the New BSD license with this software. If not, it can be
-%%% retrieved from: http://www.opensource.org/licenses/bsd-license.php
-%%%-------------------------------------------------------------------
--module(getopt).
--author('juanjo@comellas.org').
-
--export([parse/2, usage/2, usage/3, usage/4, tokenize/1]).
--export([usage_cmd_line/2]).
-
--define(LINE_LENGTH, 75).
--define(MIN_USAGE_COMMAND_LINE_OPTION_LENGTH, 25).
-
-%% Position of each field in the option specification tuple.
--define(OPT_NAME, 1).
--define(OPT_SHORT, 2).
--define(OPT_LONG, 3).
--define(OPT_ARG, 4).
--define(OPT_HELP, 5).
-
--define(IS_OPT_SPEC(Opt), (tuple_size(Opt) =:= ?OPT_HELP)).
--define(IS_WHITESPACE(Char), ((Char) =:= $\s orelse (Char) =:= $\t orelse
- (Char) =:= $\n orelse (Char) =:= $\r)).
-
-%% Atom indicating the data type that an argument can be converted to.
--type arg_type() :: 'atom' | 'binary' | 'boolean' | 'float' | 'integer' | 'string'.
-%% Data type that an argument can be converted to.
--type arg_value() :: atom() | binary() | boolean() | float() | integer() | string().
-%% Argument specification.
--type arg_spec() :: arg_type() | {arg_type(), arg_value()} | undefined.
-%% Option type and optional default argument.
--type simple_option() :: atom().
--type compound_option() :: {atom(), arg_value()}.
--type option() :: simple_option() | compound_option().
-%% Command line option specification.
--type option_spec() :: {
- Name :: atom(),
- Short :: char() | undefined,
- Long :: string() | undefined,
- ArgSpec :: arg_spec(),
- Help :: string() | undefined
- }.
-%% Output streams
--type output_stream() :: 'standard_io' | 'standard_error'.
-
-%% For internal use
--type usage_line() :: {OptionText :: string(), HelpText :: string()}.
--type usage_line_with_length() :: {OptionLength :: non_neg_integer(), OptionText :: string(), HelpText :: string()}.
-
-
--export_type([arg_type/0, arg_value/0, arg_spec/0, simple_option/0, compound_option/0, option/0, option_spec/0]).
-
-
-%% @doc Parse the command line options and arguments returning a list of tuples
-%% and/or atoms using the Erlang convention for sending options to a
-%% function.
--spec parse([option_spec()], string() | [string()]) ->
- {ok, {[option()], [string()]}} | {error, {Reason :: atom(), Data :: any()}}.
-parse(OptSpecList, CmdLine) when is_list(CmdLine) ->
- try
- Args = if
- is_integer(hd(CmdLine)) -> tokenize(CmdLine);
- true -> CmdLine
- end,
- parse(OptSpecList, [], [], 0, Args)
- catch
- throw: {error, {_Reason, _Data}} = Error ->
- Error
- end.
-
-
--spec parse([option_spec()], [option()], [string()], integer(), [string()]) ->
- {ok, {[option()], [string()]}}.
-%% Process the option terminator.
-parse(OptSpecList, OptAcc, ArgAcc, _ArgPos, ["--" | Tail]) ->
- %% Any argument present after the terminator is not considered an option.
- {ok, {lists:reverse(append_default_options(OptSpecList, OptAcc)), lists:reverse(ArgAcc, Tail)}};
-%% Process long options.
-parse(OptSpecList, OptAcc, ArgAcc, ArgPos, ["--" ++ OptArg = OptStr | Tail]) ->
- parse_long_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Tail, OptStr, OptArg);
-%% Process short options.
-parse(OptSpecList, OptAcc, ArgAcc, ArgPos, ["-" ++ ([_Char | _] = OptArg) = OptStr | Tail]) ->
- parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Tail, OptStr, OptArg);
-%% Process non-option arguments.
-parse(OptSpecList, OptAcc, ArgAcc, ArgPos, [Arg | Tail]) ->
- case find_non_option_arg(OptSpecList, ArgPos) of
- {value, OptSpec} when ?IS_OPT_SPEC(OptSpec) ->
- parse(OptSpecList, add_option_with_arg(OptSpec, Arg, OptAcc), ArgAcc, ArgPos + 1, Tail);
- false ->
- parse(OptSpecList, OptAcc, [Arg | ArgAcc], ArgPos, Tail)
- end;
-parse(OptSpecList, OptAcc, ArgAcc, _ArgPos, []) ->
- %% Once we have completed gathering the options we add the ones that were
- %% not present but had default arguments in the specification.
- {ok, {lists:reverse(append_default_options(OptSpecList, OptAcc)), lists:reverse(ArgAcc)}}.
-
-
-%% @doc Parse a long option, add it to the option accumulator and continue
-%% parsing the rest of the arguments recursively.
-%% A long option can have the following syntax:
-%% --foo Single option 'foo', no argument
-%% --foo=bar Single option 'foo', argument "bar"
-%% --foo bar Single option 'foo', argument "bar"
--spec parse_long_option([option_spec()], [option()], [string()], integer(), [string()], string(), string()) ->
- {ok, {[option()], [string()]}}.
-parse_long_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptArg) ->
- case split_assigned_arg(OptArg) of
- {Long, Arg} ->
- %% Get option that has its argument within the same string
- %% separated by an equal ('=') character (e.g. "--port=1000").
- parse_long_option_assigned_arg(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, Long, Arg);
-
- Long ->
- case lists:keyfind(Long, ?OPT_LONG, OptSpecList) of
- {Name, _Short, Long, undefined, _Help} ->
- parse(OptSpecList, [Name | OptAcc], ArgAcc, ArgPos, Args);
-
- {_Name, _Short, Long, _ArgSpec, _Help} = OptSpec ->
- %% The option argument string is empty, but the option requires
- %% an argument, so we look into the next string in the list.
- %% e.g ["--port", "1000"]
- parse_long_option_next_arg(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptSpec);
- false ->
- throw({error, {invalid_option, OptStr}})
- end
- end.
-
-
-%% @doc Parse an option where the argument is 'assigned' in the same string using
-%% the '=' character, add it to the option accumulator and continue parsing the
-%% rest of the arguments recursively. This syntax is only valid for long options.
--spec parse_long_option_assigned_arg([option_spec()], [option()], [string()], integer(),
- [string()], string(), string(), string()) ->
- {ok, {[option()], [string()]}}.
-parse_long_option_assigned_arg(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, Long, Arg) ->
- case lists:keyfind(Long, ?OPT_LONG, OptSpecList) of
- {_Name, _Short, Long, ArgSpec, _Help} = OptSpec ->
- case ArgSpec of
- undefined ->
- throw({error, {invalid_option_arg, OptStr}});
- _ ->
- parse(OptSpecList, add_option_with_assigned_arg(OptSpec, Arg, OptAcc), ArgAcc, ArgPos, Args)
- end;
- false ->
- throw({error, {invalid_option, OptStr}})
- end.
-
-
-%% @doc Split an option string that may contain an option with its argument
-%% separated by an equal ('=') character (e.g. "port=1000").
--spec split_assigned_arg(string()) -> {Name :: string(), Arg :: string()} | string().
-split_assigned_arg(OptStr) ->
- split_assigned_arg(OptStr, OptStr, []).
-
-split_assigned_arg(_OptStr, "=" ++ Tail, Acc) ->
- {lists:reverse(Acc), Tail};
-split_assigned_arg(OptStr, [Char | Tail], Acc) ->
- split_assigned_arg(OptStr, Tail, [Char | Acc]);
-split_assigned_arg(OptStr, [], _Acc) ->
- OptStr.
-
-
-%% @doc Retrieve the argument for an option from the next string in the list of
-%% command-line parameters or set the value of the argument from the argument
-%% specification (for boolean and integer arguments), if possible.
-parse_long_option_next_arg(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, {Name, _Short, _Long, ArgSpec, _Help} = OptSpec) ->
- ArgSpecType = arg_spec_type(ArgSpec),
- case Args =:= [] orelse is_implicit_arg(ArgSpecType, hd(Args)) of
- true ->
- parse(OptSpecList, add_option_with_implicit_arg(OptSpec, OptAcc), ArgAcc, ArgPos, Args);
- false ->
- [Arg | Tail] = Args,
- try
- parse(OptSpecList, [{Name, to_type(ArgSpecType, Arg)} | OptAcc], ArgAcc, ArgPos, Tail)
- catch
- error:_ ->
- throw({error, {invalid_option_arg, {Name, Arg}}})
- end
- end.
-
-
-%% @doc Parse a short option, add it to the option accumulator and continue
-%% parsing the rest of the arguments recursively.
-%% A short option can have the following syntax:
-%% -a Single option 'a', no argument or implicit boolean argument
-%% -a foo Single option 'a', argument "foo"
-%% -afoo Single option 'a', argument "foo"
-%% -abc Multiple options: 'a'; 'b'; 'c'
-%% -bcafoo Multiple options: 'b'; 'c'; 'a' with argument "foo"
-%% -aaa Multiple repetitions of option 'a' (only valid for options with integer arguments)
--spec parse_short_option([option_spec()], [option()], [string()], integer(), [string()], string(), string()) ->
- {ok, {[option()], [string()]}}.
-parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptArg) ->
- parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, first, OptArg).
-
-parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptPos, [Short | Arg]) ->
- case lists:keyfind(Short, ?OPT_SHORT, OptSpecList) of
- {Name, Short, _Long, undefined, _Help} ->
- parse_short_option(OptSpecList, [Name | OptAcc], ArgAcc, ArgPos, Args, OptStr, first, Arg);
-
- {_Name, Short, _Long, ArgSpec, _Help} = OptSpec ->
- %% The option has a specification, so it requires an argument.
- case Arg of
- [] ->
- %% The option argument string is empty, but the option requires
- %% an argument, so we look into the next string in the list.
- parse_short_option_next_arg(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptSpec, OptPos);
-
- _ ->
- case is_valid_arg(ArgSpec, Arg) of
- true ->
- parse(OptSpecList, add_option_with_arg(OptSpec, Arg, OptAcc), ArgAcc, ArgPos, Args);
- _ ->
- NewOptAcc = case OptPos of
- first -> add_option_with_implicit_arg(OptSpec, OptAcc);
- _ -> add_option_with_implicit_incrementable_arg(OptSpec, OptAcc)
- end,
- parse_short_option(OptSpecList, NewOptAcc, ArgAcc, ArgPos, Args, OptStr, next, Arg)
- end
- end;
-
- false ->
- throw({error, {invalid_option, OptStr}})
- end;
-parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, _OptStr, _OptPos, []) ->
- parse(OptSpecList, OptAcc, ArgAcc, ArgPos, Args).
-
-
-%% @doc Retrieve the argument for an option from the next string in the list of
-%% command-line parameters or set the value of the argument from the argument
-%% specification (for boolean and integer arguments), if possible.
-parse_short_option_next_arg(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, {Name, _Short, _Long, ArgSpec, _Help} = OptSpec, OptPos) ->
- case Args =:= [] orelse is_implicit_arg(ArgSpec, hd(Args)) of
- true when OptPos =:= first ->
- parse(OptSpecList, add_option_with_implicit_arg(OptSpec, OptAcc), ArgAcc, ArgPos, Args);
- true ->
- parse(OptSpecList, add_option_with_implicit_incrementable_arg(OptSpec, OptAcc), ArgAcc, ArgPos, Args);
- false ->
- [Arg | Tail] = Args,
- try
- parse(OptSpecList, [{Name, to_type(ArgSpec, Arg)} | OptAcc], ArgAcc, ArgPos, Tail)
- catch
- error:_ ->
- throw({error, {invalid_option_arg, {Name, Arg}}})
- end
- end.
-
-
-%% @doc Find the option for the discrete argument in position specified in the
-%% Pos argument.
--spec find_non_option_arg([option_spec()], integer()) -> {value, option_spec()} | false.
-find_non_option_arg([{_Name, undefined, undefined, _ArgSpec, _Help} = OptSpec | _Tail], 0) ->
- {value, OptSpec};
-find_non_option_arg([{_Name, undefined, undefined, _ArgSpec, _Help} | Tail], Pos) ->
- find_non_option_arg(Tail, Pos - 1);
-find_non_option_arg([_Head | Tail], Pos) ->
- find_non_option_arg(Tail, Pos);
-find_non_option_arg([], _Pos) ->
- false.
-
-
-%% @doc Append options that were not present in the command line arguments with
-%% their default arguments.
--spec append_default_options([option_spec()], [option()]) -> [option()].
-append_default_options([{Name, _Short, _Long, {_Type, DefaultArg}, _Help} | Tail], OptAcc) ->
- append_default_options(Tail,
- case lists:keymember(Name, 1, OptAcc) of
- false ->
- [{Name, DefaultArg} | OptAcc];
- _ ->
- OptAcc
- end);
-%% For options with no default argument.
-append_default_options([_Head | Tail], OptAcc) ->
- append_default_options(Tail, OptAcc);
-append_default_options([], OptAcc) ->
- OptAcc.
-
-
-%% @doc Add an option with argument converting it to the data type indicated by the
-%% argument specification.
--spec add_option_with_arg(option_spec(), string(), [option()]) -> [option()].
-add_option_with_arg({Name, _Short, _Long, ArgSpec, _Help} = OptSpec, Arg, OptAcc) ->
- case is_valid_arg(ArgSpec, Arg) of
- true ->
- try
- [{Name, to_type(ArgSpec, Arg)} | OptAcc]
- catch
- error:_ ->
- throw({error, {invalid_option_arg, {Name, Arg}}})
- end;
- false ->
- add_option_with_implicit_arg(OptSpec, OptAcc)
- end.
-
-
-%% @doc Add an option with argument that was part of an assignment expression
-%% (e.g. "--verbose=3") converting it to the data type indicated by the
-%% argument specification.
--spec add_option_with_assigned_arg(option_spec(), string(), [option()]) -> [option()].
-add_option_with_assigned_arg({Name, _Short, _Long, ArgSpec, _Help}, Arg, OptAcc) ->
- try
- [{Name, to_type(ArgSpec, Arg)} | OptAcc]
- catch
- error:_ ->
- throw({error, {invalid_option_arg, {Name, Arg}}})
- end.
-
-
-%% @doc Add an option that required an argument but did not have one. Some data
-%% types (boolean, integer) allow implicit or assumed arguments.
--spec add_option_with_implicit_arg(option_spec(), [option()]) -> [option()].
-add_option_with_implicit_arg({Name, _Short, _Long, ArgSpec, _Help}, OptAcc) ->
- case arg_spec_type(ArgSpec) of
- boolean ->
- %% Special case for boolean arguments: if there is no argument we
- %% set the value to 'true'.
- [{Name, true} | OptAcc];
- integer ->
- %% Special case for integer arguments: if the option had not been set
- %% before we set the value to 1. This is needed to support options like
- %% "-v" to return something like {verbose, 1}.
- [{Name, 1} | OptAcc];
- _ ->
- throw({error, {missing_option_arg, Name}})
- end.
-
-
-%% @doc Add an option with an implicit or assumed argument.
--spec add_option_with_implicit_incrementable_arg(option_spec() | arg_spec(), [option()]) -> [option()].
-add_option_with_implicit_incrementable_arg({Name, _Short, _Long, ArgSpec, _Help}, OptAcc) ->
- case arg_spec_type(ArgSpec) of
- boolean ->
- %% Special case for boolean arguments: if there is no argument we
- %% set the value to 'true'.
- [{Name, true} | OptAcc];
- integer ->
- %% Special case for integer arguments: if the option had not been set
- %% before we set the value to 1; if not we increment the previous value
- %% the option had. This is needed to support options like "-vvv" to
- %% return something like {verbose, 3}.
- case OptAcc of
- [{Name, Count} | Tail] ->
- [{Name, Count + 1} | Tail];
- _ ->
- [{Name, 1} | OptAcc]
- end;
- _ ->
- throw({error, {missing_option_arg, Name}})
- end.
-
-
-%% @doc Retrieve the data type form an argument specification.
--spec arg_spec_type(arg_spec()) -> arg_type() | undefined.
-arg_spec_type({Type, _DefaultArg}) ->
- Type;
-arg_spec_type(Type) when is_atom(Type) ->
- Type.
-
-
-%% @doc Convert an argument string to its corresponding data type.
--spec to_type(arg_spec() | arg_type(), string()) -> arg_value().
-to_type({Type, _DefaultArg}, Arg) ->
- to_type(Type, Arg);
-to_type(binary, Arg) ->
- list_to_binary(Arg);
-to_type(atom, Arg) ->
- list_to_atom(Arg);
-to_type(integer, Arg) ->
- list_to_integer(Arg);
-to_type(float, Arg) ->
- list_to_float(Arg);
-to_type(boolean, Arg) ->
- LowerArg = string:to_lower(Arg),
- case is_arg_true(LowerArg) of
- true ->
- true;
- _ ->
- case is_arg_false(LowerArg) of
- true ->
- false;
- false ->
- erlang:error(badarg)
- end
- end;
-to_type(_Type, Arg) ->
- Arg.
-
-
--spec is_arg_true(string()) -> boolean().
-is_arg_true(Arg) ->
- (Arg =:= "true") orelse (Arg =:= "t") orelse
- (Arg =:= "yes") orelse (Arg =:= "y") orelse
- (Arg =:= "on") orelse (Arg =:= "enabled") orelse
- (Arg =:= "1").
-
-
--spec is_arg_false(string()) -> boolean().
-is_arg_false(Arg) ->
- (Arg =:= "false") orelse (Arg =:= "f") orelse
- (Arg =:= "no") orelse (Arg =:= "n") orelse
- (Arg =:= "off") orelse (Arg =:= "disabled") orelse
- (Arg =:= "0").
-
-
--spec is_valid_arg(arg_spec(), nonempty_string()) -> boolean().
-is_valid_arg({Type, _DefaultArg}, Arg) ->
- is_valid_arg(Type, Arg);
-is_valid_arg(boolean, Arg) ->
- is_boolean_arg(Arg);
-is_valid_arg(integer, Arg) ->
- is_non_neg_integer_arg(Arg);
-is_valid_arg(float, Arg) ->
- is_non_neg_float_arg(Arg);
-is_valid_arg(_Type, _Arg) ->
- true.
-
-
--spec is_implicit_arg(arg_spec(), nonempty_string()) -> boolean().
-is_implicit_arg({Type, _DefaultArg}, Arg) ->
- is_implicit_arg(Type, Arg);
-is_implicit_arg(boolean, Arg) ->
- not is_boolean_arg(Arg);
-is_implicit_arg(integer, Arg) ->
- not is_integer_arg(Arg);
-is_implicit_arg(_Type, _Arg) ->
- false.
-
-
--spec is_boolean_arg(string()) -> boolean().
-is_boolean_arg(Arg) ->
- LowerArg = string:to_lower(Arg),
- is_arg_true(LowerArg) orelse is_arg_false(LowerArg).
-
-
--spec is_integer_arg(string()) -> boolean().
-is_integer_arg("-" ++ Tail) ->
- is_non_neg_integer_arg(Tail);
-is_integer_arg(Arg) ->
- is_non_neg_integer_arg(Arg).
-
-
--spec is_non_neg_integer_arg(string()) -> boolean().
-is_non_neg_integer_arg([Head | Tail]) when Head >= $0, Head =< $9 ->
- is_non_neg_integer_arg(Tail);
-is_non_neg_integer_arg([_Head | _Tail]) ->
- false;
-is_non_neg_integer_arg([]) ->
- true.
-
-
--spec is_non_neg_float_arg(string()) -> boolean().
-is_non_neg_float_arg([Head | Tail]) when (Head >= $0 andalso Head =< $9) orelse Head =:= $. ->
- is_non_neg_float_arg(Tail);
-is_non_neg_float_arg([_Head | _Tail]) ->
- false;
-is_non_neg_float_arg([]) ->
- true.
-
-
-%% @doc Show a message on standard_error indicating the command line options and
-%% arguments that are supported by the program.
--spec usage([option_spec()], string()) -> ok.
-usage(OptSpecList, ProgramName) ->
- usage(OptSpecList, ProgramName, standard_error).
-
-
-%% @doc Show a message on standard_error or standard_io indicating the command line options and
-%% arguments that are supported by the program.
--spec usage([option_spec()], string(), output_stream() | string()) -> ok.
-usage(OptSpecList, ProgramName, OutputStream) when is_atom(OutputStream) ->
- io:format(OutputStream, "~s~n~n~s~n",
- [usage_cmd_line(ProgramName, OptSpecList), usage_options(OptSpecList)]);
-%% @doc Show a message on standard_error indicating the command line options and
-%% arguments that are supported by the program. The CmdLineTail argument
-%% is a string that is added to the end of the usage command line.
-usage(OptSpecList, ProgramName, CmdLineTail) ->
- usage(OptSpecList, ProgramName, CmdLineTail, standard_error).
-
-
-%% @doc Show a message on standard_error or standard_io indicating the command line options and
-%% arguments that are supported by the program. The CmdLineTail argument
-%% is a string that is added to the end of the usage command line.
--spec usage([option_spec()], ProgramName :: string(), CmdLineTail :: string(), output_stream() | [{string(), string()}]) -> ok.
-usage(OptSpecList, ProgramName, CmdLineTail, OutputStream) when is_atom(OutputStream) ->
- io:format(OutputStream, "~s~n~n~s~n",
- [usage_cmd_line(ProgramName, OptSpecList, CmdLineTail), usage_options(OptSpecList)]);
-%% @doc Show a message on standard_error indicating the command line options and
-%% arguments that are supported by the program. The CmdLineTail and OptionsTail
-%% arguments are a string that is added to the end of the usage command line
-%% and a list of tuples that are added to the end of the options' help lines.
-usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail) ->
- usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail, standard_error).
-
-
-%% @doc Show a message on standard_error or standard_io indicating the command line options and
-%% arguments that are supported by the program. The CmdLineTail and OptionsTail
-%% arguments are a string that is added to the end of the usage command line
-%% and a list of tuples that are added to the end of the options' help lines.
--spec usage([option_spec()], ProgramName :: string(), CmdLineTail :: string(),
- [{OptionName :: string(), Help :: string()}], output_stream()) -> ok.
-usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail, OutputStream) ->
- io:format(OutputStream, "~s~n~n~s~n",
- [usage_cmd_line(ProgramName, OptSpecList, CmdLineTail), usage_options(OptSpecList, OptionsTail)]).
-
-
--spec usage_cmd_line(ProgramName :: string(), [option_spec()]) -> iolist().
-usage_cmd_line(ProgramName, OptSpecList) ->
- usage_cmd_line(ProgramName, OptSpecList, "").
-
--spec usage_cmd_line(ProgramName :: string(), [option_spec()], CmdLineTail :: string()) -> iolist().
-usage_cmd_line(ProgramName, OptSpecList, CmdLineTail) ->
- Prefix = "Usage: " ++ ProgramName,
- PrefixLength = length(Prefix),
- LineLength = line_length(),
- %% Only align the command line options after the program name when there is
- %% enough room to do so (i.e. at least 25 characters). If not, show the
- %% command line options below the program name with a 2-character indentation.
- if
- (LineLength - PrefixLength) > ?MIN_USAGE_COMMAND_LINE_OPTION_LENGTH ->
- Indentation = lists:duplicate(PrefixLength, $\s),
- [FirstOptLine | OptLines] = usage_cmd_line_options(LineLength - PrefixLength, OptSpecList, CmdLineTail),
- IndentedOptLines = [[Indentation | OptLine] || OptLine <- OptLines],
- [Prefix, FirstOptLine | IndentedOptLines];
- true ->
- IndentedOptLines = [[" " | OptLine] || OptLine <- usage_cmd_line_options(LineLength, OptSpecList, CmdLineTail)],
- [Prefix, $\n, IndentedOptLines]
- end.
-
-
-%% @doc Return a list of the lines corresponding to the usage command line
-%% already wrapped according to the maximum MaxLineLength.
--spec usage_cmd_line_options(MaxLineLength :: non_neg_integer(), [option_spec()], CmdLineTail :: string()) -> iolist().
-usage_cmd_line_options(MaxLineLength, OptSpecList, CmdLineTail) ->
- usage_cmd_line_options(MaxLineLength, OptSpecList ++ string:tokens(CmdLineTail, " "), [], 0, []).
-
-usage_cmd_line_options(MaxLineLength, [OptSpec | Tail], LineAcc, LineAccLength, Acc) ->
- Option = [$\s | lists:flatten(usage_cmd_line_option(OptSpec))],
- OptionLength = length(Option),
- %% We accumulate the options in LineAcc until its length is over the
- %% maximum allowed line length. When that happens, we append the line in
- %% LineAcc to the list with all the lines in the command line (Acc).
- NewLineAccLength = LineAccLength + OptionLength,
- if
- NewLineAccLength < MaxLineLength ->
- usage_cmd_line_options(MaxLineLength, Tail, [Option | LineAcc], NewLineAccLength, Acc);
- true ->
- usage_cmd_line_options(MaxLineLength, Tail, [Option], OptionLength + 1,
- [lists:reverse([$\n | LineAcc]) | Acc])
- end;
-usage_cmd_line_options(MaxLineLength, [], [_ | _] = LineAcc, _LineAccLength, Acc) ->
- %% If there was a non-empty line in LineAcc when there are no more options
- %% to process, we add it to the list of lines to return.
- usage_cmd_line_options(MaxLineLength, [], [], 0, [lists:reverse(LineAcc) | Acc]);
-usage_cmd_line_options(_MaxLineLength, [], [], _LineAccLength, Acc) ->
- lists:reverse(Acc).
-
-
--spec usage_cmd_line_option(option_spec()) -> string().
-usage_cmd_line_option({_Name, Short, _Long, undefined, _Help}) when Short =/= undefined ->
- %% For options with short form and no argument.
- [$[, $-, Short, $]];
-usage_cmd_line_option({_Name, _Short, Long, undefined, _Help}) when Long =/= undefined ->
- %% For options with only long form and no argument.
- [$[, $-, $-, Long, $]];
-usage_cmd_line_option({_Name, _Short, _Long, undefined, _Help}) ->
- [];
-usage_cmd_line_option({Name, Short, Long, ArgSpec, _Help}) when is_atom(ArgSpec) ->
- %% For options with no default argument.
- if
- %% For options with short form and argument.
- Short =/= undefined -> [$[, $-, Short, $\s, $<, atom_to_list(Name), $>, $]];
- %% For options with only long form and argument.
- Long =/= undefined -> [$[, $-, $-, Long, $\s, $<, atom_to_list(Name), $>, $]];
- %% For options with neither short nor long form and argument.
- true -> [$[, $<, atom_to_list(Name), $>, $]]
- end;
-usage_cmd_line_option({Name, Short, Long, ArgSpec, _Help}) when is_tuple(ArgSpec) ->
- %% For options with default argument.
- if
- %% For options with short form and default argument.
- Short =/= undefined -> [$[, $-, Short, $\s, $[, $<, atom_to_list(Name), $>, $], $]];
- %% For options with only long form and default argument.
- Long =/= undefined -> [$[, $-, $-, Long, $\s, $[, $<, atom_to_list(Name), $>, $], $]];
- %% For options with neither short nor long form and default argument.
- true -> [$[, $<, atom_to_list(Name), $>, $]]
- end;
-usage_cmd_line_option(Option) when is_list(Option) ->
- %% For custom options that are added to the command line.
- Option.
-
-
-%% @doc Return a list of help messages to print for each of the options and arguments.
--spec usage_options([option_spec()]) -> [string()].
-usage_options(OptSpecList) ->
- usage_options(OptSpecList, []).
-
-
-%% @doc Return a list of usage lines to print for each of the options and arguments.
--spec usage_options([option_spec()], [{OptionName :: string(), Help :: string()}]) -> [string()].
-usage_options(OptSpecList, CustomHelp) ->
- %% Add the usage lines corresponding to the option specifications.
- {MaxOptionLength0, UsageLines0} = add_option_spec_help_lines(OptSpecList, 0, []),
- %% Add the custom usage lines.
- {MaxOptionLength, UsageLines} = add_custom_help_lines(CustomHelp, MaxOptionLength0, UsageLines0),
- MaxLineLength = line_length(),
- lists:reverse([format_usage_line(MaxOptionLength + 1, MaxLineLength, UsageLine) || UsageLine <- UsageLines]).
-
-
--spec add_option_spec_help_lines([option_spec()], PrevMaxOptionLength :: non_neg_integer(), [usage_line_with_length()]) ->
- {MaxOptionLength :: non_neg_integer(), [usage_line_with_length()]}.
-add_option_spec_help_lines([OptSpec | Tail], PrevMaxOptionLength, Acc) ->
- OptionText = usage_option_text(OptSpec),
- HelpText = usage_help_text(OptSpec),
- {MaxOptionLength, ColsWithLength} = get_max_option_length({OptionText, HelpText}, PrevMaxOptionLength),
- add_option_spec_help_lines(Tail, MaxOptionLength, [ColsWithLength | Acc]);
-add_option_spec_help_lines([], MaxOptionLength, Acc) ->
- {MaxOptionLength, Acc}.
-
-
--spec add_custom_help_lines([usage_line()], PrevMaxOptionLength :: non_neg_integer(), [usage_line_with_length()]) ->
- {MaxOptionLength :: non_neg_integer(), [usage_line_with_length()]}.
-add_custom_help_lines([CustomCols | Tail], PrevMaxOptionLength, Acc) ->
- {MaxOptionLength, ColsWithLength} = get_max_option_length(CustomCols, PrevMaxOptionLength),
- add_custom_help_lines(Tail, MaxOptionLength, [ColsWithLength | Acc]);
-add_custom_help_lines([], MaxOptionLength, Acc) ->
- {MaxOptionLength, Acc}.
-
-
--spec usage_option_text(option_spec()) -> string().
-usage_option_text({Name, undefined, undefined, _ArgSpec, _Help}) ->
- %% Neither short nor long form (non-option argument).
- "<" ++ atom_to_list(Name) ++ ">";
-usage_option_text({_Name, Short, undefined, _ArgSpec, _Help}) ->
- %% Only short form.
- [$-, Short];
-usage_option_text({_Name, undefined, Long, _ArgSpec, _Help}) ->
- %% Only long form.
- [$-, $- | Long];
-usage_option_text({_Name, Short, Long, _ArgSpec, _Help}) ->
- %% Both short and long form.
- [$-, Short, $,, $\s, $-, $- | Long].
-
-
--spec usage_help_text(option_spec()) -> string().
-usage_help_text({_Name, _Short, _Long, {_ArgType, ArgValue}, [_ | _] = Help}) ->
- Help ++ " [default: " ++ default_arg_value_to_string(ArgValue) ++ "]";
-usage_help_text({_Name, _Short, _Long, _ArgSpec, Help}) ->
- Help.
-
-
-%% @doc Calculate the maximum width of the column that shows the option's short
-%% and long form.
--spec get_max_option_length(usage_line(), PrevMaxOptionLength :: non_neg_integer()) ->
- {MaxOptionLength :: non_neg_integer(), usage_line_with_length()}.
-get_max_option_length({OptionText, HelpText}, PrevMaxOptionLength) ->
- OptionLength = length(OptionText),
- {erlang:max(OptionLength, PrevMaxOptionLength), {OptionLength, OptionText, HelpText}}.
-
-
-%% @doc Format the usage line that is shown for the options' usage. Each usage
-%% line has 2 columns. The first column shows the options in their short
-%% and long form. The second column shows the wrapped (if necessary) help
-%% text lines associated with each option. e.g.:
-%%
-%% -h, --host Database server host name or IP address; this is the
-%% hostname of the server where the database is running
-%% [default: localhost]
-%% -p, --port Database server port [default: 1000]
-%%
--spec format_usage_line(MaxOptionLength :: non_neg_integer(), MaxLineLength :: non_neg_integer(),
- usage_line_with_length()) -> iolist().
-format_usage_line(MaxOptionLength, MaxLineLength, {OptionLength, OptionText, [_ | _] = HelpText})
- when MaxOptionLength < (MaxLineLength div 2) ->
- %% If the width of the column where the options are shown is smaller than
- %% half the width of a console line then we show the help text line aligned
- %% next to its corresponding option, with a separation of at least 2
- %% characters.
- [Head | Tail] = wrap_text_line(MaxLineLength - MaxOptionLength - 3, HelpText),
- FirstLineIndentation = lists:duplicate(MaxOptionLength - OptionLength + 1, $\s),
- Indentation = [$\n | lists:duplicate(MaxOptionLength + 3, $\s)],
- [" ", OptionText, FirstLineIndentation, Head,
- [[Indentation, Line] || Line <- Tail], $\n];
-format_usage_line(_MaxOptionLength, MaxLineLength, {_OptionLength, OptionText, [_ | _] = HelpText}) ->
- %% If the width of the first column is bigger than the width of a console
- %% line, we show the help text on the next line with an indentation of 6
- %% characters.
- HelpLines = wrap_text_line(MaxLineLength - 6, HelpText),
- [" ", OptionText, [["\n ", Line] || Line <- HelpLines], $\n];
-format_usage_line(_MaxOptionLength, _MaxLineLength, {_OptionLength, OptionText, _HelpText}) ->
- [" ", OptionText, $\n].
-
-
-%% @doc Wrap a text line converting it into several text lines so that the
-%% length of each one of them is never over HelpLength characters.
--spec wrap_text_line(Length :: non_neg_integer(), Text :: string()) -> [string()].
-wrap_text_line(Length, Text) ->
- wrap_text_line(Length, Text, [], 0, []).
-
-wrap_text_line(Length, [Char | Tail], Acc, Count, CurrentLineAcc) when Count < Length ->
- wrap_text_line(Length, Tail, Acc, Count + 1, [Char | CurrentLineAcc]);
-wrap_text_line(Length, [_ | _] = Help, Acc, Count, CurrentLineAcc) ->
- %% Look for the first whitespace character in the current (reversed) line
- %% buffer to get a wrapped line. If there is no whitespace just cut the
- %% line at the position corresponding to the maximum length.
- {NextLineAcc, WrappedLine} = case string:cspan(CurrentLineAcc, " \t") of
- WhitespacePos when WhitespacePos < Count ->
- lists:split(WhitespacePos, CurrentLineAcc);
- _ ->
- {[], CurrentLineAcc}
- end,
- wrap_text_line(Length, Help, [lists:reverse(WrappedLine) | Acc], length(NextLineAcc), NextLineAcc);
-wrap_text_line(_Length, [], Acc, _Count, [_ | _] = CurrentLineAcc) ->
- %% If there was a non-empty line when we reached the buffer, add it to the accumulator
- lists:reverse([lists:reverse(CurrentLineAcc) | Acc]);
-wrap_text_line(_Length, [], Acc, _Count, _CurrentLineAcc) ->
- lists:reverse(Acc).
-
-
-default_arg_value_to_string(Value) when is_atom(Value) ->
- atom_to_list(Value);
-default_arg_value_to_string(Value) when is_binary(Value) ->
- binary_to_list(Value);
-default_arg_value_to_string(Value) when is_integer(Value) ->
- integer_to_list(Value);
-default_arg_value_to_string(Value) when is_float(Value) ->
- float_to_list(Value);
-default_arg_value_to_string(Value) ->
- Value.
-
-
-%% @doc Tokenize a command line string with support for single and double
-%% quoted arguments (needed for arguments that have embedded whitespace).
-%% The function also supports the expansion of environment variables in
-%% both the Unix (${VAR}; $VAR) and Windows (%VAR%) formats. It does NOT
-%% support wildcard expansion of paths.
--spec tokenize(CmdLine :: string()) -> [nonempty_string()].
-tokenize(CmdLine) ->
- tokenize(CmdLine, [], []).
-
--spec tokenize(CmdLine :: string(), Acc :: [string()], ArgAcc :: string()) -> [string()].
-tokenize([Sep | Tail], Acc, ArgAcc) when ?IS_WHITESPACE(Sep) ->
- NewAcc = case ArgAcc of
- [_ | _] ->
- %% Found separator: add to the list of arguments.
- [lists:reverse(ArgAcc) | Acc];
- [] ->
- %% Found separator with no accumulated argument; discard it.
- Acc
- end,
- tokenize(Tail, NewAcc, []);
-tokenize([QuotationMark | Tail], Acc, ArgAcc) when QuotationMark =:= $"; QuotationMark =:= $' ->
- %% Quoted argument (might contain spaces, tabs, etc.)
- tokenize_quoted_arg(QuotationMark, Tail, Acc, ArgAcc);
-tokenize([Char | _Tail] = CmdLine, Acc, ArgAcc) when Char =:= $$; Char =:= $% ->
- %% Unix and Windows environment variable expansion: ${VAR}; $VAR; %VAR%
- {NewCmdLine, Var} = expand_env_var(CmdLine),
- tokenize(NewCmdLine, Acc, lists:reverse(Var, ArgAcc));
-tokenize([$\\, Char | Tail], Acc, ArgAcc) ->
- %% Escaped char.
- tokenize(Tail, Acc, [Char | ArgAcc]);
-tokenize([Char | Tail], Acc, ArgAcc) ->
- tokenize(Tail, Acc, [Char | ArgAcc]);
-tokenize([], Acc, []) ->
- lists:reverse(Acc);
-tokenize([], Acc, ArgAcc) ->
- lists:reverse([lists:reverse(ArgAcc) | Acc]).
-
--spec tokenize_quoted_arg(QuotationMark :: char(), CmdLine :: string(), Acc :: [string()], ArgAcc :: string()) -> [string()].
-tokenize_quoted_arg(QuotationMark, [QuotationMark | Tail], Acc, ArgAcc) ->
- %% End of quoted argument
- tokenize(Tail, Acc, ArgAcc);
-tokenize_quoted_arg(QuotationMark, [$\\, Char | Tail], Acc, ArgAcc) ->
- %% Escaped char.
- tokenize_quoted_arg(QuotationMark, Tail, Acc, [Char | ArgAcc]);
-tokenize_quoted_arg($" = QuotationMark, [Char | _Tail] = CmdLine, Acc, ArgAcc) when Char =:= $$; Char =:= $% ->
- %% Unix and Windows environment variable expansion (only for double-quoted arguments): ${VAR}; $VAR; %VAR%
- {NewCmdLine, Var} = expand_env_var(CmdLine),
- tokenize_quoted_arg(QuotationMark, NewCmdLine, Acc, lists:reverse(Var, ArgAcc));
-tokenize_quoted_arg(QuotationMark, [Char | Tail], Acc, ArgAcc) ->
- tokenize_quoted_arg(QuotationMark, Tail, Acc, [Char | ArgAcc]);
-tokenize_quoted_arg(_QuotationMark, CmdLine, Acc, ArgAcc) ->
- tokenize(CmdLine, Acc, ArgAcc).
-
-
--spec expand_env_var(CmdLine :: nonempty_string()) -> {string(), string()}.
-expand_env_var(CmdLine) ->
- case CmdLine of
- "${" ++ Tail ->
- expand_env_var("${", $}, Tail, []);
- "$" ++ Tail ->
- expand_env_var("$", Tail, []);
- "%" ++ Tail ->
- expand_env_var("%", $%, Tail, [])
- end.
-
--spec expand_env_var(Prefix :: string(), EndMark :: char(), CmdLine :: string(), Acc :: string()) -> {string(), string()}.
-expand_env_var(Prefix, EndMark, [Char | Tail], Acc)
- when (Char >= $A andalso Char =< $Z) orelse (Char >= $a andalso Char =< $z) orelse
- (Char >= $0 andalso Char =< $9) orelse (Char =:= $_) ->
- expand_env_var(Prefix, EndMark, Tail, [Char | Acc]);
-expand_env_var(Prefix, EndMark, [EndMark | Tail], Acc) ->
- {Tail, get_env_var(Prefix, [EndMark], Acc)};
-expand_env_var(Prefix, _EndMark, CmdLine, Acc) ->
- {CmdLine, Prefix ++ lists:reverse(Acc)}.
-
-
--spec expand_env_var(Prefix :: string(), CmdLine :: string(), Acc :: string()) -> {string(), string()}.
-expand_env_var(Prefix, [Char | Tail], Acc)
- when (Char >= $A andalso Char =< $Z) orelse (Char >= $a andalso Char =< $z) orelse
- (Char >= $0 andalso Char =< $9) orelse (Char =:= $_) ->
- expand_env_var(Prefix, Tail, [Char | Acc]);
-expand_env_var(Prefix, CmdLine, Acc) ->
- {CmdLine, get_env_var(Prefix, "", Acc)}.
-
-
--spec get_env_var(Prefix :: string(), Suffix :: string(), Acc :: string()) -> string().
-get_env_var(Prefix, Suffix, [_ | _] = Acc) ->
- Name = lists:reverse(Acc),
- %% Only expand valid/existing variables.
- case os:getenv(Name) of
- false -> Prefix ++ Name ++ Suffix;
- Value -> Value
- end;
-get_env_var(Prefix, Suffix, []) ->
- Prefix ++ Suffix.
-
-
--spec line_length() -> non_neg_integer().
-line_length() ->
- case io:columns() of
- {ok, Columns} when Columns < ?LINE_LENGTH ->
- Columns - 1;
- _ ->
- ?LINE_LENGTH
- end.
diff --git a/src/rebar/src/mustache.erl b/src/rebar/src/mustache.erl
deleted file mode 100644
index f6963cd7a..000000000
--- a/src/rebar/src/mustache.erl
+++ /dev/null
@@ -1,228 +0,0 @@
-%% The MIT License
-%%
-%% Copyright (c) 2009 Tom Preston-Werner <tom@mojombo.com>
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-
-%% See the README at http://github.com/mojombo/mustache.erl for additional
-%% documentation and usage examples.
-
--module(mustache). %% v0.1.0
--author("Tom Preston-Werner").
--export([compile/1, compile/2, render/1, render/2, render/3, get/2, get/3, escape/1, start/1]).
-
--record(mstate, {mod = undefined,
- section_re = undefined,
- tag_re = undefined}).
-
-compile(Body) when is_list(Body) ->
- State = #mstate{},
- CompiledTemplate = pre_compile(Body, State),
- % io:format("~p~n~n", [CompiledTemplate]),
- % io:format(CompiledTemplate ++ "~n", []),
- {ok, Tokens, _} = erl_scan:string(CompiledTemplate),
- {ok, [Form]} = erl_parse:parse_exprs(Tokens),
- Bindings = erl_eval:new_bindings(),
- {value, Fun, _} = erl_eval:expr(Form, Bindings),
- Fun;
-compile(Mod) ->
- TemplatePath = template_path(Mod),
- compile(Mod, TemplatePath).
-
-compile(Mod, File) ->
- code:purge(Mod),
- {module, _} = code:load_file(Mod),
- {ok, TemplateBin} = file:read_file(File),
- Template = re:replace(TemplateBin, "\"", "\\\\\"", [global, {return,list}]),
- State = #mstate{mod = Mod},
- CompiledTemplate = pre_compile(Template, State),
- % io:format("~p~n~n", [CompiledTemplate]),
- % io:format(CompiledTemplate ++ "~n", []),
- {ok, Tokens, _} = erl_scan:string(CompiledTemplate),
- {ok, [Form]} = erl_parse:parse_exprs(Tokens),
- Bindings = erl_eval:new_bindings(),
- {value, Fun, _} = erl_eval:expr(Form, Bindings),
- Fun.
-
-render(Mod) ->
- TemplatePath = template_path(Mod),
- render(Mod, TemplatePath).
-
-render(Body, Ctx) when is_list(Body) ->
- TFun = compile(Body),
- render(undefined, TFun, Ctx);
-render(Mod, File) when is_list(File) ->
- render(Mod, File, dict:new());
-render(Mod, CompiledTemplate) ->
- render(Mod, CompiledTemplate, dict:new()).
-
-render(Mod, File, Ctx) when is_list(File) ->
- CompiledTemplate = compile(Mod, File),
- render(Mod, CompiledTemplate, Ctx);
-render(Mod, CompiledTemplate, Ctx) ->
- Ctx2 = dict:store('__mod__', Mod, Ctx),
- lists:flatten(CompiledTemplate(Ctx2)).
-
-pre_compile(T, State) ->
- SectionRE = "\{\{\#([^\}]*)}}\s*(.+?){{\/\\1\}\}\s*",
- {ok, CompiledSectionRE} = re:compile(SectionRE, [dotall]),
- TagRE = "\{\{(#|=|!|<|>|\{)?(.+?)\\1?\}\}+",
- {ok, CompiledTagRE} = re:compile(TagRE, [dotall]),
- State2 = State#mstate{section_re = CompiledSectionRE, tag_re = CompiledTagRE},
- "fun(Ctx) -> " ++
- "CFun = fun(A, B) -> A end, " ++
- compiler(T, State2) ++ " end.".
-
-compiler(T, State) ->
- Res = re:run(T, State#mstate.section_re),
- case Res of
- {match, [{M0, M1}, {N0, N1}, {C0, C1}]} ->
- Front = string:substr(T, 1, M0),
- Back = string:substr(T, M0 + M1 + 1),
- Name = string:substr(T, N0 + 1, N1),
- Content = string:substr(T, C0 + 1, C1),
- "[" ++ compile_tags(Front, State) ++
- " | [" ++ compile_section(Name, Content, State) ++
- " | [" ++ compiler(Back, State) ++ "]]]";
- nomatch ->
- compile_tags(T, State)
- end.
-
-compile_section(Name, Content, State) ->
- Mod = State#mstate.mod,
- Result = compiler(Content, State),
- "fun() -> " ++
- "case mustache:get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
- "\"true\" -> " ++
- Result ++ "; " ++
- "\"false\" -> " ++
- "[]; " ++
- "List when is_list(List) -> " ++
- "[fun(Ctx) -> " ++ Result ++ " end(dict:merge(CFun, SubCtx, Ctx)) || SubCtx <- List]; " ++
- "Else -> " ++
- "throw({template, io_lib:format(\"Bad context for ~p: ~p\", [" ++ Name ++ ", Else])}) " ++
- "end " ++
- "end()".
-
-compile_tags(T, State) ->
- Res = re:run(T, State#mstate.tag_re),
- case Res of
- {match, [{M0, M1}, K, {C0, C1}]} ->
- Front = string:substr(T, 1, M0),
- Back = string:substr(T, M0 + M1 + 1),
- Content = string:substr(T, C0 + 1, C1),
- Kind = tag_kind(T, K),
- Result = compile_tag(Kind, Content, State),
- "[\"" ++ Front ++
- "\" | [" ++ Result ++
- " | " ++ compile_tags(Back, State) ++ "]]";
- nomatch ->
- "[\"" ++ T ++ "\"]"
- end.
-
-tag_kind(_T, {-1, 0}) ->
- none;
-tag_kind(T, {K0, K1}) ->
- string:substr(T, K0 + 1, K1).
-
-compile_tag(none, Content, State) ->
- Mod = State#mstate.mod,
- "mustache:escape(mustache:get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ "))";
-compile_tag("{", Content, State) ->
- Mod = State#mstate.mod,
- "mustache:get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ ")";
-compile_tag("!", _Content, _State) ->
- "[]".
-
-template_dir(Mod) ->
- DefaultDirPath = filename:dirname(code:which(Mod)),
- case application:get_env(mustache, templates_dir) of
- {ok, DirPath} when is_list(DirPath) ->
- case filelib:ensure_dir(DirPath) of
- ok -> DirPath;
- _ -> DefaultDirPath
- end;
- _ ->
- DefaultDirPath
- end.
-template_path(Mod) ->
- DirPath = template_dir(Mod),
- Basename = atom_to_list(Mod),
- filename:join(DirPath, Basename ++ ".mustache").
-
-get(Key, Ctx) when is_list(Key) ->
- {ok, Mod} = dict:find('__mod__', Ctx),
- get(list_to_atom(Key), Ctx, Mod);
-get(Key, Ctx) ->
- {ok, Mod} = dict:find('__mod__', Ctx),
- get(Key, Ctx, Mod).
-
-get(Key, Ctx, Mod) when is_list(Key) ->
- get(list_to_atom(Key), Ctx, Mod);
-get(Key, Ctx, Mod) ->
- case dict:find(Key, Ctx) of
- {ok, Val} ->
- % io:format("From Ctx {~p, ~p}~n", [Key, Val]),
- to_s(Val);
- error ->
- case erlang:function_exported(Mod, Key, 1) of
- true ->
- Val = to_s(Mod:Key(Ctx)),
- % io:format("From Mod/1 {~p, ~p}~n", [Key, Val]),
- Val;
- false ->
- case erlang:function_exported(Mod, Key, 0) of
- true ->
- Val = to_s(Mod:Key()),
- % io:format("From Mod/0 {~p, ~p}~n", [Key, Val]),
- Val;
- false ->
- []
- end
- end
- end.
-
-to_s(Val) when is_integer(Val) ->
- integer_to_list(Val);
-to_s(Val) when is_float(Val) ->
- io_lib:format("~.2f", [Val]);
-to_s(Val) when is_atom(Val) ->
- atom_to_list(Val);
-to_s(Val) ->
- Val.
-
-escape(HTML) ->
- escape(HTML, []).
-
-escape([], Acc) ->
- lists:reverse(Acc);
-escape(["<" | Rest], Acc) ->
- escape(Rest, lists:reverse("&lt;", Acc));
-escape([">" | Rest], Acc) ->
- escape(Rest, lists:reverse("&gt;", Acc));
-escape(["&" | Rest], Acc) ->
- escape(Rest, lists:reverse("&amp;", Acc));
-escape([X | Rest], Acc) ->
- escape(Rest, [X | Acc]).
-
-%%---------------------------------------------------------------------------
-
-start([T]) ->
- Out = render(list_to_atom(T)),
- io:format(Out ++ "~n", []).
diff --git a/src/rebar/src/rebar.erl b/src/rebar/src/rebar.erl
deleted file mode 100644
index 2d9fe04f2..000000000
--- a/src/rebar/src/rebar.erl
+++ /dev/null
@@ -1,501 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar).
-
--export([main/1,
- run/2,
- help/0,
- parse_args/1,
- version/0,
- get_jobs/1]).
-
--include("rebar.hrl").
-
--ifndef(BUILD_TIME).
--define(BUILD_TIME, "undefined").
--endif.
-
--ifndef(VCS_INFO).
--define(VCS_INFO, "undefined").
--endif.
-
--ifndef(OTP_INFO).
--define(OTP_INFO, "undefined").
--endif.
-
--define(DEFAULT_JOBS, 3).
-
-%% ====================================================================
-%% Public API
-%% ====================================================================
-
-%% escript Entry point
-main(Args) ->
- case catch(run(Args)) of
- ok ->
- ok;
- rebar_abort ->
- rebar_utils:delayed_halt(1);
- Error ->
- %% Nothing should percolate up from rebar_core;
- %% Dump this error to console
- io:format("Uncaught error in rebar_core: ~p\n", [Error]),
- rebar_utils:delayed_halt(1)
- end.
-
-%% Erlang-API entry point
-run(BaseConfig, Commands) ->
- _ = application:load(rebar),
- run_aux(BaseConfig, Commands).
-
-%% ====================================================================
-%% Internal functions
-%% ====================================================================
-
-run(["help"|RawCmds]) when RawCmds =/= [] ->
- ok = load_rebar_app(),
- Cmds = unabbreviate_command_names(RawCmds),
- Args = parse_args(Cmds),
- BaseConfig = init_config(Args),
- {BaseConfig1, _} = save_options(BaseConfig, Args),
- BaseConfig2 = init_config1(BaseConfig1),
- rebar_core:help(BaseConfig2, [list_to_atom(C) || C <- Cmds]);
-run(["help"]) ->
- help();
-run(["info"|_]) ->
- help();
-run(["version"]) ->
- ok = load_rebar_app(),
- %% Display vsn and build time info
- version();
-run(RawArgs) ->
- ok = load_rebar_app(),
- %% Parse out command line arguments -- what's left is a list of commands to
- %% run -- and start running commands
- Args = parse_args(RawArgs),
- BaseConfig = init_config(Args),
- {BaseConfig1, Cmds} = save_options(BaseConfig, Args),
-
- case rebar_config:get_xconf(BaseConfig1, enable_profiling, false) of
- true ->
- io:format("Profiling!\n"),
- try
- fprof:apply(fun run_aux/2, [BaseConfig1, Cmds])
- after
- ok = fprof:profile(),
- ok = fprof:analyse([{dest, "fprof.analysis"}])
- end;
- false ->
- run_aux(BaseConfig1, Cmds)
- end.
-
-load_rebar_app() ->
- %% Pre-load the rebar app so that we get default configuration
- ok = application:load(rebar).
-
-init_config({Options, _NonOptArgs}) ->
- %% If $HOME/.rebar/config exists load and use as global config
- GlobalConfigFile = filename:join([os:getenv("HOME"), ".rebar", "config"]),
- GlobalConfig = case filelib:is_regular(GlobalConfigFile) of
- true ->
- ?DEBUG("Load global config file ~p~n",
- [GlobalConfigFile]),
- rebar_config:new(GlobalConfigFile);
- false ->
- rebar_config:new()
- end,
-
- %% Set the rebar config to use
- GlobalConfig1 = case proplists:get_value(config, Options) of
- undefined ->
- GlobalConfig;
- Conf ->
- rebar_config:set_global(GlobalConfig, config, Conf)
- end,
-
- GlobalConfig2 = set_log_level(GlobalConfig1, Options),
- %% Initialize logging system
- ok = rebar_log:init(GlobalConfig2),
-
- BaseConfig = rebar_config:base_config(GlobalConfig2),
-
- %% Keep track of how many operations we do, so we can detect bad commands
- BaseConfig1 = rebar_config:set_xconf(BaseConfig, operations, 0),
- %% Initialize vsn cache
- rebar_config:set_xconf(BaseConfig1, vsn_cache, dict:new()).
-
-init_config1(BaseConfig) ->
- %% Determine the location of the rebar executable; important for pulling
- %% resources out of the escript
- ScriptName = filename:absname(escript:script_name()),
- BaseConfig1 = rebar_config:set_xconf(BaseConfig, escript, ScriptName),
- ?DEBUG("Rebar location: ~p\n", [ScriptName]),
- %% Note the top-level directory for reference
- AbsCwd = filename:absname(rebar_utils:get_cwd()),
- rebar_config:set_xconf(BaseConfig1, base_dir, AbsCwd).
-
-run_aux(BaseConfig, Commands) ->
- %% Make sure crypto is running
- case crypto:start() of
- ok -> ok;
- {error,{already_started,crypto}} -> ok
- end,
-
- %% Convert command strings to atoms
- CommandAtoms = [list_to_atom(C) || C <- Commands],
-
- BaseConfig1 = init_config1(BaseConfig),
-
- %% Process each command, resetting any state between each one
- rebar_core:process_commands(CommandAtoms, BaseConfig1).
-
-%%
-%% print help/usage string
-%%
-help() ->
- OptSpecList = option_spec_list(),
- getopt:usage(OptSpecList, "rebar",
- "[var=value,...] <command,...>",
- [{"var=value", "rebar global variables (e.g. force=1)"},
- {"command", "Command to run (e.g. compile)"}]),
- ?CONSOLE(
- "Type 'rebar help <CMD1> <CMD2>' for help on specific commands."
- "~n~n", []),
- ?CONSOLE(
- "Core rebar.config options:~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n",
- [
- {lib_dirs, []},
- {sub_dirs, ["dir1", "dir2"]},
- {plugins, [plugin1, plugin2]},
- {plugin_dir, "some_other_directory"},
- {pre_hooks, [{clean, "./prepare_package_files.sh"},
- {"linux", compile, "c_src/build_linux.sh"},
- {compile, "escript generate_headers"},
- {compile, "escript check_headers"}]},
- {post_hooks, [{clean, "touch file1.out"},
- {"freebsd", compile, "c_src/freebsd_tweaks.sh"},
- {eunit, "touch file2.out"},
- {compile, "touch postcompile.out"}]}
- ]).
-
-%%
-%% Parse command line arguments using getopt and also filtering out any
-%% key=value pairs. What's left is the list of commands to run
-%%
-parse_args(RawArgs) ->
- %% Parse getopt options
- OptSpecList = option_spec_list(),
- case getopt:parse(OptSpecList, RawArgs) of
- {ok, Args} ->
- Args;
- {error, {Reason, Data}} ->
- ?ERROR("~s ~p~n~n", [Reason, Data]),
- help(),
- rebar_utils:delayed_halt(1)
- end.
-
-save_options(Config, {Options, NonOptArgs}) ->
- %% Check options and maybe halt execution
- ok = show_info_maybe_halt(Options, NonOptArgs),
-
- GlobalDefines = proplists:get_all_values(defines, Options),
-
- Config1 = rebar_config:set_xconf(Config, defines, GlobalDefines),
-
- %% Setup profiling flag
- Config2 = rebar_config:set_xconf(Config1, enable_profiling,
- proplists:get_bool(profile, Options)),
-
- %% Setup flag to keep running after a single command fails
- Config3 = rebar_config:set_xconf(Config2, keep_going,
- proplists:get_bool(keep_going, Options)),
-
- %% Set global variables based on getopt options
- Config4 = set_global_flag(Config3, Options, force),
- Config5 = case proplists:get_value(jobs, Options, ?DEFAULT_JOBS) of
- ?DEFAULT_JOBS ->
- Config4;
- Jobs ->
- rebar_config:set_global(Config4, jobs, Jobs)
- end,
-
- %% Filter all the flags (i.e. strings of form key=value) from the
- %% command line arguments. What's left will be the commands to run.
- {Config6, RawCmds} = filter_flags(Config5, NonOptArgs, []),
- {Config6, unabbreviate_command_names(RawCmds)}.
-
-%%
-%% set log level based on getopt option
-%%
-set_log_level(Config, Options) ->
- LogLevel = case proplists:get_all_values(verbose, Options) of
- [] ->
- rebar_log:default_level();
- Verbosities ->
- lists:last(Verbosities)
- end,
- rebar_config:set_global(Config, verbose, LogLevel).
-
-%%
-%% show version information and halt
-%%
-version() ->
- {ok, Vsn} = application:get_key(rebar, vsn),
- ?CONSOLE("rebar ~s ~s ~s ~s\n",
- [Vsn, ?OTP_INFO, ?BUILD_TIME, ?VCS_INFO]).
-
-
-%%
-%% set global flag based on getopt option boolean value
-%%
-set_global_flag(Config, Options, Flag) ->
- Value = case proplists:get_bool(Flag, Options) of
- true ->
- "1";
- false ->
- "0"
- end,
- rebar_config:set_global(Config, Flag, Value).
-
-%%
-%% show info and maybe halt execution
-%%
-show_info_maybe_halt(Opts, NonOptArgs) ->
- false = show_info_maybe_halt(help, Opts, fun help/0),
- false = show_info_maybe_halt(commands, Opts, fun commands/0),
- false = show_info_maybe_halt(version, Opts, fun version/0),
- case NonOptArgs of
- [] ->
- ?CONSOLE("No command to run specified!~n",[]),
- help(),
- rebar_utils:delayed_halt(1);
- _ ->
- ok
- end.
-
-show_info_maybe_halt(O, Opts, F) ->
- case proplists:get_bool(O, Opts) of
- true ->
- F(),
- rebar_utils:delayed_halt(0);
- false ->
- false
- end.
-
-%%
-%% print known commands
-%%
-commands() ->
- S = <<"
-clean Clean
-compile Compile sources
-
-escriptize Generate escript archive
-
-create template= [var=foo,...] Create skel based on template and vars
-create-app [appid=myapp] Create simple app skel
-create-node [nodeid=mynode] Create simple node skel
-list-templates List available templates
-
-doc Generate Erlang program documentation
-
-check-deps Display to be fetched dependencies
-get-deps Fetch dependencies
-update-deps Update fetched dependencies
-delete-deps Delete fetched dependencies
-list-deps List dependencies
-
-generate [dump_spec=0/1] Build release with reltool
-overlay Run reltool overlays only
-
-generate-upgrade previous_release=path Build an upgrade package
-
-generate-appups previous_release=path Generate appup files
-
-eunit [suites=foo] Run eunit tests in foo.erl and
- test/foo_tests.erl
- [suites=foo] [tests=bar] Run specific eunit tests [first test name
- starting with 'bar' in foo.erl and
- test/foo_tests.erl]
- [tests=bar] For every existing suite, run the first
- test whose name starts with bar and, if
- no such test exists, run the test whose
- name starts with bar in the suite's
- _tests module
-
-ct [suites=] [case=] Run common_test suites
-
-qc Test QuickCheck properties
-
-xref Run cross reference analysis
-
-help Show the program options
-version Show version information
-">>,
- io:put_chars(S).
-
-get_jobs(Config) ->
- rebar_config:get_global(Config, jobs, ?DEFAULT_JOBS).
-
-%%
-%% options accepted via getopt
-%%
-option_spec_list() ->
- Jobs = ?DEFAULT_JOBS,
- JobsHelp = io_lib:format(
- "Number of concurrent workers a command may use. Default: ~B",
- [Jobs]),
- VerboseHelp = "Verbosity level (-v, -vv, -vvv, --verbose 3). Default: 0",
- [
- %% {Name, ShortOpt, LongOpt, ArgSpec, HelpMsg}
- {help, $h, "help", undefined, "Show the program options"},
- {commands, $c, "commands", undefined, "Show available commands"},
- {verbose, $v, "verbose", integer, VerboseHelp},
- {version, $V, "version", undefined, "Show version information"},
- {force, $f, "force", undefined, "Force"},
- {defines, $D, undefined, string, "Define compiler macro"},
- {jobs, $j, "jobs", integer, JobsHelp},
- {config, $C, "config", string, "Rebar config file to use"},
- {profile, $p, "profile", undefined, "Profile this run of rebar"},
- {keep_going, $k, "keep-going", undefined,
- "Keep running after a command fails"}
- ].
-
-%%
-%% Seperate all commands (single-words) from flags (key=value) and store
-%% values into the rebar_config global storage.
-%%
-filter_flags(Config, [], Commands) ->
- {Config, lists:reverse(Commands)};
-filter_flags(Config, [Item | Rest], Commands) ->
- case string:tokens(Item, "=") of
- [Command] ->
- filter_flags(Config, Rest, [Command | Commands]);
- [KeyStr, RawValue] ->
- Key = list_to_atom(KeyStr),
- Value = case Key of
- verbose ->
- list_to_integer(RawValue);
- _ ->
- RawValue
- end,
- Config1 = rebar_config:set_global(Config, Key, Value),
- filter_flags(Config1, Rest, Commands);
- Other ->
- ?CONSOLE("Ignoring command line argument: ~p\n", [Other]),
- filter_flags(Config, Rest, Commands)
- end.
-
-command_names() ->
- [
- "check-deps",
- "clean",
- "compile",
- "create",
- "create-app",
- "create-node",
- "ct",
- "delete-deps",
- "doc",
- "eunit",
- "escriptize",
- "generate",
- "generate-appups",
- "generate-upgrade",
- "get-deps",
- "help",
- "list-deps",
- "list-templates",
- "qc",
- "update-deps",
- "overlay",
- "shell",
- "version",
- "xref"
- ].
-
-unabbreviate_command_names([]) ->
- [];
-unabbreviate_command_names([Command | Commands]) ->
- case get_command_name_candidates(Command) of
- [] ->
- %% let the rest of the code detect that the command doesn't exist
- %% (this would perhaps be a good place to fail)
- [Command | unabbreviate_command_names(Commands)];
- [FullCommand] ->
- [FullCommand | unabbreviate_command_names(Commands)];
- Candidates ->
- ?ABORT("Found more than one match for abbreviated command name "
- " '~s',~nplease be more specific. Possible candidates:~n"
- " ~s~n",
- [Command, string:join(Candidates, ", ")])
- end.
-
-get_command_name_candidates(Command) ->
- %% Get the command names which match the given (abbreviated) command name.
- %% * "c" matches commands like compile, clean and create-app
- %% * "create" matches command create only, since it's unique
- %% * "create-" matches commands starting with create-
- %% * "c-a" matches create-app
- %% * "create-a" matches create-app
- %% * "c-app" matches create-app
- Candidates = [Candidate || Candidate <- command_names(),
- is_command_name_candidate(Command, Candidate)],
- %% Is there a complete match? If so return only that, return a
- %% list of candidates otherwise
- case lists:member(Command, Candidates) of
- true -> [Command];
- false -> Candidates
- end.
-
-is_command_name_candidate(Command, Candidate) ->
- lists:prefix(Command, Candidate)
- orelse is_command_name_sub_word_candidate(Command, Candidate).
-
-is_command_name_sub_word_candidate(Command, Candidate) ->
- %% Allow for parts of commands to be abbreviated, i.e. create-app
- %% can be shortened to "create-a", "c-a" or "c-app" (but not
- %% "create-" since that would be ambiguous).
- ReOpts = [{return, list}],
- CommandSubWords = re:split(Command, "-", ReOpts),
- CandidateSubWords = re:split(Candidate, "-", ReOpts),
- is_command_name_sub_word_candidate_aux(CommandSubWords, CandidateSubWords).
-
-is_command_name_sub_word_candidate_aux([CmdSW | CmdSWs],
- [CandSW | CandSWs]) ->
- lists:prefix(CmdSW, CandSW) andalso
- is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs);
-is_command_name_sub_word_candidate_aux([], []) ->
- true;
-is_command_name_sub_word_candidate_aux(_CmdSWs, _CandSWs) ->
- false.
diff --git a/src/rebar/src/rebar_abnfc_compiler.erl b/src/rebar/src/rebar_abnfc_compiler.erl
deleted file mode 100644
index 37731b579..000000000
--- a/src/rebar/src/rebar_abnfc_compiler.erl
+++ /dev/null
@@ -1,123 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2010 Anthony Ramine (nox@dev-extend.eu),
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-
-%% The rebar_abnfc_compiler module is a plugin for rebar that compiles
-%% ABNF grammars into parsers. By default, it compiles all src/*.abnf
-%% to src/*.erl.
-%%
-%% Configuration options should be placed in rebar.config under
-%% 'abnfc_opts'. Available options include:
-%%
-%% doc_root: where to find the ABNF grammars to compile
-%% "src" by default
-%%
-%% out_dir: where to put the generated files.
-%% "src" by default
-%%
-%% source_ext: the file extension the ABNF grammars have.
-%% ".abnf" by default
-%%
-%% module_ext: characters to append to the parser's module name
-%% "" by default
--module(rebar_abnfc_compiler).
-
--export([compile/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-compile(Config, _AppFile) ->
- DtlOpts = abnfc_opts(Config),
- rebar_base_compiler:run(Config, [],
- option(doc_root, DtlOpts),
- option(source_ext, DtlOpts),
- option(out_dir, DtlOpts),
- option(module_ext, DtlOpts) ++ ".erl",
- fun compile_abnfc/3).
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- ?CONSOLE(
- "Build ABNF (*.abnf) sources.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n",
- [
- {abnfc_opts, [{doc_root, "src"},
- {out_dir, "src"},
- {source_ext, ".abnfc"},
- {module_ext, ""}]}
- ]).
-
-abnfc_opts(Config) ->
- rebar_config:get(Config, abnfc_opts, []).
-
-option(Opt, DtlOpts) ->
- proplists:get_value(Opt, DtlOpts, default(Opt)).
-
-default(doc_root) -> "src";
-default(out_dir) -> "src";
-default(source_ext) -> ".abnf";
-default(module_ext) -> "".
-
-abnfc_is_present() ->
- code:which(abnfc) =/= non_existing.
-
-compile_abnfc(Source, _Target, Config) ->
- case abnfc_is_present() of
- false ->
- ?ERROR("~n===============================================~n"
- " You need to install abnfc to compile ABNF grammars~n"
- " Download the latest tarball release from github~n"
- " https://github.com/nygge/abnfc~n"
- " and install it into your erlang library dir~n"
- "===============================================~n~n", []),
- ?FAIL;
- true ->
- AbnfcOpts = abnfc_opts(Config),
- SourceExt = option(source_ext, AbnfcOpts),
- Opts = [noobj,
- {o, option(out_dir, AbnfcOpts)},
- {mod, filename:basename(Source, SourceExt) ++
- option(module_ext, AbnfcOpts)}],
- case abnfc:file(Source, Opts) of
- ok -> ok;
- Error ->
- ?ERROR("Compiling grammar ~s failed:~n ~p~n",
- [Source, Error]),
- ?FAIL
- end
- end.
diff --git a/src/rebar/src/rebar_app_utils.erl b/src/rebar/src/rebar_app_utils.erl
deleted file mode 100644
index 8158eb6cc..000000000
--- a/src/rebar/src/rebar_app_utils.erl
+++ /dev/null
@@ -1,208 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_app_utils).
-
--export([is_app_dir/0, is_app_dir/1,
- is_app_src/1,
- app_src_to_app/1,
- app_name/2,
- app_applications/2,
- app_vsn/2,
- is_skipped_app/2]).
-
--export([load_app_file/2]). % TEMPORARY
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-is_app_dir() ->
- is_app_dir(rebar_utils:get_cwd()).
-
-is_app_dir(Dir) ->
- SrcDir = filename:join([Dir, "src"]),
- AppSrc = filename:join([SrcDir, "*.app.src"]),
- case filelib:wildcard(AppSrc) of
- [AppSrcFile] ->
- {true, AppSrcFile};
- [] ->
- EbinDir = filename:join([Dir, "ebin"]),
- App = filename:join([EbinDir, "*.app"]),
- case filelib:wildcard(App) of
- [AppFile] ->
- {true, AppFile};
- [] ->
- false;
- _ ->
- ?ERROR("More than one .app file in ~s~n", [EbinDir]),
- false
- end;
- _ ->
- ?ERROR("More than one .app.src file in ~s~n", [SrcDir]),
- false
- end.
-
-
-is_app_src(Filename) ->
- %% If removing the extension .app.src yields a shorter name,
- %% this is an .app.src file.
- Filename =/= filename:rootname(Filename, ".app.src").
-
-app_src_to_app(Filename) ->
- filename:join("ebin", filename:basename(Filename, ".app.src") ++ ".app").
-
-app_name(Config, AppFile) ->
- case load_app_file(Config, AppFile) of
- {ok, NewConfig, AppName, _} ->
- {NewConfig, AppName};
- {error, Reason} ->
- ?ABORT("Failed to extract name from ~s: ~p\n",
- [AppFile, Reason])
- end.
-
-app_applications(Config, AppFile) ->
- case load_app_file(Config, AppFile) of
- {ok, NewConfig, _, AppInfo} ->
- {NewConfig, get_value(applications, AppInfo, AppFile)};
- {error, Reason} ->
- ?ABORT("Failed to extract applications from ~s: ~p\n",
- [AppFile, Reason])
- end.
-
-app_vsn(Config, AppFile) ->
- case load_app_file(Config, AppFile) of
- {ok, Config1, _, AppInfo} ->
- AppDir = filename:dirname(filename:dirname(AppFile)),
- rebar_utils:vcs_vsn(Config1, get_value(vsn, AppInfo, AppFile),
- AppDir);
- {error, Reason} ->
- ?ABORT("Failed to extract vsn from ~s: ~p\n",
- [AppFile, Reason])
- end.
-
-is_skipped_app(Config, AppFile) ->
- {Config1, ThisApp} = app_name(Config, AppFile),
- %% Check for apps global parameter; this is a comma-delimited list
- %% of apps on which we want to run commands
- Skipped =
- case get_apps(Config) of
- undefined ->
- %% No apps parameter specified, check the skip_apps list..
- case get_skip_apps(Config) of
- undefined ->
- %% No skip_apps list, run everything..
- false;
- SkipApps ->
- TargetApps = [list_to_atom(A) ||
- A <- string:tokens(SkipApps, ",")],
- is_skipped(ThisApp, TargetApps)
- end;
- Apps ->
- %% run only selected apps
- TargetApps = [list_to_atom(A) || A <- string:tokens(Apps, ",")],
- is_selected(ThisApp, TargetApps)
- end,
- {Config1, Skipped}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-load_app_file(Config, Filename) ->
- AppFile = {app_file, Filename},
- case rebar_config:get_xconf(Config, {appfile, AppFile}, undefined) of
- undefined ->
- case consult_app_file(Filename) of
- {ok, [{application, AppName, AppData}]} ->
- Config1 = rebar_config:set_xconf(Config,
- {appfile, AppFile},
- {AppName, AppData}),
- {ok, Config1, AppName, AppData};
- {error, _} = Error ->
- Error;
- Other ->
- {error, {unexpected_terms, Other}}
- end;
- {AppName, AppData} ->
- {ok, Config, AppName, AppData}
- end.
-
-%% In the case of *.app.src we want to give the user the ability to
-%% dynamically script the application resource file (think dynamic version
-%% string, etc.), in a way similar to what can be done with the rebar
-%% config. However, in the case of *.app, rebar should not manipulate
-%% that file. This enforces that dichotomy between app and app.src.
-consult_app_file(Filename) ->
- case lists:suffix(".app.src", Filename) of
- false ->
- file:consult(Filename);
- true ->
- %% TODO: EXPERIMENTAL For now let's warn the user if a
- %% script is going to be run.
- case filelib:is_regular([Filename, ".script"]) of
- true ->
- ?CONSOLE("NOTICE: Using experimental *.app.src.script "
- "functionality on ~s ~n", [Filename]);
- _ ->
- ok
- end,
- rebar_config:consult_file(Filename)
- end.
-
-get_value(Key, AppInfo, AppFile) ->
- case proplists:get_value(Key, AppInfo) of
- undefined ->
- ?ABORT("Failed to get app value '~p' from '~s'~n", [Key, AppFile]);
- Value ->
- Value
- end.
-
-%% apps= for selecting apps
-is_selected(ThisApp, TargetApps) ->
- case lists:member(ThisApp, TargetApps) of
- false ->
- {true, ThisApp};
- true ->
- false
- end.
-
-%% skip_apps= for filtering apps
-is_skipped(ThisApp, TargetApps) ->
- case lists:member(ThisApp, TargetApps) of
- false ->
- false;
- true ->
- {true, ThisApp}
- end.
-
-get_apps(Config) ->
- rebar_config:get_global(Config, apps, undefined).
-
-get_skip_apps(Config) ->
- rebar_config:get_global(Config, skip_apps, undefined).
diff --git a/src/rebar/src/rebar_appups.erl b/src/rebar/src/rebar_appups.erl
deleted file mode 100644
index 722f161e9..000000000
--- a/src/rebar/src/rebar_appups.erl
+++ /dev/null
@@ -1,210 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2011 Joe Williams (joe@joetify.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% ------------------------------------------------------------------
-
--module(rebar_appups).
-
--include("rebar.hrl").
-
--export(['generate-appups'/2]).
-
-%% for internal use only
--export([info/2]).
-
--define(APPUPFILEFORMAT, "%% appup generated for ~p by rebar (~p)~n"
- "{~p, [{~p, ~p}], [{~p, []}]}.~n").
-
-%% ====================================================================
-%% Public API
-%% ====================================================================
-
-'generate-appups'(Config, ReltoolFile) ->
- %% Get the old release path
- {Config1, ReltoolConfig} = rebar_rel_utils:load_config(Config, ReltoolFile),
- TargetParentDir = rebar_rel_utils:get_target_parent_dir(Config,
- ReltoolConfig),
-
- PrevRelPath = rebar_rel_utils:get_previous_release_path(Config),
- OldVerPath = filename:join([TargetParentDir, PrevRelPath]),
-
- %% Get the new and old release name and versions
- {Name, _Ver} = rebar_rel_utils:get_reltool_release_info(ReltoolConfig),
- NewVerPath = filename:join([TargetParentDir, Name]),
- {NewName, NewVer} = rebar_rel_utils:get_rel_release_info(Name, NewVerPath),
- {OldName, OldVer} = rebar_rel_utils:get_rel_release_info(Name, OldVerPath),
-
- %% Run some simple checks
- true = rebar_utils:prop_check(NewVer =/= OldVer,
- "New and old .rel versions match~n", []),
- true = rebar_utils:prop_check(
- NewName == OldName,
- "Reltool and .rel release names do not match~n", []),
-
- %% Find all the apps that have been upgraded
- {_Added, _Removed, Upgraded} = get_apps(Name, OldVerPath, NewVerPath),
-
- %% Get a list of any appup files that exist in the new release
- NewAppUpFiles = rebar_utils:find_files(
- filename:join([NewVerPath, "lib"]), "^.*.appup$"),
-
- %% Convert the list of appup files into app names
- AppUpApps = [file_to_name(File) || File <- NewAppUpFiles],
-
- %% Create a list of apps that don't already have appups
- UpgradeApps = genappup_which_apps(Upgraded, AppUpApps),
-
- %% Generate appup files for upgraded apps
- generate_appup_files(NewVerPath, OldVerPath, UpgradeApps),
-
- {ok, Config1}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, 'generate-appups') ->
- ?CONSOLE("Generate appup files.~n"
- "~n"
- "Valid command line options:~n"
- " previous_release=path~n",
- []).
-
-get_apps(Name, OldVerPath, NewVerPath) ->
- OldApps = rebar_rel_utils:get_rel_apps(Name, OldVerPath),
- ?DEBUG("Old Version Apps: ~p~n", [OldApps]),
-
- NewApps = rebar_rel_utils:get_rel_apps(Name, NewVerPath),
- ?DEBUG("New Version Apps: ~p~n", [NewApps]),
-
- Added = app_list_diff(NewApps, OldApps),
- ?DEBUG("Added: ~p~n", [Added]),
-
- Removed = app_list_diff(OldApps, NewApps),
- ?DEBUG("Removed: ~p~n", [Removed]),
-
- PossiblyUpgraded = proplists:get_keys(NewApps),
-
- UpgradedApps = [upgraded_app(AppName,
- proplists:get_value(AppName, OldApps),
- proplists:get_value(AppName, NewApps))
- || AppName <- PossiblyUpgraded],
-
- Upgraded = lists:dropwhile(fun(Elem) ->
- Elem == false
- end, lists:sort(UpgradedApps)),
-
- ?DEBUG("Upgraded: ~p~n", [Upgraded]),
-
- {Added, Removed, Upgraded}.
-
-upgraded_app(AppName, OldAppVer, NewAppVer) when OldAppVer /= NewAppVer ->
- {AppName, {OldAppVer, NewAppVer}};
-upgraded_app(_, _, _) ->
- false.
-
-app_list_diff(List1, List2) ->
- List3 = lists:umerge(lists:sort(proplists:get_keys(List1)),
- lists:sort(proplists:get_keys(List2))),
- List3 -- proplists:get_keys(List2).
-
-file_to_name(File) ->
- filename:rootname(filename:basename(File)).
-
-genappup_which_apps(UpgradedApps, [First|Rest]) ->
- List = proplists:delete(list_to_atom(First), UpgradedApps),
- genappup_which_apps(List, Rest);
-genappup_which_apps(Apps, []) ->
- Apps.
-
-generate_appup_files(NewVerPath, OldVerPath, [{_App, {undefined, _}}|Rest]) ->
- generate_appup_files(NewVerPath, OldVerPath, Rest);
-generate_appup_files(NewVerPath, OldVerPath, [{App, {OldVer, NewVer}}|Rest]) ->
- OldEbinDir = filename:join([OldVerPath, "lib",
- atom_to_list(App) ++ "-" ++ OldVer, "ebin"]),
- NewEbinDir = filename:join([NewVerPath, "lib",
- atom_to_list(App) ++ "-" ++ NewVer, "ebin"]),
-
- {AddedFiles, DeletedFiles, ChangedFiles} = beam_lib:cmp_dirs(NewEbinDir,
- OldEbinDir),
-
- Added = [generate_instruction(added, File) || File <- AddedFiles],
- Deleted = [generate_instruction(deleted, File) || File <- DeletedFiles],
- Changed = [generate_instruction(changed, File) || File <- ChangedFiles],
-
- Inst = lists:append([Added, Deleted, Changed]),
-
- AppUpFile = filename:join([NewEbinDir, atom_to_list(App) ++ ".appup"]),
-
- ok = file:write_file(AppUpFile,
- io_lib:fwrite(?APPUPFILEFORMAT,
- [App, rebar_utils:now_str(), NewVer,
- OldVer, Inst, OldVer])),
-
- ?CONSOLE("Generated appup for ~p~n", [App]),
- generate_appup_files(NewVerPath, OldVerPath, Rest);
-generate_appup_files(_, _, []) ->
- ?CONSOLE("Appup generation complete~n", []).
-
-generate_instruction(added, File) ->
- Name = list_to_atom(file_to_name(File)),
- {add_module, Name};
-generate_instruction(deleted, File) ->
- Name = list_to_atom(file_to_name(File)),
- {delete_module, Name};
-generate_instruction(changed, {File, _}) ->
- {ok, {Name, List}} = beam_lib:chunks(File, [attributes, exports]),
- Behavior = get_behavior(List),
- CodeChange = is_code_change(List),
- generate_instruction_advanced(Name, Behavior, CodeChange).
-
-generate_instruction_advanced(Name, undefined, undefined) ->
- %% Not a behavior or code change, assume purely functional
- {load_module, Name};
-generate_instruction_advanced(Name, [supervisor], _) ->
- %% Supervisor
- {update, Name, supervisor};
-generate_instruction_advanced(Name, _, code_change) ->
- %% Includes code_change export
- {update, Name, {advanced, []}};
-generate_instruction_advanced(Name, _, _) ->
- %% Anything else
- {load_module, Name}.
-
-get_behavior(List) ->
- Attributes = proplists:get_value(attributes, List),
- case proplists:get_value(behavior, Attributes) of
- undefined -> proplists:get_value(behaviour, Attributes);
- Else -> Else
- end.
-
-is_code_change(List) ->
- Exports = proplists:get_value(exports, List),
- case proplists:is_defined(code_change, Exports) of
- true ->
- code_change;
- false ->
- undefined
- end.
diff --git a/src/rebar/src/rebar_asn1_compiler.erl b/src/rebar/src/rebar_asn1_compiler.erl
deleted file mode 100644
index 25e3fd3ab..000000000
--- a/src/rebar/src/rebar_asn1_compiler.erl
+++ /dev/null
@@ -1,100 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009, 2010 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_asn1_compiler).
--author('ruslan@babayev.com').
-
--export([compile/2,
- clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
--spec compile(rebar_config:config(), file:filename()) -> 'ok'.
-compile(Config, _AppFile) ->
- rebar_base_compiler:run(Config, filelib:wildcard("asn1/*.asn1"),
- "asn1", ".asn1", "src", ".erl",
- fun compile_asn1/3).
-
--spec clean(rebar_config:config(), file:filename()) -> 'ok'.
-clean(_Config, _AppFile) ->
- GeneratedFiles = asn_generated_files("asn1", "src", "include"),
- ok = rebar_file_utils:delete_each(GeneratedFiles),
- ok.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- info_help("Build ASN.1 (*.asn1) sources");
-info(help, clean) ->
- info_help("Delete ASN.1 (*.asn1) results").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " {asn1_opts, []} (see asn1ct:compile/2 documentation)~n",
- [Description]).
-
--spec compile_asn1(file:filename(), file:filename(),
- rebar_config:config()) -> ok.
-compile_asn1(Source, Target, Config) ->
- ok = filelib:ensure_dir(Target),
- ok = filelib:ensure_dir(filename:join("include", "dummy.hrl")),
- Opts = [{outdir, "src"}, noobj] ++ rebar_config:get(Config, asn1_opts, []),
- case asn1ct:compile(Source, Opts) of
- ok ->
- Asn1 = filename:basename(Source, ".asn1"),
- HrlFile = filename:join("src", Asn1 ++ ".hrl"),
- case filelib:is_regular(HrlFile) of
- true ->
- ok = rebar_file_utils:mv(HrlFile, "include");
- false ->
- ok
- end;
- {error, _Reason} ->
- ?FAIL
- end.
-
-asn_generated_files(AsnDir, SrcDir, IncDir) ->
- lists:foldl(
- fun(AsnFile, Acc) ->
- Base = filename:rootname(filename:basename(AsnFile)),
- [filename:join([IncDir, Base ++ ".hrl"])|
- filelib:wildcard(filename:join([SrcDir, Base ++ ".*"]))] ++ Acc
- end,
- [],
- filelib:wildcard(filename:join([AsnDir, "*.asn1"]))
- ).
diff --git a/src/rebar/src/rebar_base_compiler.erl b/src/rebar/src/rebar_base_compiler.erl
deleted file mode 100644
index a0dec3092..000000000
--- a/src/rebar/src/rebar_base_compiler.erl
+++ /dev/null
@@ -1,260 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_base_compiler).
-
--include("rebar.hrl").
-
--export([run/4, run/7, run/8,
- ok_tuple/3, error_tuple/5]).
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-run(Config, FirstFiles, RestFiles, CompileFn) ->
- %% Compile the first files in sequence
- compile_each(FirstFiles, Config, CompileFn),
-
- %% Spin up workers for the rest of the files
- case RestFiles of
- [] ->
- ok;
- _ ->
- Self = self(),
- F = fun() -> compile_worker(Self, Config, CompileFn) end,
- Jobs = rebar:get_jobs(Config),
- ?DEBUG("Starting ~B compile worker(s)~n", [Jobs]),
- Pids = [spawn_monitor(F) || _I <- lists:seq(1,Jobs)],
- compile_queue(Pids, RestFiles)
- end.
-
-run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
- Compile3Fn) ->
- run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
- Compile3Fn, [check_last_mod]).
-
-run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
- Compile3Fn, Opts) ->
- %% Convert simple extension to proper regex
- SourceExtRe = ".*\\" ++ SourceExt ++ [$$],
-
- Recursive = proplists:get_value(recursive, Opts, true),
- %% Find all possible source files
- FoundFiles = rebar_utils:find_files(SourceDir, SourceExtRe, Recursive),
- %% Remove first files from found files
- RestFiles = [Source || Source <- FoundFiles,
- not lists:member(Source, FirstFiles)],
-
- %% Check opts for flag indicating that compile should check lastmod
- CheckLastMod = proplists:get_bool(check_last_mod, Opts),
-
- run(Config, FirstFiles, RestFiles,
- fun(S, C) ->
- Target = target_file(S, SourceDir, SourceExt,
- TargetDir, TargetExt),
- simple_compile_wrapper(S, Target, Compile3Fn, C, CheckLastMod)
- end).
-
-ok_tuple(Config, Source, Ws) ->
- {ok, format_warnings(Config, Source, Ws)}.
-
-error_tuple(Config, Source, Es, Ws, Opts) ->
- {error, format_errors(Config, Source, Es),
- format_warnings(Config, Source, Ws, Opts)}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-simple_compile_wrapper(Source, Target, Compile3Fn, Config, false) ->
- Compile3Fn(Source, Target, Config);
-simple_compile_wrapper(Source, Target, Compile3Fn, Config, true) ->
- case filelib:last_modified(Target) < filelib:last_modified(Source) of
- true ->
- Compile3Fn(Source, Target, Config);
- false ->
- skipped
- end.
-
-target_file(SourceFile, SourceDir, SourceExt, TargetDir, TargetExt) ->
- %% Remove all leading components of the source dir from the file -- we want
- %% to maintain the deeper structure (if any) of the source file path
- BaseFile = remove_common_path(SourceFile, SourceDir),
- filename:join([TargetDir, filename:dirname(BaseFile),
- filename:basename(BaseFile, SourceExt) ++ TargetExt]).
-
-
-remove_common_path(Fname, Path) ->
- remove_common_path1(filename:split(Fname), filename:split(Path)).
-
-remove_common_path1([Part | RestFilename], [Part | RestPath]) ->
- remove_common_path1(RestFilename, RestPath);
-remove_common_path1(FilenameParts, _) ->
- filename:join(FilenameParts).
-
-
-compile(Source, Config, CompileFn) ->
- case CompileFn(Source, Config) of
- ok ->
- ok;
- skipped ->
- skipped;
- Error ->
- Error
- end.
-
-compile_each([], _Config, _CompileFn) ->
- ok;
-compile_each([Source | Rest], Config, CompileFn) ->
- case compile(Source, Config, CompileFn) of
- ok ->
- ?CONSOLE("Compiled ~s\n", [Source]);
- {ok, Warnings} ->
- report(Warnings),
- ?CONSOLE("Compiled ~s\n", [Source]);
- skipped ->
- ?INFO("Skipped ~s\n", [Source]);
- Error ->
- maybe_report(Error),
- ?DEBUG("Compilation failed: ~p\n", [Error]),
- ?FAIL
- end,
- compile_each(Rest, Config, CompileFn).
-
-compile_queue([], []) ->
- ok;
-compile_queue(Pids, Targets) ->
- receive
- {next, Worker} ->
- case Targets of
- [] ->
- Worker ! empty,
- compile_queue(Pids, Targets);
- [Source | Rest] ->
- Worker ! {compile, Source},
- compile_queue(Pids, Rest)
- end;
-
- {fail, Error} ->
- maybe_report(Error),
- ?DEBUG("Worker compilation failed: ~p\n", [Error]),
- ?FAIL;
-
- {compiled, Source, Warnings} ->
- report(Warnings),
- ?CONSOLE("Compiled ~s\n", [Source]),
- compile_queue(Pids, Targets);
-
- {compiled, Source} ->
- ?CONSOLE("Compiled ~s\n", [Source]),
- compile_queue(Pids, Targets);
-
- {skipped, Source} ->
- ?INFO("Skipped ~s\n", [Source]),
- compile_queue(Pids, Targets);
-
- {'DOWN', Mref, _, Pid, normal} ->
- ?DEBUG("Worker exited cleanly\n", []),
- Pids2 = lists:delete({Pid, Mref}, Pids),
- compile_queue(Pids2, Targets);
-
- {'DOWN', _Mref, _, _Pid, Info} ->
- ?DEBUG("Worker failed: ~p\n", [Info]),
- ?FAIL
- end.
-
-compile_worker(QueuePid, Config, CompileFn) ->
- QueuePid ! {next, self()},
- receive
- {compile, Source} ->
- case catch(compile(Source, Config, CompileFn)) of
- {ok, Ws} ->
- QueuePid ! {compiled, Source, Ws},
- compile_worker(QueuePid, Config, CompileFn);
- ok ->
- QueuePid ! {compiled, Source},
- compile_worker(QueuePid, Config, CompileFn);
- skipped ->
- QueuePid ! {skipped, Source},
- compile_worker(QueuePid, Config, CompileFn);
- Error ->
- QueuePid ! {fail, [{error, Error},
- {source, Source}]},
- ok
- end;
-
- empty ->
- ok
- end.
-
-format_errors(Config, Source, Errors) ->
- format_errors(Config, Source, "", Errors).
-
-format_warnings(Config, Source, Warnings) ->
- format_warnings(Config, Source, Warnings, []).
-
-format_warnings(Config, Source, Warnings, Opts) ->
- Prefix = case lists:member(warnings_as_errors, Opts) of
- true -> "";
- false -> "Warning: "
- end,
- format_errors(Config, Source, Prefix, Warnings).
-
-maybe_report([{error, {error, _Es, _Ws}=ErrorsAndWarnings}, {source, _}]) ->
- maybe_report(ErrorsAndWarnings);
-maybe_report([{error, E}, {source, S}]) ->
- report(["unexpected error compiling " ++ S, io_lib:fwrite("~n~p~n", [E])]);
-maybe_report({error, Es, Ws}) ->
- report(Es),
- report(Ws);
-maybe_report(_) ->
- ok.
-
-report(Messages) ->
- lists:foreach(fun(Msg) -> io:format("~s", [Msg]) end, Messages).
-
-format_errors(Config, _MainSource, Extra, Errors) ->
- [begin
- AbsSource = case rebar_utils:processing_base_dir(Config) of
- true ->
- Source;
- false ->
- filename:absname(Source)
- end,
- [format_error(AbsSource, Extra, Desc) || Desc <- Descs]
- end
- || {Source, Descs} <- Errors].
-
-format_error(AbsSource, Extra, {{Line, Column}, Mod, Desc}) ->
- ErrorDesc = Mod:format_error(Desc),
- ?FMT("~s:~w:~w: ~s~s~n", [AbsSource, Line, Column, Extra, ErrorDesc]);
-format_error(AbsSource, Extra, {Line, Mod, Desc}) ->
- ErrorDesc = Mod:format_error(Desc),
- ?FMT("~s:~w: ~s~s~n", [AbsSource, Line, Extra, ErrorDesc]);
-format_error(AbsSource, Extra, {Mod, Desc}) ->
- ErrorDesc = Mod:format_error(Desc),
- ?FMT("~s: ~s~s~n", [AbsSource, Extra, ErrorDesc]).
diff --git a/src/rebar/src/rebar_cleaner.erl b/src/rebar/src/rebar_cleaner.erl
deleted file mode 100644
index 7a762f548..000000000
--- a/src/rebar/src/rebar_cleaner.erl
+++ /dev/null
@@ -1,56 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_cleaner).
-
--export([clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-clean(Config, _AppFile) ->
- %% Get a list of files to delete from config and remove them
- FilesToClean = rebar_config:get(Config, clean_files, []),
- lists:foreach(fun (F) -> rebar_file_utils:rm_rf(F) end, FilesToClean).
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, clean) ->
- ?CONSOLE(
- "Delete list of files.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n",
- [
- {clean_files, ["file", "file2"]}
- ]).
diff --git a/src/rebar/src/rebar_config.erl b/src/rebar/src/rebar_config.erl
deleted file mode 100644
index 461de5def..000000000
--- a/src/rebar/src/rebar_config.erl
+++ /dev/null
@@ -1,249 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_config).
-
--export([new/0, new/1, base_config/1, consult_file/1,
- get/3, get_local/3, get_list/3,
- get_all/2,
- set/3,
- set_global/3, get_global/3,
- is_verbose/1,
- save_env/3, get_env/2, reset_envs/1,
- set_skip_dir/2, is_skip_dir/2, reset_skip_dirs/1,
- clean_config/2,
- set_xconf/3, get_xconf/2, get_xconf/3, erase_xconf/2]).
-
--include("rebar.hrl").
-
--record(config, { dir :: file:filename(),
- opts = [] :: list(),
- globals = new_globals() :: dict(),
- envs = new_env() :: dict(),
- %% cross-directory/-command config
- skip_dirs = new_skip_dirs() :: dict(),
- xconf = new_xconf() :: dict() }).
-
--export_type([config/0]).
-
--opaque config() :: #config{}.
-
--define(DEFAULT_NAME, "rebar.config").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-base_config(GlobalConfig) ->
- ConfName = rebar_config:get_global(GlobalConfig, config, ?DEFAULT_NAME),
- new(GlobalConfig, ConfName).
-
-new() ->
- #config{dir = rebar_utils:get_cwd()}.
-
-new(ConfigFile) when is_list(ConfigFile) ->
- case consult_file(ConfigFile) of
- {ok, Opts} ->
- #config { dir = rebar_utils:get_cwd(),
- opts = Opts };
- Other ->
- ?ABORT("Failed to load ~s: ~p~n", [ConfigFile, Other])
- end;
-new(_ParentConfig=#config{opts=Opts0, globals=Globals, skip_dirs=SkipDirs,
- xconf=Xconf}) ->
- new(#config{opts=Opts0, globals=Globals, skip_dirs=SkipDirs, xconf=Xconf},
- ?DEFAULT_NAME).
-
-get(Config, Key, Default) ->
- proplists:get_value(Key, Config#config.opts, Default).
-
-get_list(Config, Key, Default) ->
- get(Config, Key, Default).
-
-get_local(Config, Key, Default) ->
- proplists:get_value(Key, local_opts(Config#config.opts, []), Default).
-
-get_all(Config, Key) ->
- proplists:get_all_values(Key, Config#config.opts).
-
-set(Config, Key, Value) ->
- Opts = proplists:delete(Key, Config#config.opts),
- Config#config { opts = [{Key, Value} | Opts] }.
-
-set_global(Config, jobs=Key, Value) when is_list(Value) ->
- set_global(Config, Key, list_to_integer(Value));
-set_global(Config, jobs=Key, Value) when is_integer(Value) ->
- NewGlobals = dict:store(Key, erlang:max(1, Value), Config#config.globals),
- Config#config{globals = NewGlobals};
-set_global(Config, Key, Value) ->
- NewGlobals = dict:store(Key, Value, Config#config.globals),
- Config#config{globals = NewGlobals}.
-
-get_global(Config, Key, Default) ->
- case dict:find(Key, Config#config.globals) of
- error ->
- Default;
- {ok, Value} ->
- Value
- end.
-
-is_verbose(Config) ->
- DefaulLevel = rebar_log:default_level(),
- get_global(Config, verbose, DefaulLevel) > DefaulLevel.
-
-consult_file(File) ->
- case filename:extension(File) of
- ".script" ->
- consult_and_eval(remove_script_ext(File), File);
- _ ->
- Script = File ++ ".script",
- case filelib:is_regular(Script) of
- true ->
- consult_and_eval(File, Script);
- false ->
- ?DEBUG("Consult config file ~p~n", [File]),
- file:consult(File)
- end
- end.
-
-save_env(Config, Mod, Env) ->
- NewEnvs = dict:store(Mod, Env, Config#config.envs),
- Config#config{envs = NewEnvs}.
-
-get_env(Config, Mod) ->
- dict:fetch(Mod, Config#config.envs).
-
-reset_envs(Config) ->
- Config#config{envs = new_env()}.
-
-set_skip_dir(Config, Dir) ->
- OldSkipDirs = Config#config.skip_dirs,
- NewSkipDirs = case is_skip_dir(Config, Dir) of
- false ->
- ?DEBUG("Adding skip dir: ~s\n", [Dir]),
- dict:store(Dir, true, OldSkipDirs);
- true ->
- OldSkipDirs
- end,
- Config#config{skip_dirs = NewSkipDirs}.
-
-is_skip_dir(Config, Dir) ->
- dict:is_key(Dir, Config#config.skip_dirs).
-
-reset_skip_dirs(Config) ->
- Config#config{skip_dirs = new_skip_dirs()}.
-
-set_xconf(Config, Key, Value) ->
- NewXconf = dict:store(Key, Value, Config#config.xconf),
- Config#config{xconf=NewXconf}.
-
-get_xconf(Config, Key) ->
- {ok, Value} = dict:find(Key, Config#config.xconf),
- Value.
-
-get_xconf(Config, Key, Default) ->
- case dict:find(Key, Config#config.xconf) of
- error ->
- Default;
- {ok, Value} ->
- Value
- end.
-
-erase_xconf(Config, Key) ->
- NewXconf = dict:erase(Key, Config#config.xconf),
- Config#config{xconf = NewXconf}.
-
-%% TODO: reconsider after config inheritance removal/redesign
-clean_config(Old, New) ->
- New#config{opts=Old#config.opts}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-new(ParentConfig, ConfName) ->
- %% Load terms from rebar.config, if it exists
- Dir = rebar_utils:get_cwd(),
- ConfigFile = filename:join([Dir, ConfName]),
- Opts0 = ParentConfig#config.opts,
- Opts = case consult_file(ConfigFile) of
- {ok, Terms} ->
- %% Found a config file with some terms. We need to
- %% be able to distinguish between local definitions
- %% (i.e. from the file in the cwd) and inherited
- %% definitions. To accomplish this, we use a marker
- %% in the proplist (since order matters) between
- %% the new and old defs.
- Terms ++ [local] ++
- [Opt || Opt <- Opts0, Opt /= local];
- {error, enoent} ->
- [local] ++
- [Opt || Opt <- Opts0, Opt /= local];
- Other ->
- ?ABORT("Failed to load ~s: ~p\n", [ConfigFile, Other])
- end,
-
- ParentConfig#config{dir = Dir, opts = Opts}.
-
-consult_and_eval(File, Script) ->
- ?DEBUG("Evaluating config script ~p~n", [Script]),
- ConfigData = try_consult(File),
- file:script(Script, bs([{'CONFIG', ConfigData}, {'SCRIPT', Script}])).
-
-remove_script_ext(F) ->
- "tpircs." ++ Rev = lists:reverse(F),
- lists:reverse(Rev).
-
-try_consult(File) ->
- case file:consult(File) of
- {ok, Terms} ->
- ?DEBUG("Consult config file ~p~n", [File]),
- Terms;
- {error, enoent} ->
- [];
- {error, Reason} ->
- ?ABORT("Failed to read config file ~s: ~p~n", [File, Reason])
- end.
-
-bs(Vars) ->
- lists:foldl(fun({K,V}, Bs) ->
- erl_eval:add_binding(K, V, Bs)
- end, erl_eval:new_bindings(), Vars).
-
-local_opts([], Acc) ->
- lists:reverse(Acc);
-local_opts([local | _Rest], Acc) ->
- lists:reverse(Acc);
-local_opts([Item | Rest], Acc) ->
- local_opts(Rest, [Item | Acc]).
-
-new_globals() -> dict:new().
-
-new_env() -> dict:new().
-
-new_skip_dirs() -> dict:new().
-
-new_xconf() -> dict:new().
diff --git a/src/rebar/src/rebar_core.erl b/src/rebar/src/rebar_core.erl
deleted file mode 100644
index 631cef223..000000000
--- a/src/rebar/src/rebar_core.erl
+++ /dev/null
@@ -1,608 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_core).
-
--export([process_commands/2, help/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-help(ParentConfig, Commands) ->
- %% get all core modules
- {ok, AnyDirModules} = application:get_env(rebar, any_dir_modules),
- {ok, RawCoreModules} = application:get_env(rebar, modules),
- AppDirModules = proplists:get_value(app_dir, RawCoreModules),
- RelDirModules = proplists:get_value(rel_dir, RawCoreModules),
- CoreModules = AnyDirModules ++ AppDirModules ++ RelDirModules,
-
- %% get plugin modules
- Predirs = [],
- Dir = rebar_utils:get_cwd(),
- PredirsAssoc = remember_cwd_predirs(Dir, Predirs),
- Config = maybe_load_local_config(Dir, ParentConfig),
- {ok, PluginModules} = plugin_modules(Config, PredirsAssoc),
-
- AllModules = CoreModules ++ PluginModules,
-
- lists:foreach(
- fun(Cmd) ->
- ?CONSOLE("==> help ~p~n~n", [Cmd]),
- CmdModules = select_modules(AllModules, Cmd, []),
- Modules = select_modules(CmdModules, info, []),
- lists:foreach(fun(M) ->
- ?CONSOLE("=== ~p:~p ===~n", [M, Cmd]),
- M:info(help, Cmd),
- ?CONSOLE("~n", [])
- end, Modules)
- end, Commands).
-
-process_commands([], ParentConfig) ->
- AbortTrapped = rebar_config:get_xconf(ParentConfig, abort_trapped, false),
- case {get_operations(ParentConfig), AbortTrapped} of
- {0, _} ->
- %% None of the commands had any effect
- ?FAIL;
- {_, true} ->
- %% An abort was previously trapped
- ?FAIL;
- _ ->
- ok
- end;
-process_commands([Command | Rest], ParentConfig) ->
- %% Reset skip dirs
- ParentConfig1 = rebar_config:reset_skip_dirs(ParentConfig),
- Operations = get_operations(ParentConfig1),
-
- ParentConfig4 =
- try
- %% Convert the code path so that all the entries are
- %% absolute paths. If not, code:set_path() may choke on
- %% invalid relative paths when trying to restore the code
- %% path from inside a subdirectory.
- true = rebar_utils:expand_code_path(),
- {ParentConfig2, _DirSet} = process_dir(rebar_utils:get_cwd(),
- ParentConfig1, Command,
- sets:new()),
- case get_operations(ParentConfig2) of
- Operations ->
- %% This command didn't do anything
- ?CONSOLE("Command '~p' not understood or not applicable~n",
- [Command]);
- _ ->
- ok
- end,
- %% TODO: reconsider after config inheritance removal/re-design
- ParentConfig3 = rebar_config:clean_config(ParentConfig1,
- ParentConfig2),
- %% Wipe out vsn cache to avoid invalid hits when
- %% dependencies are updated
- rebar_config:set_xconf(ParentConfig3, vsn_cache, dict:new())
- catch
- throw:rebar_abort ->
- case rebar_config:get_xconf(ParentConfig1, keep_going, false) of
- false ->
- ?FAIL;
- true ->
- ?WARN("Continuing on after abort: ~p\n", [Rest]),
- rebar_config:set_xconf(ParentConfig1,
- abort_trapped, true)
- end
- end,
- process_commands(Rest, ParentConfig4).
-
-process_dir(Dir, ParentConfig, Command, DirSet) ->
- case filelib:is_dir(Dir) of
- false ->
- ?WARN("Skipping non-existent sub-dir: ~p\n", [Dir]),
- {ParentConfig, DirSet};
-
- true ->
- ok = file:set_cwd(Dir),
- Config = maybe_load_local_config(Dir, ParentConfig),
-
- %% Save the current code path and then update it with
- %% lib_dirs. Children inherit parents code path, but we
- %% also want to ensure that we restore everything to pristine
- %% condition after processing this child
- CurrentCodePath = update_code_path(Config),
-
- %% Get the list of processing modules and check each one against
- %% CWD to see if it's a fit -- if it is, use that set of modules
- %% to process this dir.
- {ok, AvailModuleSets} = application:get_env(rebar, modules),
- ModuleSet = choose_module_set(AvailModuleSets, Dir),
- skip_or_process_dir(ModuleSet, Config, CurrentCodePath,
- Dir, Command, DirSet)
- end.
-
-skip_or_process_dir({[], undefined}=ModuleSet, Config, CurrentCodePath,
- Dir, Command, DirSet) ->
- process_dir1(Dir, Command, DirSet, Config, CurrentCodePath, ModuleSet);
-skip_or_process_dir({_, ModuleSetFile}=ModuleSet, Config, CurrentCodePath,
- Dir, Command, DirSet) ->
- case lists:suffix(".app.src", ModuleSetFile)
- orelse lists:suffix(".app", ModuleSetFile) of
- true ->
- %% .app or .app.src file, check if is_skipped_app
- skip_or_process_dir1(ModuleSetFile, ModuleSet,
- Config, CurrentCodePath, Dir,
- Command, DirSet);
- false ->
- %% not an app dir, no need to consider apps=/skip_apps=
- process_dir1(Dir, Command, DirSet, Config,
- CurrentCodePath, ModuleSet)
- end.
-
-skip_or_process_dir1(AppFile, ModuleSet, Config, CurrentCodePath,
- Dir, Command, DirSet) ->
- case rebar_app_utils:is_skipped_app(Config, AppFile) of
- {Config1, {true, _SkippedApp}} when Command == 'update-deps' ->
- %% update-deps does its own app skipping. Unfortunately there's no
- %% way to signal this to rebar_core, so we have to explicitly do it
- %% here... Otherwise if you use app=, it'll skip the toplevel
- %% directory and nothing will be updated.
- process_dir1(Dir, Command, DirSet, Config1,
- CurrentCodePath, ModuleSet);
- {Config1, {true, SkippedApp}} ->
- ?DEBUG("Skipping app: ~p~n", [SkippedApp]),
- Config2 = increment_operations(Config1),
- {Config2, DirSet};
- {Config1, false} ->
- process_dir1(Dir, Command, DirSet, Config1,
- CurrentCodePath, ModuleSet)
- end.
-
-process_dir1(Dir, Command, DirSet, Config, CurrentCodePath,
- {DirModules, ModuleSetFile}) ->
- Config0 = rebar_config:set_xconf(Config, current_command, Command),
- %% Get the list of modules for "any dir". This is a catch-all list
- %% of modules that are processed in addition to modules associated
- %% with this directory type. These any_dir modules are processed
- %% FIRST.
- {ok, AnyDirModules} = application:get_env(rebar, any_dir_modules),
-
- Modules = AnyDirModules ++ DirModules,
-
- %% Invoke 'preprocess' on the modules -- this yields a list of other
- %% directories that should be processed _before_ the current one.
- {Config1, Predirs} = acc_modules(Modules, preprocess, Config0,
- ModuleSetFile),
-
- %% Remember associated pre-dirs (used for plugin lookup)
- PredirsAssoc = remember_cwd_predirs(Dir, Predirs),
-
- %% Get the list of plug-in modules from rebar.config. These
- %% modules may participate in preprocess and postprocess.
- {ok, PluginModules} = plugin_modules(Config1, PredirsAssoc),
-
- {Config2, PluginPredirs} = acc_modules(PluginModules, preprocess,
- Config1, ModuleSetFile),
-
- AllPredirs = Predirs ++ PluginPredirs,
-
- ?DEBUG("Predirs: ~p\n", [AllPredirs]),
- {Config3, DirSet2} = process_each(AllPredirs, Command, Config2,
- ModuleSetFile, DirSet),
-
- %% Make sure the CWD is reset properly; processing the dirs may have
- %% caused it to change
- ok = file:set_cwd(Dir),
-
- %% Check that this directory is not on the skip list
- Config7 = case rebar_config:is_skip_dir(Config3, Dir) of
- true ->
- %% Do not execute the command on the directory, as some
- %% module has requested a skip on it.
- ?INFO("Skipping ~s in ~s\n", [Command, Dir]),
- Config3;
-
- false ->
- %% Check for and get command specific environments
- {Config4, Env} = setup_envs(Config3, Modules),
-
- %% Execute any before_command plugins on this directory
- Config5 = execute_pre(Command, PluginModules,
- Config4, ModuleSetFile, Env),
-
- %% Execute the current command on this directory
- Config6 = execute(Command, Modules ++ PluginModules,
- Config5, ModuleSetFile, Env),
-
- %% Execute any after_command plugins on this directory
- execute_post(Command, PluginModules,
- Config6, ModuleSetFile, Env)
- end,
-
- %% Mark the current directory as processed
- DirSet3 = sets:add_element(Dir, DirSet2),
-
- %% Invoke 'postprocess' on the modules. This yields a list of other
- %% directories that should be processed _after_ the current one.
- {Config8, Postdirs} = acc_modules(Modules ++ PluginModules, postprocess,
- Config7, ModuleSetFile),
- ?DEBUG("Postdirs: ~p\n", [Postdirs]),
- Res = process_each(Postdirs, Command, Config8,
- ModuleSetFile, DirSet3),
-
- %% Make sure the CWD is reset properly; processing the dirs may have
- %% caused it to change
- ok = file:set_cwd(Dir),
-
- %% Once we're all done processing, reset the code path to whatever
- %% the parent initialized it to
- restore_code_path(CurrentCodePath),
-
- %% Return the updated {config, dirset} as result
- Res.
-
-remember_cwd_predirs(Cwd, Predirs) ->
- Store = fun(Dir, Dict) ->
- case dict:find(Dir, Dict) of
- error ->
- ?DEBUG("Associate sub_dir ~s with ~s~n",
- [Dir, Cwd]),
- dict:store(Dir, Cwd, Dict);
- {ok, Existing} ->
- ?ABORT("Internal consistency assertion failed.~n"
- "sub_dir ~s already associated with ~s.~n"
- "Duplicate sub_dirs or deps entries?",
- [Dir, Existing])
- end
- end,
- lists:foldl(Store, dict:new(), Predirs).
-
-maybe_load_local_config(Dir, ParentConfig) ->
- %% We need to ensure we don't overwrite custom
- %% config when we are dealing with base_dir.
- case rebar_utils:processing_base_dir(ParentConfig, Dir) of
- true ->
- ParentConfig;
- false ->
- rebar_config:new(ParentConfig)
- end.
-
-%%
-%% Given a list of directories and a set of previously processed directories,
-%% process each one we haven't seen yet
-%%
-process_each([], _Command, Config, _ModuleSetFile, DirSet) ->
- %% reset cached (setup_env) envs
- Config1 = rebar_config:reset_envs(Config),
- {Config1, DirSet};
-process_each([Dir | Rest], Command, Config, ModuleSetFile, DirSet) ->
- case sets:is_element(Dir, DirSet) of
- true ->
- ?DEBUG("Skipping ~s; already processed!\n", [Dir]),
- process_each(Rest, Command, Config, ModuleSetFile, DirSet);
- false ->
- {Config1, DirSet2} = process_dir(Dir, Config, Command, DirSet),
- Config2 = rebar_config:clean_config(Config, Config1),
- %% reset cached (setup_env) envs
- Config3 = rebar_config:reset_envs(Config2),
- process_each(Rest, Command, Config3, ModuleSetFile, DirSet2)
- end.
-
-%%
-%% Given a list of module sets from rebar.app and a directory, find
-%% the appropriate subset of modules for this directory
-%%
-choose_module_set([], _Dir) ->
- {[], undefined};
-choose_module_set([{Type, Modules} | Rest], Dir) ->
- case is_dir_type(Type, Dir) of
- {true, File} ->
- {Modules, File};
- false ->
- choose_module_set(Rest, Dir)
- end.
-
-is_dir_type(app_dir, Dir) ->
- rebar_app_utils:is_app_dir(Dir);
-is_dir_type(rel_dir, Dir) ->
- rebar_rel_utils:is_rel_dir(Dir);
-is_dir_type(_, _) ->
- false.
-
-execute_pre(Command, Modules, Config, ModuleFile, Env) ->
- execute_plugin_hook("pre_", Command, Modules,
- Config, ModuleFile, Env).
-
-execute_post(Command, Modules, Config, ModuleFile, Env) ->
- execute_plugin_hook("post_", Command, Modules,
- Config, ModuleFile, Env).
-
-execute_plugin_hook(Hook, Command, Modules, Config, ModuleFile, Env) ->
- HookFunction = list_to_atom(Hook ++ atom_to_list(Command)),
- execute(HookFunction, Modules, Config, ModuleFile, Env).
-
-%%
-%% Execute a command across all applicable modules
-%%
-execute(Command, Modules, Config, ModuleFile, Env) ->
- case select_modules(Modules, Command, []) of
- [] ->
- Cmd = atom_to_list(Command),
- case lists:prefix("pre_", Cmd)
- orelse lists:prefix("post_", Cmd) of
- true ->
- ok;
- false ->
- ?WARN("'~p' command does not apply to directory ~s\n",
- [Command, rebar_utils:get_cwd()])
- end,
- Config;
-
- TargetModules ->
- %% Provide some info on where we are
- Dir = rebar_utils:get_cwd(),
- ?CONSOLE("==> ~s (~s)\n", [filename:basename(Dir), Command]),
-
- Config1 = increment_operations(Config),
-
- %% Run the available modules
- apply_hooks(pre_hooks, Config1, Command, Env),
- case catch(run_modules(TargetModules, Command,
- Config1, ModuleFile)) of
- {ok, NewConfig} ->
- apply_hooks(post_hooks, NewConfig, Command, Env),
- NewConfig;
- {error, failed} ->
- ?FAIL;
- {Module, {error, _} = Other} ->
- ?ABORT("~p failed while processing ~s in module ~s: ~s\n",
- [Command, Dir, Module,
- io_lib:print(Other, 1, 80, -1)]);
- Other ->
- ?ABORT("~p failed while processing ~s: ~s\n",
- [Command, Dir, io_lib:print(Other, 1, 80, -1)])
- end
- end.
-
-%% Increment the count of operations, since some module
-%% responds to this command
-increment_operations(Config) ->
- Operations = get_operations(Config),
- rebar_config:set_xconf(Config, operations, Operations + 1).
-
-get_operations(Config) ->
- rebar_config:get_xconf(Config, operations).
-
-update_code_path(Config) ->
- case rebar_config:get_local(Config, lib_dirs, []) of
- [] ->
- no_change;
- Paths ->
- LibPaths = expand_lib_dirs(Paths, rebar_utils:get_cwd(), []),
- ok = code:add_pathsa(LibPaths),
- %% track just the paths we added, so we can remove them without
- %% removing other paths added by this dep
- {added, LibPaths}
- end.
-
-restore_code_path(no_change) ->
- ok;
-restore_code_path({added, Paths}) ->
- %% Verify that all of the paths still exist -- some dynamically
- %% added paths can get blown away during clean.
- _ = [code:del_path(F) || F <- Paths, erl_prim_loader_is_file(F)],
- ok.
-
-erl_prim_loader_is_file(File) ->
- erl_prim_loader:read_file_info(File) =/= error.
-
-expand_lib_dirs([], _Root, Acc) ->
- Acc;
-expand_lib_dirs([Dir | Rest], Root, Acc) ->
- Apps = filelib:wildcard(filename:join([Dir, "*", "ebin"])),
- FqApps = case filename:pathtype(Dir) of
- absolute -> Apps;
- _ -> [filename:join([Root, A]) || A <- Apps]
- end,
- expand_lib_dirs(Rest, Root, Acc ++ FqApps).
-
-
-
-select_modules([], _Command, Acc) ->
- lists:reverse(Acc);
-select_modules([Module | Rest], Command, Acc) ->
- {module, Module} = code:ensure_loaded(Module),
- case erlang:function_exported(Module, Command, 2) of
- true ->
- select_modules(Rest, Command, [Module | Acc]);
- false ->
- select_modules(Rest, Command, Acc)
- end.
-
-run_modules([], _Command, Config, _File) ->
- {ok, Config};
-run_modules([Module | Rest], Command, Config, File) ->
- case Module:Command(Config, File) of
- ok ->
- run_modules(Rest, Command, Config, File);
- {ok, NewConfig} ->
- run_modules(Rest, Command, NewConfig, File);
- {error, _} = Error ->
- {Module, Error}
- end.
-
-apply_hooks(Mode, Config, Command, Env) ->
- Hooks = rebar_config:get_local(Config, Mode, []),
- lists:foreach(fun apply_hook/1,
- [{Env, Hook} || Hook <- Hooks,
- element(1, Hook) =:= Command orelse
- element(2, Hook) =:= Command]).
-
-apply_hook({Env, {Arch, Command, Hook}}) ->
- case rebar_utils:is_arch(Arch) of
- true ->
- apply_hook({Env, {Command, Hook}});
- false ->
- ok
- end;
-apply_hook({Env, {Command, Hook}}) ->
- Msg = lists:flatten(io_lib:format("Command [~p] failed!~n", [Command])),
- rebar_utils:sh(Hook, [{env, Env}, {abort_on_error, Msg}]).
-
-setup_envs(Config, Modules) ->
- lists:foldl(fun(M, {C,E}=T) ->
- case erlang:function_exported(M, setup_env, 1) of
- true ->
- Env = M:setup_env(C),
- C1 = rebar_config:save_env(C, M, Env),
- {C1, E++Env};
- false ->
- T
- end
- end, {Config, []}, Modules).
-
-acc_modules(Modules, Command, Config, File) ->
- acc_modules(select_modules(Modules, Command, []),
- Command, Config, File, []).
-
-acc_modules([], _Command, Config, _File, Acc) ->
- {Config, Acc};
-acc_modules([Module | Rest], Command, Config, File, Acc) ->
- {Config1, Dirs1} = case Module:Command(Config, File) of
- {ok, Dirs} ->
- {Config, Dirs};
- {ok, NewConfig, Dirs} ->
- {NewConfig, Dirs}
- end,
- acc_modules(Rest, Command, Config1, File, Acc ++ Dirs1).
-
-%%
-%% Return a flat list of rebar plugin modules.
-%%
-plugin_modules(Config, PredirsAssoc) ->
- Modules = lists:flatten(rebar_config:get_all(Config, plugins)),
- plugin_modules(Config, PredirsAssoc, ulist(Modules)).
-
-ulist(L) ->
- ulist(L, []).
-
-ulist([], Acc) ->
- lists:reverse(Acc);
-ulist([H | T], Acc) ->
- case lists:member(H, Acc) of
- true ->
- ulist(T, Acc);
- false ->
- ulist(T, [H | Acc])
- end.
-
-plugin_modules(_Config, _PredirsAssoc, []) ->
- {ok, []};
-plugin_modules(Config, PredirsAssoc, Modules) ->
- FoundModules = [M || M <- Modules, code:which(M) =/= non_existing],
- plugin_modules(Config, PredirsAssoc, FoundModules, Modules -- FoundModules).
-
-plugin_modules(_Config, _PredirsAssoc, FoundModules, []) ->
- {ok, FoundModules};
-plugin_modules(Config, PredirsAssoc, FoundModules, MissingModules) ->
- {Loaded, NotLoaded} = load_plugin_modules(Config, PredirsAssoc,
- MissingModules),
- AllViablePlugins = FoundModules ++ Loaded,
- case NotLoaded =/= [] of
- true ->
- %% NB: we continue to ignore this situation, as did the
- %% original code
- ?WARN("Missing plugins: ~p\n", [NotLoaded]);
- false ->
- ?DEBUG("Loaded plugins: ~p~n", [AllViablePlugins]),
- ok
- end,
- {ok, AllViablePlugins}.
-
-load_plugin_modules(Config, PredirsAssoc, Modules) ->
- Cwd = rebar_utils:get_cwd(),
- PluginDirs = get_all_plugin_dirs(Config, Cwd, PredirsAssoc),
-
- %% Find relevant sources in base_dir and plugin_dir
- Erls = string:join([atom_to_list(M)++"\\.erl" || M <- Modules], "|"),
- RE = "^" ++ Erls ++ "\$",
- %% If a plugin is found both in base_dir and plugin_dir, the clash
- %% will provoke an error and we'll abort.
- Sources = [rebar_utils:find_files(PD, RE, false) || PD <- PluginDirs],
-
- %% Compile and load plugins
- Loaded = [load_plugin(Src) || Src <- lists:append(Sources)],
- FilterMissing = is_missing_plugin(Loaded),
- NotLoaded = [V || V <- Modules, FilterMissing(V)],
- {Loaded, NotLoaded}.
-
-get_all_plugin_dirs(Config, Cwd, PredirsAssoc) ->
- get_plugin_dir(Config, Cwd) ++ get_base_plugin_dirs(Cwd, PredirsAssoc).
-
-get_plugin_dir(Config, Cwd) ->
- case rebar_config:get_local(Config, plugin_dir, undefined) of
- undefined ->
- %% Plugin can be in the project's "plugins" folder
- [filename:join(Cwd, "plugins")];
- Dir ->
- [Dir]
- end.
-
-%% We also want to include this case:
-%% Plugin can be in "plugins" directory of the plugin base directory.
-%% For example, Cwd depends on Plugin, and deps/Plugin/plugins/Plugin.erl
-%% is the plugin.
-get_base_plugin_dirs(Cwd, PredirsAssoc) ->
- [filename:join(Dir, "plugins") ||
- Dir <- get_plugin_base_dirs(Cwd, PredirsAssoc)].
-
-%% @doc PredirsAssoc is a dictionary of plugindir -> 'parent' pairs
-%% 'parent' in this case depends on plugin; therefore we have to give
-%% all plugins that Cwd ('parent' in this case) depends on.
-get_plugin_base_dirs(Cwd, PredirsAssoc) ->
- [PluginDir || {PluginDir, Master} <- dict:to_list(PredirsAssoc),
- Master =:= Cwd].
-
-is_missing_plugin(Loaded) ->
- fun(Mod) -> not lists:member(Mod, Loaded) end.
-
-load_plugin(Src) ->
- case compile:file(Src, [binary, return_errors]) of
- {ok, Mod, Bin} ->
- load_plugin_module(Mod, Bin, Src);
- {error, Errors, _Warnings} ->
- ?ABORT("Plugin ~s contains compilation errors: ~p~n",
- [Src, Errors])
- end.
-
-load_plugin_module(Mod, Bin, Src) ->
- case code:is_loaded(Mod) of
- {file, Loaded} ->
- ?ABORT("Plugin ~p clashes with previously loaded module ~p~n",
- [Mod, Loaded]);
- false ->
- ?INFO("Loading plugin ~p from ~s~n", [Mod, Src]),
- {module, Mod} = code:load_binary(Mod, Src, Bin),
- Mod
- end.
diff --git a/src/rebar/src/rebar_ct.erl b/src/rebar/src/rebar_ct.erl
deleted file mode 100644
index 74ae618ca..000000000
--- a/src/rebar/src/rebar_ct.erl
+++ /dev/null
@@ -1,350 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-%%
-%% Targets:
-%% test - run common test suites in ./test
-%% int_test - run suites in ./int_test
-%% perf_test - run suites inm ./perf_test
-%%
-%% Global options:
-%% verbose=1 - show output from the common_test run as it goes
-%% suites="foo,bar" - run <test>/foo_SUITE and <test>/bar_SUITE
-%% case="mycase" - run individual test case foo_SUITE:mycase
-%% -------------------------------------------------------------------
--module(rebar_ct).
-
--export([ct/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-ct(Config, File) ->
- TestDir = rebar_config:get_local(Config, ct_dir, "test"),
- LogDir = rebar_config:get_local(Config, ct_log_dir, "logs"),
- run_test_if_present(TestDir, LogDir, Config, File).
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, ct) ->
- ?CONSOLE(
- "Run common_test suites.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- "Valid command line options:~n"
- " suites=foo,bar - run <test>/foo_SUITE and <test>/bar_SUITE~n"
- " case=\"mycase\" - run individual test case foo_SUITE:mycase~n",
- [
- {ct_dir, "itest"},
- {ct_log_dir, "test/logs"},
- {ct_extra_params, "-boot start_sasl -s myapp"},
- {ct_use_short_names, true}
- ]).
-
-run_test_if_present(TestDir, LogDir, Config, File) ->
- case filelib:is_dir(TestDir) of
- false ->
- ?WARN("~s directory not present - skipping\n", [TestDir]),
- ok;
- true ->
- case filelib:wildcard(TestDir ++ "/*_SUITE.{beam,erl}") of
- [] ->
- ?WARN("~s directory present, but no common_test"
- ++ " SUITES - skipping\n", [TestDir]),
- ok;
- _ ->
- try
- run_test(TestDir, LogDir, Config, File)
- catch
- throw:skip ->
- ok
- end
- end
- end.
-
-run_test(TestDir, LogDir, Config, _File) ->
- {Cmd, RawLog} = make_cmd(TestDir, LogDir, Config),
- ?DEBUG("ct_run cmd:~n~p~n", [Cmd]),
- clear_log(LogDir, RawLog),
- Output = case rebar_config:is_verbose(Config) of
- false ->
- " >> " ++ RawLog ++ " 2>&1";
- true ->
- " 2>&1 | tee -a " ++ RawLog
- end,
-
- ShOpts = [{env,[{"TESTDIR", TestDir}]}, return_on_error],
- case rebar_utils:sh(Cmd ++ Output, ShOpts) of
- {ok,_} ->
- %% in older versions of ct_run, this could have been a failure
- %% that returned a non-0 code. Check for that!
- check_success_log(Config, RawLog);
- {error,Res} ->
- %% In newer ct_run versions, this may be a sign of a good compile
- %% that failed cases. In older version, it's a worse error.
- check_fail_log(Config, RawLog, Cmd ++ Output, Res)
- end.
-
-clear_log(LogDir, RawLog) ->
- case filelib:ensure_dir(filename:join(LogDir, "index.html")) of
- ok ->
- NowStr = rebar_utils:now_str(),
- LogHeader = "--- Test run on " ++ NowStr ++ " ---\n",
- ok = file:write_file(RawLog, LogHeader);
- {error, Reason} ->
- ?ERROR("Could not create log dir - ~p\n", [Reason]),
- ?FAIL
- end.
-
-%% calling ct with erl does not return non-zero on failure - have to check
-%% log results
-check_success_log(Config, RawLog) ->
- check_log(Config, RawLog, fun(Msg) -> ?CONSOLE("DONE.\n~s\n", [Msg]) end).
-
--type err_handler() :: fun((string()) -> no_return()).
--spec failure_logger(string(), {integer(), string()}) -> err_handler().
-failure_logger(Command, {Rc, Output}) ->
- fun(_Msg) ->
- ?ABORT("~s failed with error: ~w and output:~n~s~n",
- [Command, Rc, Output])
- end.
-
-check_fail_log(Config, RawLog, Command, Result) ->
- check_log(Config, RawLog, failure_logger(Command, Result)).
-
-check_log(Config,RawLog,Fun) ->
- {ok, Msg} =
- rebar_utils:sh("grep -e \"TEST COMPLETE\" -e \"{error,make_failed}\" "
- ++ RawLog, [{use_stdout, false}]),
- MakeFailed = string:str(Msg, "{error,make_failed}") =/= 0,
- RunFailed = string:str(Msg, ", 0 failed") =:= 0,
- if
- MakeFailed ->
- show_log(Config, RawLog),
- ?ERROR("Building tests failed\n",[]),
- ?FAIL;
-
- RunFailed ->
- show_log(Config, RawLog),
- ?ERROR("One or more tests failed\n",[]),
- ?FAIL;
-
- true ->
- Fun(Msg)
- end.
-
-
-%% Show the log if it hasn't already been shown because verbose was on
-show_log(Config, RawLog) ->
- ?CONSOLE("Showing log\n", []),
- case rebar_config:is_verbose(Config) of
- false ->
- {ok, Contents} = file:read_file(RawLog),
- ?CONSOLE("~s", [Contents]);
- true ->
- ok
- end.
-
-make_cmd(TestDir, RawLogDir, Config) ->
- Cwd = rebar_utils:get_cwd(),
- LogDir = filename:join(Cwd, RawLogDir),
- EbinDir = filename:absname(filename:join(Cwd, "ebin")),
- IncludeDir = filename:join(Cwd, "include"),
- Include = case filelib:is_dir(IncludeDir) of
- true ->
- " -include \"" ++ IncludeDir ++ "\"";
- false ->
- ""
- end,
-
- %% Check for the availability of ct_run; if we can't find it, generate a
- %% warning and use the old school, less reliable approach to running CT.
- BaseCmd = case os:find_executable("ct_run") of
- false ->
- "erl -noshell -s ct_run script_start -s erlang halt";
- _ ->
- "ct_run -noshell"
- end,
-
- %% Add the code path of the rebar process to the code path. This
- %% includes the dependencies in the code path. The directories
- %% that are part of the root Erlang install are filtered out to
- %% avoid duplication
- R = code:root_dir(),
- NonLibCodeDirs = [P || P <- code:get_path(), not lists:prefix(R, P)],
- CodeDirs = [io_lib:format("\"~s\"", [Dir]) ||
- Dir <- [EbinDir|NonLibCodeDirs]],
- CodePathString = string:join(CodeDirs, " "),
- Cmd = case get_ct_specs(Cwd) of
- undefined ->
- ?FMT("~s"
- " -pa ~s"
- " ~s"
- " ~s"
- " -logdir \"~s\""
- " -env TEST_DIR \"~s\""
- " ~s",
- [BaseCmd,
- CodePathString,
- Include,
- build_name(Config),
- LogDir,
- filename:join(Cwd, TestDir),
- get_extra_params(Config)]) ++
- get_cover_config(Config, Cwd) ++
- get_ct_config_file(TestDir) ++
- get_config_file(TestDir) ++
- get_suites(Config, TestDir) ++
- get_case(Config);
- SpecFlags ->
- ?FMT("~s"
- " -pa ~s"
- " ~s"
- " ~s"
- " -logdir \"~s\""
- " -env TEST_DIR \"~s\""
- " ~s",
- [BaseCmd,
- CodePathString,
- Include,
- build_name(Config),
- LogDir,
- filename:join(Cwd, TestDir),
- get_extra_params(Config)]) ++
- SpecFlags ++ get_cover_config(Config, Cwd)
- end,
- RawLog = filename:join(LogDir, "raw.log"),
- {Cmd, RawLog}.
-
-build_name(Config) ->
- case rebar_config:get_local(Config, ct_use_short_names, false) of
- true -> "-sname test";
- false -> " -name test@" ++ net_adm:localhost()
- end.
-
-get_extra_params(Config) ->
- rebar_config:get_local(Config, ct_extra_params, "").
-
-get_ct_specs(Cwd) ->
- case collect_glob(Cwd, ".*\.test\.spec\$") of
- [] -> undefined;
- [Spec] ->
- " -spec " ++ Spec;
- Specs ->
- " -spec " ++
- lists:flatten([io_lib:format("~s ", [Spec]) || Spec <- Specs])
- end.
-
-get_cover_config(Config, Cwd) ->
- case rebar_config:get_local(Config, cover_enabled, false) of
- false ->
- "";
- true ->
- case collect_glob(Cwd, ".*cover\.spec\$") of
- [] ->
- ?DEBUG("No cover spec found: ~s~n", [Cwd]),
- "";
- [Spec] ->
- ?DEBUG("Found cover file ~w~n", [Spec]),
- " -cover " ++ Spec;
- Specs ->
- ?ABORT("Multiple cover specs found: ~p~n", [Specs])
- end
- end.
-
-collect_glob(Cwd, Glob) ->
- filelib:fold_files(Cwd, Glob, true, fun collect_files/2, []).
-
-collect_files(F, Acc) ->
- %% Ignore any specs under the deps/ directory. Do this pulling
- %% the dirname off the the F and then splitting it into a list.
- Parts = filename:split(filename:dirname(F)),
- case lists:member("deps", Parts) of
- true ->
- Acc; % There is a directory named "deps" in path
- false ->
- [F | Acc] % No "deps" directory in path
- end.
-
-get_ct_config_file(TestDir) ->
- Config = filename:join(TestDir, "test.config"),
- case filelib:is_regular(Config) of
- false ->
- " ";
- true ->
- " -ct_config " ++ Config
- end.
-
-get_config_file(TestDir) ->
- Config = filename:join(TestDir, "app.config"),
- case filelib:is_regular(Config) of
- false ->
- " ";
- true ->
- " -config " ++ Config
- end.
-
-get_suites(Config, TestDir) ->
- case rebar_config:get_global(Config, suites, undefined) of
- undefined ->
- " -dir " ++ TestDir;
- Suites ->
- Suites1 = string:tokens(Suites, ","),
- Suites2 = [find_suite_path(Suite, TestDir) || Suite <- Suites1],
- string:join([" -suite"] ++ Suites2, " ")
- end.
-
-find_suite_path(Suite, TestDir) ->
- Path = filename:join(TestDir, Suite ++ "_SUITE.erl"),
- case filelib:is_regular(Path) of
- false ->
- ?WARN("Suite ~s not found\n", [Suite]),
- %% Note - this throw is caught in run_test_if_present/3;
- %% this solution was easier than refactoring the entire module.
- throw(skip);
- true ->
- Path
- end.
-
-get_case(Config) ->
- case rebar_config:get_global(Config, 'case', undefined) of
- undefined ->
- "";
- Case ->
- " -case " ++ Case
- end.
diff --git a/src/rebar/src/rebar_deps.erl b/src/rebar/src/rebar_deps.erl
deleted file mode 100644
index 2e305d525..000000000
--- a/src/rebar/src/rebar_deps.erl
+++ /dev/null
@@ -1,774 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_deps).
-
--include("rebar.hrl").
-
--export([preprocess/2,
- postprocess/2,
- compile/2,
- setup_env/1,
- 'check-deps'/2,
- 'get-deps'/2,
- 'update-deps'/2,
- 'delete-deps'/2,
- 'list-deps'/2]).
-
-%% for internal use only
--export([info/2]).
-
--record(dep, { dir,
- app,
- vsn_regex,
- source,
- is_raw }). %% is_raw = true means non-Erlang/OTP dependency
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-preprocess(Config, _) ->
- %% Side effect to set deps_dir globally for all dependencies from
- %% top level down. Means the root deps_dir is honoured or the default
- %% used globally since it will be set on the first time through here
- Config1 = set_shared_deps_dir(Config, get_shared_deps_dir(Config, [])),
-
- %% Get the list of deps for the current working directory and identify those
- %% deps that are available/present.
- Deps = rebar_config:get_local(Config1, deps, []),
- {Config2, {AvailableDeps, MissingDeps}} = find_deps(Config1, find, Deps),
-
- ?DEBUG("Available deps: ~p\n", [AvailableDeps]),
- ?DEBUG("Missing deps : ~p\n", [MissingDeps]),
-
- %% Add available deps to code path
- Config3 = update_deps_code_path(Config2, AvailableDeps),
-
- %% Filtering out 'raw' dependencies so that no commands other than
- %% deps-related can be executed on their directories.
- NonRawAvailableDeps = [D || D <- AvailableDeps, not D#dep.is_raw],
-
- case rebar_config:get_xconf(Config, current_command, undefined) of
- 'update-deps' ->
- %% Skip ALL of the dep folders, we do this because we don't want
- %% any other calls to preprocess() for update-deps beyond the
- %% toplevel directory. They aren't actually harmful, but they slow
- %% things down unnecessarily.
- NewConfig = lists:foldl(
- fun(D, Acc) ->
- rebar_config:set_skip_dir(Acc, D#dep.dir)
- end,
- Config3,
- collect_deps(rebar_utils:get_cwd(), Config3)),
- %% Return the empty list, as we don't want anything processed before
- %% us.
- {ok, NewConfig, []};
- _ ->
- %% If skip_deps=true, mark each dep dir as a skip_dir w/ the core
- %% so that the current command doesn't run on the dep dir.
- %% However, pre/postprocess WILL run (and we want it to) for
- %% transitivity purposes.
- %%
- %% Also, if skip_deps=comma,separated,app,list, then only the given
- %% dependencies are skipped.
- NewConfig =
- case rebar_config:get_global(Config3, skip_deps, false) of
- "true" ->
- lists:foldl(
- fun(#dep{dir = Dir}, C) ->
- rebar_config:set_skip_dir(C, Dir)
- end, Config3, AvailableDeps);
- Apps when is_list(Apps) ->
- SkipApps = [list_to_atom(App) ||
- App <- string:tokens(Apps, ",")],
- lists:foldl(
- fun(#dep{dir = Dir, app = App}, C) ->
- case lists:member(App, SkipApps) of
- true -> rebar_config:set_skip_dir(C, Dir);
- false -> C
- end
- end, Config3, AvailableDeps);
- _ ->
- Config3
- end,
-
- %% Return all the available dep directories for process
- {ok, NewConfig, dep_dirs(NonRawAvailableDeps)}
- end.
-
-postprocess(Config, _) ->
- case rebar_config:get_xconf(Config, ?MODULE, undefined) of
- undefined ->
- {ok, []};
- Dirs ->
- NewConfig = rebar_config:erase_xconf(Config, ?MODULE),
- {ok, NewConfig, Dirs}
- end.
-
-compile(Config, _) ->
- {Config1, _AvailDeps} = do_check_deps(Config),
- {ok, Config1}.
-
-%% set REBAR_DEPS_DIR and ERL_LIBS environment variables
-setup_env(Config) ->
- {true, DepsDir} = get_deps_dir(Config),
- %% include rebar's DepsDir in ERL_LIBS
- Separator = case os:type() of
- {win32, nt} ->
- ";";
- _ ->
- ":"
- end,
- ERL_LIBS = case os:getenv("ERL_LIBS") of
- false ->
- {"ERL_LIBS", DepsDir};
- PrevValue ->
- {"ERL_LIBS", DepsDir ++ Separator ++ PrevValue}
- end,
- [{"REBAR_DEPS_DIR", DepsDir}, ERL_LIBS].
-
-%% common function used by 'check-deps' and 'compile'
-do_check_deps(Config) ->
- %% Get the list of immediate (i.e. non-transitive) deps that are missing
- Deps = rebar_config:get_local(Config, deps, []),
- case find_deps(Config, find, Deps) of
- {Config1, {AvailDeps, []}} ->
- %% No missing deps
- {Config1, AvailDeps};
- {_Config1, {_, MissingDeps}} ->
- lists:foreach(fun (#dep{app=App, vsn_regex=Vsn, source=Src}) ->
- ?CONSOLE("Dependency not available: "
- "~p-~s (~p)\n", [App, Vsn, Src])
- end, MissingDeps),
- ?FAIL
- end.
-
-'check-deps'(Config, _) ->
- {Config1, AvailDeps} = do_check_deps(Config),
- {ok, save_dep_dirs(Config1, AvailDeps)}.
-
-'get-deps'(Config, _) ->
- %% Determine what deps are available and missing
- Deps = rebar_config:get_local(Config, deps, []),
- {Config1, {_AvailableDeps, MissingDeps}} = find_deps(Config, find, Deps),
- MissingDeps1 = [D || D <- MissingDeps, D#dep.source =/= undefined],
-
- %% For each missing dep with a specified source, try to pull it.
- {Config2, PulledDeps} =
- lists:foldl(fun(D, {C, PulledDeps0}) ->
- {C1, D1} = use_source(C, D),
- {C1, [D1 | PulledDeps0]}
- end, {Config1, []}, MissingDeps1),
-
- %% Add each pulled dep to our list of dirs for post-processing. This yields
- %% the necessary transitivity of the deps
- {ok, save_dep_dirs(Config2, lists:reverse(PulledDeps))}.
-
-'update-deps'(Config, _) ->
- Config1 = rebar_config:set_xconf(Config, depowner, dict:new()),
- {Config2, UpdatedDeps} = update_deps_int(Config1, []),
- DepOwners = rebar_config:get_xconf(Config2, depowner, dict:new()),
-
- %% check for conflicting deps
- _ = [?ERROR("Conflicting dependencies for ~p: ~p~n",
- [K, [{"From: " ++ string:join(dict:fetch(D, DepOwners), ", "),
- {D#dep.vsn_regex, D#dep.source}} || D <- V]])
- || {K, V} <- dict:to_list(
- lists:foldl(
- fun(Dep, Acc) ->
- dict:append(Dep#dep.app, Dep, Acc)
- end, dict:new(), UpdatedDeps)),
- length(V) > 1],
-
- %% Add each updated dep to our list of dirs for post-processing. This yields
- %% the necessary transitivity of the deps
- {ok, save_dep_dirs(Config, UpdatedDeps)}.
-
-'delete-deps'(Config, _) ->
- %% Delete all the available deps in our deps/ directory, if any
- {true, DepsDir} = get_deps_dir(Config),
- Deps = rebar_config:get_local(Config, deps, []),
- {Config1, {AvailableDeps, _}} = find_deps(Config, find, Deps),
- _ = [delete_dep(D)
- || D <- AvailableDeps,
- lists:prefix(DepsDir, D#dep.dir)],
- {ok, Config1}.
-
-'list-deps'(Config, _) ->
- Deps = rebar_config:get_local(Config, deps, []),
- case find_deps(Config, find, Deps) of
- {Config1, {AvailDeps, []}} ->
- lists:foreach(fun(Dep) -> print_source(Dep) end, AvailDeps),
- {ok, save_dep_dirs(Config1, AvailDeps)};
- {_, MissingDeps} ->
- ?ABORT("Missing dependencies: ~p\n", [MissingDeps])
- end.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- info_help("Display to be fetched dependencies");
-info(help, 'check-deps') ->
- info_help("Display to be fetched dependencies");
-info(help, 'get-deps') ->
- info_help("Fetch dependencies");
-info(help, 'update-deps') ->
- info_help("Update fetched dependencies");
-info(help, 'delete-deps') ->
- info_help("Delete fetched dependencies");
-info(help, 'list-deps') ->
- info_help("List dependencies").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n"
- " ~p~n"
- "Valid command line options:~n"
- " deps_dir=\"deps\" (override default or rebar.config deps_dir)~n",
- [
- Description,
- {deps_dir, "deps"},
- {deps,
- [app_name,
- {rebar, "1.0.*"},
- {rebar, ".*",
- {git, "git://github.com/rebar/rebar.git"}},
- {rebar, ".*",
- {git, "git://github.com/rebar/rebar.git", "Rev"}},
- {rebar, "1.0.*",
- {git, "git://github.com/rebar/rebar.git", {branch, "master"}}},
- {rebar, "1.0.0",
- {git, "git://github.com/rebar/rebar.git", {tag, "1.0.0"}}},
- {rebar, "",
- {git, "git://github.com/rebar/rebar.git", {branch, "master"}},
- [raw]},
- {app_name, ".*", {hg, "https://www.example.org/url"}},
- {app_name, ".*", {rsync, "Url"}},
- {app_name, ".*", {svn, "https://www.example.org/url"}},
- {app_name, ".*", {svn, "svn://svn.example.org/url"}},
- {app_name, ".*", {bzr, "https://www.example.org/url", "Rev"}},
- {app_name, ".*", {fossil, "https://www.example.org/url"}},
- {app_name, ".*", {fossil, "https://www.example.org/url", "Vsn"}}]}
- ]).
-
-%% Added because of trans deps,
-%% need all deps in same dir and should be the one set by the root rebar.config
-%% In case one is given globally, it has higher priority
-%% Sets a default if root config has no deps_dir set
-set_shared_deps_dir(Config, []) ->
- LocalDepsDir = rebar_config:get_local(Config, deps_dir, "deps"),
- GlobalDepsDir = rebar_config:get_global(Config, deps_dir, LocalDepsDir),
- DepsDir = case os:getenv("REBAR_DEPS_DIR") of
- false ->
- GlobalDepsDir;
- Dir ->
- Dir
- end,
- rebar_config:set_xconf(Config, deps_dir, DepsDir);
-set_shared_deps_dir(Config, _DepsDir) ->
- Config.
-
-get_shared_deps_dir(Config, Default) ->
- rebar_config:get_xconf(Config, deps_dir, Default).
-
-get_deps_dir(Config) ->
- get_deps_dir(Config, "").
-
-get_deps_dir(Config, App) ->
- BaseDir = rebar_config:get_xconf(Config, base_dir, []),
- DepsDir = get_shared_deps_dir(Config, "deps"),
- {true, filename:join([BaseDir, DepsDir, App])}.
-
-dep_dirs(Deps) ->
- [D#dep.dir || D <- Deps].
-
-save_dep_dirs(Config, Deps) ->
- rebar_config:set_xconf(Config, ?MODULE, dep_dirs(Deps)).
-
-get_lib_dir(App) ->
- %% Find App amongst the reachable lib directories
- %% Returns either the found path or a tagged tuple with a boolean
- %% to match get_deps_dir's return type
- case code:lib_dir(App) of
- {error, bad_name} -> {false, bad_name};
- Path -> {true, Path}
- end.
-
-update_deps_code_path(Config, []) ->
- Config;
-update_deps_code_path(Config, [Dep | Rest]) ->
- Config2 =
- case is_app_available(Config, Dep#dep.app,
- Dep#dep.vsn_regex, Dep#dep.dir, Dep#dep.is_raw) of
- {Config1, {true, _}} ->
- Dir = filename:join(Dep#dep.dir, "ebin"),
- ok = filelib:ensure_dir(filename:join(Dir, "dummy")),
- ?DEBUG("Adding ~s to code path~n", [Dir]),
- true = code:add_patha(Dir),
- Config1;
- {Config1, {false, _}} ->
- Config1
- end,
- update_deps_code_path(Config2, Rest).
-
-find_deps(Config, find=Mode, Deps) ->
- find_deps(Config, Mode, Deps, {[], []});
-find_deps(Config, read=Mode, Deps) ->
- find_deps(Config, Mode, Deps, []).
-
-find_deps(Config, find, [], {Avail, Missing}) ->
- {Config, {lists:reverse(Avail), lists:reverse(Missing)}};
-find_deps(Config, read, [], Deps) ->
- {Config, lists:reverse(Deps)};
-find_deps(Config, Mode, [App | Rest], Acc) when is_atom(App) ->
- find_deps(Config, Mode, [{App, ".*", undefined} | Rest], Acc);
-find_deps(Config, Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) ->
- find_deps(Config, Mode, [{App, VsnRegex, undefined} | Rest], Acc);
-find_deps(Config, Mode, [{App, VsnRegex, Source} | Rest], Acc) ->
- find_deps(Config, Mode, [{App, VsnRegex, Source, []} | Rest], Acc);
-find_deps(Config, Mode, [{App, VsnRegex, Source, Opts} | Rest], Acc)
- when is_list(Opts) ->
- Dep = #dep { app = App,
- vsn_regex = VsnRegex,
- source = Source,
- %% dependency is considered raw (i.e. non-Erlang/OTP) when
- %% 'raw' option is present
- is_raw = proplists:get_value(raw, Opts, false) },
- {Config1, {Availability, FoundDir}} = find_dep(Config, Dep),
- find_deps(Config1, Mode, Rest,
- acc_deps(Mode, Availability, Dep, FoundDir, Acc));
-find_deps(_Config, _Mode, [Other | _Rest], _Acc) ->
- ?ABORT("Invalid dependency specification ~p in ~s\n",
- [Other, rebar_utils:get_cwd()]).
-
-find_dep(Config, Dep) ->
- %% Find a dep based on its source,
- %% e.g. {git, "https://github.com/mochi/mochiweb.git", "HEAD"}
- %% Deps with a source must be found (or fetched) locally.
- %% Those without a source may be satisfied from lib dir (get_lib_dir).
- find_dep(Config, Dep, Dep#dep.source).
-
-find_dep(Config, Dep, undefined) ->
- %% 'source' is undefined. If Dep is not satisfied locally,
- %% go ahead and find it amongst the lib_dir's.
- case find_dep_in_dir(Config, Dep, get_deps_dir(Config, Dep#dep.app)) of
- {_Config1, {avail, _Dir}} = Avail ->
- Avail;
- {Config1, {missing, _}} ->
- find_dep_in_dir(Config1, Dep, get_lib_dir(Dep#dep.app))
- end;
-find_dep(Config, Dep, _Source) ->
- %% _Source is defined. Regardless of what it is, we must find it
- %% locally satisfied or fetch it from the original source
- %% into the project's deps
- find_dep_in_dir(Config, Dep, get_deps_dir(Config, Dep#dep.app)).
-
-find_dep_in_dir(Config, _Dep, {false, Dir}) ->
- {Config, {missing, Dir}};
-find_dep_in_dir(Config, Dep, {true, Dir}) ->
- App = Dep#dep.app,
- VsnRegex = Dep#dep.vsn_regex,
- IsRaw = Dep#dep.is_raw,
- case is_app_available(Config, App, VsnRegex, Dir, IsRaw) of
- {Config1, {true, _AppFile}} -> {Config1, {avail, Dir}};
- {Config1, {false, _}} -> {Config1, {missing, Dir}}
- end.
-
-acc_deps(find, avail, Dep, AppDir, {Avail, Missing}) ->
- {[Dep#dep { dir = AppDir } | Avail], Missing};
-acc_deps(find, missing, Dep, AppDir, {Avail, Missing}) ->
- {Avail, [Dep#dep { dir = AppDir } | Missing]};
-acc_deps(read, _, Dep, AppDir, Acc) ->
- [Dep#dep { dir = AppDir } | Acc].
-
-delete_dep(D) ->
- case filelib:is_dir(D#dep.dir) of
- true ->
- ?INFO("Deleting dependency: ~s\n", [D#dep.dir]),
- rebar_file_utils:rm_rf(D#dep.dir);
- false ->
- ok
- end.
-
-require_source_engine(Source) ->
- true = source_engine_avail(Source),
- ok.
-
-%% IsRaw = false means regular Erlang/OTP dependency
-%%
-%% IsRaw = true means non-Erlang/OTP dependency, e.g. the one that does not
-%% have a proper .app file
-is_app_available(Config, App, VsnRegex, Path, _IsRaw = false) ->
- ?DEBUG("is_app_available, looking for App ~p with Path ~p~n", [App, Path]),
- case rebar_app_utils:is_app_dir(Path) of
- {true, AppFile} ->
- case rebar_app_utils:app_name(Config, AppFile) of
- {Config1, App} ->
- {Config2, Vsn} = rebar_app_utils:app_vsn(Config1, AppFile),
- ?INFO("Looking for ~s-~s ; found ~s-~s at ~s\n",
- [App, VsnRegex, App, Vsn, Path]),
- case re:run(Vsn, VsnRegex, [{capture, none}]) of
- match ->
- {Config2, {true, Path}};
- nomatch ->
- ?WARN("~s has version ~p; requested regex was ~s\n",
- [AppFile, Vsn, VsnRegex]),
- {Config2,
- {false, {version_mismatch,
- {AppFile,
- {expected, VsnRegex}, {has, Vsn}}}}}
- end;
- {Config1, OtherApp} ->
- ?WARN("~s has application id ~p; expected ~p\n",
- [AppFile, OtherApp, App]),
- {Config1,
- {false, {name_mismatch,
- {AppFile, {expected, App}, {has, OtherApp}}}}}
- end;
- false ->
- ?WARN("Expected ~s to be an app dir (containing ebin/*.app), "
- "but no .app found.\n", [Path]),
- {Config, {false, {missing_app_file, Path}}}
- end;
-is_app_available(Config, App, _VsnRegex, Path, _IsRaw = true) ->
- ?DEBUG("is_app_available, looking for Raw Depencency ~p with Path ~p~n",
- [App, Path]),
- case filelib:is_dir(Path) of
- true ->
- %% TODO: look for version string in <Path>/VERSION file? Not clear
- %% how to detect git/svn/hg/{cmd, ...} settings that can be passed
- %% to rebar_utils:vcs_vsn/2 to obtain version dynamically
- {Config, {true, Path}};
- false ->
- ?WARN("Expected ~s to be a raw dependency directory, "
- "but no directory found.\n", [Path]),
- {Config, {false, {missing_raw_dependency_directory, Path}}}
- end.
-
-use_source(Config, Dep) ->
- use_source(Config, Dep, 3).
-
-use_source(_Config, Dep, 0) ->
- ?ABORT("Failed to acquire source from ~p after 3 tries.\n",
- [Dep#dep.source]);
-use_source(Config, Dep, Count) ->
- case filelib:is_dir(Dep#dep.dir) of
- true ->
- %% Already downloaded -- verify the versioning matches the regex
- case is_app_available(Config, Dep#dep.app, Dep#dep.vsn_regex,
- Dep#dep.dir, Dep#dep.is_raw) of
- {Config1, {true, _}} ->
- Dir = filename:join(Dep#dep.dir, "ebin"),
- ok = filelib:ensure_dir(filename:join(Dir, "dummy")),
- %% Available version matches up -- we're good to go;
- %% add the app dir to our code path
- true = code:add_patha(Dir),
- {Config1, Dep};
- {_Config1, {false, Reason}} ->
- %% The app that was downloaded doesn't match up (or had
- %% errors or something). For the time being, abort.
- ?ABORT("Dependency dir ~s failed application validation "
- "with reason:~n~p.\n", [Dep#dep.dir, Reason])
- end;
- false ->
- ?CONSOLE("Pulling ~p from ~p\n", [Dep#dep.app, Dep#dep.source]),
- require_source_engine(Dep#dep.source),
- {true, TargetDir} = get_deps_dir(Config, Dep#dep.app),
- download_source(TargetDir, Dep#dep.source),
- use_source(Config, Dep#dep { dir = TargetDir }, Count-1)
- end.
-
-download_source(AppDir, {hg, Url, Rev}) ->
- ok = filelib:ensure_dir(AppDir),
- rebar_utils:sh(?FMT("hg clone -U ~s ~s", [Url, filename:basename(AppDir)]),
- [{cd, filename:dirname(AppDir)}]),
- rebar_utils:sh(?FMT("hg update ~s", [Rev]), [{cd, AppDir}]);
-download_source(AppDir, {git, Url}) ->
- download_source(AppDir, {git, Url, {branch, "HEAD"}});
-download_source(AppDir, {git, Url, ""}) ->
- download_source(AppDir, {git, Url, {branch, "HEAD"}});
-download_source(AppDir, {git, Url, {branch, Branch}}) ->
- ok = filelib:ensure_dir(AppDir),
- rebar_utils:sh(?FMT("git clone -n ~s ~s", [Url, filename:basename(AppDir)]),
- [{cd, filename:dirname(AppDir)}]),
- rebar_utils:sh(?FMT("git checkout -q origin/~s", [Branch]), [{cd, AppDir}]);
-download_source(AppDir, {git, Url, {tag, Tag}}) ->
- ok = filelib:ensure_dir(AppDir),
- rebar_utils:sh(?FMT("git clone -n ~s ~s", [Url, filename:basename(AppDir)]),
- [{cd, filename:dirname(AppDir)}]),
- rebar_utils:sh(?FMT("git checkout -q ~s", [Tag]), [{cd, AppDir}]);
-download_source(AppDir, {git, Url, Rev}) ->
- ok = filelib:ensure_dir(AppDir),
- rebar_utils:sh(?FMT("git clone -n ~s ~s", [Url, filename:basename(AppDir)]),
- [{cd, filename:dirname(AppDir)}]),
- rebar_utils:sh(?FMT("git checkout -q ~s", [Rev]), [{cd, AppDir}]);
-download_source(AppDir, {bzr, Url, Rev}) ->
- ok = filelib:ensure_dir(AppDir),
- rebar_utils:sh(?FMT("bzr branch -r ~s ~s ~s",
- [Rev, Url, filename:basename(AppDir)]),
- [{cd, filename:dirname(AppDir)}]);
-download_source(AppDir, {svn, Url, Rev}) ->
- ok = filelib:ensure_dir(AppDir),
- rebar_utils:sh(?FMT("svn checkout -r ~s ~s ~s",
- [Rev, Url, filename:basename(AppDir)]),
- [{cd, filename:dirname(AppDir)}]);
-download_source(AppDir, {rsync, Url}) ->
- ok = filelib:ensure_dir(AppDir),
- rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s", [Url, AppDir]), []);
-download_source(AppDir, {fossil, Url}) ->
- download_source(AppDir, {fossil, Url, ""});
-download_source(AppDir, {fossil, Url, Version}) ->
- Repository = filename:join(AppDir, filename:basename(AppDir) ++ ".fossil"),
- ok = filelib:ensure_dir(Repository),
- ok = file:set_cwd(AppDir),
- rebar_utils:sh(?FMT("fossil clone ~s ~s", [Url, Repository]),
- [{cd, AppDir}]),
- rebar_utils:sh(?FMT("fossil open ~s ~s --nested", [Repository, Version]),
- []).
-
-update_source(Config, Dep) ->
- %% It's possible when updating a source, that a given dep does not have a
- %% VCS directory, such as when a source archive is built of a project, with
- %% all deps already downloaded/included. So, verify that the necessary VCS
- %% directory exists before attempting to do the update.
- {true, AppDir} = get_deps_dir(Config, Dep#dep.app),
- case has_vcs_dir(element(1, Dep#dep.source), AppDir) of
- true ->
- ?CONSOLE("Updating ~p from ~p\n", [Dep#dep.app, Dep#dep.source]),
- require_source_engine(Dep#dep.source),
- update_source1(AppDir, Dep#dep.source),
- Dep;
- false ->
- ?WARN("Skipping update for ~p: "
- "no VCS directory available!\n", [Dep]),
- Dep
- end.
-
-update_source1(AppDir, {git, Url}) ->
- update_source1(AppDir, {git, Url, {branch, "HEAD"}});
-update_source1(AppDir, {git, Url, ""}) ->
- update_source1(AppDir, {git, Url, {branch, "HEAD"}});
-update_source1(AppDir, {git, _Url, {branch, Branch}}) ->
- ShOpts = [{cd, AppDir}],
- rebar_utils:sh("git fetch origin", ShOpts),
- rebar_utils:sh(?FMT("git checkout -q ~s", [Branch]), ShOpts),
- rebar_utils:sh(
- ?FMT("git pull --ff-only --no-rebase -q origin ~s", [Branch]),ShOpts);
-update_source1(AppDir, {git, _Url, {tag, Tag}}) ->
- ShOpts = [{cd, AppDir}],
- rebar_utils:sh("git fetch origin", ShOpts),
- rebar_utils:sh(?FMT("git checkout -q ~s", [Tag]), ShOpts);
-update_source1(AppDir, {git, _Url, Refspec}) ->
- ShOpts = [{cd, AppDir}],
- rebar_utils:sh("git fetch origin", ShOpts),
- rebar_utils:sh(?FMT("git checkout -q ~s", [Refspec]), ShOpts);
-update_source1(AppDir, {svn, _Url, Rev}) ->
- rebar_utils:sh(?FMT("svn up -r ~s", [Rev]), [{cd, AppDir}]);
-update_source1(AppDir, {hg, _Url, Rev}) ->
- rebar_utils:sh(?FMT("hg pull -u -r ~s", [Rev]), [{cd, AppDir}]);
-update_source1(AppDir, {bzr, _Url, Rev}) ->
- rebar_utils:sh(?FMT("bzr update -r ~s", [Rev]), [{cd, AppDir}]);
-update_source1(AppDir, {rsync, Url}) ->
- rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s",[Url,AppDir]),[]);
-update_source1(AppDir, {fossil, Url}) ->
- update_source1(AppDir, {fossil, Url, ""});
-update_source1(AppDir, {fossil, _Url, Version}) ->
- ok = file:set_cwd(AppDir),
- rebar_utils:sh("fossil pull", [{cd, AppDir}]),
- rebar_utils:sh(?FMT("fossil update ~s", [Version]), []).
-
-%% Recursively update deps, this is not done via rebar's usual dep traversal as
-%% that is the wrong order (tips are updated before branches). Instead we do a
-%% traverse the deps at each level completely before traversing *their* deps.
-%% This allows updates to actually propogate down the tree, rather than fail to
-%% flow up the tree, which was the previous behaviour.
-update_deps_int(Config0, UDD) ->
- %% Determine what deps are required
- ConfDir = filename:basename(rebar_utils:get_cwd()),
- RawDeps = rebar_config:get_local(Config0, deps, []),
- {Config1, Deps} = find_deps(Config0, read, RawDeps),
-
- %% Update each dep
- UpdatedDeps = [update_source(Config1, D)
- || D <- Deps, D#dep.source =/= undefined,
- not lists:member(D, UDD),
- not should_skip_update_dep(Config1, D)
- ],
-
- lists:foldl(fun(Dep, {Config, Updated}) ->
- {true, AppDir} = get_deps_dir(Config, Dep#dep.app),
- Config2 = case has_vcs_dir(element(1, Dep#dep.source),
- AppDir) of
- false ->
- %% If the dep did not exist (maybe it
- %% was added), clone it.
- %% We'll traverse ITS deps below and
- %% clone them if needed.
- {C1, _D1} = use_source(Config, Dep),
- C1;
- true ->
- Config
- end,
- ok = file:set_cwd(AppDir),
- Config3 = rebar_config:new(Config2),
- %% track where a dep comes from...
- DepOwner = dict:append(
- Dep, ConfDir,
- rebar_config:get_xconf(Config3, depowner,
- dict:new())),
- Config4 = rebar_config:set_xconf(Config3, depowner,
- DepOwner),
-
- {Config5, Res} = update_deps_int(Config4, Updated),
- {Config5, lists:umerge(lists:sort(Res),
- lists:sort(Updated))}
- end, {Config1, lists:umerge(lists:sort(UpdatedDeps),
- lists:sort(UDD))}, UpdatedDeps).
-
-should_skip_update_dep(Config, Dep) ->
- {true, AppDir} = get_deps_dir(Config, Dep#dep.app),
- case rebar_app_utils:is_app_dir(AppDir) of
- false ->
- false;
- {true, AppFile} ->
- case rebar_app_utils:is_skipped_app(Config, AppFile) of
- {_Config, {true, _SkippedApp}} ->
- true;
- _ ->
- false
- end
- end.
-
-%% Recursively walk the deps and build a list of them.
-collect_deps(Dir, C) ->
- case file:set_cwd(Dir) of
- ok ->
- Config = rebar_config:new(C),
- RawDeps = rebar_config:get_local(Config, deps, []),
- {Config1, Deps} = find_deps(Config, read, RawDeps),
-
- lists:flatten(Deps ++ [begin
- {true, AppDir} = get_deps_dir(
- Config1, Dep#dep.app),
- collect_deps(AppDir, C)
- end || Dep <- Deps]);
- _ ->
- []
- end.
-
-
-%% ===================================================================
-%% Source helper functions
-%% ===================================================================
-
-source_engine_avail(Source) ->
- Name = element(1, Source),
- source_engine_avail(Name, Source).
-
-source_engine_avail(Name, Source)
- when Name == hg; Name == git; Name == svn; Name == bzr; Name == rsync;
- Name == fossil ->
- case vcs_client_vsn(Name) >= required_vcs_client_vsn(Name) of
- true ->
- true;
- false ->
- ?ABORT("Rebar requires version ~p or higher of ~s to process ~p\n",
- [required_vcs_client_vsn(Name), Name, Source])
- end.
-
-vcs_client_vsn(false, _VsnArg, _VsnRegex) ->
- false;
-vcs_client_vsn(Path, VsnArg, VsnRegex) ->
- {ok, Info} = rebar_utils:sh(Path ++ VsnArg, [{env, [{"LANG", "C"}]},
- {use_stdout, false}]),
- case re:run(Info, VsnRegex, [{capture, all_but_first, list}]) of
- {match, Match} ->
- list_to_tuple([list_to_integer(S) || S <- Match]);
- _ ->
- false
- end.
-
-required_vcs_client_vsn(hg) -> {1, 1};
-required_vcs_client_vsn(git) -> {1, 5};
-required_vcs_client_vsn(bzr) -> {2, 0};
-required_vcs_client_vsn(svn) -> {1, 6};
-required_vcs_client_vsn(rsync) -> {2, 0};
-required_vcs_client_vsn(fossil) -> {1, 0}.
-
-vcs_client_vsn(hg) ->
- vcs_client_vsn(rebar_utils:find_executable("hg"), " --version",
- "version (\\d+).(\\d+)");
-vcs_client_vsn(git) ->
- vcs_client_vsn(rebar_utils:find_executable("git"), " --version",
- "git version (\\d+).(\\d+)");
-vcs_client_vsn(bzr) ->
- vcs_client_vsn(rebar_utils:find_executable("bzr"), " --version",
- "Bazaar \\(bzr\\) (\\d+).(\\d+)");
-vcs_client_vsn(svn) ->
- vcs_client_vsn(rebar_utils:find_executable("svn"), " --version",
- "svn, version (\\d+).(\\d+)");
-vcs_client_vsn(rsync) ->
- vcs_client_vsn(rebar_utils:find_executable("rsync"), " --version",
- "rsync version (\\d+).(\\d+)");
-vcs_client_vsn(fossil) ->
- vcs_client_vsn(rebar_utils:find_executable("fossil"), " version",
- "version (\\d+).(\\d+)").
-
-has_vcs_dir(git, Dir) ->
- filelib:is_dir(filename:join(Dir, ".git"));
-has_vcs_dir(hg, Dir) ->
- filelib:is_dir(filename:join(Dir, ".hg"));
-has_vcs_dir(bzr, Dir) ->
- filelib:is_dir(filename:join(Dir, ".bzr"));
-has_vcs_dir(svn, Dir) ->
- filelib:is_dir(filename:join(Dir, ".svn"))
- orelse filelib:is_dir(filename:join(Dir, "_svn"));
-has_vcs_dir(rsync, _) ->
- true;
-has_vcs_dir(_, _) ->
- true.
-
-print_source(#dep{app=App, source=Source}) ->
- ?CONSOLE("~s~n", [format_source(App, Source)]).
-
-format_source(App, {git, Url}) ->
- ?FMT("~p BRANCH ~s ~s", [App, "HEAD", Url]);
-format_source(App, {git, Url, ""}) ->
- ?FMT("~p BRANCH ~s ~s", [App, "HEAD", Url]);
-format_source(App, {git, Url, {branch, Branch}}) ->
- ?FMT("~p BRANCH ~s ~s", [App, Branch, Url]);
-format_source(App, {git, Url, {tag, Tag}}) ->
- ?FMT("~p TAG ~s ~s", [App, Tag, Url]);
-format_source(App, {_, Url, Rev}) ->
- ?FMT("~p REV ~s ~s", [App, Rev, Url]);
-format_source(App, undefined) ->
- ?FMT("~p", [App]).
diff --git a/src/rebar/src/rebar_dia_compiler.erl b/src/rebar/src/rebar_dia_compiler.erl
deleted file mode 100644
index f81c73438..000000000
--- a/src/rebar/src/rebar_dia_compiler.erl
+++ /dev/null
@@ -1,106 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009, 2010 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_dia_compiler).
-
--export([compile/2, clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
--spec compile(rebar_config:config(), file:filename()) -> 'ok'.
-compile(Config, _AppFile) ->
- rebar_base_compiler:run(Config, filelib:wildcard("dia/*.dia"),
- "dia", ".dia", "src", ".erl",
- fun compile_dia/3).
-
--spec clean(rebar_config:config(), file:filename()) -> 'ok'.
-clean(_Config, _AppFile) ->
- GeneratedFiles = dia_generated_files("dia", "src", "include"),
- ok = rebar_file_utils:delete_each(GeneratedFiles),
- ok.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- info_help("Build Diameter (*.dia) sources");
-info(help, clean) ->
- info_help("Delete generated Diameter files").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " {dia_opts, []} (see diameter_codegen:from_dict/4 documentation)~n",
- [Description]).
-
--spec compile_dia(file:filename(), file:filename(),
- rebar_config:config()) -> ok.
-compile_dia(Source, Target, Config) ->
- ok = filelib:ensure_dir(Target),
- ok = filelib:ensure_dir(filename:join("include", "dummy.hrl")),
- Opts = [{outdir, "src"}] ++ rebar_config:get(Config, dia_opts, []),
- case diameter_dict_util:parse({path, Source}, []) of
- {ok, Spec} ->
- FileName = dia_filename(Source, Spec),
- diameter_codegen:from_dict(FileName, Spec, Opts, erl),
- diameter_codegen:from_dict(FileName, Spec, Opts, hrl),
- HrlFile = filename:join("src", FileName ++ ".hrl"),
- case filelib:is_regular(HrlFile) of
- true ->
- ok = rebar_file_utils:mv(HrlFile, "include");
- false ->
- ok
- end;
- {error, Reason} ->
- ?ERROR("~s~n", [diameter_dict_util:format_error(Reason)])
- end.
-
-dia_generated_files(DiaDir, SrcDir, IncDir) ->
- F = fun(File, Acc) ->
- {ok, Spec} = diameter_dict_util:parse({path, File}, []),
- FileName = dia_filename(File, Spec),
- [filename:join([IncDir, FileName ++ ".hrl"]) |
- filelib:wildcard(filename:join([SrcDir, FileName ++ ".*"]))] ++ Acc
- end,
- lists:foldl(F, [], filelib:wildcard(filename:join([DiaDir, "*.dia"]))).
-
-dia_filename(File, Spec) ->
- case proplists:get_value(name, Spec) of
- undefined ->
- filename:rootname(filename:basename(File));
- Name ->
- Name
- end.
diff --git a/src/rebar/src/rebar_edoc.erl b/src/rebar/src/rebar_edoc.erl
deleted file mode 100644
index c828d2718..000000000
--- a/src/rebar/src/rebar_edoc.erl
+++ /dev/null
@@ -1,130 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2010 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-%% @author Dave Smith <dizzyd@dizzyd.com>
-%% @doc rebar_edoc supports the following command:
-%% <ul>
-%% <li>doc (essentially erl -noshell -run edoc_run application
-%% "'$(&lt;app_name&gt;)'"
-%% '"."' '[&lt;options&gt;]')</li>
-%% </ul>
-%% EDoc options can be given in the <code>edoc_opts</code> option in
-%% <code>rebar.config</code>.
-%% @copyright 2010 Dave Smith
-%% -------------------------------------------------------------------
--module(rebar_edoc).
-
--export([doc/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-doc(Config, File) ->
- %% Save code path
- CodePath = setup_code_path(),
-
- %% Get the edoc_opts and app file info
- EDocOpts = rebar_config:get(Config, edoc_opts, []),
- {ok, Config1, AppName, _AppData} =
- rebar_app_utils:load_app_file(Config, File),
-
- case needs_regen(EDocOpts) of
- true ->
- ?INFO("Regenerating edocs for ~p\n", [AppName]),
- ok = edoc:application(AppName, ".", EDocOpts);
- false ->
- ?INFO("Skipping regeneration of edocs for ~p\n", [AppName]),
- ok
- end,
-
- %% Restore code path
- true = code:set_path(CodePath),
- {ok, Config1}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, doc) ->
- ?CONSOLE(
- "Generate Erlang program documentation.~n"
- "~n"
- "Valid rebar.config options:~n"
- " {edoc_opts, []} (see edoc:application/3 documentation)~n",
- []).
-
-setup_code_path() ->
- %% Setup code path prior to calling edoc so that edown, asciiedoc,
- %% and the like can work properly when generating their own
- %% documentation.
- CodePath = code:get_path(),
- true = code:add_patha(rebar_utils:ebin_dir()),
- CodePath.
-
--type path_spec() :: {'file', file:filename()} | file:filename().
--spec newer_file_exists(Paths::[path_spec()], OldFile::string()) -> boolean().
-newer_file_exists(Paths, OldFile) ->
- OldModTime = filelib:last_modified(OldFile),
-
- ThrowIfNewer = fun(Fn, _Acc) ->
- FModTime = filelib:last_modified(Fn),
- (FModTime > OldModTime) andalso
- throw({newer_file_exists, {Fn, FModTime}})
- end,
-
- try
- lists:foldl(fun({file, F}, _) ->
- ThrowIfNewer(F, false);
- (P, _) ->
- filelib:fold_files(P, ".*.erl", true,
- ThrowIfNewer, false)
- end, undefined, Paths)
- catch
- throw:{newer_file_exists, {Filename, FMod}} ->
- ?DEBUG("~p is more recent than ~p: "
- "~120p > ~120p\n",
- [Filename, OldFile, FMod, OldModTime]),
- true
- end.
-
-%% Needs regen if any dependent file is changed since the last
-%% edoc run. Dependent files are the erlang source files,
-%% and the overview file, if it exists.
--spec needs_regen(proplists:proplist()) -> boolean().
-needs_regen(EDocOpts) ->
- DocDir = proplists:get_value(dir, EDocOpts, "doc"),
- EDocInfoName = filename:join(DocDir, "edoc-info"),
- OverviewFile = proplists:get_value(overview, EDocOpts, "overview.edoc"),
- EDocOverviewName = filename:join(DocDir, OverviewFile),
- SrcPaths = proplists:get_value(source_path, EDocOpts, ["src"]),
-
- newer_file_exists([{file, EDocOverviewName} | SrcPaths], EDocInfoName).
diff --git a/src/rebar/src/rebar_erlc_compiler.erl b/src/rebar/src/rebar_erlc_compiler.erl
deleted file mode 100644
index dbefa4aaf..000000000
--- a/src/rebar/src/rebar_erlc_compiler.erl
+++ /dev/null
@@ -1,511 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009, 2010 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_erlc_compiler).
-
--export([compile/2,
- clean/2]).
-
-%% for internal use only
--export([test_compile/3,
- info/2]).
-
--include("rebar.hrl").
--include_lib("stdlib/include/erl_compile.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-%% Supported configuration variables:
-%%
-%% * erl_opts - Erlang list of options passed to compile:file/2
-%% It is also possible to specify platform specific
-%% options by specifying a pair or a triplet where the
-%% first string is a regex that is checked against the
-%% string
-%%
-%% OtpRelease ++ "-" ++ SysArch ++ "-" ++ Words.
-%%
-%% where
-%%
-%% OtpRelease = erlang:system_info(otp_release).
-%% SysArch = erlang:system_info(system_architecture).
-%% Words = integer_to_list(8 *
-%% erlang:system_info({wordsize, external})).
-%%
-%% E.g. to define HAVE_SENDFILE only on systems with
-%% sendfile(), to define BACKLOG on Linux/FreeBSD as 128,
-%% and to define 'old_inets' for R13 OTP release do:
-%%
-%% {erl_opts, [{platform_define,
-%% "(linux|solaris|freebsd|darwin)",
-%% 'HAVE_SENDFILE'},
-%% {platform_define, "(linux|freebsd)",
-%% 'BACKLOG', 128},
-%% {platform_define, "R13",
-%% 'old_inets'}]}.
-%%
-
--spec compile(rebar_config:config(), file:filename()) -> 'ok'.
-compile(Config, _AppFile) ->
- rebar_base_compiler:run(Config,
- check_files(rebar_config:get_local(
- Config, xrl_first_files, [])),
- "src", ".xrl", "src", ".erl",
- fun compile_xrl/3),
- rebar_base_compiler:run(Config,
- check_files(rebar_config:get_local(
- Config, yrl_first_files, [])),
- "src", ".yrl", "src", ".erl",
- fun compile_yrl/3),
- rebar_base_compiler:run(Config,
- check_files(rebar_config:get_local(
- Config, mib_first_files, [])),
- "mibs", ".mib", "priv/mibs", ".bin",
- fun compile_mib/3),
- doterl_compile(Config, "ebin").
-
--spec clean(rebar_config:config(), file:filename()) -> 'ok'.
-clean(_Config, _AppFile) ->
- MibFiles = rebar_utils:find_files("mibs", "^.*\\.mib\$"),
- MIBs = [filename:rootname(filename:basename(MIB)) || MIB <- MibFiles],
- rebar_file_utils:delete_each(
- [filename:join(["include",MIB++".hrl"]) || MIB <- MIBs]),
- lists:foreach(fun(F) -> ok = rebar_file_utils:rm_rf(F) end,
- ["ebin/*.beam", "priv/mibs/*.bin"]),
-
- YrlFiles = rebar_utils:find_files("src", "^.*\\.[x|y]rl\$"),
- rebar_file_utils:delete_each(
- [ binary_to_list(iolist_to_binary(re:replace(F, "\\.[x|y]rl$", ".erl")))
- || F <- YrlFiles ]),
-
- %% Erlang compilation is recursive, so it's possible that we have a nested
- %% directory structure in ebin with .beam files within. As such, we want
- %% to scan whatever is left in the ebin/ directory for sub-dirs which
- %% satisfy our criteria.
- BeamFiles = rebar_utils:find_files("ebin", "^.*\\.beam\$"),
- rebar_file_utils:delete_each(BeamFiles),
- lists:foreach(fun(Dir) -> delete_dir(Dir, dirs(Dir)) end, dirs("ebin")),
- ok.
-
-%% ===================================================================
-%% .erl Compilation API (externally used by only eunit and qc)
-%% ===================================================================
-
-test_compile(Config, Cmd, OutDir) ->
- %% Obtain all the test modules for inclusion in the compile stage.
- TestErls = rebar_utils:find_files("test", ".*\\.erl\$"),
-
- %% Copy source files to eunit dir for cover in case they are not directly
- %% in src but in a subdirectory of src. Cover only looks in cwd and ../src
- %% for source files. Also copy files from src_dirs.
- ErlOpts = rebar_utils:erl_opts(Config),
-
- SrcDirs = rebar_utils:src_dirs(proplists:append_values(src_dirs, ErlOpts)),
- SrcErls = lists:foldl(
- fun(Dir, Acc) ->
- Files = rebar_utils:find_files(Dir, ".*\\.erl\$"),
- lists:append(Acc, Files)
- end, [], SrcDirs),
-
- %% If it is not the first time rebar eunit is executed, there will be source
- %% files already present in OutDir. Since some SCMs (like Perforce) set
- %% the source files as being read only (unless they are checked out), we
- %% need to be sure that the files already present in OutDir are writable
- %% before doing the copy. This is done here by removing any file that was
- %% already present before calling rebar_file_utils:cp_r.
-
- %% Get the full path to a file that was previously copied in OutDir
- ToCleanUp = fun(F, Acc) ->
- F2 = filename:basename(F),
- F3 = filename:join([OutDir, F2]),
- case filelib:is_regular(F3) of
- true -> [F3|Acc];
- false -> Acc
- end
- end,
-
- ok = rebar_file_utils:delete_each(lists:foldl(ToCleanUp, [], TestErls)),
- ok = rebar_file_utils:delete_each(lists:foldl(ToCleanUp, [], SrcErls)),
-
- ok = rebar_file_utils:cp_r(SrcErls ++ TestErls, OutDir),
-
- %% Compile erlang code to OutDir, using a tweaked config
- %% with appropriate defines for eunit, and include all the test modules
- %% as well.
- ok = doterl_compile(test_compile_config(Config, ErlOpts, Cmd),
- OutDir, TestErls),
-
- {ok, SrcErls}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- info_help("Build *.erl, *.yrl, *.xrl, and *.mib sources");
-info(help, clean) ->
- info_help("Delete *.erl, *.yrl, *.xrl, and *.mib build results").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n",
- [
- Description,
- {erl_opts, [no_debug_info,
- {i, "myinclude"},
- {src_dirs, ["src", "src2", "src3"]},
- {platform_define,
- "(linux|solaris|freebsd|darwin)", 'HAVE_SENDFILE'},
- {platform_define, "(linux|freebsd)", 'BACKLOG', 128},
- {platform_define, "R13", 'old_inets'}]},
- {erl_first_files, ["mymib1", "mymib2"]},
- {mib_opts, []},
- {mib_first_files, []},
- {xrl_opts, []},
- {xrl_first_files, []},
- {yrl_opts, []},
- {yrl_first_files, []}
- ]).
-
-test_compile_config(Config, ErlOpts, Cmd) ->
- {Config1, TriqOpts} = triq_opts(Config),
- {Config2, PropErOpts} = proper_opts(Config1),
- {Config3, EqcOpts} = eqc_opts(Config2),
-
- OptsAtom = list_to_atom(Cmd ++ "_compile_opts"),
- EunitOpts = rebar_config:get_list(Config3, OptsAtom, []),
- Opts0 = [{d, 'TEST'}] ++
- ErlOpts ++ EunitOpts ++ TriqOpts ++ PropErOpts ++ EqcOpts,
- Opts = [O || O <- Opts0, O =/= no_debug_info],
- Config4 = rebar_config:set(Config3, erl_opts, Opts),
-
- FirstFilesAtom = list_to_atom(Cmd ++ "_first_files"),
- FirstErls = rebar_config:get_list(Config4, FirstFilesAtom, []),
- rebar_config:set(Config4, erl_first_files, FirstErls).
-
-triq_opts(Config) ->
- {NewConfig, IsAvail} = is_lib_avail(Config, is_triq_avail, triq,
- "triq.hrl", "Triq"),
- Opts = define_if('TRIQ', IsAvail),
- {NewConfig, Opts}.
-
-proper_opts(Config) ->
- {NewConfig, IsAvail} = is_lib_avail(Config, is_proper_avail, proper,
- "proper.hrl", "PropEr"),
- Opts = define_if('PROPER', IsAvail),
- {NewConfig, Opts}.
-
-eqc_opts(Config) ->
- {NewConfig, IsAvail} = is_lib_avail(Config, is_eqc_avail, eqc,
- "eqc.hrl", "QuickCheck"),
- Opts = define_if('EQC', IsAvail),
- {NewConfig, Opts}.
-
-define_if(Def, true) -> [{d, Def}];
-define_if(_Def, false) -> [].
-
-is_lib_avail(Config, DictKey, Mod, Hrl, Name) ->
- case rebar_config:get_xconf(Config, DictKey, undefined) of
- undefined ->
- IsAvail = case code:lib_dir(Mod, include) of
- {error, bad_name} ->
- false;
- Dir ->
- filelib:is_regular(filename:join(Dir, Hrl))
- end,
- NewConfig = rebar_config:set_xconf(Config, DictKey, IsAvail),
- ?DEBUG("~s availability: ~p\n", [Name, IsAvail]),
- {NewConfig, IsAvail};
- IsAvail ->
- {Config, IsAvail}
- end.
-
--spec doterl_compile(rebar_config:config(), file:filename()) -> 'ok'.
-doterl_compile(Config, OutDir) ->
- doterl_compile(Config, OutDir, []).
-
-doterl_compile(Config, OutDir, MoreSources) ->
- FirstErls = rebar_config:get_list(Config, erl_first_files, []),
- ErlOpts = rebar_utils:erl_opts(Config),
- ?DEBUG("erl_opts ~p~n", [ErlOpts]),
- %% Support the src_dirs option allowing multiple directories to
- %% contain erlang source. This might be used, for example, should
- %% eunit tests be separated from the core application source.
- SrcDirs = rebar_utils:src_dirs(proplists:append_values(src_dirs, ErlOpts)),
- RestErls = [Source || Source <- gather_src(SrcDirs, []) ++ MoreSources,
- not lists:member(Source, FirstErls)],
-
- %% Split RestErls so that parse_transforms and behaviours are instead added
- %% to erl_first_files, parse transforms first.
- %% This should probably be somewhat combined with inspect_epp
- [ParseTransforms, Behaviours, OtherErls] =
- lists:foldl(fun(F, [A, B, C]) ->
- case compile_priority(F) of
- parse_transform ->
- [[F | A], B, C];
- behaviour ->
- [A, [F | B], C];
- callback ->
- [A, [F | B], C];
- _ ->
- [A, B, [F | C]]
- end
- end, [[], [], []], RestErls),
-
- NewFirstErls = FirstErls ++ ParseTransforms ++ Behaviours,
-
- %% Make sure that ebin/ exists and is on the path
- ok = filelib:ensure_dir(filename:join("ebin", "dummy.beam")),
- CurrPath = code:get_path(),
- true = code:add_path(filename:absname("ebin")),
- OutDir1 = proplists:get_value(outdir, ErlOpts, OutDir),
- rebar_base_compiler:run(Config, NewFirstErls, OtherErls,
- fun(S, C) ->
- internal_erl_compile(C, S, OutDir1, ErlOpts)
- end),
- true = code:set_path(CurrPath),
- ok.
-
--spec include_path(file:filename(),
- rebar_config:config()) -> [file:filename(), ...].
-include_path(Source, Config) ->
- ErlOpts = rebar_config:get(Config, erl_opts, []),
- ["include", filename:dirname(Source)]
- ++ proplists:get_all_values(i, ErlOpts).
-
--spec inspect(file:filename(),
- [file:filename(), ...]) -> {string(), [string()]}.
-inspect(Source, IncludePath) ->
- ModuleDefault = filename:basename(Source, ".erl"),
- case epp:open(Source, IncludePath) of
- {ok, Epp} ->
- inspect_epp(Epp, Source, ModuleDefault, []);
- {error, Reason} ->
- ?DEBUG("Failed to inspect ~s: ~p\n", [Source, Reason]),
- {ModuleDefault, []}
- end.
-
--spec inspect_epp(pid(), file:filename(), file:filename(),
- [string()]) -> {string(), [string()]}.
-inspect_epp(Epp, Source, Module, Includes) ->
- case epp:parse_erl_form(Epp) of
- {ok, {attribute, _, module, ModInfo}} ->
- ActualModuleStr =
- case ModInfo of
- %% Typical module name, single atom
- ActualModule when is_atom(ActualModule) ->
- atom_to_list(ActualModule);
- %% Packag-ized module name, list of atoms
- ActualModule when is_list(ActualModule) ->
- string:join([atom_to_list(P) ||
- P <- ActualModule], ".");
- %% Parameterized module name, single atom
- {ActualModule, _} when is_atom(ActualModule) ->
- atom_to_list(ActualModule);
- %% Parameterized and packagized module name, list of atoms
- {ActualModule, _} when is_list(ActualModule) ->
- string:join([atom_to_list(P) ||
- P <- ActualModule], ".")
- end,
- inspect_epp(Epp, Source, ActualModuleStr, Includes);
- {ok, {attribute, 1, file, {Module, 1}}} ->
- inspect_epp(Epp, Source, Module, Includes);
- {ok, {attribute, 1, file, {Source, 1}}} ->
- inspect_epp(Epp, Source, Module, Includes);
- {ok, {attribute, 1, file, {IncFile, 1}}} ->
- inspect_epp(Epp, Source, Module, [IncFile | Includes]);
- {eof, _} ->
- epp:close(Epp),
- {Module, Includes};
- _ ->
- inspect_epp(Epp, Source, Module, Includes)
- end.
-
--spec needs_compile(file:filename(), file:filename(),
- [string()]) -> boolean().
-needs_compile(Source, Target, Hrls) ->
- TargetLastMod = filelib:last_modified(Target),
- lists:any(fun(I) -> TargetLastMod < filelib:last_modified(I) end,
- [Source] ++ Hrls).
-
--spec internal_erl_compile(rebar_config:config(), file:filename(),
- file:filename(), list()) -> 'ok' | 'skipped'.
-internal_erl_compile(Config, Source, Outdir, ErlOpts) ->
- %% Determine the target name and includes list by inspecting the source file
- {Module, Hrls} = inspect(Source, include_path(Source, Config)),
-
- %% Construct the target filename
- Target = filename:join([Outdir | string:tokens(Module, ".")]) ++ ".beam",
- ok = filelib:ensure_dir(Target),
-
- %% If the file needs compilation, based on last mod date of includes or
- %% the target
- case needs_compile(Source, Target, Hrls) of
- true ->
- Opts = [{outdir, filename:dirname(Target)}] ++
- ErlOpts ++ [{i, "include"}, return],
- case compile:file(Source, Opts) of
- {ok, _Mod} ->
- ok;
- {ok, _Mod, Ws} ->
- rebar_base_compiler:ok_tuple(Config, Source, Ws);
- {error, Es, Ws} ->
- rebar_base_compiler:error_tuple(Config, Source,
- Es, Ws, Opts)
- end;
- false ->
- skipped
- end.
-
--spec compile_mib(file:filename(), file:filename(),
- rebar_config:config()) -> 'ok'.
-compile_mib(Source, Target, Config) ->
- ok = rebar_utils:ensure_dir(Target),
- ok = rebar_utils:ensure_dir(filename:join("include", "dummy.hrl")),
- Opts = [{outdir, "priv/mibs"}, {i, ["priv/mibs"]}] ++
- rebar_config:get(Config, mib_opts, []),
- case snmpc:compile(Source, Opts) of
- {ok, _} ->
- Mib = filename:rootname(Target),
- MibToHrlOpts =
- case proplists:get_value(verbosity, Opts, undefined) of
- undefined ->
- #options{specific = []};
- Verbosity ->
- #options{specific = [{verbosity, Verbosity}]}
- end,
- ok = snmpc:mib_to_hrl(Mib, Mib, MibToHrlOpts),
- Hrl_filename = Mib ++ ".hrl",
- rebar_file_utils:mv(Hrl_filename, "include"),
- ok;
- {error, compilation_failed} ->
- ?FAIL
- end.
-
--spec compile_xrl(file:filename(), file:filename(),
- rebar_config:config()) -> 'ok'.
-compile_xrl(Source, Target, Config) ->
- Opts = [{scannerfile, Target} | rebar_config:get(Config, xrl_opts, [])],
- compile_xrl_yrl(Config, Source, Target, Opts, leex).
-
--spec compile_yrl(file:filename(), file:filename(),
- rebar_config:config()) -> 'ok'.
-compile_yrl(Source, Target, Config) ->
- Opts = [{parserfile, Target} | rebar_config:get(Config, yrl_opts, [])],
- compile_xrl_yrl(Config, Source, Target, Opts, yecc).
-
--spec compile_xrl_yrl(rebar_config:config(), file:filename(),
- file:filename(), list(), module()) -> 'ok'.
-compile_xrl_yrl(Config, Source, Target, Opts, Mod) ->
- case needs_compile(Source, Target, []) of
- true ->
- case Mod:file(Source, Opts ++ [{return, true}]) of
- {ok, _} ->
- ok;
- {ok, _Mod, Ws} ->
- rebar_base_compiler:ok_tuple(Config, Source, Ws);
- {error, Es, Ws} ->
- rebar_base_compiler:error_tuple(Config, Source,
- Es, Ws, Opts)
- end;
- false ->
- skipped
- end.
-
-gather_src([], Srcs) ->
- Srcs;
-gather_src([Dir|Rest], Srcs) ->
- gather_src(Rest, Srcs ++ rebar_utils:find_files(Dir, ".*\\.erl\$")).
-
--spec dirs(file:filename()) -> [file:filename()].
-dirs(Dir) ->
- [F || F <- filelib:wildcard(filename:join([Dir, "*"])), filelib:is_dir(F)].
-
--spec delete_dir(file:filename(), [string()]) -> 'ok' | {'error', atom()}.
-delete_dir(Dir, []) ->
- file:del_dir(Dir);
-delete_dir(Dir, Subdirs) ->
- lists:foreach(fun(D) -> delete_dir(D, dirs(D)) end, Subdirs),
- file:del_dir(Dir).
-
--spec compile_priority(file:filename()) -> 'normal' | 'behaviour' |
- 'callback' |
- 'parse_transform'.
-compile_priority(File) ->
- case epp_dodger:parse_file(File) of
- {error, _} ->
- normal; % couldn't parse the file, default priority
- {ok, Trees} ->
- F2 = fun({tree,arity_qualifier,_,
- {arity_qualifier,{tree,atom,_,behaviour_info},
- {tree,integer,_,1}}}, _) ->
- behaviour;
- ({tree,arity_qualifier,_,
- {arity_qualifier,{tree,atom,_,parse_transform},
- {tree,integer,_,2}}}, _) ->
- parse_transform;
- (_, Acc) ->
- Acc
- end,
-
- F = fun({tree, attribute, _,
- {attribute, {tree, atom, _, export},
- [{tree, list, _, {list, List, none}}]}}, Acc) ->
- lists:foldl(F2, Acc, List);
- ({tree, attribute, _,
- {attribute, {tree, atom, _, callback},_}}, _Acc) ->
- callback;
- (_, Acc) ->
- Acc
- end,
-
- lists:foldl(F, normal, Trees)
- end.
-
-%%
-%% Ensure all files in a list are present and abort if one is missing
-%%
--spec check_files([file:filename()]) -> [file:filename()].
-check_files(FileList) ->
- [check_file(F) || F <- FileList].
-
-check_file(File) ->
- case filelib:is_regular(File) of
- false -> ?ABORT("File ~p is missing, aborting\n", [File]);
- true -> File
- end.
diff --git a/src/rebar/src/rebar_erlydtl_compiler.erl b/src/rebar/src/rebar_erlydtl_compiler.erl
deleted file mode 100644
index 6172879ac..000000000
--- a/src/rebar/src/rebar_erlydtl_compiler.erl
+++ /dev/null
@@ -1,265 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com),
-%% Bryan Fink (bryan@basho.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-
-%% The rebar_erlydtl_compiler module is a plugin for rebar that compiles
-%% ErlyDTL templates. By default, it compiles all templates/*.dtl
-%% to ebin/*_dtl.beam.
-%%
-%% Configuration options should be placed in rebar.config under
-%% 'erlydtl_opts'. It can be a list of name-value tuples or a list of
-%% lists of name-value tuples if you have multiple template directories
-%% that need to have different settings (see example below).
-%%
-%% Available options include:
-%%
-%% doc_root: where to find templates to compile
-%% "templates" by default
-%%
-%% out_dir: where to put compiled template beam files
-%% "ebin" by default
-%%
-%% source_ext: the file extension the template sources have
-%% ".dtl" by default
-%%
-%% module_ext: characters to append to the template's module name
-%% "_dtl" by default
-%%
-%% recursive: boolean that determines if doc_root(s) need to be
-%% scanned recursively for matching template file names
-%% (default: true).
-%% For example, if you had:
-%% /t_src/
-%% base.html
-%% foo.html
-%%
-%% And you wanted them compiled to:
-%% /priv/
-%% base.beam
-%% foo.beam
-%%
-%% You would add to your rebar.config:
-%% {erlydtl_opts, [
-%% {doc_root, "t_src"},
-%% {out_dir, "priv"},
-%% {source_ext, ".html"},
-%% {module_ext, ""}
-%% ]}.
-%%
-%% The default settings are the equivalent of:
-%% {erlydtl_opts, [
-%% {doc_root, "templates"},
-%% {out_dir, "ebin"},
-%% {source_ext, ".dtl"},
-%% {module_ext, "_dtl"}
-%% ]}.
-%%
-%% The following example will compile the following templates:
-%% "src/*.dtl" files into "ebin/*_dtl.beam" and
-%% "templates/*.html" into "ebin/*.beam". Note that any tuple option
-%% (such as 'out_dir') in the outer list is added to each inner list:
-%% {erlydtl_opts, [
-%% {out_dir, "ebin"},
-%% {recursive, false},
-%% [
-%% {doc_root, "src"}, {module_ext, "_dtl"}
-%% ],
-%% [
-%% {doc_root, "templates", {module_ext, ""}, {source_ext, ".html"}
-%% ]
-%% ]}.
--module(rebar_erlydtl_compiler).
-
--export([compile/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-compile(Config, _AppFile) ->
- MultiDtlOpts = erlydtl_opts(Config),
- OrigPath = code:get_path(),
- true = code:add_path(rebar_utils:ebin_dir()),
-
- Result = lists:foldl(fun(DtlOpts, _) ->
- rebar_base_compiler:run(Config, [],
- option(doc_root, DtlOpts),
- option(source_ext, DtlOpts),
- option(out_dir, DtlOpts),
- option(module_ext, DtlOpts) ++ ".beam",
- fun(S, T, C) ->
- compile_dtl(C, S, T, DtlOpts)
- end,
- [{check_last_mod, false},
- {recursive, option(recursive, DtlOpts)}])
- end, ok, MultiDtlOpts),
-
- true = code:set_path(OrigPath),
- Result.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- ?CONSOLE(
- "Build ErlyDtl (*.dtl) sources.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n",
- [
- {erlydtl_opts, [{doc_root, "templates"},
- {out_dir, "ebin"},
- {source_ext, ".dtl"},
- {module_ext, "_dtl"},
- {recursive, true}]}
- ]).
-
-erlydtl_opts(Config) ->
- Opts = rebar_config:get(Config, erlydtl_opts, []),
- Tuples = [{K,V} || {K,V} <- Opts],
- case [L || L <- Opts, is_list(L), not io_lib:printable_list(L)] of
- [] ->
- [lists:keysort(1, Tuples)];
- Lists ->
- lists:map(
- fun(L) ->
- lists:keysort(1,
- lists:foldl(
- fun({K,T}, Acc) ->
- lists:keystore(K, 1, Acc, {K, T})
- end, Tuples, L))
- end, Lists)
- end.
-
-option(Opt, DtlOpts) ->
- proplists:get_value(Opt, DtlOpts, default(Opt)).
-
-default(doc_root) -> "templates";
-default(out_dir) -> "ebin";
-default(source_ext) -> ".dtl";
-default(module_ext) -> "_dtl";
-default(custom_tags_dir) -> "";
-default(compiler_options) -> [return];
-default(recursive) -> true.
-
-compile_dtl(Config, Source, Target, DtlOpts) ->
- case code:which(erlydtl) of
- non_existing ->
- ?ERROR("~n===============================================~n"
- " You need to install erlydtl to compile DTL templates~n"
- " Download the latest tarball release from github~n"
- " http://code.google.com/p/erlydtl/~n"
- " and install it into your erlang library dir~n"
- "===============================================~n~n", []),
- ?FAIL;
- _ ->
- case needs_compile(Source, Target, DtlOpts) of
- true ->
- do_compile(Config, Source, Target, DtlOpts);
- false ->
- skipped
- end
- end.
-
-do_compile(Config, Source, Target, DtlOpts) ->
- %% TODO: Check last mod on target and referenced DTLs here..
-
- %% ensure that doc_root and out_dir are defined,
- %% using defaults if necessary
- Opts = lists:ukeymerge(1,
- DtlOpts,
- lists:sort(
- [{out_dir, option(out_dir, DtlOpts)},
- {doc_root, option(doc_root, DtlOpts)},
- {custom_tags_dir, option(custom_tags_dir, DtlOpts)},
- {compiler_options, option(compiler_options, DtlOpts)}])),
- ?INFO("Compiling \"~s\" -> \"~s\" with options:~n ~s~n",
- [Source, Target, io_lib:format("~p", [Opts])]),
- case erlydtl:compile(Source,
- module_name(Target),
- Opts) of
- ok ->
- ok;
- error ->
- rebar_base_compiler:error_tuple(Config, Source, [], [], Opts);
- {error, {_File, _Msgs} = Error} ->
- rebar_base_compiler:error_tuple(Config, Source, [Error], [], Opts);
- {error, Msg} ->
- Es = [{Source, [{erlydtl_parser, Msg}]}],
- rebar_base_compiler:error_tuple(Config, Source, Es, [], Opts)
- end.
-
-module_name(Target) ->
- F = filename:basename(Target),
- string:substr(F, 1, length(F)-length(".beam")).
-
-needs_compile(Source, Target, DtlOpts) ->
- LM = filelib:last_modified(Target),
- LM < filelib:last_modified(Source) orelse
- lists:any(fun(D) -> LM < filelib:last_modified(D) end,
- referenced_dtls(Source, DtlOpts)).
-
-referenced_dtls(Source, DtlOpts) ->
- DtlOpts1 = lists:keyreplace(doc_root, 1, DtlOpts,
- {doc_root, filename:dirname(Source)}),
- Set = referenced_dtls1([Source], DtlOpts1,
- sets:add_element(Source, sets:new())),
- sets:to_list(sets:del_element(Source, Set)).
-
-referenced_dtls1(Step, DtlOpts, Seen) ->
- ExtMatch = re:replace(option(source_ext, DtlOpts), "\.", "\\\\\\\\.",
- [{return, list}]),
-
- ShOpts = [{use_stdout, false}, return_on_error],
- AllRefs =
- lists:append(
- [begin
- Cmd = lists:flatten(["grep -o [^\\\"]*\\",
- ExtMatch, "[^\\\"]* ", F]),
- case rebar_utils:sh(Cmd, ShOpts) of
- {ok, Res} ->
- string:tokens(Res, "\n");
- {error, _} ->
- ""
- end
- end || F <- Step]),
- DocRoot = option(doc_root, DtlOpts),
- WithPaths = [ filename:join([DocRoot, F]) || F <- AllRefs ],
- ?DEBUG("All deps: ~p\n", [WithPaths]),
- Existing = [F || F <- WithPaths, filelib:is_regular(F)],
- New = sets:subtract(sets:from_list(Existing), Seen),
- case sets:size(New) of
- 0 -> Seen;
- _ -> referenced_dtls1(sets:to_list(New), DtlOpts,
- sets:union(New, Seen))
- end.
diff --git a/src/rebar/src/rebar_escripter.erl b/src/rebar/src/rebar_escripter.erl
deleted file mode 100644
index 0cc43efd4..000000000
--- a/src/rebar/src/rebar_escripter.erl
+++ /dev/null
@@ -1,197 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_escripter).
-
--export([escriptize/2,
- clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
--include_lib("kernel/include/file.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-escriptize(Config0, AppFile) ->
- %% Extract the application name from the archive -- this is the default
- %% name of the generated script
- {Config, AppName} = rebar_app_utils:app_name(Config0, AppFile),
- AppNameStr = atom_to_list(AppName),
-
- %% Get the output filename for the escript -- this may include dirs
- Filename = rebar_config:get_local(Config, escript_name, AppName),
- ok = filelib:ensure_dir(Filename),
-
- %% Look for a list of other applications (dependencies) to include
- %% in the output file. We then use the .app files for each of these
- %% to pull in all the .beam files.
- InclBeams = get_app_beams(
- rebar_config:get_local(Config, escript_incl_apps, []), []),
-
- %% Look for a list of extra files to include in the output file.
- %% For internal rebar-private use only. Do not use outside rebar.
- InclExtra = get_extra(Config),
-
- %% Construct the archive of everything in ebin/ dir -- put it on the
- %% top-level of the zip file so that code loading works properly.
- EbinPrefix = filename:join(AppNameStr, "ebin"),
- EbinFiles = usort(load_files(EbinPrefix, "*", "ebin")),
- ExtraFiles = usort(InclBeams ++ InclExtra),
- Files = EbinFiles ++ ExtraFiles,
-
- case zip:create("mem", Files, [memory]) of
- {ok, {"mem", ZipBin}} ->
- %% Archive was successfully created. Prefix that binary with our
- %% header and write to our escript file
- Shebang = rebar_config:get(Config, escript_shebang,
- "#!/usr/bin/env escript\n"),
- Comment = rebar_config:get(Config, escript_comment, "%%\n"),
- DefaultEmuArgs = ?FMT("%%! -pa ~s/~s/ebin\n",
- [AppNameStr, AppNameStr]),
- EmuArgs = rebar_config:get(Config, escript_emu_args,
- DefaultEmuArgs),
- Script = iolist_to_binary([Shebang, Comment, EmuArgs, ZipBin]),
- case file:write_file(Filename, Script) of
- ok ->
- ok;
- {error, WriteError} ->
- ?ERROR("Failed to write ~p script: ~p\n",
- [AppName, WriteError]),
- ?FAIL
- end;
- {error, ZipError} ->
- ?ERROR("Failed to construct ~p escript: ~p\n",
- [AppName, ZipError]),
- ?FAIL
- end,
-
- %% Finally, update executable perms for our script
- {ok, #file_info{mode = Mode}} = file:read_file_info(Filename),
- ok = file:change_mode(Filename, Mode bor 8#00111),
- {ok, Config}.
-
-clean(Config0, AppFile) ->
- %% Extract the application name from the archive -- this is the default
- %% name of the generated script
- {Config, AppName} = rebar_app_utils:app_name(Config0, AppFile),
-
- %% Get the output filename for the escript -- this may include dirs
- Filename = rebar_config:get_local(Config, escript_name, AppName),
- rebar_file_utils:delete_each([Filename]),
- {ok, Config}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, escriptize) ->
- info_help("Generate escript archive");
-info(help, clean) ->
- info_help("Delete generated escript archive").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n",
- [
- Description,
- {escript_name, "application"},
- {escript_incl_apps, []},
- {escript_shebang, "#!/usr/bin/env escript\n"},
- {escript_comment, "%%\n"},
- {escript_emu_args, "%%! -pa application/application/ebin\n"}
- ]).
-
-get_app_beams([], Acc) ->
- Acc;
-get_app_beams([App | Rest], Acc) ->
- case code:lib_dir(App, ebin) of
- {error, bad_name} ->
- ?ABORT("Failed to get ebin/ directory for "
- "~p escript_incl_apps.", [App]);
- Path ->
- Prefix = filename:join(atom_to_list(App), "ebin"),
- Acc2 = load_files(Prefix, "*", Path),
- get_app_beams(Rest, Acc2 ++ Acc)
- end.
-
-get_extra(Config) ->
- Extra = rebar_config:get_local(Config, escript_incl_extra, []),
- lists:foldl(fun({Wildcard, Dir}, Files) ->
- load_files(Wildcard, Dir) ++ Files
- end, [], Extra).
-
-load_files(Wildcard, Dir) ->
- load_files("", Wildcard, Dir).
-
-load_files(Prefix, Wildcard, Dir) ->
- [read_file(Prefix, Filename, Dir)
- || Filename <- filelib:wildcard(Wildcard, Dir)].
-
-read_file(Prefix, Filename, Dir) ->
- Filename1 = case Prefix of
- "" ->
- Filename;
- _ ->
- filename:join([Prefix, Filename])
- end,
- [dir_entries(filename:dirname(Filename1)),
- {Filename1, file_contents(filename:join(Dir, Filename))}].
-
-file_contents(Filename) ->
- {ok, Bin} = file:read_file(Filename),
- Bin.
-
-%% Given a filename, return zip archive dir entries for each sub-dir.
-%% Required to work around issues fixed in OTP-10071.
-dir_entries(File) ->
- Dirs = dirs(File),
- [{Dir ++ "/", <<>>} || Dir <- Dirs].
-
-%% Given "foo/bar/baz", return ["foo", "foo/bar", "foo/bar/baz"].
-dirs(Dir) ->
- dirs1(filename:split(Dir), "", []).
-
-dirs1([], _, Acc) ->
- lists:reverse(Acc);
-dirs1([H|T], "", []) ->
- dirs1(T, H, [H]);
-dirs1([H|T], Last, Acc) ->
- Dir = filename:join(Last, H),
- dirs1(T, Dir, [Dir|Acc]).
-
-usort(List) ->
- lists:ukeysort(1, lists:flatten(List)).
diff --git a/src/rebar/src/rebar_eunit.erl b/src/rebar/src/rebar_eunit.erl
deleted file mode 100644
index d39b1a219..000000000
--- a/src/rebar/src/rebar_eunit.erl
+++ /dev/null
@@ -1,812 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009, 2010 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-%% @author Dave Smith <dizzyd@dizzyd.com>
-%% @doc rebar_eunit supports the following commands:
-%% <ul>
-%% <li>eunit - runs eunit tests</li>
-%% <li>clean - remove ?EUNIT_DIR directory</li>
-%% <li>reset_after_eunit::boolean() - default = true.
-%% If true, try to "reset" VM state to approximate state prior to
-%% running the EUnit tests:
-%% <ul>
-%% <li>Stop net_kernel if it was started</li>
-%% <li>Stop OTP applications not running before EUnit tests were run</li>
-%% <li>Kill processes not running before EUnit tests were run</li>
-%% <li>Reset OTP application environment variables</li>
-%% </ul>
-%% </li>
-%% </ul>
-%% The following Global options are supported:
-%% <ul>
-%% <li>verbose=1 - show extra output from the eunit test</li>
-%% <li>
-%% suites="foo,bar" - runs tests in foo.erl, test/foo_tests.erl and
-%% tests in bar.erl, test/bar_tests.erl
-%% </li>
-%% <li>
-%% suites="foo,bar" tests="baz"- runs first test with name starting
-%% with 'baz' in foo.erl, test/foo_tests.erl and tests in bar.erl,
-%% test/bar_tests.erl
-%% </li>
-%% <li>
-%% tests="baz"- For every existing suite, run the first test whose
-%% name starts with bar and, if no such test exists, run the test
-%% whose name starts with bar in the suite's _tests module
-%% </li>
-%% </ul>
-%% Additionally, for projects that have separate folders for the core
-%% implementation, and for the unit tests, then the following
-%% <code>rebar.config</code> option can be provided:
-%% <code>{eunit_compile_opts, [{src_dirs, ["src", "dir"]}]}.</code>.
-%% @copyright 2009, 2010 Dave Smith
-%% -------------------------------------------------------------------
--module(rebar_eunit).
-
--export([eunit/2,
- clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
--define(EUNIT_DIR, ".eunit").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-eunit(Config, _AppFile) ->
- ok = ensure_dirs(),
- %% Save code path
- CodePath = setup_code_path(),
- CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
- false),
- {ok, SrcErls} = rebar_erlc_compiler:test_compile(Config, "eunit",
- ?EUNIT_DIR),
- case CompileOnly of
- "true" ->
- true = code:set_path(CodePath),
- ?CONSOLE("Compiled modules for eunit~n", []);
- false ->
- run_eunit(Config, CodePath, SrcErls)
- end.
-
-clean(_Config, _File) ->
- rebar_file_utils:rm_rf(?EUNIT_DIR).
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, eunit) ->
- info_help("Run eunit tests");
-info(help, clean) ->
- Description = ?FMT("Delete eunit test dir (~s)", [?EUNIT_DIR]),
- info_help(Description).
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- " ~p~n"
- "Valid command line options:~n"
- " suites=\"foo,bar\" (Run tests in foo.erl, test/foo_tests.erl and~n"
- " tests in bar.erl, test/bar_tests.erl)~n"
- " tests=\"baz\" (For every existing suite, run the first test whose~n"
- " name starts with bar and, if no such test exists,~n"
- " run the test whose name starts with bar in the~n"
- " suite's _tests module)~n",
- [
- Description,
- {eunit_opts, []},
- {eunit_compile_opts, []},
- {eunit_first_files, []},
- {cover_enabled, false},
- {cover_print_enabled, false},
- {cover_export_enabled, false}
- ]).
-
-run_eunit(Config, CodePath, SrcErls) ->
- %% Build a list of all the .beams in ?EUNIT_DIR -- use this for
- %% cover and eunit testing. Normally you can just tell cover
- %% and/or eunit to scan the directory for you, but eunit does a
- %% code:purge in conjunction with that scan and causes any cover
- %% compilation info to be lost.
-
- AllBeamFiles = rebar_utils:beams(?EUNIT_DIR),
- {BeamFiles, TestBeamFiles} =
- lists:partition(fun(N) -> string:str(N, "_tests.beam") =:= 0 end,
- AllBeamFiles),
- OtherBeamFiles = TestBeamFiles --
- [filename:rootname(N) ++ "_tests.beam" || N <- AllBeamFiles],
- ModuleBeamFiles = BeamFiles ++ OtherBeamFiles,
-
- %% Get modules to be run in eunit
- AllModules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- AllBeamFiles],
- {SuitesProvided, FilteredModules} = filter_suites(Config, AllModules),
-
- %% Get matching tests
- Tests = get_tests(Config, SuitesProvided, ModuleBeamFiles, FilteredModules),
-
- SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls],
-
- {ok, CoverLog} = cover_init(Config, ModuleBeamFiles),
-
- StatusBefore = status_before_eunit(),
- EunitResult = perform_eunit(Config, Tests),
-
- perform_cover(Config, FilteredModules, SrcModules),
- cover_close(CoverLog),
-
- case proplists:get_value(reset_after_eunit, get_eunit_opts(Config),
- true) of
- true ->
- reset_after_eunit(StatusBefore);
- false ->
- ok
- end,
-
- %% Stop cover to clean the cover_server state. This is important if we want
- %% eunit+cover to not slow down when analyzing many Erlang modules.
- ok = cover:stop(),
-
- case EunitResult of
- ok ->
- ok;
- _ ->
- ?ABORT("One or more eunit tests failed.~n", [])
- end,
-
- %% Restore code path
- true = code:set_path(CodePath),
- ok.
-
-ensure_dirs() ->
- %% Make sure ?EUNIT_DIR/ and ebin/ directory exists (append dummy module)
- ok = filelib:ensure_dir(filename:join(eunit_dir(), "dummy")),
- ok = filelib:ensure_dir(filename:join(rebar_utils:ebin_dir(), "dummy")).
-
-eunit_dir() ->
- filename:join(rebar_utils:get_cwd(), ?EUNIT_DIR).
-
-setup_code_path() ->
- %% Setup code path prior to compilation so that parse_transforms
- %% and the like work properly. Also, be sure to add ebin_dir()
- %% to the END of the code path so that we don't have to jump
- %% through hoops to access the .app file
- CodePath = code:get_path(),
- true = code:add_patha(eunit_dir()),
- true = code:add_pathz(rebar_utils:ebin_dir()),
- CodePath.
-
-%%
-%% == filter suites ==
-%%
-
-filter_suites(Config, Modules) ->
- RawSuites = rebar_config:get_global(Config, suites, ""),
- SuitesProvided = RawSuites =/= "",
- Suites = [list_to_atom(Suite) || Suite <- string:tokens(RawSuites, ",")],
- {SuitesProvided, filter_suites1(Modules, Suites)}.
-
-filter_suites1(Modules, []) ->
- Modules;
-filter_suites1(Modules, Suites) ->
- [M || M <- Suites, lists:member(M, Modules)].
-
-%%
-%% == get matching tests ==
-%%
-get_tests(Config, SuitesProvided, ModuleBeamFiles, FilteredModules) ->
- Modules = case SuitesProvided of
- false ->
- %% No specific suites have been provided, use
- %% ModuleBeamFiles which filters out "*_tests" modules
- %% so eunit won't doubly run them and cover only
- %% calculates coverage on production code. However,
- %% keep "*_tests" modules that are not automatically
- %% included by eunit.
- %%
- %% From 'Primitives' in the EUnit User's Guide
- %% http://www.erlang.org/doc/apps/eunit/chapter.html
- %% "In addition, EUnit will also look for another
- %% module whose name is ModuleName plus the suffix
- %% _tests, and if it exists, all the tests from that
- %% module will also be added. (If ModuleName already
- %% contains the suffix _tests, this is not done.) E.g.,
- %% the specification {module, mymodule} will run all
- %% tests in the modules mymodule and mymodule_tests.
- %% Typically, the _tests module should only contain
- %% test cases that use the public interface of the main
- %% module (and no other code)."
- [rebar_utils:beam_to_mod(?EUNIT_DIR, N) ||
- N <- ModuleBeamFiles];
- true ->
- %% Specific suites have been provided, return the
- %% filtered modules
- FilteredModules
- end,
- get_matching_tests(Config, Modules).
-
-get_matching_tests(Config, Modules) ->
- RawFunctions = rebar_utils:get_experimental_global(Config, tests, ""),
- Tests = [list_to_atom(F1) || F1 <- string:tokens(RawFunctions, ",")],
- case Tests of
- [] ->
- Modules;
- Functions ->
- case get_matching_tests1(Modules, Functions, []) of
- [] ->
- [];
- RawTests ->
- make_test_primitives(RawTests)
- end
- end.
-
-get_matching_tests1([], _Functions, TestFunctions) ->
- TestFunctions;
-
-get_matching_tests1([Module|TModules], Functions, TestFunctions) ->
- %% Get module exports
- ModuleStr = atom_to_list(Module),
- ModuleExports = get_beam_test_exports(ModuleStr),
- %% Get module _tests exports
- TestModuleStr = string:concat(ModuleStr, "_tests"),
- TestModuleExports = get_beam_test_exports(TestModuleStr),
- %% Build tests {M, F} list
- Tests = get_matching_tests2(Functions, {Module, ModuleExports},
- {list_to_atom(TestModuleStr),
- TestModuleExports}),
- get_matching_tests1(TModules, Functions,
- lists:merge([TestFunctions, Tests])).
-
-get_matching_tests2(Functions, {Mod, ModExports}, {TestMod, TestModExports}) ->
- %% Look for matching functions into ModExports
- ModExportsStr = [atom_to_list(E1) || E1 <- ModExports],
- TestModExportsStr = [atom_to_list(E2) || E2 <- TestModExports],
- get_matching_exports(Functions, {Mod, ModExportsStr},
- {TestMod, TestModExportsStr}, []).
-
-get_matching_exports([], _, _, Matched) ->
- Matched;
-get_matching_exports([Function|TFunctions], {Mod, ModExportsStr},
- {TestMod, TestModExportsStr}, Matched) ->
-
- FunctionStr = atom_to_list(Function),
- %% Get matching Function in module, otherwise look in _tests module
- NewMatch = case get_matching_export(FunctionStr, ModExportsStr) of
- [] ->
- {TestMod, get_matching_export(FunctionStr,
- TestModExportsStr)};
- MatchingExport ->
- {Mod, MatchingExport}
- end,
- case NewMatch of
- {_, []} ->
- get_matching_exports(TFunctions, {Mod, ModExportsStr},
- {TestMod, TestModExportsStr}, Matched);
- _ ->
- get_matching_exports(TFunctions, {Mod, ModExportsStr},
- {TestMod, TestModExportsStr},
- [NewMatch|Matched])
- end.
-
-get_matching_export(_FunctionStr, []) ->
- [];
-get_matching_export(FunctionStr, [ExportStr|TExportsStr]) ->
- case string:str(ExportStr, FunctionStr) of
- 1 ->
- list_to_atom(ExportStr);
- _ ->
- get_matching_export(FunctionStr, TExportsStr)
- end.
-
-get_beam_test_exports(ModuleStr) ->
- FilePath = filename:join(eunit_dir(),
- string:concat(ModuleStr, ".beam")),
- case filelib:is_regular(FilePath) of
- true ->
- {beam_file, _, Exports0, _, _, _} = beam_disasm:file(FilePath),
- Exports1 = [FunName || {FunName, FunArity, _} <- Exports0,
- FunArity =:= 0],
- F = fun(FName) ->
- FNameStr = atom_to_list(FName),
- re:run(FNameStr, "_test(_)?") =/= nomatch
- end,
- lists:filter(F, Exports1);
- _ ->
- []
- end.
-
-make_test_primitives(RawTests) ->
- %% Use {test,M,F} and {generator,M,F} if at least R15B02. Otherwise,
- %% use eunit_test:function_wrapper/2 fallback.
- %% eunit_test:function_wrapper/2 was renamed to eunit_test:mf_wrapper/2
- %% in R15B02; use that as >= R15B02 check.
- %% TODO: remove fallback and use only {test,M,F} and {generator,M,F}
- %% primitives once at least R15B02 is required.
- {module, eunit_test} = code:ensure_loaded(eunit_test),
- MakePrimitive = case erlang:function_exported(eunit_test, mf_wrapper, 2) of
- true -> fun eunit_primitive/3;
- false -> fun pre15b02_eunit_primitive/3
- end,
-
- ?CONSOLE(" Running test function(s):~n", []),
- F = fun({M, F2}, Acc) ->
- ?CONSOLE(" ~p:~p/0~n", [M, F2]),
- FNameStr = atom_to_list(F2),
- NewFunction =
- case re:run(FNameStr, "_test_") of
- nomatch ->
- %% Normal test
- MakePrimitive(test, M, F2);
- _ ->
- %% Generator
- MakePrimitive(generator, M, F2)
- end,
- [NewFunction|Acc]
- end,
- lists:foldl(F, [], RawTests).
-
-eunit_primitive(Type, M, F) ->
- {Type, M, F}.
-
-pre15b02_eunit_primitive(test, M, F) ->
- eunit_test:function_wrapper(M, F);
-pre15b02_eunit_primitive(generator, M, F) ->
- {generator, eunit_test:function_wrapper(M, F)}.
-
-%%
-%% == run tests ==
-%%
-
-perform_eunit(Config, Tests) ->
- EunitOpts = get_eunit_opts(Config),
-
- %% Move down into ?EUNIT_DIR while we run tests so any generated files
- %% are created there (versus in the source dir)
- Cwd = rebar_utils:get_cwd(),
- ok = file:set_cwd(?EUNIT_DIR),
-
- EunitResult = (catch eunit:test(Tests, EunitOpts)),
-
- %% Return to original working dir
- ok = file:set_cwd(Cwd),
-
- EunitResult.
-
-get_eunit_opts(Config) ->
- %% Enable verbose in eunit if so requested..
- BaseOpts = case rebar_config:is_verbose(Config) of
- true ->
- [verbose];
- false ->
- []
- end,
-
- BaseOpts ++ rebar_config:get_list(Config, eunit_opts, []).
-
-%%
-%% == code coverage ==
-%%
-
-perform_cover(Config, BeamFiles, SrcModules) ->
- perform_cover(rebar_config:get(Config, cover_enabled, false),
- Config, BeamFiles, SrcModules).
-
-perform_cover(false, _Config, _BeamFiles, _SrcModules) ->
- ok;
-perform_cover(true, Config, BeamFiles, SrcModules) ->
- cover_analyze(Config, BeamFiles, SrcModules).
-
-cover_analyze(_Config, [], _SrcModules) ->
- ok;
-cover_analyze(Config, FilteredModules, SrcModules) ->
- %% Generate coverage info for all the cover-compiled modules
- Coverage = lists:flatten([cover_analyze_mod(M)
- || M <- FilteredModules,
- cover:is_compiled(M) =/= false]),
-
- %% Write index of coverage info
- cover_write_index(lists:sort(Coverage), SrcModules),
-
- %% Write coverage details for each file
- lists:foreach(fun({M, _, _}) ->
- {ok, _} = cover:analyze_to_file(M, cover_file(M),
- [html])
- end, Coverage),
-
- Index = filename:join([rebar_utils:get_cwd(), ?EUNIT_DIR, "index.html"]),
- ?CONSOLE("Cover analysis: ~s\n", [Index]),
-
- %% Export coverage data, if configured
- case rebar_config:get(Config, cover_export_enabled, false) of
- true ->
- cover_export_coverdata();
- false ->
- ok
- end,
-
- %% Print coverage report, if configured
- case rebar_config:get(Config, cover_print_enabled, false) of
- true ->
- cover_print_coverage(lists:sort(Coverage));
- false ->
- ok
- end.
-
-cover_close(not_enabled) ->
- ok;
-cover_close(F) ->
- ok = file:close(F).
-
-cover_init(false, _BeamFiles) ->
- {ok, not_enabled};
-cover_init(true, BeamFiles) ->
- %% Attempt to start the cover server, then set its group leader to
- %% .eunit/cover.log, so all cover log messages will go there instead of
- %% to stdout. If the cover server is already started, we'll kill that
- %% server and start a new one in order not to inherit a polluted
- %% cover_server state.
- {ok, CoverPid} = case whereis(cover_server) of
- undefined ->
- cover:start();
- _ ->
- cover:stop(),
- cover:start()
- end,
-
- {ok, F} = OkOpen = file:open(
- filename:join([?EUNIT_DIR, "cover.log"]),
- [write]),
-
- group_leader(F, CoverPid),
-
- ?INFO("Cover compiling ~s\n", [rebar_utils:get_cwd()]),
-
- Compiled = [{Beam, cover:compile_beam(Beam)} || Beam <- BeamFiles],
- case [Module || {_, {ok, Module}} <- Compiled] of
- [] ->
- %% No modules compiled successfully...fail
- ?ERROR("Cover failed to compile any modules; aborting.~n", []),
- ?FAIL;
- _ ->
- %% At least one module compiled successfully
-
- %% It's not an error for cover compilation to fail partially,
- %% but we do want to warn about them
- PrintWarning =
- fun(Beam, Desc) ->
- ?CONSOLE("Cover compilation warning for ~p: ~p",
- [Beam, Desc])
- end,
- _ = [PrintWarning(Beam, Desc) || {Beam, {error, Desc}} <- Compiled],
- OkOpen
- end;
-cover_init(Config, BeamFiles) ->
- cover_init(rebar_config:get(Config, cover_enabled, false), BeamFiles).
-
-cover_analyze_mod(Module) ->
- case cover:analyze(Module, coverage, module) of
- {ok, {Module, {Covered, NotCovered}}} ->
- %% Modules that include the eunit header get an implicit
- %% test/0 fun, which cover considers a runnable line, but
- %% eunit:test(TestRepresentation) never calls. Decrement
- %% NotCovered in this case.
- [align_notcovered_count(Module, Covered, NotCovered,
- is_eunitized(Module))];
- {error, Reason} ->
- ?ERROR("Cover analyze failed for ~p: ~p ~p\n",
- [Module, Reason, code:which(Module)]),
- []
- end.
-
-is_eunitized(Mod) ->
- has_eunit_test_fun(Mod) andalso
- has_header(Mod, "include/eunit.hrl").
-
-has_eunit_test_fun(Mod) ->
- [F || {exports, Funs} <- Mod:module_info(),
- {F, 0} <- Funs, F =:= test] =/= [].
-
-has_header(Mod, Header) ->
- Mod1 = case code:which(Mod) of
- cover_compiled ->
- {file, File} = cover:is_compiled(Mod),
- File;
- non_existing -> Mod;
- preloaded -> Mod;
- L -> L
- end,
- {ok, {_, [{abstract_code, {_, AC}}]}} = beam_lib:chunks(Mod1,
- [abstract_code]),
- [F || {attribute, 1, file, {F, 1}} <- AC,
- string:str(F, Header) =/= 0] =/= [].
-
-align_notcovered_count(Module, Covered, NotCovered, false) ->
- {Module, Covered, NotCovered};
-align_notcovered_count(Module, Covered, NotCovered, true) ->
- {Module, Covered, NotCovered - 1}.
-
-cover_write_index(Coverage, SrcModules) ->
- {ok, F} = file:open(filename:join([?EUNIT_DIR, "index.html"]), [write]),
- ok = file:write(F, "<!DOCTYPE HTML><html>\n"
- "<head><meta charset=\"utf-8\">"
- "<title>Coverage Summary</title></head>\n"
- "<body>\n"),
- IsSrcCoverage = fun({Mod,_C,_N}) -> lists:member(Mod, SrcModules) end,
- {SrcCoverage, TestCoverage} = lists:partition(IsSrcCoverage, Coverage),
- cover_write_index_section(F, "Source", SrcCoverage),
- cover_write_index_section(F, "Test", TestCoverage),
- ok = file:write(F, "</body></html>"),
- ok = file:close(F).
-
-cover_write_index_section(_F, _SectionName, []) ->
- ok;
-cover_write_index_section(F, SectionName, Coverage) ->
- %% Calculate total coverage
- {Covered, NotCovered} = lists:foldl(fun({_Mod, C, N}, {CAcc, NAcc}) ->
- {CAcc + C, NAcc + N}
- end, {0, 0}, Coverage),
- TotalCoverage = percentage(Covered, NotCovered),
-
- %% Write the report
- ok = file:write(F, ?FMT("<h1>~s Summary</h1>\n", [SectionName])),
- ok = file:write(F, ?FMT("<h3>Total: ~s</h3>\n", [TotalCoverage])),
- ok = file:write(F, "<table><tr><th>Module</th><th>Coverage %</th></tr>\n"),
-
- FmtLink =
- fun(Module, Cov, NotCov) ->
- ?FMT("<tr><td><a href='~s.COVER.html'>~s</a></td><td>~s</td>\n",
- [Module, Module, percentage(Cov, NotCov)])
- end,
- lists:foreach(fun({Module, Cov, NotCov}) ->
- ok = file:write(F, FmtLink(Module, Cov, NotCov))
- end, Coverage),
- ok = file:write(F, "</table>\n").
-
-cover_print_coverage(Coverage) ->
- {Covered, NotCovered} = lists:foldl(fun({_Mod, C, N}, {CAcc, NAcc}) ->
- {CAcc + C, NAcc + N}
- end, {0, 0}, Coverage),
- TotalCoverage = percentage(Covered, NotCovered),
-
- %% Determine the longest module name for right-padding
- Width = lists:foldl(fun({Mod, _, _}, Acc) ->
- case length(atom_to_list(Mod)) of
- N when N > Acc ->
- N;
- _ ->
- Acc
- end
- end, 0, Coverage) * -1,
-
- %% Print the output the console
- ?CONSOLE("~nCode Coverage:~n", []),
- lists:foreach(fun({Mod, C, N}) ->
- ?CONSOLE("~*s : ~3s~n",
- [Width, Mod, percentage(C, N)])
- end, Coverage),
- ?CONSOLE("~n~*s : ~s~n", [Width, "Total", TotalCoverage]).
-
-cover_file(Module) ->
- filename:join([?EUNIT_DIR, atom_to_list(Module) ++ ".COVER.html"]).
-
-cover_export_coverdata() ->
- ExportFile = filename:join(eunit_dir(), "eunit.coverdata"),
- case cover:export(ExportFile) of
- ok ->
- ?CONSOLE("Coverdata export: ~s~n", [ExportFile]);
- {error, Reason} ->
- ?ERROR("Coverdata export failed: ~p~n", [Reason])
- end.
-
-percentage(0, 0) ->
- "not executed";
-percentage(Cov, NotCov) ->
- integer_to_list(trunc((Cov / (Cov + NotCov)) * 100)) ++ "%".
-
-%%
-%% == reset_after_eunit ==
-%%
-
-status_before_eunit() ->
- Apps = get_app_names(),
- AppEnvs = [{App, application:get_all_env(App)} || App <- Apps],
- {erlang:processes(), erlang:is_alive(), AppEnvs, ets:tab2list(ac_tab)}.
-
-get_app_names() ->
- [AppName || {AppName, _, _} <- application:loaded_applications()].
-
-reset_after_eunit({OldProcesses, WasAlive, OldAppEnvs, _OldACs}) ->
- IsAlive = erlang:is_alive(),
- if not WasAlive andalso IsAlive ->
- ?DEBUG("Stopping net kernel....\n", []),
- erl_epmd:stop(),
- _ = net_kernel:stop(),
- pause_until_net_kernel_stopped();
- true ->
- ok
- end,
-
- OldApps = [App || {App, _} <- OldAppEnvs],
- Apps = get_app_names(),
- _ = [begin
- _ = case lists:member(App, OldApps) of
- true -> ok;
- false -> application:stop(App)
- end,
- ok = application:unset_env(App, K)
- end || App <- Apps, App /= rebar,
- {K, _V} <- application:get_all_env(App),
- K =/= included_applications],
-
- reconstruct_app_env_vars(Apps),
-
- Processes = erlang:processes(),
- _ = kill_extras(Processes -- OldProcesses),
-
- ok.
-
-kill_extras(Pids) ->
- %% Killing any of the procs below will either:
- %% 1. Interfere with stuff that we don't want interfered with, or
- %% 2. May/will force the 'kernel' app to shutdown, which *will*
- %% interfere with rebar's ability To Do Useful Stuff(tm).
- %% This list may require changes as OTP versions and/or
- %% rebar use cases change.
- KeepProcs = [cover_server, eunit_server,
- eqc, eqc_license, eqc_locked,
- %% inet_gethost_native is started on demand, when
- %% doing name lookups. It is under kernel_sup, under
- %% a supervisor_bridge.
- inet_gethost_native],
- Killed = [begin
- Info = case erlang:process_info(Pid) of
- undefined -> [];
- Else -> Else
- end,
- Keep1 = case proplists:get_value(registered_name, Info) of
- undefined ->
- false;
- Name ->
- lists:member(Name, KeepProcs)
- end,
- Keep2 = case proplists:get_value(dictionary, Info) of
- undefined ->
- false;
- Ds ->
- case proplists:get_value('$ancestors', Ds) of
- undefined ->
- false;
- As ->
- lists:member(kernel_sup, As)
- end
- end,
- if Keep1 orelse Keep2 ->
- ok;
- true ->
- ?DEBUG("Kill ~p ~p\n", [Pid, Info]),
- exit(Pid, kill),
- Pid
- end
- end || Pid <- Pids],
- case lists:usort(Killed) -- [ok] of
- [] ->
- ?DEBUG("No processes to kill\n", []),
- [];
- Else ->
- lists:foreach(fun(Pid) -> wait_until_dead(Pid) end, Else),
- Else
- end.
-
-reconstruct_app_env_vars([App|Apps]) ->
- CmdLine0 = proplists:get_value(App, init:get_arguments(), []),
- CmdVars = [{list_to_atom(K), list_to_atom(V)} || {K, V} <- CmdLine0],
- AppFile = (catch filename:join([code:lib_dir(App),
- "ebin",
- atom_to_list(App) ++ ".app"])),
- AppVars = case file:consult(AppFile) of
- {ok, [{application, App, Ps}]} ->
- proplists:get_value(env, Ps, []);
- _ ->
- []
- end,
-
- %% App vars specified in config files override those in the .app file.
- %% Config files later in the args list override earlier ones.
- AppVars1 = case init:get_argument(config) of
- {ok, ConfigFiles} ->
- {App, MergedAppVars} = lists:foldl(fun merge_app_vars/2,
- {App, AppVars},
- ConfigFiles),
- MergedAppVars;
- error ->
- AppVars
- end,
- AllVars = CmdVars ++ AppVars1,
- ?DEBUG("Reconstruct ~p ~p\n", [App, AllVars]),
- lists:foreach(fun({K, V}) -> application:set_env(App, K, V) end, AllVars),
- reconstruct_app_env_vars(Apps);
-reconstruct_app_env_vars([]) ->
- ok.
-
-merge_app_vars(ConfigFile, {App, AppVars}) ->
- File = ensure_config_extension(ConfigFile),
- FileAppVars = app_vars_from_config_file(File, App),
- Dict1 = dict:from_list(AppVars),
- Dict2 = dict:from_list(FileAppVars),
- Dict3 = dict:merge(fun(_Key, _Value1, Value2) -> Value2 end, Dict1, Dict2),
- {App, dict:to_list(Dict3)}.
-
-ensure_config_extension(File) ->
- %% config files must end with .config on disk but when specifying them
- %% via the -config option the extension is optional
- BaseFileName = filename:basename(File, ".config"),
- DirName = filename:dirname(File),
- filename:join(DirName, BaseFileName ++ ".config").
-
-app_vars_from_config_file(File, App) ->
- case file:consult(File) of
- {ok, [Env]} ->
- proplists:get_value(App, Env, []);
- _ ->
- []
- end.
-
-wait_until_dead(Pid) when is_pid(Pid) ->
- Ref = erlang:monitor(process, Pid),
- receive
- {'DOWN', Ref, process, _Obj, Info} ->
- Info
- after 10*1000 ->
- exit({timeout_waiting_for, Pid})
- end;
-wait_until_dead(_) ->
- ok.
-
-pause_until_net_kernel_stopped() ->
- pause_until_net_kernel_stopped(10).
-
-pause_until_net_kernel_stopped(0) ->
- exit(net_kernel_stop_failed);
-pause_until_net_kernel_stopped(N) ->
- case node() of
- 'nonode@nohost' ->
- ?DEBUG("Stopped net kernel.\n", []),
- ok;
- _ ->
- timer:sleep(100),
- pause_until_net_kernel_stopped(N - 1)
- end.
diff --git a/src/rebar/src/rebar_file_utils.erl b/src/rebar/src/rebar_file_utils.erl
deleted file mode 100644
index fcd9c5e86..000000000
--- a/src/rebar/src/rebar_file_utils.erl
+++ /dev/null
@@ -1,194 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_file_utils).
-
--export([rm_rf/1,
- cp_r/2,
- mv/2,
- delete_each/1,
- write_file_if_contents_differ/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-%% @doc Remove files and directories.
-%% Target is a single filename, directoryname or wildcard expression.
--spec rm_rf(string()) -> 'ok'.
-rm_rf(Target) ->
- case os:type() of
- {unix, _} ->
- EscTarget = escape_spaces(Target),
- {ok, []} = rebar_utils:sh(?FMT("rm -rf ~s", [EscTarget]),
- [{use_stdout, false}, return_on_error]),
- ok;
- {win32, _} ->
- Filelist = filelib:wildcard(Target),
- Dirs = [F || F <- Filelist, filelib:is_dir(F)],
- Files = Filelist -- Dirs,
- ok = delete_each(Files),
- ok = delete_each_dir_win32(Dirs),
- ok
- end.
-
--spec cp_r(list(string()), file:filename()) -> 'ok'.
-cp_r([], _Dest) ->
- ok;
-cp_r(Sources, Dest) ->
- case os:type() of
- {unix, _} ->
- EscSources = [escape_spaces(Src) || Src <- Sources],
- SourceStr = string:join(EscSources, " "),
- {ok, []} = rebar_utils:sh(?FMT("cp -R ~s \"~s\"",
- [SourceStr, Dest]),
- [{use_stdout, false}, return_on_error]),
- ok;
- {win32, _} ->
- lists:foreach(fun(Src) -> ok = cp_r_win32(Src,Dest) end, Sources),
- ok
- end.
-
--spec mv(string(), file:filename()) -> 'ok'.
-mv(Source, Dest) ->
- case os:type() of
- {unix, _} ->
- EscSource = escape_spaces(Source),
- EscDest = escape_spaces(Dest),
- {ok, []} = rebar_utils:sh(?FMT("mv ~s ~s", [EscSource, EscDest]),
- [{use_stdout, false}, return_on_error]),
- ok;
- {win32, _} ->
- {ok, R} = rebar_utils:sh(
- ?FMT("move /y \"~s\" \"~s\" 1> nul",
- [filename:nativename(Source),
- filename:nativename(Dest)]),
- [{use_stdout, false}, return_on_error]),
- case R of
- [] ->
- ok;
- _ ->
- {error, lists:flatten(
- io_lib:format("Failed to move ~s to ~s~n",
- [Source, Dest]))}
- end
- end.
-
-delete_each([]) ->
- ok;
-delete_each([File | Rest]) ->
- case file:delete(File) of
- ok ->
- delete_each(Rest);
- {error, enoent} ->
- delete_each(Rest);
- {error, Reason} ->
- ?ERROR("Failed to delete file ~s: ~p\n", [File, Reason]),
- ?FAIL
- end.
-
-write_file_if_contents_differ(Filename, Bytes) ->
- ToWrite = iolist_to_binary(Bytes),
- case file:read_file(Filename) of
- {ok, ToWrite} ->
- ok;
- {ok, _} ->
- file:write_file(Filename, ToWrite);
- {error, _} ->
- file:write_file(Filename, ToWrite)
- end.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-delete_each_dir_win32([]) -> ok;
-delete_each_dir_win32([Dir | Rest]) ->
- {ok, []} = rebar_utils:sh(?FMT("rd /q /s \"~s\"",
- [filename:nativename(Dir)]),
- [{use_stdout, false}, return_on_error]),
- delete_each_dir_win32(Rest).
-
-xcopy_win32(Source,Dest)->
- {ok, R} = rebar_utils:sh(
- ?FMT("xcopy \"~s\" \"~s\" /q /y /e 2> nul",
- [filename:nativename(Source), filename:nativename(Dest)]),
- [{use_stdout, false}, return_on_error]),
- case length(R) > 0 of
- %% when xcopy fails, stdout is empty and and error message is printed
- %% to stderr (which is redirected to nul)
- true -> ok;
- false ->
- {error, lists:flatten(
- io_lib:format("Failed to xcopy from ~s to ~s~n",
- [Source, Dest]))}
- end.
-
-cp_r_win32({true, SourceDir}, {true, DestDir}) ->
- %% from directory to directory
- SourceBase = filename:basename(SourceDir),
- ok = case file:make_dir(filename:join(DestDir, SourceBase)) of
- {error, eexist} -> ok;
- Other -> Other
- end,
- ok = xcopy_win32(SourceDir, filename:join(DestDir, SourceBase));
-cp_r_win32({false, Source} = S,{true, DestDir}) ->
- %% from file to directory
- cp_r_win32(S, {false, filename:join(DestDir, filename:basename(Source))});
-cp_r_win32({false, Source},{false, Dest}) ->
- %% from file to file
- {ok,_} = file:copy(Source, Dest),
- ok;
-cp_r_win32({true, SourceDir}, {false, DestDir}) ->
- case filelib:is_regular(DestDir) of
- true ->
- %% From directory to file? This shouldn't happen
- {error, lists:flatten(
- io_lib:format("Cannot copy dir (~p) to file (~p)\n",
- [SourceDir, DestDir]))};
- false ->
- %% Specifying a target directory that doesn't currently exist.
- %% So let's attempt to create this directory
- case filelib:ensure_dir(filename:join(DestDir, "dummy")) of
- ok ->
- ok = xcopy_win32(SourceDir, DestDir);
- {error, Reason} ->
- {error, lists:flatten(
- io_lib:format("Unable to create dir ~p: ~p\n",
- [DestDir, Reason]))}
- end
- end;
-cp_r_win32(Source,Dest) ->
- Dst = {filelib:is_dir(Dest), Dest},
- lists:foreach(fun(Src) ->
- ok = cp_r_win32({filelib:is_dir(Src), Src}, Dst)
- end, filelib:wildcard(Source)),
- ok.
-
-escape_spaces(Str) ->
- re:replace(Str, " ", "\\\\ ", [global, {return, list}]).
diff --git a/src/rebar/src/rebar_lfe_compiler.erl b/src/rebar/src/rebar_lfe_compiler.erl
deleted file mode 100644
index 8488b0ff0..000000000
--- a/src/rebar/src/rebar_lfe_compiler.erl
+++ /dev/null
@@ -1,84 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com),
-%% Tim Dysinger (tim@dysinger.net)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-
--module(rebar_lfe_compiler).
-
--export([compile/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-compile(Config, _AppFile) ->
- FirstFiles = rebar_config:get_list(Config, lfe_first_files, []),
- rebar_base_compiler:run(Config, FirstFiles, "src", ".lfe", "ebin", ".beam",
- fun compile_lfe/3).
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- ?CONSOLE(
- "Build Lisp Flavoured Erlang (*.lfe) sources.~n"
- "~n"
- "Valid rebar.config options:~n"
- " erl_opts is reused.'~n",
- []).
-
-compile_lfe(Source, _Target, Config) ->
- case code:which(lfe_comp) of
- non_existing ->
- ?ERROR("~n"
- "*** MISSING LFE COMPILER ***~n"
- " You must do one of the following:~n"
- " a) Install LFE globally in your erl libs~n"
- " b) Add LFE as a dep for your project, eg:~n"
- " {lfe, \"0.6.1\",~n"
- " {git, \"git://github.com/rvirding/lfe\",~n"
- " {tag, \"v0.6.1\"}}}~n"
- "~n", []),
- ?FAIL;
- _ ->
- ErlOpts = rebar_utils:erl_opts(Config),
- Opts = [{i, "include"}, {outdir, "ebin"}, return] ++ ErlOpts,
- case lfe_comp:file(Source, Opts) of
- {ok, _Mod, Ws} ->
- rebar_base_compiler:ok_tuple(Config, Source, Ws);
- {error, Es, Ws} ->
- rebar_base_compiler:error_tuple(Config, Source,
- Es, Ws, Opts);
- _ ->
- ?FAIL
- end
- end.
diff --git a/src/rebar/src/rebar_log.erl b/src/rebar/src/rebar_log.erl
deleted file mode 100644
index 4108c9c03..000000000
--- a/src/rebar/src/rebar_log.erl
+++ /dev/null
@@ -1,83 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_log).
-
--export([init/1,
- set_level/1, default_level/0,
- log/3]).
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-init(Config) ->
- Verbosity = rebar_config:get_global(Config, verbose, default_level()),
- case valid_level(Verbosity) of
- 0 -> set_level(error);
- 1 -> set_level(warn);
- 2 -> set_level(info);
- 3 -> set_level(debug)
- end.
-
-set_level(Level) ->
- ok = application:set_env(rebar, log_level, Level).
-
-log(Level, Str, Args) ->
- {ok, LogLevel} = application:get_env(rebar, log_level),
- case should_log(LogLevel, Level) of
- true ->
- io:format(log_prefix(Level) ++ Str, Args);
- false ->
- ok
- end.
-
-default_level() -> error_level().
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-valid_level(Level) ->
- erlang:max(error_level(), erlang:min(Level, debug_level())).
-
-error_level() -> 0.
-debug_level() -> 3.
-
-should_log(debug, _) -> true;
-should_log(info, debug) -> false;
-should_log(info, _) -> true;
-should_log(warn, debug) -> false;
-should_log(warn, info) -> false;
-should_log(warn, _) -> true;
-should_log(error, error) -> true;
-should_log(error, _) -> false;
-should_log(_, _) -> false.
-
-log_prefix(debug) -> "DEBUG: ";
-log_prefix(info) -> "INFO: ";
-log_prefix(warn) -> "WARN: ";
-log_prefix(error) -> "ERROR: ".
diff --git a/src/rebar/src/rebar_neotoma_compiler.erl b/src/rebar/src/rebar_neotoma_compiler.erl
deleted file mode 100644
index 5549dc49d..000000000
--- a/src/rebar/src/rebar_neotoma_compiler.erl
+++ /dev/null
@@ -1,163 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2010 Cliff Moon (cliff@moonpolysoft.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-
-%% The rebar_neotoma module is a plugin for rebar that compiles
-%% neotoma peg files. By default, it compiles all src/*.peg to src/*.erl
-%%
-%% Configuration options should be placed in rebar.config under
-%% neotoma_opts. Available options include:
-%%
-%% doc_root: where to find the peg files to compile.
-%% "src" by default
-%% out_dir: where to put the generated erl files.
-%% "src" by defualt
-%% module_ext: characters to append to the module's name.
-%% "" by default
-%% source_ext: extension of peg source files
--module(rebar_neotoma_compiler).
-
--export([compile/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ============================================================================
-%% Public API
-%% ============================================================================
-
-compile(Config, _AppFile) ->
- NeoOpts = neotoma_opts(Config),
- rebar_base_compiler:run(Config, [],
- option(doc_root, NeoOpts), ".peg",
- option(out_dir, NeoOpts),
- option(module_ext, NeoOpts) ++ ".erl",
- fun compile_neo/3, [{check_last_mod, true}]).
-
-%% ============================================================================
-%% Internal functions
-%% ============================================================================
-
-info(help, compile) ->
- ?CONSOLE(
- "Build Neotoma (*.peg) sources.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n",
- [
- {neotoma_opts, [{doc_root, "src"},
- {out_dir, "src"},
- {source_ext, ".peg"},
- {module_ext, ""}]}
- ]).
-
-neotoma_opts(Config) ->
- rebar_config:get(Config, neotoma_opts, []).
-
-option(Opt, Options) ->
- proplists:get_value(Opt, Options, default(Opt)).
-
-default(doc_root) -> "src";
-default(out_dir) -> "src";
-default(module_ext) -> "";
-default(source_ext) -> ".peg".
-
-compile_neo(Source, Target, Config) ->
- case code:which(neotoma) of
- non_existing ->
- ?ERROR("~n===============================================~n"
- " You need to install neotoma to compile PEG grammars~n"
- " Download the latest tarball release from github~n"
- " https://github.com/seancribbs/neotoma~n"
- " and install it into your erlang library dir~n"
- "===============================================~n~n", []),
- ?FAIL;
- _ ->
- case needs_compile(Source, Target, Config) of
- true ->
- do_compile(Source, Target, Config);
- false ->
- skipped
- end
- end.
-
-do_compile(Source, _Target, Config) ->
- %% TODO: Check last mod on target and referenced DTLs here..
- NeoOpts = neotoma_opts(Config),
- %% ensure that doc_root and out_dir are defined,
- %% using defaults if necessary
- Opts = [{output, option(out_dir, NeoOpts)},
- {module, list_to_atom(filename:basename(Source, ".peg")
- ++ option(module_ext, NeoOpts))}],
- case neotoma:file(Source, Opts ++ NeoOpts) of
- ok ->
- ok;
- Reason ->
- ?ERROR("Compiling peg ~s failed:~n ~p~n",
- [Source, Reason]),
- ?FAIL
- end.
-
-needs_compile(Source, Target, Config) ->
- LM = filelib:last_modified(Target),
- LM < filelib:last_modified(Source) orelse
- lists:any(fun(D) -> LM < filelib:last_modified(D) end,
- referenced_pegs(Source, Config)).
-
-referenced_pegs(Source, Config) ->
- Set = referenced_pegs1([Source], Config,
- sets:add_element(Source, sets:new())),
- sets:to_list(sets:del_element(Source, Set)).
-
-referenced_pegs1(Step, Config, Seen) ->
- NeoOpts = neotoma_opts(Config),
- ExtMatch = re:replace(option(source_ext, NeoOpts), "\.", "\\\\\\\\.",
- [{return, list}]),
-
- ShOpts = [{use_stdout, false}, return_on_error],
- AllRefs =
- lists:append(
- [begin
- Cmd = lists:flatten(["grep -o [^\\\"]*",
- ExtMatch, " ", F]),
- case rebar_utils:sh(Cmd, ShOpts) of
- {ok, Res} ->
- string:tokens(Res, "\n");
- {error, _} ->
- ""
- end
- end || F <- Step]),
- DocRoot = option(doc_root, NeoOpts),
- WithPaths = [ filename:join([DocRoot, F]) || F <- AllRefs ],
- Existing = [F || F <- WithPaths, filelib:is_regular(F)],
- New = sets:subtract(sets:from_list(Existing), Seen),
- case sets:size(New) of
- 0 -> Seen;
- _ -> referenced_pegs1(sets:to_list(New), Config,
- sets:union(New, Seen))
- end.
diff --git a/src/rebar/src/rebar_otp_app.erl b/src/rebar/src/rebar_otp_app.erl
deleted file mode 100644
index b3566c861..000000000
--- a/src/rebar/src/rebar_otp_app.erl
+++ /dev/null
@@ -1,220 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_otp_app).
-
--export([compile/2,
- clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-compile(Config, File) ->
- %% If we get an .app.src file, it needs to be pre-processed and
- %% written out as a ebin/*.app file. That resulting file will then
- %% be validated as usual.
- {Config1, AppFile} = case rebar_app_utils:is_app_src(File) of
- true ->
- preprocess(Config, File);
- false ->
- {Config, File}
- end,
-
- %% Load the app file and validate it.
- case rebar_app_utils:load_app_file(Config1, AppFile) of
- {ok, Config2, AppName, AppData} ->
- validate_name(AppName, AppFile),
-
- %% In general, the list of modules is an important thing to validate
- %% for compliance with OTP guidelines and upgrade procedures.
- %% However, some people prefer not to validate this list.
- case rebar_config:get_local(Config1, validate_app_modules, true) of
- true ->
- Modules = proplists:get_value(modules, AppData),
- {validate_modules(AppName, Modules), Config2};
- false ->
- {ok, Config2}
- end;
- {error, Reason} ->
- ?ABORT("Failed to load app file ~s: ~p\n", [AppFile, Reason])
- end.
-
-clean(_Config, File) ->
- %% If the app file is a .app.src, delete the generated .app file
- case rebar_app_utils:is_app_src(File) of
- true ->
- case file:delete(rebar_app_utils:app_src_to_app(File)) of
- ok ->
- ok;
- {error, enoent} ->
- %% The file not existing is OK, we can ignore the error.
- ok;
- Other ->
- Other
- end;
- false ->
- ok
- end.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- info_help("Validate .app file");
-info(help, clean) ->
- info_help("Delete .app file if generated from .app.src").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n",
- [
- Description,
- {validate_app_modules, true}
- ]).
-
-preprocess(Config, AppSrcFile) ->
- case rebar_app_utils:load_app_file(Config, AppSrcFile) of
- {ok, Config1, AppName, AppData} ->
- %% Look for a configuration file with vars we want to
- %% substitute. Note that we include the list of modules available in
- %% ebin/ and update the app data accordingly.
- AppVars = load_app_vars(Config1) ++ [{modules, ebin_modules()}],
- A1 = apply_app_vars(AppVars, AppData),
-
-
- %% AppSrcFile may contain instructions for generating a vsn number
- {Config2, Vsn} = rebar_app_utils:app_vsn(Config1, AppSrcFile),
- A2 = lists:keystore(vsn, 1, A1, {vsn, Vsn}),
-
- %% systools:make_relup/4 fails with {missing_param, registered}
- %% without a 'registered' value.
- A3 = ensure_registered(A2),
-
- %% Build the final spec as a string
- Spec = io_lib:format("~p.\n", [{application, AppName, A3}]),
-
- %% Setup file .app filename and write new contents
- AppFile = rebar_app_utils:app_src_to_app(AppSrcFile),
- ok = rebar_file_utils:write_file_if_contents_differ(AppFile, Spec),
-
- %% Make certain that the ebin/ directory is available
- %% on the code path
- true = code:add_path(filename:absname(filename:dirname(AppFile))),
-
- {Config2, AppFile};
-
- {error, Reason} ->
- ?ABORT("Failed to read ~s for preprocessing: ~p\n",
- [AppSrcFile, Reason])
- end.
-
-load_app_vars(Config) ->
- case rebar_config:get_local(Config, app_vars_file, undefined) of
- undefined ->
- ?INFO("No app_vars_file defined.\n", []),
- [];
- Filename ->
- ?INFO("Loading app vars from ~p\n", [Filename]),
- {ok, Vars} = file:consult(Filename),
- Vars
- end.
-
-apply_app_vars([], AppData) ->
- AppData;
-apply_app_vars([{Key, Value} | Rest], AppData) ->
- AppData2 = lists:keystore(Key, 1, AppData, {Key, Value}),
- apply_app_vars(Rest, AppData2).
-
-validate_name(AppName, File) ->
- %% Convert the .app file name to an atom -- check it against the
- %% identifier within the file
- ExpApp = list_to_atom(filename:basename(File, ".app")),
- case ExpApp == AppName of
- true ->
- ok;
- false ->
- ?ERROR("Invalid ~s: name of application (~p) "
- "must match filename.\n", [File, AppName]),
- ?FAIL
- end.
-
-validate_modules(AppName, undefined) ->
- ?ERROR("Missing modules declaration in ~p.app~n", [AppName]),
- ?FAIL;
-
-validate_modules(AppName, Mods) ->
- %% Construct two sets -- one for the actual .beam files in ebin/
- %% and one for the modules
- %% listed in the .app file
- EbinSet = ordsets:from_list(ebin_modules()),
- ModSet = ordsets:from_list(Mods),
-
- %% Identify .beam files listed in the .app, but not present in ebin/
- case ordsets:subtract(ModSet, EbinSet) of
- [] ->
- ok;
- MissingBeams ->
- Msg1 = lists:flatten([io_lib:format("\t* ~p\n", [M]) ||
- M <- MissingBeams]),
- ?ERROR("One or more modules listed in ~p.app are not "
- "present in ebin/*.beam:\n~s", [AppName, Msg1]),
- ?FAIL
- end,
-
- %% Identify .beam files NOT list in the .app, but present in ebin/
- case ordsets:subtract(EbinSet, ModSet) of
- [] ->
- ok;
- MissingMods ->
- Msg2 = lists:flatten([io_lib:format("\t* ~p\n", [M]) ||
- M <- MissingMods]),
- ?ERROR("One or more .beam files exist that are not "
- "listed in ~p.app:\n~s", [AppName, Msg2]),
- ?FAIL
- end.
-
-ebin_modules() ->
- lists:sort([rebar_utils:beam_to_mod("ebin", N) ||
- N <- rebar_utils:beams("ebin")]).
-
-ensure_registered(AppData) ->
- case lists:keyfind(registered, 1, AppData) of
- false ->
- [{registered, []} | AppData];
- {registered, _} ->
- %% We could further check whether the value is a list of atoms.
- AppData
- end.
diff --git a/src/rebar/src/rebar_port_compiler.erl b/src/rebar/src/rebar_port_compiler.erl
deleted file mode 100644
index 0abb044e6..000000000
--- a/src/rebar/src/rebar_port_compiler.erl
+++ /dev/null
@@ -1,607 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_port_compiler).
-
--export([compile/2,
- clean/2]).
-
-%% for internal use only
--export([setup_env/1,
- info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-%% Supported configuration variables:
-%%
-%% * port_specs - Erlang list of tuples of the forms
-%% {ArchRegex, TargetFile, Sources, Options}
-%% {ArchRegex, TargetFile, Sources}
-%% {TargetFile, Sources}
-%%
-%% * port_env - Erlang list of key/value pairs which will control
-%% the environment when running the compiler and linker.
-%%
-%% By default, the following variables are defined:
-%% CC - C compiler
-%% CXX - C++ compiler
-%% CFLAGS - C compiler
-%% CXXFLAGS - C++ compiler
-%% LDFLAGS - Link flags
-%% ERL_CFLAGS - default -I paths for erts and ei
-%% ERL_LDFLAGS - default -L and -lerl_interface -lei
-%% DRV_CFLAGS - flags that will be used for compiling
-%% DRV_LDFLAGS - flags that will be used for linking
-%% EXE_CFLAGS - flags that will be used for compiling
-%% EXE_LDFLAGS - flags that will be used for linking
-%% ERL_EI_LIBDIR - ei library directory
-%% DRV_CXX_TEMPLATE - C++ command template
-%% DRV_CC_TEMPLATE - C command template
-%% DRV_LINK_TEMPLATE - Linker command template
-%% EXE_CXX_TEMPLATE - C++ command template
-%% EXE_CC_TEMPLATE - C command template
-%% EXE_LINK_TEMPLATE - Linker command template
-%% PORT_IN_FILES - contains a space separated list of input
-%% file(s), (used in command template)
-%% PORT_OUT_FILE - contains the output filename (used in
-%% command template)
-%%
-%% Note that if you wish to extend (vs. replace) these variables,
-%% you MUST include a shell-style reference in your definition.
-%% e.g. to extend CFLAGS, do something like:
-%%
-%% {port_env, [{"CFLAGS", "$CFLAGS -MyOtherOptions"}]}
-%%
-%% It is also possible to specify platform specific options
-%% by specifying a triplet where the first string is a regex
-%% that is checked against Erlang's system architecture string.
-%% e.g. to specify a CFLAG that only applies to x86_64 on linux
-%% do:
-%%
-%% {port_env, [{"x86_64.*-linux", "CFLAGS",
-%% "$CFLAGS -X86Options"}]}
-%%
-
--record(spec, {type::'drv' | 'exe',
- target::file:filename(),
- sources = [] :: [file:filename(), ...],
- objects = [] :: [file:filename(), ...],
- opts = [] ::list() | []}).
-
-compile(Config, AppFile) ->
- case get_specs(Config, AppFile) of
- [] ->
- ok;
- Specs ->
- SharedEnv = rebar_config:get_env(Config, rebar_deps) ++
- rebar_config:get_env(Config, ?MODULE),
-
- %% Compile each of the sources
- NewBins = compile_sources(Config, Specs, SharedEnv),
-
- %% Make sure that the target directories exist
- ?INFO("Using specs ~p\n", [Specs]),
- lists:foreach(fun(#spec{target=Target}) ->
- ok = filelib:ensure_dir(Target)
- end, Specs),
-
- %% Only relink if necessary, given the Target
- %% and list of new binaries
- lists:foreach(
- fun(#spec{target=Target, objects=Bins, opts=Opts}) ->
- AllBins = [sets:from_list(Bins),
- sets:from_list(NewBins)],
- Intersection = sets:intersection(AllBins),
- case needs_link(Target, sets:to_list(Intersection)) of
- true ->
- LinkTemplate = select_link_template(Target),
- Env = proplists:get_value(env, Opts, SharedEnv),
- Cmd = expand_command(LinkTemplate, Env,
- string:join(Bins, " "),
- Target),
- rebar_utils:sh(Cmd, [{env, Env}]);
- false ->
- ?INFO("Skipping relink of ~s\n", [Target]),
- ok
- end
- end, Specs)
- end.
-
-clean(Config, AppFile) ->
- case get_specs(Config, AppFile) of
- [] ->
- ok;
- Specs ->
- lists:foreach(fun(#spec{target=Target, objects=Objects}) ->
- rebar_file_utils:delete_each([Target]),
- rebar_file_utils:delete_each(Objects)
- end, Specs)
- end,
- ok.
-
-setup_env(Config) ->
- setup_env(Config, []).
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- info_help("Build port sources");
-info(help, clean) ->
- info_help("Delete port build results").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n"
- " ~p~n",
- [
- Description,
- {port_env, [{"CFLAGS", "$CFLAGS -Ifoo"},
- {"freebsd", "LDFLAGS", "$LDFLAGS -lfoo"}]},
- {port_specs, [{"priv/so_name.so", ["c_src/*.c"]},
- {"linux", "priv/hello_linux", ["c_src/hello_linux.c"]},
- {"linux", "priv/hello_linux", ["c_src/*.c"], [{env, []}]}]}
- ]).
-
-setup_env(Config, ExtraEnv) ->
- %% Extract environment values from the config (if specified) and
- %% merge with the default for this operating system. This enables
- %% max flexibility for users.
- DefaultEnv = filter_env(default_env(), []),
-
- %% Get any port-specific envs; use port_env first and then fallback
- %% to port_envs for compatibility
- RawPortEnv = rebar_config:get_list(Config, port_env,
- rebar_config:get_list(Config, port_envs, [])),
-
- PortEnv = filter_env(RawPortEnv, []),
- Defines = get_defines(Config),
- OverrideEnv = Defines ++ PortEnv ++ filter_env(ExtraEnv, []),
- RawEnv = apply_defaults(os_env(), DefaultEnv) ++ OverrideEnv,
- expand_vars_loop(merge_each_var(RawEnv, [])).
-
-get_defines(Config) ->
- RawDefines = rebar_config:get_xconf(Config, defines, []),
- Defines = string:join(["-D" ++ D || D <- RawDefines], " "),
- [{"ERL_CFLAGS", "$ERL_CFLAGS " ++ Defines}].
-
-replace_extension(File, NewExt) ->
- OldExt = filename:extension(File),
- replace_extension(File, OldExt, NewExt).
-
-replace_extension(File, OldExt, NewExt) ->
- filename:rootname(File, OldExt) ++ NewExt.
-
-%%
-%% == compile and link ==
-%%
-
-compile_sources(Config, Specs, SharedEnv) ->
- lists:foldl(
- fun(#spec{sources=Sources, type=Type, opts=Opts}, NewBins) ->
- Env = proplists:get_value(env, Opts, SharedEnv),
- compile_each(Config, Sources, Type, Env, NewBins)
- end, [], Specs).
-
-compile_each(_Config, [], _Type, _Env, NewBins) ->
- lists:reverse(NewBins);
-compile_each(Config, [Source | Rest], Type, Env, NewBins) ->
- Ext = filename:extension(Source),
- Bin = replace_extension(Source, Ext, ".o"),
- case needs_compile(Source, Bin) of
- true ->
- Template = select_compile_template(Type, compiler(Ext)),
- Cmd = expand_command(Template, Env, Source, Bin),
- ShOpts = [{env, Env}, return_on_error, {use_stdout, false}],
- exec_compiler(Config, Source, Cmd, ShOpts),
- compile_each(Config, Rest, Type, Env, [Bin | NewBins]);
- false ->
- ?INFO("Skipping ~s\n", [Source]),
- compile_each(Config, Rest, Type, Env, NewBins)
- end.
-
-exec_compiler(Config, Source, Cmd, ShOpts) ->
- case rebar_utils:sh(Cmd, ShOpts) of
- {error, {_RC, RawError}} ->
- AbsSource = case rebar_utils:processing_base_dir(Config) of
- true ->
- Source;
- false ->
- filename:absname(Source)
- end,
- ?CONSOLE("Compiling ~s\n", [AbsSource]),
- Error = re:replace(RawError, Source, AbsSource,
- [{return, list}, global]),
- ?CONSOLE("~s", [Error]),
- ?FAIL;
- {ok, Output} ->
- ?CONSOLE("Compiling ~s\n", [Source]),
- ?CONSOLE("~s", [Output])
- end.
-
-needs_compile(Source, Bin) ->
- %% TODO: Generate depends using gcc -MM so we can also
- %% check for include changes
- filelib:last_modified(Bin) < filelib:last_modified(Source).
-
-needs_link(SoName, []) ->
- filelib:last_modified(SoName) == 0;
-needs_link(SoName, NewBins) ->
- MaxLastMod = lists:max([filelib:last_modified(B) || B <- NewBins]),
- case filelib:last_modified(SoName) of
- 0 ->
- ?DEBUG("Last mod is 0 on ~s\n", [SoName]),
- true;
- Other ->
- ?DEBUG("Checking ~p >= ~p\n", [MaxLastMod, Other]),
- MaxLastMod >= Other
- end.
-
-%%
-%% == port_specs ==
-%%
-
-get_specs(Config, AppFile) ->
- Specs = case rebar_config:get_local(Config, port_specs, []) of
- [] ->
- %% No spec provided. Construct a spec
- %% from old-school so_name and sources
- [port_spec_from_legacy(Config, AppFile)];
- PortSpecs ->
- Filtered = filter_port_specs(PortSpecs),
- OsType = os:type(),
- [get_port_spec(Config, OsType, Spec) || Spec <- Filtered]
- end,
- [S || S <- Specs, S#spec.sources /= []].
-
-port_spec_from_legacy(Config, AppFile) ->
- %% Get the target from the so_name variable
- Target = case rebar_config:get(Config, so_name, undefined) of
- undefined ->
- %% Generate a sensible default from app file
- {_, AppName} = rebar_app_utils:app_name(Config, AppFile),
- filename:join("priv",
- lists:concat([AppName, "_drv.so"]));
- AName ->
- %% Old form is available -- use it
- filename:join("priv", AName)
- end,
- %% Get the list of source files from port_sources
- Sources = port_sources(rebar_config:get_list(Config, port_sources,
- ["c_src/*.c"])),
- #spec { type = target_type(Target),
- target = maybe_switch_extension(os:type(), Target),
- sources = Sources,
- objects = port_objects(Sources) }.
-
-filter_port_specs(Specs) ->
- [S || S <- Specs, filter_port_spec(S)].
-
-filter_port_spec({ArchRegex, _, _, _}) ->
- rebar_utils:is_arch(ArchRegex);
-filter_port_spec({ArchRegex, _, _}) ->
- rebar_utils:is_arch(ArchRegex);
-filter_port_spec({_, _}) ->
- true.
-
-get_port_spec(Config, OsType, {Target, Sources}) ->
- get_port_spec(Config, OsType, {undefined, Target, Sources, []});
-get_port_spec(Config, OsType, {Arch, Target, Sources}) ->
- get_port_spec(Config, OsType, {Arch, Target, Sources, []});
-get_port_spec(Config, OsType, {_Arch, Target, Sources, Opts}) ->
- SourceFiles = port_sources(Sources),
- ObjectFiles = port_objects(SourceFiles),
- #spec{type=target_type(Target),
- target=maybe_switch_extension(OsType, Target),
- sources=SourceFiles,
- objects=ObjectFiles,
- opts=port_opts(Config, Opts)}.
-
-port_sources(Sources) ->
- lists:flatmap(fun filelib:wildcard/1, Sources).
-
-port_objects(SourceFiles) ->
- [replace_extension(O, ".o") || O <- SourceFiles].
-
-port_opts(Config, Opts) ->
- [port_opt(Config, O) || O <- Opts].
-
-port_opt(Config, {env, Env}) ->
- {env, setup_env(Config, Env)};
-port_opt(_Config, Opt) ->
- Opt.
-
-maybe_switch_extension({win32, nt}, Target) ->
- switch_to_dll_or_exe(Target);
-maybe_switch_extension(_OsType, Target) ->
- Target.
-
-switch_to_dll_or_exe(Target) ->
- case filename:extension(Target) of
- ".so" -> filename:rootname(Target, ".so") ++ ".dll";
- [] -> Target ++ ".exe";
- _Other -> Target
- end.
-
-%%
-%% == port_env ==
-%%
-
-%%
-%% Choose a compiler variable, based on a provided extension
-%%
-compiler(".cc") -> "$CXX";
-compiler(".cp") -> "$CXX";
-compiler(".cxx") -> "$CXX";
-compiler(".cpp") -> "$CXX";
-compiler(".CPP") -> "$CXX";
-compiler(".c++") -> "$CXX";
-compiler(".C") -> "$CXX";
-compiler(_) -> "$CC".
-
-%%
-%% Given a list of {Key, Value} variables, and another list of default
-%% {Key, Value} variables, return a merged list where the rule is if the
-%% default is expandable expand it with the value of the variable list,
-%% otherwise just return the value of the variable.
-%%
-apply_defaults(Vars, Defaults) ->
- dict:to_list(
- dict:merge(fun(Key, VarValue, DefaultValue) ->
- case is_expandable(DefaultValue) of
- true ->
- rebar_utils:expand_env_variable(DefaultValue,
- Key,
- VarValue);
- false -> VarValue
- end
- end,
- dict:from_list(Vars),
- dict:from_list(Defaults))).
-
-%%
-%% Given a list of {Key, Value} environment variables, where Key may be defined
-%% multiple times, walk the list and expand each self-reference so that we
-%% end with a list of each variable singly-defined.
-%%
-merge_each_var([], Vars) ->
- Vars;
-merge_each_var([{Key, Value} | Rest], Vars) ->
- Evalue = case orddict:find(Key, Vars) of
- error ->
- %% Nothing yet defined for this key/value.
- %% Expand any self-references as blank.
- rebar_utils:expand_env_variable(Value, Key, "");
- {ok, Value0} ->
- %% Use previous definition in expansion
- rebar_utils:expand_env_variable(Value, Key, Value0)
- end,
- merge_each_var(Rest, orddict:store(Key, Evalue, Vars)).
-
-%%
-%% Give a unique list of {Key, Value} environment variables, expand each one
-%% for every other key until no further expansions are possible.
-%%
-expand_vars_loop(Vars) ->
- expand_vars_loop(Vars, [], dict:from_list(Vars), 10).
-
-expand_vars_loop(_Pending, _Recurse, _Vars, 0) ->
- ?ABORT("Max. expansion reached for ENV vars!\n", []);
-expand_vars_loop([], [], Vars, _Count) ->
- lists:keysort(1, dict:to_list(Vars));
-expand_vars_loop([], Recurse, Vars, Count) ->
- expand_vars_loop(Recurse, [], Vars, Count-1);
-expand_vars_loop([{K, V} | Rest], Recurse, Vars, Count) ->
- %% Identify the variables that need expansion in this value
- ReOpts = [global, {capture, all_but_first, list}, unicode],
- case re:run(V, "\\\${?(\\w+)}?", ReOpts) of
- {match, Matches} ->
- %% Identify the unique variables that need to be expanded
- UniqueMatches = lists:usort([M || [M] <- Matches]),
-
- %% For each variable, expand it and return the final
- %% value. Note that if we have a bunch of unresolvable
- %% variables, nothing happens and we don't bother
- %% attempting further expansion
- case expand_keys_in_value(UniqueMatches, V, Vars) of
- V ->
- %% No change after expansion; move along
- expand_vars_loop(Rest, Recurse, Vars, Count);
- Expanded ->
- %% Some expansion occurred; move to next k/v but
- %% revisit this value in the next loop to check
- %% for further expansion
- NewVars = dict:store(K, Expanded, Vars),
- expand_vars_loop(Rest, [{K, Expanded} | Recurse],
- NewVars, Count)
- end;
-
- nomatch ->
- %% No values in this variable need expansion; move along
- expand_vars_loop(Rest, Recurse, Vars, Count)
- end.
-
-expand_keys_in_value([], Value, _Vars) ->
- Value;
-expand_keys_in_value([Key | Rest], Value, Vars) ->
- NewValue = case dict:find(Key, Vars) of
- {ok, KValue} ->
- rebar_utils:expand_env_variable(Value, Key, KValue);
- error ->
- Value
- end,
- expand_keys_in_value(Rest, NewValue, Vars).
-
-expand_command(TmplName, Env, InFiles, OutFile) ->
- Cmd0 = proplists:get_value(TmplName, Env),
- Cmd1 = rebar_utils:expand_env_variable(Cmd0, "PORT_IN_FILES", InFiles),
- rebar_utils:expand_env_variable(Cmd1, "PORT_OUT_FILE", OutFile).
-
-%%
-%% Given a string, determine if it is expandable
-%%
-is_expandable(InStr) ->
- case re:run(InStr,"\\\$",[{capture,none}]) of
- match -> true;
- nomatch -> false
- end.
-
-%%
-%% Filter a list of env vars such that only those which match the provided
-%% architecture regex (or do not have a regex) are returned.
-%%
-filter_env([], Acc) ->
- lists:reverse(Acc);
-filter_env([{ArchRegex, Key, Value} | Rest], Acc) ->
- case rebar_utils:is_arch(ArchRegex) of
- true ->
- filter_env(Rest, [{Key, Value} | Acc]);
- false ->
- filter_env(Rest, Acc)
- end;
-filter_env([{Key, Value} | Rest], Acc) ->
- filter_env(Rest, [{Key, Value} | Acc]).
-
-erts_dir() ->
- lists:concat([code:root_dir(), "/erts-", erlang:system_info(version)]).
-
-os_env() ->
- ReOpts = [{return, list}, {parts, 2}, unicode],
- Os = [list_to_tuple(re:split(S, "=", ReOpts)) || S <- os:getenv()],
- %% Drop variables without a name (win32)
- [T1 || {K, _V} = T1 <- Os, K =/= []].
-
-select_compile_template(drv, Compiler) ->
- select_compile_drv_template(Compiler);
-select_compile_template(exe, Compiler) ->
- select_compile_exe_template(Compiler).
-
-select_compile_drv_template("$CC") -> "DRV_CC_TEMPLATE";
-select_compile_drv_template("$CXX") -> "DRV_CXX_TEMPLATE".
-
-select_compile_exe_template("$CC") -> "EXE_CC_TEMPLATE";
-select_compile_exe_template("$CXX") -> "EXE_CXX_TEMPLATE".
-
-select_link_template(Target) ->
- case target_type(Target) of
- drv -> "DRV_LINK_TEMPLATE";
- exe -> "EXE_LINK_TEMPLATE"
- end.
-
-target_type(Target) -> target_type1(filename:extension(Target)).
-
-target_type1(".so") -> drv;
-target_type1(".dll") -> drv;
-target_type1("") -> exe;
-target_type1(".exe") -> exe.
-
-erl_interface_dir(Subdir) ->
- case code:lib_dir(erl_interface, Subdir) of
- {error, bad_name} ->
- throw({error, {erl_interface,Subdir,"code:lib_dir(erl_interface)"
- "is unable to find the erl_interface library."}});
- Dir -> Dir
- end.
-
-default_env() ->
- [
- {"CC" , "cc"},
- {"CXX", "c++"},
- {"DRV_CXX_TEMPLATE",
- "$CXX -c $CXXFLAGS $DRV_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
- {"DRV_CC_TEMPLATE",
- "$CC -c $CFLAGS $DRV_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
- {"DRV_LINK_TEMPLATE",
- "$CC $PORT_IN_FILES $LDFLAGS $DRV_LDFLAGS -o $PORT_OUT_FILE"},
- {"EXE_CXX_TEMPLATE",
- "$CXX -c $CXXFLAGS $EXE_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
- {"EXE_CC_TEMPLATE",
- "$CC -c $CFLAGS $EXE_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
- {"EXE_LINK_TEMPLATE",
- "$CC $PORT_IN_FILES $LDFLAGS $EXE_LDFLAGS -o $PORT_OUT_FILE"},
- {"DRV_CFLAGS" , "-g -Wall -fPIC $ERL_CFLAGS"},
- {"DRV_LDFLAGS", "-shared $ERL_LDFLAGS"},
- {"EXE_CFLAGS" , "-g -Wall -fPIC $ERL_CFLAGS"},
- {"EXE_LDFLAGS", "$ERL_LDFLAGS"},
-
- {"ERL_CFLAGS", lists:concat([" -I", erl_interface_dir(include),
- " -I", filename:join(erts_dir(), "include"),
- " "])},
- {"ERL_EI_LIBDIR", erl_interface_dir(lib)},
- {"ERL_LDFLAGS" , " -L$ERL_EI_LIBDIR -lerl_interface -lei"},
- {"ERLANG_ARCH" , rebar_utils:wordsize()},
- {"ERLANG_TARGET", rebar_utils:get_arch()},
-
- {"darwin", "DRV_LDFLAGS",
- "-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"},
-
- %% Solaris specific flags
- {"solaris.*-64$", "CFLAGS", "-D_REENTRANT -m64 $CFLAGS"},
- {"solaris.*-64$", "CXXFLAGS", "-D_REENTRANT -m64 $CXXFLAGS"},
- {"solaris.*-64$", "LDFLAGS", "-m64 $LDFLAGS"},
-
- %% OS X Leopard flags for 64-bit
- {"darwin9.*-64$", "CFLAGS", "-m64 $CFLAGS"},
- {"darwin9.*-64$", "CXXFLAGS", "-m64 $CXXFLAGS"},
- {"darwin9.*-64$", "LDFLAGS", "-arch x86_64 $LDFLAGS"},
-
- %% OS X Snow Leopard, Lion, and Mountain Lion flags for 32-bit
- {"darwin1[0-2].*-32", "CFLAGS", "-m32 $CFLAGS"},
- {"darwin1[0-2].*-32", "CXXFLAGS", "-m32 $CXXFLAGS"},
- {"darwin1[0-2].*-32", "LDFLAGS", "-arch i386 $LDFLAGS"},
-
- %% Windows specific flags
- %% add MS Visual C++ support to rebar on Windows
- {"win32", "CC", "cl.exe"},
- {"win32", "CXX", "cl.exe"},
- {"win32", "LINKER", "link.exe"},
- {"win32", "DRV_CXX_TEMPLATE",
- %% DRV_* and EXE_* Templates are identical
- "$CXX /c $CXXFLAGS $DRV_CFLAGS $PORT_IN_FILES /Fo$PORT_OUT_FILE"},
- {"win32", "DRV_CC_TEMPLATE",
- "$CC /c $CFLAGS $DRV_CFLAGS $PORT_IN_FILES /Fo$PORT_OUT_FILE"},
- {"win32", "DRV_LINK_TEMPLATE",
- "$LINKER $PORT_IN_FILES $LDFLAGS $DRV_LDFLAGS /OUT:$PORT_OUT_FILE"},
- %% DRV_* and EXE_* Templates are identical
- {"win32", "EXE_CXX_TEMPLATE",
- "$CXX /c $CXXFLAGS $EXE_CFLAGS $PORT_IN_FILES /Fo$PORT_OUT_FILE"},
- {"win32", "EXE_CC_TEMPLATE",
- "$CC /c $CFLAGS $EXE_CFLAGS $PORT_IN_FILES /Fo$PORT_OUT_FILE"},
- {"win32", "EXE_LINK_TEMPLATE",
- "$LINKER $PORT_IN_FILES $LDFLAGS $EXE_LDFLAGS /OUT:$PORT_OUT_FILE"},
- %% ERL_CFLAGS are ok as -I even though strictly it should be /I
- {"win32", "ERL_LDFLAGS", " /LIBPATH:$ERL_EI_LIBDIR erl_interface.lib ei.lib"},
- {"win32", "DRV_CFLAGS", "/Zi /Wall $ERL_CFLAGS"},
- {"win32", "DRV_LDFLAGS", "/DLL $ERL_LDFLAGS"}
- ].
diff --git a/src/rebar/src/rebar_protobuffs_compiler.erl b/src/rebar/src/rebar_protobuffs_compiler.erl
deleted file mode 100644
index 579ecfb2a..000000000
--- a/src/rebar/src/rebar_protobuffs_compiler.erl
+++ /dev/null
@@ -1,153 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_protobuffs_compiler).
-
--export([compile/2,
- clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-compile(Config, _AppFile) ->
- case rebar_utils:find_files("src", ".*\\.proto$") of
- [] ->
- ok;
- FoundFiles ->
- %% Check for protobuffs library -- if it's not present, fail
- %% since we have.proto files that need building
- case protobuffs_is_present() of
- true ->
- %% Build a list of output files - { Proto, Beam, Hrl }
- Targets = [{Proto, beam_file(Proto), hrl_file(Proto)} ||
- Proto <- FoundFiles],
-
- %% Compile each proto file
- compile_each(Config, Targets);
- false ->
- ?ERROR("Protobuffs library not present in code path!\n",
- []),
- ?FAIL
- end
- end.
-
-clean(_Config, _AppFile) ->
- %% Get a list of generated .beam and .hrl files and then delete them
- Protos = rebar_utils:find_files("src", ".*\\.proto$"),
- BeamFiles = [fq_beam_file(F) || F <- Protos],
- HrlFiles = [fq_hrl_file(F) || F <- Protos],
- Targets = BeamFiles ++ HrlFiles,
- case Targets of
- [] ->
- ok;
- _ ->
- delete_each(Targets)
- end.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, compile) ->
- info_help("Build Protobuffs (*.proto) sources");
-info(help, clean) ->
- info_help("Delete Protobuffs (*.proto) build results").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " erl_opts is passed as compile_flags to "
- "protobuffs_compile:scan_file/2~n",
- [Description]).
-
-protobuffs_is_present() ->
- code:which(protobuffs_compile) =/= non_existing.
-
-beam_file(Proto) ->
- filename:basename(Proto, ".proto") ++ "_pb.beam".
-
-hrl_file(Proto) ->
- filename:basename(Proto, ".proto") ++ "_pb.hrl".
-
-fq_beam_file(Proto) ->
- filename:join(["ebin", filename:basename(Proto, ".proto") ++ "_pb.beam"]).
-
-fq_hrl_file(Proto) ->
- filename:join(["include", filename:basename(Proto, ".proto") ++ "_pb.hrl"]).
-
-needs_compile(Proto, Beam) ->
- ActualBeam = filename:join(["ebin", filename:basename(Beam)]),
- filelib:last_modified(ActualBeam) < filelib:last_modified(Proto).
-
-compile_each(_, []) ->
- ok;
-compile_each(Config, [{Proto, Beam, Hrl} | Rest]) ->
- case needs_compile(Proto, Beam) of
- true ->
- ?CONSOLE("Compiling ~s\n", [Proto]),
- ErlOpts = rebar_utils:erl_opts(Config),
- case protobuffs_compile:scan_file(Proto,
- [{compile_flags,ErlOpts}]) of
- ok ->
- %% Compilation worked, but we need to move the
- %% beam and .hrl file into the ebin/ and include/
- %% directories respectively
- %% TODO: Protobuffs really needs to be better about this
- ok = filelib:ensure_dir(filename:join("ebin","dummy")),
- ok = rebar_file_utils:mv(Beam, "ebin"),
- ok = filelib:ensure_dir(filename:join("include", Hrl)),
- ok = rebar_file_utils:mv(Hrl, "include"),
- ok;
- Other ->
- ?ERROR("Protobuffs compile of ~s failed: ~p\n",
- [Proto, Other]),
- ?FAIL
- end;
- false ->
- ok
- end,
- compile_each(Config, Rest).
-
-delete_each([]) ->
- ok;
-delete_each([File | Rest]) ->
- case file:delete(File) of
- ok ->
- ok;
- {error, enoent} ->
- ok;
- {error, Reason} ->
- ?ERROR("Failed to delete ~s: ~p\n", [File, Reason])
- end,
- delete_each(Rest).
diff --git a/src/rebar/src/rebar_qc.erl b/src/rebar/src/rebar_qc.erl
deleted file mode 100644
index 53a6f52bf..000000000
--- a/src/rebar/src/rebar_qc.erl
+++ /dev/null
@@ -1,187 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2011-2012 Tuncer Ayaz
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_qc).
-
--export([qc/2, triq/2, eqc/2, clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
--define(QC_DIR, ".qc").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-qc(Config, _AppFile) ->
- ?CONSOLE("NOTICE: Using experimental 'qc' command~n", []),
- run_qc(Config, qc_opts(Config)).
-
-triq(Config, _AppFile) ->
- ?CONSOLE("NOTICE: Using experimental 'triq' command~n", []),
- ok = load_qc_mod(triq),
- run_qc(Config, qc_opts(Config), triq).
-
-eqc(Config, _AppFile) ->
- ?CONSOLE("NOTICE: Using experimental 'eqc' command~n", []),
- ok = load_qc_mod(eqc),
- run_qc(Config, qc_opts(Config), eqc).
-
-clean(_Config, _File) ->
- rebar_file_utils:rm_rf(?QC_DIR).
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, qc) ->
- ?CONSOLE(
- "Test QuickCheck properties.~n"
- "~n"
- "Valid rebar.config options:~n"
- " {qc_opts, [{qc_mod, module()}, Options]}~n"
- " ~p~n"
- " ~p~n",
- [
- {qc_compile_opts, []},
- {qc_first_files, []}
- ]).
-
--define(TRIQ_MOD, triq).
--define(EQC_MOD, eqc).
-
-qc_opts(Config) ->
- rebar_config:get(Config, qc_opts, []).
-
-run_qc(Config, QCOpts) ->
- run_qc(Config, QCOpts, select_qc_mod(QCOpts)).
-
-run_qc(Config, RawQCOpts, QC) ->
- ?DEBUG("Selected QC module: ~p~n", [QC]),
- QCOpts = lists:filter(fun({qc_mod, _}) -> false;
- (_) -> true
- end, RawQCOpts),
- run(Config, QC, QCOpts).
-
-select_qc_mod(QCOpts) ->
- case proplists:get_value(qc_mod, QCOpts) of
- undefined ->
- detect_qc_mod();
- QC ->
- case code:ensure_loaded(QC) of
- {module, QC} ->
- QC;
- {error, nofile} ->
- ?ABORT("Configured QC library '~p' not available~n", [QC])
- end
- end.
-
-detect_qc_mod() ->
- case code:ensure_loaded(?TRIQ_MOD) of
- {module, ?TRIQ_MOD} ->
- ?TRIQ_MOD;
- {error, nofile} ->
- case code:ensure_loaded(?EQC_MOD) of
- {module, ?EQC_MOD} ->
- ?EQC_MOD;
- {error, nofile} ->
- ?ABORT("No QC library available~n", [])
- end
- end.
-
-load_qc_mod(Mod) ->
- case code:ensure_loaded(Mod) of
- {module, Mod} ->
- ok;
- {error, nofile} ->
- ?ABORT("Failed to load QC lib '~p'~n", [Mod])
- end.
-
-ensure_dirs() ->
- ok = filelib:ensure_dir(filename:join(qc_dir(), "dummy")),
- ok = filelib:ensure_dir(filename:join(rebar_utils:ebin_dir(), "dummy")).
-
-setup_codepath() ->
- CodePath = code:get_path(),
- true = code:add_patha(qc_dir()),
- true = code:add_pathz(rebar_utils:ebin_dir()),
- CodePath.
-
-qc_dir() ->
- filename:join(rebar_utils:get_cwd(), ?QC_DIR).
-
-run(Config, QC, QCOpts) ->
- ?DEBUG("qc_opts: ~p~n", [QCOpts]),
-
- ok = ensure_dirs(),
- CodePath = setup_codepath(),
-
- CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
- false),
- %% Compile erlang code to ?QC_DIR, using a tweaked config
- %% with appropriate defines, and include all the test modules
- %% as well.
- {ok, _SrcErls} = rebar_erlc_compiler:test_compile(Config, "qc", ?QC_DIR),
-
- case CompileOnly of
- "true" ->
- true = code:set_path(CodePath),
- ?CONSOLE("Compiled modules for qc~n", []);
- false ->
- run1(QC, QCOpts, CodePath)
- end.
-
-run1(QC, QCOpts, CodePath) ->
- TestModule = fun(M) -> qc_module(QC, QCOpts, M) end,
- case lists:flatmap(TestModule, find_prop_mods()) of
- [] ->
- true = code:set_path(CodePath),
- ok;
- Errors ->
- ?ABORT("One or more QC properties didn't hold true:~n~p~n",
- [Errors])
- end.
-
-qc_module(QC=triq, _QCOpts, M) ->
- case QC:module(M) of
- true ->
- [];
- Failed ->
- [Failed]
- end;
-qc_module(QC=eqc, [], M) -> QC:module(M);
-qc_module(QC=eqc, QCOpts, M) -> QC:module(QCOpts, M).
-
-find_prop_mods() ->
- Beams = rebar_utils:find_files(?QC_DIR, ".*\\.beam\$"),
- [M || M <- [rebar_utils:erl_to_mod(Beam) || Beam <- Beams], has_prop(M)].
-
-has_prop(Mod) ->
- lists:any(fun({F,_A}) -> lists:prefix("prop_", atom_to_list(F)) end,
- Mod:module_info(exports)).
diff --git a/src/rebar/src/rebar_rel_utils.erl b/src/rebar/src/rebar_rel_utils.erl
deleted file mode 100644
index 085dbd91c..000000000
--- a/src/rebar/src/rebar_rel_utils.erl
+++ /dev/null
@@ -1,238 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_rel_utils).
-
--export([is_rel_dir/0,
- is_rel_dir/1,
- get_reltool_release_info/1,
- get_rel_release_info/1,
- get_rel_release_info/2,
- get_rel_apps/1,
- get_rel_apps/2,
- get_previous_release_path/1,
- get_rel_file_path/2,
- load_config/2,
- get_sys_tuple/1,
- get_target_dir/2,
- get_root_dir/2,
- get_target_parent_dir/2]).
-
--include("rebar.hrl").
-
-is_rel_dir() ->
- is_rel_dir(rebar_utils:get_cwd()).
-
-is_rel_dir(Dir) ->
- Fname = filename:join([Dir, "reltool.config"]),
- Scriptname = Fname ++ ".script",
- Res = case filelib:is_regular(Scriptname) of
- true ->
- {true, Scriptname};
- false ->
- case filelib:is_regular(Fname) of
- true ->
- {true, Fname};
- false ->
- false
- end
- end,
- ?DEBUG("is_rel_dir(~s) -> ~p~n", [Dir, Res]),
- Res.
-
-%% Get release name and version from a reltool.config
-get_reltool_release_info([{sys, Config}| _]) ->
- {rel, Name, Ver, _} = proplists:lookup(rel, Config),
- {Name, Ver};
-get_reltool_release_info(ReltoolFile) when is_list(ReltoolFile) ->
- case file:consult(ReltoolFile) of
- {ok, ReltoolConfig} ->
- get_reltool_release_info(ReltoolConfig);
- _ ->
- ?ABORT("Failed to parse ~s~n", [ReltoolFile])
- end.
-
-%% Get release name and version from a rel file
-get_rel_release_info(RelFile) ->
- case file:consult(RelFile) of
- {ok, [{release, {Name, Ver}, _, _}]} ->
- {Name, Ver};
- _ ->
- ?ABORT("Failed to parse ~s~n", [RelFile])
- end.
-
-%% Get release name and version from a name and a path
-get_rel_release_info(Name, Path) ->
- RelPath = get_rel_file_path(Name, Path),
- get_rel_release_info(RelPath).
-
-%% Get list of apps included in a release from a rel file
-get_rel_apps(RelFile) ->
- case file:consult(RelFile) of
- {ok, [{release, _, _, Apps}]} ->
- make_proplist(Apps, []);
- _ ->
- ?ABORT("Failed to parse ~s~n", [RelFile])
- end.
-
-%% Get list of apps included in a release from a name and a path
-get_rel_apps(Name, Path) ->
- RelPath = get_rel_file_path(Name, Path),
- get_rel_apps(RelPath).
-
-%% Get rel file path from name and path
-get_rel_file_path(Name, Path) ->
- [RelFile] = filelib:wildcard(filename:join([Path, "releases", "*",
- Name ++ ".rel"])),
- RelFile.
-
-%% Get the previous release path from a global variable
-get_previous_release_path(Config) ->
- case rebar_config:get_global(Config, previous_release, false) of
- false ->
- ?ABORT("previous_release=PATH is required to "
- "create upgrade package~n", []);
- OldVerPath ->
- OldVerPath
- end.
-
-%%
-%% Load terms from reltool.config
-%%
-load_config(Config, ReltoolFile) ->
- case rebar_config:consult_file(ReltoolFile) of
- {ok, Terms} ->
- expand_version(Config, Terms, filename:dirname(ReltoolFile));
- Other ->
- ?ABORT("Failed to load expected config from ~s: ~p\n",
- [ReltoolFile, Other])
- end.
-
-%%
-%% Look for the {sys, [...]} tuple in the reltool.config file.
-%% Without this present, we can't run reltool.
-%%
-get_sys_tuple(ReltoolConfig) ->
- case lists:keyfind(sys, 1, ReltoolConfig) of
- {sys, _} = SysTuple ->
- SysTuple;
- false ->
- ?ABORT("Failed to find {sys, [...]} tuple in reltool.config.", [])
- end.
-
-%%
-%% Look for {target_dir, TargetDir} in the reltool config file; if none is
-%% found, use the name of the release as the default target directory.
-%%
-get_target_dir(Config, ReltoolConfig) ->
- case rebar_config:get_global(Config, target_dir, undefined) of
- undefined ->
- case lists:keyfind(target_dir, 1, ReltoolConfig) of
- {target_dir, TargetDir} ->
- filename:absname(TargetDir);
- false ->
- {sys, SysInfo} = get_sys_tuple(ReltoolConfig),
- case lists:keyfind(rel, 1, SysInfo) of
- {rel, Name, _Vsn, _Apps} ->
- filename:absname(Name);
- false ->
- filename:absname("target")
- end
- end;
- TargetDir ->
- filename:absname(TargetDir)
- end.
-
-get_target_parent_dir(Config, ReltoolConfig) ->
- TargetDir = get_target_dir(Config, ReltoolConfig),
- case lists:reverse(tl(lists:reverse(filename:split(TargetDir)))) of
- [] -> ".";
- Components -> filename:join(Components)
- end.
-
-%%
-%% Look for root_dir in sys tuple and command line; fall back to
-%% code:root_dir().
-%%
-get_root_dir(Config, ReltoolConfig) ->
- {sys, SysInfo} = get_sys_tuple(ReltoolConfig),
- SysRootDirTuple = lists:keyfind(root_dir, 1, SysInfo),
- CmdRootDir = rebar_config:get_global(Config, root_dir, undefined),
- case {SysRootDirTuple, CmdRootDir} of
- %% root_dir in sys typle and no root_dir on cmd-line
- {{root_dir, SysRootDir}, undefined} ->
- SysRootDir;
- %% root_dir in sys typle and also root_dir on cmd-line
- {{root_dir, SysRootDir}, CmdRootDir} when CmdRootDir =/= undefined ->
- case string:equal(SysRootDir, CmdRootDir) of
- true ->
- ok;
- false ->
- ?WARN("overriding reltool.config root_dir with "
- "different command line root_dir~n", [])
- end,
- CmdRootDir;
- %% no root_dir in sys typle and no root_dir on cmd-line
- {false, undefined} ->
- code:root_dir();
- %% no root_dir in sys tuple but root_dir on cmd-line
- {false, CmdRootDir} when CmdRootDir =/= undefined ->
- CmdRootDir
- end.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-make_proplist([{_,_}=H|T], Acc) ->
- make_proplist(T, [H|Acc]);
-make_proplist([H|T], Acc) ->
- App = element(1, H),
- Ver = element(2, H),
- make_proplist(T, [{App,Ver}|Acc]);
-make_proplist([], Acc) ->
- Acc.
-
-expand_version(Config, ReltoolConfig, Dir) ->
- case lists:keyfind(sys, 1, ReltoolConfig) of
- {sys, Sys} ->
- {Config1, Rels} =
- lists:foldl(
- fun(Term, {C, R}) ->
- {C1, Rel} = expand_rel_version(C, Term, Dir),
- {C1, [Rel|R]}
- end, {Config, []}, Sys),
- ExpandedSys = {sys, lists:reverse(Rels)},
- {Config1, lists:keyreplace(sys, 1, ReltoolConfig, ExpandedSys)};
- _ ->
- {Config, ReltoolConfig}
- end.
-
-expand_rel_version(Config, {rel, Name, Version, Apps}, Dir) ->
- {NewConfig, VsnString} = rebar_utils:vcs_vsn(Config, Version, Dir),
- {NewConfig, {rel, Name, VsnString, Apps}};
-expand_rel_version(Config, Other, _Dir) ->
- {Config, Other}.
diff --git a/src/rebar/src/rebar_reltool.erl b/src/rebar/src/rebar_reltool.erl
deleted file mode 100644
index 9f9488e15..000000000
--- a/src/rebar/src/rebar_reltool.erl
+++ /dev/null
@@ -1,408 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_reltool).
-
--export([generate/2,
- overlay/2,
- clean/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
--include_lib("kernel/include/file.hrl").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-generate(Config0, ReltoolFile) ->
- %% Make sure we have decent version of reltool available
- check_vsn(),
-
- %% Load the reltool configuration from the file
- {Config, ReltoolConfig} = rebar_rel_utils:load_config(Config0, ReltoolFile),
-
- Sys = rebar_rel_utils:get_sys_tuple(ReltoolConfig),
-
- %% Spin up reltool server and load our config into it
- {ok, Server} = reltool:start_server([Sys]),
-
- %% Do some validation of the reltool configuration; error messages out of
- %% reltool are still pretty cryptic
- validate_rel_apps(Server, Sys),
-
- %% Finally, run reltool
- case catch(run_reltool(Server, Config, ReltoolConfig)) of
- ok ->
- {ok, Config};
- {error, failed} ->
- ?FAIL;
- Other2 ->
- ?ERROR("Unexpected error: ~p\n", [Other2]),
- ?FAIL
- end.
-
-overlay(Config, ReltoolFile) ->
- %% Load the reltool configuration from the file
- {Config1, ReltoolConfig} = rebar_rel_utils:load_config(Config, ReltoolFile),
- {process_overlay(Config, ReltoolConfig), Config1}.
-
-clean(Config, ReltoolFile) ->
- {Config1, ReltoolConfig} = rebar_rel_utils:load_config(Config, ReltoolFile),
- TargetDir = rebar_rel_utils:get_target_dir(Config, ReltoolConfig),
- rebar_file_utils:rm_rf(TargetDir),
- rebar_file_utils:delete_each(["reltool.spec"]),
- {ok, Config1}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, generate) ->
- info_help("Build release with reltool");
-info(help, clean) ->
- info_help("Delete release");
-info(help, overlay) ->
- info_help("Run reltool overlays only").
-
-info_help(Description) ->
- ?CONSOLE(
- "~s.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~n"
- "Valid reltool.config options:~n"
- " {sys, []}~n"
- " {target_dir, \"target\"}~n"
- " {overlay_vars, \"overlay\"}~n"
- " {overlay, []}~n"
- "Valid command line options:~n"
- " target_dir=target~n"
- " overlay_vars=VarsFile~n"
- " dump_spec=1 (write reltool target spec to reltool.spec)~n",
- [
- Description
- ]).
-
-check_vsn() ->
- %% TODO: use application:load and application:get_key once we require
- %% R14A or newer. There's no reltool.app before R14A.
- case code:lib_dir(reltool) of
- {error, bad_name} ->
- ?ABORT("Reltool support requires the reltool application "
- "to be installed!", []);
- Path ->
- ReltoolVsn = filename:basename(Path),
- case ReltoolVsn < "reltool-0.5.2" of
- true ->
- ?ABORT("Reltool support requires at least reltool-0.5.2; "
- "this VM is using ~s\n", [ReltoolVsn]);
- false ->
- ok
- end
- end.
-
-process_overlay(Config, ReltoolConfig) ->
- TargetDir = rebar_rel_utils:get_target_dir(Config, ReltoolConfig),
-
- {_BootRelName, BootRelVsn} =
- rebar_rel_utils:get_reltool_release_info(ReltoolConfig),
-
- %% Initialize overlay vars with some basics
- %% (that can get overwritten)
- OverlayVars0 =
- dict:from_list([{erts_vsn, "erts-" ++ erlang:system_info(version)},
- {rel_vsn, BootRelVsn},
- {target_dir, TargetDir},
- {hostname, net_adm:localhost()}]),
-
- %% Load up any variables specified by overlay_vars
- OverlayVars1 = overlay_vars(Config, OverlayVars0, ReltoolConfig),
- OverlayVars = rebar_templater:resolve_variables(dict:to_list(OverlayVars1),
- OverlayVars1),
-
- %% Finally, overlay the files specified by the overlay section
- case lists:keyfind(overlay, 1, ReltoolConfig) of
- {overlay, Overlay} when is_list(Overlay) ->
- execute_overlay(Overlay, OverlayVars, rebar_utils:get_cwd(),
- TargetDir);
- false ->
- ?INFO("No {overlay, [...]} found in reltool.config.\n", []);
- _ ->
- ?ABORT("{overlay, [...]} entry in reltool.config "
- "must be a list.\n", [])
- end.
-
-%%
-%% Look for overlay_vars file reference. If the user provides an overlay_vars on
-%% the command line (i.e. a global), the terms from that file OVERRIDE the one
-%% listed in reltool.config. To re-iterate, this means you can specify a
-%% variable in the file from reltool.config and then override that value by
-%% providing an additional file on the command-line.
-%%
-overlay_vars(Config, Vars0, ReltoolConfig) ->
- BaseVars = load_vars_file([proplists:get_value(overlay_vars, ReltoolConfig)]),
- OverlayVars = rebar_config:get_global(Config, overlay_vars, []),
- OverrideVars = load_vars_file(string:tokens(OverlayVars, ",")),
- M = fun merge_overlay_var/3,
- dict:merge(M, dict:merge(M, Vars0, BaseVars), OverrideVars).
-
-merge_overlay_var(_Key, _Base, Override) -> Override.
-
-%%
-%% If a filename is provided, construct a dict of terms
-%%
-load_vars_file([undefined]) ->
- dict:new();
-load_vars_file([]) ->
- dict:new();
-load_vars_file(Files) ->
- load_vars_file(Files, dict:new()).
-
-load_vars_file([], Dict) ->
- Dict;
-load_vars_file([File | Files], BaseVars) ->
- case rebar_config:consult_file(File) of
- {ok, Terms} ->
- OverrideVars = dict:from_list(Terms),
- M = fun merge_overlay_var/3,
- load_vars_file(Files, dict:merge(M, BaseVars, OverrideVars));
- {error, Reason} ->
- ?ABORT("Unable to load overlay_vars from ~p: ~p\n", [File, Reason])
- end.
-
-validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) ->
- case lists:keyfind(rel, 1, ReltoolConfig) of
- false ->
- ok;
- {rel, _Name, _Vsn, Apps} ->
- %% Identify all the apps that do NOT exist, based on
- %% what's available from the reltool server
- Missing = lists:sort(
- [App || App <- Apps,
- app_exists(App, ReltoolServer) == false]),
- case Missing of
- [] ->
- ok;
- _ ->
- ?ABORT("Apps in {rel, ...} section not found by "
- "reltool: ~p\n", [Missing])
- end;
- Rel ->
- %% Invalid release format!
- ?ABORT("Invalid {rel, ...} section in reltools.config: ~p\n", [Rel])
- end.
-
-app_exists(App, Server) when is_atom(App) ->
- case reltool_server:get_app(Server, App) of
- {ok, _} ->
- true;
- _ ->
- false
- end;
-app_exists(AppTuple, Server) when is_tuple(AppTuple) ->
- app_exists(element(1, AppTuple), Server).
-
-run_reltool(Server, Config, ReltoolConfig) ->
- case reltool:get_target_spec(Server) of
- {ok, Spec} ->
- %% Pull the target dir and make sure it exists
- TargetDir = rebar_rel_utils:get_target_dir(Config, ReltoolConfig),
- mk_target_dir(Config, TargetDir),
-
- %% Determine the otp root dir to use
- RootDir = rebar_rel_utils:get_root_dir(Config, ReltoolConfig),
-
- %% Dump the spec, if necessary
- dump_spec(Config, Spec),
-
- %% Have reltool actually run
- case reltool:eval_target_spec(Spec, RootDir, TargetDir) of
- ok ->
- ok;
- {error, Reason} ->
- ?ABORT("Failed to generate target from spec: ~p\n",
- [Reason])
- end,
-
- {BootRelName, BootRelVsn} =
- rebar_rel_utils:get_reltool_release_info(ReltoolConfig),
-
- ok = create_RELEASES(TargetDir, BootRelName, BootRelVsn),
-
- process_overlay(Config, ReltoolConfig);
-
- {error, Reason} ->
- ?ABORT("Unable to generate spec: ~s\n", [Reason])
- end.
-
-mk_target_dir(Config, TargetDir) ->
- case filelib:ensure_dir(filename:join(TargetDir, "dummy")) of
- ok ->
- ok;
- {error, eexist} ->
- %% Output directory already exists; if force=1, wipe it out
- case rebar_config:get_global(Config, force, "0") of
- "1" ->
- rebar_file_utils:rm_rf(TargetDir),
- ok = file:make_dir(TargetDir);
- _ ->
- ?ERROR("Release target directory ~p already exists!\n",
- [TargetDir]),
- ?FAIL
- end;
- {error, Reason} ->
- ?ERROR("Failed to make target dir ~p: ~s\n",
- [TargetDir, file:format_error(Reason)]),
- ?FAIL
- end.
-
-dump_spec(Config, Spec) ->
- case rebar_config:get_global(Config, dump_spec, "0") of
- "1" ->
- SpecBin = list_to_binary(io_lib:print(Spec, 1, 120, -1)),
- ok = file:write_file("reltool.spec", SpecBin);
- _ ->
- ok
- end.
-
-
-%% TODO: Merge functionality here with rebar_templater
-
-execute_overlay([], _Vars, _BaseDir, _TargetDir) ->
- ok;
-execute_overlay([{mkdir, Out} | Rest], Vars, BaseDir, TargetDir) ->
- OutFile = rebar_templater:render(
- filename:join([TargetDir, Out, "dummy"]), Vars),
- ok = filelib:ensure_dir(OutFile),
- ?DEBUG("Created dir ~s\n", [filename:dirname(OutFile)]),
- execute_overlay(Rest, Vars, BaseDir, TargetDir);
-execute_overlay([{copy, In} | Rest], _Vars, BaseDir, TargetDir) ->
- execute_overlay([{copy, In, ""} | Rest], _Vars, BaseDir, TargetDir);
-execute_overlay([{copy, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
- InFile = rebar_templater:render(filename:join(BaseDir, In), Vars),
- OutFile = rebar_templater:render(filename:join(TargetDir, Out), Vars),
- case filelib:is_dir(InFile) of
- true ->
- ok;
- false ->
- ok = filelib:ensure_dir(OutFile)
- end,
- rebar_file_utils:cp_r([InFile], OutFile),
- execute_overlay(Rest, Vars, BaseDir, TargetDir);
-execute_overlay([{template_wildcard, Wildcard, OutDir} | Rest], Vars,
- BaseDir, TargetDir) ->
- %% Generate a series of {template, In, Out} instructions from the wildcard
- %% that will get processed per normal
- Ifun = fun(F, Acc0) ->
- [{template, F,
- filename:join(OutDir, filename:basename(F))} | Acc0]
- end,
- NewInstrs = lists:foldl(Ifun, Rest, filelib:wildcard(Wildcard, BaseDir)),
- case length(NewInstrs) =:= length(Rest) of
- true ->
- ?WARN("template_wildcard: ~s did not match any files!\n",
- [Wildcard]);
- false ->
- ok
- end,
- ?DEBUG("template_wildcard: ~s expanded to ~p\n", [Wildcard, NewInstrs]),
- execute_overlay(NewInstrs, Vars, BaseDir, TargetDir);
-execute_overlay([{template, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
- InFile = rebar_templater:render(filename:join(BaseDir, In), Vars),
- {ok, InFileData} = file:read_file(InFile),
- OutFile = rebar_templater:render(filename:join(TargetDir, Out), Vars),
- ok = filelib:ensure_dir(OutFile),
- case file:write_file(OutFile, rebar_templater:render(InFileData, Vars)) of
- ok ->
- ok = apply_file_info(InFile, OutFile),
- ?DEBUG("Templated ~p\n", [OutFile]),
- execute_overlay(Rest, Vars, BaseDir, TargetDir);
- {error, Reason} ->
- ?ABORT("Failed to template ~p: ~p\n", [OutFile, Reason])
- end;
-execute_overlay([{create, Out, Contents} | Rest], Vars, BaseDir, TargetDir) ->
- OutFile = rebar_templater:render(filename:join(TargetDir, Out), Vars),
- ok = filelib:ensure_dir(OutFile),
- case file:write_file(OutFile, Contents) of
- ok ->
- ?DEBUG("Created ~p\n", [OutFile]),
- execute_overlay(Rest, Vars, BaseDir, TargetDir);
- {error, Reason} ->
- ?ABORT("Failed to create ~p: ~p\n", [OutFile, Reason])
- end;
-execute_overlay([{replace, Out, Regex, Replacement} | Rest],
- Vars, BaseDir, TargetDir) ->
- execute_overlay([{replace, Out, Regex, Replacement, []} | Rest],
- Vars, BaseDir, TargetDir);
-execute_overlay([{replace, Out, Regex, Replacement, Opts} | Rest],
- Vars, BaseDir, TargetDir) ->
- Filename = rebar_templater:render(filename:join(TargetDir, Out), Vars),
- {ok, OrigData} = file:read_file(Filename),
- Data = re:replace(OrigData, Regex,
- rebar_templater:render(Replacement, Vars),
- [global, {return, binary}] ++ Opts),
- case file:write_file(Filename, Data) of
- ok ->
- ?DEBUG("Edited ~s: s/~s/~s/\n", [Filename, Regex, Replacement]),
- execute_overlay(Rest, Vars, BaseDir, TargetDir);
- {error, Reason} ->
- ?ABORT("Failed to edit ~p: ~p\n", [Filename, Reason])
- end;
-execute_overlay([Other | _Rest], _Vars, _BaseDir, _TargetDir) ->
- {error, {unsupported_operation, Other}}.
-
-
-apply_file_info(InFile, OutFile) ->
- {ok, FileInfo} = file:read_file_info(InFile),
- ok = file:write_file_info(OutFile, FileInfo).
-
-create_RELEASES(TargetDir, RelName, RelVsn) ->
- ReleasesDir = filename:join(TargetDir, "releases"),
- RelFile = filename:join([ReleasesDir, RelVsn, RelName ++ ".rel"]),
- Apps = rebar_rel_utils:get_rel_apps(RelFile),
- TargetLib = filename:join(TargetDir,"lib"),
-
- AppDirs =
- [ {App, Vsn, TargetLib}
- || {App, Vsn} <- Apps,
- filelib:is_dir(
- filename:join(TargetLib,
- lists:concat([App, "-", Vsn]))) ],
-
- case release_handler:create_RELEASES(
- code:root_dir(),
- ReleasesDir,
- RelFile,
- AppDirs) of
- ok ->
- ok;
- {error, Reason} ->
- ?ABORT("Failed to create RELEASES file: ~p\n",
- [Reason])
- end.
diff --git a/src/rebar/src/rebar_require_vsn.erl b/src/rebar/src/rebar_require_vsn.erl
deleted file mode 100644
index 385f55c31..000000000
--- a/src/rebar/src/rebar_require_vsn.erl
+++ /dev/null
@@ -1,121 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%%
-%% -------------------------------------------------------------------
-
--module(rebar_require_vsn).
-
--include("rebar.hrl").
-
--export([compile/2,
- eunit/2]).
-
-%% for internal use only
--export([info/2]).
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-compile(Config, _) ->
- check_versions(Config).
-
-eunit(Config, _) ->
- check_versions(Config).
-
-%% ====================================================================
-%% Internal functions
-%% ====================================================================
-
-info(help, compile) ->
- info_help();
-info(help, eunit) ->
- info_help().
-
-info_help() ->
- ?CONSOLE(
- "Check required ERTS or OTP release version.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n"
- " ~p~n"
- " ~p~n",
- [
- {require_erts_vsn, ".*"},
- {require_otp_vsn, ".*"},
- {require_min_otp_vsn, ".*"}
- ]).
-
-check_versions(Config) ->
- ErtsRegex = rebar_config:get(Config, require_erts_vsn, ".*"),
- ReOpts = [{capture, none}],
- case re:run(erlang:system_info(version), ErtsRegex, ReOpts) of
- match ->
- ?DEBUG("Matched required ERTS version: ~s -> ~s\n",
- [erlang:system_info(version), ErtsRegex]);
- nomatch ->
- ?ABORT("ERTS version ~s does not match required regex ~s\n",
- [erlang:system_info(version), ErtsRegex])
- end,
-
- OtpRegex = rebar_config:get(Config, require_otp_vsn, ".*"),
- case re:run(erlang:system_info(otp_release), OtpRegex, ReOpts) of
- match ->
- ?DEBUG("Matched required OTP release: ~s -> ~s\n",
- [erlang:system_info(otp_release), OtpRegex]);
- nomatch ->
- ?ABORT("OTP release ~s does not match required regex ~s\n",
- [erlang:system_info(otp_release), OtpRegex])
- end,
-
- case rebar_config:get(Config, require_min_otp_vsn, undefined) of
- undefined -> ?DEBUG("Min OTP version unconfigured~n", []);
- MinOtpVsn ->
- {MinMaj, MinMin} = version_tuple(MinOtpVsn, "configured"),
- {OtpMaj, OtpMin} = version_tuple(erlang:system_info(otp_release),
- "OTP Release"),
- case {OtpMaj, OtpMin} >= {MinMaj, MinMin} of
- true ->
- ?DEBUG("~s satisfies the requirement for vsn ~s~n",
- [erlang:system_info(otp_release),
- MinOtpVsn]);
- false ->
- ?ABORT("OTP release ~s or later is required, you have: ~s~n",
- [MinOtpVsn,
- erlang:system_info(otp_release)])
- end
- end.
-
-version_tuple(OtpRelease, Type) ->
- case re:run(OtpRelease, "R(\\d+)B?-?(\\d+)?", [{capture, all, list}]) of
- {match, [_Full, Maj, Min]} ->
- {list_to_integer(Maj), list_to_integer(Min)};
- {match, [_Full, Maj]} ->
- {list_to_integer(Maj), 0};
- nomatch ->
- ?ABORT("Cannot parse ~s version string: ~s~n",
- [Type, OtpRelease])
- end.
diff --git a/src/rebar/src/rebar_shell.erl b/src/rebar/src/rebar_shell.erl
deleted file mode 100644
index 2dbf4a0a2..000000000
--- a/src/rebar/src/rebar_shell.erl
+++ /dev/null
@@ -1,56 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2011 Trifork
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-
--module(rebar_shell).
--author("Kresten Krab Thorup <krab@trifork.com>").
-
--include("rebar.hrl").
-
--export([shell/2]).
-
-shell(_Config, _AppFile) ->
- ?CONSOLE("NOTICE: Using experimental 'shell' command~n", []),
- %% backwards way to say we only want this executed
- %% for the "top level" directory
- case is_deps_dir(rebar_utils:get_cwd()) of
- false ->
- true = code:add_pathz(rebar_utils:ebin_dir()),
- user_drv:start(),
- %% this call never returns (until user quits shell)
- shell:server(false, false);
- true ->
- ok
- end,
- ok.
-
-is_deps_dir(Dir) ->
- case lists:reverse(filename:split(Dir)) of
- [_, "deps" | _] ->
- true;
- _V ->
- false
- end.
diff --git a/src/rebar/src/rebar_subdirs.erl b/src/rebar/src/rebar_subdirs.erl
deleted file mode 100644
index f444a5943..000000000
--- a/src/rebar/src/rebar_subdirs.erl
+++ /dev/null
@@ -1,84 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_subdirs).
-
--include("rebar.hrl").
--include_lib("kernel/include/file.hrl").
-
--export([preprocess/2]).
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-preprocess(Config, _) ->
- %% Get the list of subdirs specified in the config (if any).
- Cwd = rebar_utils:get_cwd(),
- ListSubdirs = rebar_config:get_local(Config, sub_dirs, []),
- Subdirs0 = lists:flatmap(fun filelib:wildcard/1, ListSubdirs),
- case {rebar_config:is_skip_dir(Config, Cwd), Subdirs0} of
- {true, []} ->
- {ok, []};
- {true, _} ->
- ?WARN("Ignoring sub_dirs for ~s~n", [Cwd]),
- {ok, []};
- {false, _} ->
- Check = check_loop(Cwd),
- ok = lists:foreach(Check, Subdirs0),
- Subdirs = [filename:join(Cwd, Dir) || Dir <- Subdirs0],
- {ok, Subdirs}
- end.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-check_loop(Cwd) ->
- RebarConfig = filename:join(Cwd, "rebar.config"),
- fun(Dir0) ->
- IsSymlink = case file:read_link_info(Dir0) of
- {ok, #file_info{type=symlink}} ->
- {true, resolve_symlink(Dir0)};
- _ ->
- {false, Dir0}
- end,
- case IsSymlink of
- {false, Dir="."} ->
- ?ERROR("infinite loop detected:~nsub_dirs"
- " entry ~p in ~s~n", [Dir, RebarConfig]);
- {true, Cwd} ->
- ?ERROR("infinite loop detected:~nsub_dirs"
- " entry ~p in ~s is a symlink to \".\"~n",
- [Dir0, RebarConfig]);
- _ ->
- ok
- end
- end.
-
-resolve_symlink(Dir0) ->
- {ok, Dir} = file:read_link(Dir0),
- Dir.
diff --git a/src/rebar/src/rebar_templater.erl b/src/rebar/src/rebar_templater.erl
deleted file mode 100644
index b8f7087ca..000000000
--- a/src/rebar/src/rebar_templater.erl
+++ /dev/null
@@ -1,462 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_templater).
-
--export(['create-app'/2,
- 'create-node'/2,
- 'list-templates'/2,
- create/2]).
-
-%% API for other utilities that need templating functionality
--export([resolve_variables/2,
- render/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
--define(TEMPLATE_RE, ".*\\.template\$").
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-'create-app'(Config, _File) ->
- %% Alias for create w/ template=simpleapp
- create1(Config, "simpleapp").
-
-'create-node'(Config, _File) ->
- %% Alias for create w/ template=simplenode
- create1(Config, "simplenode").
-
-'list-templates'(Config, _File) ->
- {AvailTemplates, Files} = find_templates(Config),
- ?DEBUG("Available templates: ~p\n", [AvailTemplates]),
-
- lists:foreach(
- fun({Type, F}) ->
- BaseName = filename:basename(F, ".template"),
- TemplateTerms = consult(load_file(Files, Type, F)),
- {_, VarList} = lists:keyfind(variables, 1, TemplateTerms),
- Vars = lists:foldl(fun({V,_}, Acc) ->
- [atom_to_list(V) | Acc]
- end, [], VarList),
- ?CONSOLE(" * ~s: ~s (~p) (variables: ~p)\n",
- [BaseName, F, Type, string:join(Vars, ", ")])
- end, AvailTemplates),
- ok.
-
-create(Config, _) ->
- TemplateId = template_id(Config),
- create1(Config, TemplateId).
-
-%%
-%% Given a list of key value pairs, for each string value attempt to
-%% render it using Dict as the context. Storing the result in Dict as Key.
-%%
-resolve_variables([], Dict) ->
- Dict;
-resolve_variables([{Key, Value0} | Rest], Dict) when is_list(Value0) ->
- Value = render(list_to_binary(Value0), Dict),
- resolve_variables(Rest, dict:store(Key, Value, Dict));
-resolve_variables([{Key, {list, Dicts}} | Rest], Dict) when is_list(Dicts) ->
- %% just un-tag it so mustache can use it
- resolve_variables(Rest, dict:store(Key, Dicts, Dict));
-resolve_variables([_Pair | Rest], Dict) ->
- resolve_variables(Rest, Dict).
-
-%%
-%% Render a binary to a string, using mustache and the specified context
-%%
-render(Bin, Context) ->
- %% Be sure to escape any double-quotes before rendering...
- ReOpts = [global, {return, list}],
- Str0 = re:replace(Bin, "\\\\", "\\\\\\", ReOpts),
- Str1 = re:replace(Str0, "\"", "\\\\\"", ReOpts),
- mustache:render(Str1, Context).
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, create) ->
- ?CONSOLE(
- "Create skel based on template and vars.~n"
- "~n"
- "Valid command line options:~n"
- " template= [var=foo,...]~n", []);
-info(help, 'create-app') ->
- ?CONSOLE(
- "Create simple app skel.~n"
- "~n"
- "Valid command line options:~n"
- " [appid=myapp]~n", []);
-info(help, 'create-node') ->
- ?CONSOLE(
- "Create simple node skel.~n"
- "~n"
- "Valid command line options:~n"
- " [nodeid=mynode]~n", []);
-info(help, 'list-templates') ->
- ?CONSOLE("List available templates.~n", []).
-
-create1(Config, TemplateId) ->
- {AvailTemplates, Files} = find_templates(Config),
- ?DEBUG("Available templates: ~p\n", [AvailTemplates]),
-
- %% Using the specified template id, find the matching template file/type.
- %% Note that if you define the same template in both ~/.rebar/templates
- %% that is also present in the escript, the one on the file system will
- %% be preferred.
- {Type, Template} = select_template(AvailTemplates, TemplateId),
-
- %% Load the template definition as is and get the list of variables the
- %% template requires.
- TemplateTerms = consult(load_file(Files, Type, Template)),
- case lists:keyfind(variables, 1, TemplateTerms) of
- {variables, Vars} ->
- case parse_vars(Vars, dict:new()) of
- {error, Entry} ->
- Context0 = undefined,
- ?ABORT("Failed while processing variables from template ~p."
- "Variable definitions must follow form of "
- "[{atom(), term()}]. Failed at: ~p\n",
- [TemplateId, Entry]);
- Context0 ->
- ok
- end;
- false ->
- ?WARN("No variables section found in template ~p; "
- "using empty context.\n", [TemplateId]),
- Context0 = dict:new()
- end,
-
- %% Load variables from disk file, if provided
- Context1 = case rebar_config:get_global(Config, template_vars, undefined) of
- undefined ->
- Context0;
- File ->
- case consult(load_file([], file, File)) of
- {error, Reason} ->
- ?ABORT("Unable to load template_vars from ~s: ~p\n",
- [File, Reason]);
- Terms ->
- %% TODO: Cleanup/merge with similar code in rebar_reltool
- M = fun(_Key, _Base, Override) -> Override end,
- dict:merge(M, Context0, dict:from_list(Terms))
- end
- end,
-
- %% For each variable, see if it's defined in global vars -- if it is,
- %% prefer that value over the defaults
- Context2 = update_vars(Config, dict:fetch_keys(Context1), Context1),
- ?DEBUG("Template ~p context: ~p\n", [TemplateId, dict:to_list(Context1)]),
-
- %% Handle variables that possibly include other variables in their
- %% definition
- Context = resolve_variables(dict:to_list(Context2), Context2),
-
- ?DEBUG("Resolved Template ~p context: ~p\n",
- [TemplateId, dict:to_list(Context)]),
-
- %% Now, use our context to process the template definition -- this
- %% permits us to use variables within the definition for filenames.
- FinalTemplate = consult(render(load_file(Files, Type, Template), Context)),
- ?DEBUG("Final template def ~p: ~p\n", [TemplateId, FinalTemplate]),
-
- %% Execute the instructions in the finalized template
- Force = rebar_config:get_global(Config, force, "0"),
- execute_template(Files, FinalTemplate, Type, Template, Context, Force, []).
-
-find_templates(Config) ->
- %% Load a list of all the files in the escript -- cache them since
- %% we'll potentially need to walk it several times over the course of
- %% a run.
- Files = cache_escript_files(Config),
-
- %% Build a list of available templates
- AvailTemplates = find_disk_templates(Config)
- ++ find_escript_templates(Files),
-
- {AvailTemplates, Files}.
-
-%%
-%% Scan the current escript for available files
-%%
-cache_escript_files(Config) ->
- {ok, Files} = rebar_utils:escript_foldl(
- fun(Name, _, GetBin, Acc) ->
- [{Name, GetBin()} | Acc]
- end,
- [], rebar_config:get_xconf(Config, escript)),
- Files.
-
-template_id(Config) ->
- case rebar_config:get_global(Config, template, undefined) of
- undefined ->
- ?ABORT("No template specified.\n", []);
- TemplateId ->
- TemplateId
- end.
-
-find_escript_templates(Files) ->
- [{escript, Name}
- || {Name, _Bin} <- Files,
- re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match].
-
-find_disk_templates(Config) ->
- OtherTemplates = find_other_templates(Config),
- HomeFiles = rebar_utils:find_files(filename:join([os:getenv("HOME"),
- ".rebar", "templates"]),
- ?TEMPLATE_RE),
- LocalFiles = rebar_utils:find_files(".", ?TEMPLATE_RE),
- [{file, F} || F <- OtherTemplates ++ HomeFiles ++ LocalFiles].
-
-find_other_templates(Config) ->
- case rebar_config:get_global(Config, template_dir, undefined) of
- undefined ->
- [];
- TemplateDir ->
- rebar_utils:find_files(TemplateDir, ?TEMPLATE_RE)
- end.
-
-select_template([], Template) ->
- ?ABORT("Template ~s not found.\n", [Template]);
-select_template([{Type, Avail} | Rest], Template) ->
- case filename:basename(Avail, ".template") == Template of
- true ->
- {Type, Avail};
- false ->
- select_template(Rest, Template)
- end.
-
-%%
-%% Read the contents of a file from the appropriate source
-%%
-load_file(Files, escript, Name) ->
- {Name, Bin} = lists:keyfind(Name, 1, Files),
- Bin;
-load_file(_Files, file, Name) ->
- {ok, Bin} = file:read_file(Name),
- Bin.
-
-%%
-%% Parse/validate variables out from the template definition
-%%
-parse_vars([], Dict) ->
- Dict;
-parse_vars([{Key, Value} | Rest], Dict) when is_atom(Key) ->
- parse_vars(Rest, dict:store(Key, Value, Dict));
-parse_vars([Other | _Rest], _Dict) ->
- {error, Other};
-parse_vars(Other, _Dict) ->
- {error, Other}.
-
-%%
-%% Given a list of keys in Dict, see if there is a corresponding value defined
-%% in the global config; if there is, update the key in Dict with it
-%%
-update_vars(_Config, [], Dict) ->
- Dict;
-update_vars(Config, [Key | Rest], Dict) ->
- Value = rebar_config:get_global(Config, Key, dict:fetch(Key, Dict)),
- update_vars(Config, Rest, dict:store(Key, Value, Dict)).
-
-
-%%
-%% Given a string or binary, parse it into a list of terms, ala file:consult/1
-%%
-consult(Str) when is_list(Str) ->
- consult([], Str, []);
-consult(Bin) when is_binary(Bin)->
- consult([], binary_to_list(Bin), []).
-
-consult(Cont, Str, Acc) ->
- case erl_scan:tokens(Cont, Str, 0) of
- {done, Result, Remaining} ->
- case Result of
- {ok, Tokens, _} ->
- {ok, Term} = erl_parse:parse_term(Tokens),
- consult([], Remaining, [maybe_dict(Term) | Acc]);
- {eof, _Other} ->
- lists:reverse(Acc);
- {error, Info, _} ->
- {error, Info}
- end;
- {more, Cont1} ->
- consult(Cont1, eof, Acc)
- end.
-
-
-maybe_dict({Key, {list, Dicts}}) ->
- %% this is a 'list' element; a list of lists representing dicts
- {Key, {list, [dict:from_list(D) || D <- Dicts]}};
-maybe_dict(Term) ->
- Term.
-
-
-write_file(Output, Data, Force) ->
- %% determine if the target file already exists
- FileExists = filelib:is_regular(Output),
-
- %% perform the function if we're allowed,
- %% otherwise just process the next template
- case Force =:= "1" orelse FileExists =:= false of
- true ->
- ok = filelib:ensure_dir(Output),
- case {Force, FileExists} of
- {"1", true} ->
- ?CONSOLE("Writing ~s (forcibly overwriting)~n",
- [Output]);
- _ ->
- ?CONSOLE("Writing ~s~n", [Output])
- end,
- case file:write_file(Output, Data) of
- ok ->
- ok;
- {error, Reason} ->
- ?ABORT("Failed to write output file ~p: ~p\n",
- [Output, Reason])
- end;
- false ->
- {error, exists}
- end.
-
-prepend_instructions(Instructions, Rest) when is_list(Instructions) ->
- Instructions ++ Rest;
-prepend_instructions(Instruction, Rest) ->
- [Instruction|Rest].
-
-%%
-%% Execute each instruction in a template definition file.
-%%
-execute_template(_Files, [], _TemplateType, _TemplateName,
- _Context, _Force, ExistingFiles) ->
- case ExistingFiles of
- [] ->
- ok;
- _ ->
- Msg = lists:flatten([io_lib:format("\t* ~p~n", [F]) ||
- F <- lists:reverse(ExistingFiles)]),
- Help = "To force overwriting, specify -f/--force/force=1"
- " on the command line.\n",
- ?ERROR("One or more files already exist on disk and "
- "were not generated:~n~s~s", [Msg , Help])
- end;
-execute_template(Files, [{'if', Cond, True} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles) ->
- execute_template(Files, [{'if', Cond, True, []}|Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles);
-execute_template(Files, [{'if', Cond, True, False} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles) ->
- Instructions = case dict:find(Cond, Context) of
- {ok, true} ->
- True;
- {ok, "true"} ->
- True;
- _ ->
- False
- end,
- execute_template(Files, prepend_instructions(Instructions, Rest),
- TemplateType, TemplateName, Context, Force,
- ExistingFiles);
-execute_template(Files, [{template, Input, Output} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles) ->
- InputName = filename:join(filename:dirname(TemplateName), Input),
- File = load_file(Files, TemplateType, InputName),
- case write_file(Output, render(File, Context), Force) of
- ok ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, ExistingFiles);
- {error, exists} ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, [Output|ExistingFiles])
- end;
-execute_template(Files, [{file, Input, Output} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles) ->
- InputName = filename:join(filename:dirname(TemplateName), Input),
- File = load_file(Files, TemplateType, InputName),
- case write_file(Output, File, Force) of
- ok ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, ExistingFiles);
- {error, exists} ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, [Output|ExistingFiles])
- end;
-execute_template(Files, [{dir, Name} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles) ->
- case filelib:ensure_dir(filename:join(Name, "dummy")) of
- ok ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, ExistingFiles);
- {error, Reason} ->
- ?ABORT("Failed while processing template instruction "
- "{dir, ~s}: ~p\n", [Name, Reason])
- end;
-execute_template(Files, [{copy, Input, Output} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles) ->
- InputName = filename:join(filename:dirname(TemplateName), Input),
- try rebar_file_utils:cp_r([InputName ++ "/*"], Output) of
- ok ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, ExistingFiles)
- catch _:_ ->
- ?ABORT("Failed while processing template instruction "
- "{copy, ~s, ~s}~n", [Input, Output])
- end;
-execute_template(Files, [{chmod, Mod, File} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles)
- when is_integer(Mod) ->
- case file:change_mode(File, Mod) of
- ok ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, ExistingFiles);
- {error, Reason} ->
- ?ABORT("Failed while processing template instruction "
- "{chmod, ~b, ~s}: ~p~n", [Mod, File, Reason])
- end;
-execute_template(Files, [{symlink, Existing, New} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles) ->
- case file:make_symlink(Existing, New) of
- ok ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, ExistingFiles);
- {error, Reason} ->
- ?ABORT("Failed while processing template instruction "
- "{symlink, ~s, ~s}: ~p~n", [Existing, New, Reason])
- end;
-execute_template(Files, [{variables, _} | Rest], TemplateType,
- TemplateName, Context, Force, ExistingFiles) ->
- execute_template(Files, Rest, TemplateType, TemplateName,
- Context, Force, ExistingFiles);
-execute_template(Files, [Other | Rest], TemplateType, TemplateName,
- Context, Force, ExistingFiles) ->
- ?WARN("Skipping unknown template instruction: ~p\n", [Other]),
- execute_template(Files, Rest, TemplateType, TemplateName, Context,
- Force, ExistingFiles).
diff --git a/src/rebar/src/rebar_upgrade.erl b/src/rebar/src/rebar_upgrade.erl
deleted file mode 100644
index 5814e518b..000000000
--- a/src/rebar/src/rebar_upgrade.erl
+++ /dev/null
@@ -1,268 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2011 Joe Williams (joe@joetify.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-
--module(rebar_upgrade).
-
--include("rebar.hrl").
--include_lib("kernel/include/file.hrl").
-
--export(['generate-upgrade'/2]).
-
-%% for internal use only
--export([info/2]).
-
--define(TMP, "_tmp").
-
-%% ====================================================================
-%% Public API
-%% ====================================================================
-
-'generate-upgrade'(Config0, ReltoolFile) ->
- %% Get the old release path
- {Config, ReltoolConfig} = rebar_rel_utils:load_config(Config0, ReltoolFile),
- TargetParentDir = rebar_rel_utils:get_target_parent_dir(Config,
- ReltoolConfig),
- TargetDir = rebar_rel_utils:get_target_dir(Config, ReltoolConfig),
-
- PrevRelPath = rebar_rel_utils:get_previous_release_path(Config),
- OldVerPath = filename:join([TargetParentDir, PrevRelPath]),
-
- %% Run checks to make sure that building a package is possible
- {NewVerPath, NewName, NewVer} = run_checks(Config, OldVerPath,
- ReltoolConfig),
- NameVer = NewName ++ "_" ++ NewVer,
-
- %% Save the code path prior to doing anything
- OrigPath = code:get_path(),
-
- %% Prepare the environment for building the package
- ok = setup(OldVerPath, NewVerPath, NewName, NewVer, NameVer),
-
- %% Build the package
- run_systools(NameVer, NewName),
-
- %% Boot file changes
- {ok, _} = boot_files(TargetDir, NewVer, NewName),
-
- %% Extract upgrade and tar it back up with changes
- make_tar(NameVer, NewVer, NewName),
-
- %% Clean up files that systools created
- ok = cleanup(NameVer),
-
- %% Restore original path
- true = code:set_path(OrigPath),
-
- {ok, Config}.
-
-%% ===================================================================
-%% Internal functions
-%% ==================================================================
-
-info(help, 'generate-upgrade') ->
- ?CONSOLE("Build an upgrade package.~n"
- "~n"
- "Valid command line options:~n"
- " previous_release=path~n",
- []).
-
-run_checks(Config, OldVerPath, ReltoolConfig) ->
- true = rebar_utils:prop_check(filelib:is_dir(OldVerPath),
- "Release directory doesn't exist (~p)~n",
- [OldVerPath]),
-
- {Name, Ver} = rebar_rel_utils:get_reltool_release_info(ReltoolConfig),
-
- NewVerPath =
- filename:join(
- [rebar_rel_utils:get_target_parent_dir(Config, ReltoolConfig),
- Name]),
- true = rebar_utils:prop_check(filelib:is_dir(NewVerPath),
- "Release directory doesn't exist (~p)~n",
- [NewVerPath]),
-
- {NewName, NewVer} = rebar_rel_utils:get_rel_release_info(Name, NewVerPath),
- {OldName, OldVer} = rebar_rel_utils:get_rel_release_info(Name, OldVerPath),
-
- true =
- rebar_utils:prop_check(NewName == OldName,
- "New and old .rel release names do not match~n",
- []),
- true =
- rebar_utils:prop_check(Name == NewName,
- "Reltool and .rel release names do not match~n",
- []),
- true =
- rebar_utils:prop_check(NewVer =/= OldVer,
- "New and old .rel contain the same version~n",
- []),
- true =
- rebar_utils:prop_check(Ver == NewVer,
- "Reltool and .rel versions do not match~n", []),
-
- {NewVerPath, NewName, NewVer}.
-
-setup(OldVerPath, NewVerPath, NewName, NewVer, NameVer) ->
- Src = filename:join([NewVerPath, "releases",
- NewVer, NewName ++ ".rel"]),
- Dst = filename:join([".", NameVer ++ ".rel"]),
- {ok, _} = file:copy(Src, Dst),
- ok = code:add_pathsa(
- lists:append([
- filelib:wildcard(filename:join([NewVerPath,
- "lib", "*", "ebin"])),
- filelib:wildcard(filename:join([OldVerPath,
- "releases", "*"])),
- filelib:wildcard(filename:join([OldVerPath,
- "lib", "*", "ebin"]))
- ])).
-
-run_systools(NewVer, Name) ->
- Opts = [silent],
- NameList = [Name],
- case systools:make_relup(NewVer, NameList, NameList, Opts) of
- {error, _, Msg} ->
- ?ABORT("Systools [systools:make_relup/4] aborted with: ~p~n",
- [Msg]);
- _ ->
- ?DEBUG("Relup created~n", []),
- case systools:make_script(NewVer, Opts) of
- {error, _, Msg1} ->
- ?ABORT("Systools [systools:make_script/2] "
- "aborted with: ~p~n", [Msg1]);
- _ ->
- ?DEBUG("Script created~n", []),
- case systools:make_tar(NewVer, Opts) of
- {error, _, Msg2} ->
- ?ABORT("Systools [systools:make_tar/2] "
- "aborted with: ~p~n", [Msg2]);
- _ ->
- ?DEBUG("Tarball created~n", []),
- ok
- end
- end
- end.
-
-boot_files(TargetDir, Ver, Name) ->
- ok = file:make_dir(filename:join([".", ?TMP])),
- ok = file:make_dir(filename:join([".", ?TMP, "releases"])),
- ok = file:make_dir(filename:join([".", ?TMP, "releases", Ver])),
- case os:type() of
- {win32,_} ->
- ok;
- _ ->
- ok = file:make_symlink(
- filename:join(["start.boot"]),
- filename:join([".", ?TMP, "releases", Ver, Name ++ ".boot"]))
- end,
- {ok, _} =
- file:copy(
- filename:join([TargetDir, "releases", Ver, "start_clean.boot"]),
- filename:join([".", ?TMP, "releases", Ver, "start_clean.boot"])),
-
- SysConfig = filename:join([TargetDir, "releases", Ver, "sys.config"]),
- _ = case filelib:is_regular(SysConfig) of
- true ->
- {ok, _} = file:copy(
- SysConfig,
- filename:join([".", ?TMP, "releases", Ver,
- "sys.config"]));
- false -> ok
- end,
-
- VmArgs = filename:join([TargetDir, "releases", Ver, "vm.args"]),
- case filelib:is_regular(VmArgs) of
- true ->
- {ok, _} = file:copy(
- VmArgs,
- filename:join([".", ?TMP, "releases", Ver, "vm.args"]));
- false -> {ok, 0}
- end.
-
-make_tar(NameVer, NewVer, NewName) ->
- Filename = NameVer ++ ".tar.gz",
- {ok, Cwd} = file:get_cwd(),
- Absname = filename:join([Cwd, Filename]),
- ok = file:set_cwd(?TMP),
- ok = erl_tar:extract(Absname, [compressed]),
- ok = file:delete(Absname),
- case os:type() of
- {win32,_} ->
- {ok, _} =
- file:copy(
- filename:join([".", "releases", NewVer, "start.boot"]),
- filename:join([".", "releases", NewVer, NewName ++ ".boot"])),
- ok;
- _ ->
- ok
- end,
- {ok, Tar} = erl_tar:open(Absname, [write, compressed]),
- ok = erl_tar:add(Tar, "lib", []),
- ok = erl_tar:add(Tar, "releases", []),
- ok = erl_tar:close(Tar),
- ok = file:set_cwd(Cwd),
- ?CONSOLE("~s upgrade package created~n", [NameVer]).
-
-cleanup(NameVer) ->
- ?DEBUG("Removing files needed for building the upgrade~n", []),
- Files = [
- filename:join([".", NameVer ++ ".rel"]),
- filename:join([".", NameVer ++ ".boot"]),
- filename:join([".", NameVer ++ ".script"]),
- filename:join([".", "relup"])
- ],
- lists:foreach(fun(F) -> ok = file:delete(F) end, Files),
-
- ok = remove_dir_tree(?TMP).
-
-%% adapted from http://www.erlang.org/doc/system_principles/create_target.html
-remove_dir_tree(Dir) ->
- remove_all_files(".", [Dir]).
-remove_all_files(Dir, Files) ->
- lists:foreach(fun(File) ->
- FilePath = filename:join([Dir, File]),
- {ok, FileInfo, Link} = file_info(FilePath),
- case {Link, FileInfo#file_info.type} of
- {false, directory} ->
- {ok, DirFiles} = file:list_dir(FilePath),
- remove_all_files(FilePath, DirFiles),
- file:del_dir(FilePath);
- _ ->
- file:delete(FilePath)
- end
- end, Files).
-
-file_info(Path) ->
- case file:read_file_info(Path) of
- {ok, Info} ->
- {ok, Info, false};
- {error, enoent} ->
- {ok, Info} = file:read_link_info(Path),
- {ok, Info, true};
- Error ->
- Error
- end.
diff --git a/src/rebar/src/rebar_utils.erl b/src/rebar/src/rebar_utils.erl
deleted file mode 100644
index 618427f1b..000000000
--- a/src/rebar/src/rebar_utils.erl
+++ /dev/null
@@ -1,510 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009, 2010 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
--module(rebar_utils).
-
--export([get_cwd/0,
- is_arch/1,
- get_arch/0,
- wordsize/0,
- sh/2,
- find_files/2, find_files/3,
- now_str/0,
- ensure_dir/1,
- beam_to_mod/2, beams/1,
- erl_to_mod/1,
- abort/0, abort/2,
- escript_foldl/3,
- find_executable/1,
- prop_check/3,
- expand_code_path/0,
- expand_env_variable/3,
- vcs_vsn/3,
- deprecated/3, deprecated/4,
- get_deprecated_global/4, get_deprecated_global/5,
- get_experimental_global/3, get_experimental_local/3,
- get_deprecated_list/4, get_deprecated_list/5,
- get_deprecated_local/4, get_deprecated_local/5,
- delayed_halt/1,
- erl_opts/1,
- src_dirs/1,
- ebin_dir/0,
- processing_base_dir/1, processing_base_dir/2]).
-
--include("rebar.hrl").
-
-%% ====================================================================
-%% Public API
-%% ====================================================================
-
-get_cwd() ->
- {ok, Dir} = file:get_cwd(),
- Dir.
-
-is_arch(ArchRegex) ->
- case re:run(get_arch(), ArchRegex, [{capture, none}]) of
- match ->
- true;
- nomatch ->
- false
- end.
-
-get_arch() ->
- Words = wordsize(),
- erlang:system_info(otp_release) ++ "-"
- ++ erlang:system_info(system_architecture) ++ "-" ++ Words.
-
-wordsize() ->
- try erlang:system_info({wordsize, external}) of
- Val ->
- integer_to_list(8 * Val)
- catch
- error:badarg ->
- integer_to_list(8 * erlang:system_info(wordsize))
- end.
-
-%%
-%% Options = [Option] -- defaults to [use_stdout, abort_on_error]
-%% Option = ErrorOption | OutputOption | {cd, string()} | {env, Env}
-%% ErrorOption = return_on_error | abort_on_error | {abort_on_error, string()}
-%% OutputOption = use_stdout | {use_stdout, bool()}
-%% Env = [{string(), Val}]
-%% Val = string() | false
-%%
-sh(Command0, Options0) ->
- ?INFO("sh info:\n\tcwd: ~p\n\tcmd: ~s\n", [get_cwd(), Command0]),
- ?DEBUG("\topts: ~p\n", [Options0]),
-
- DefaultOptions = [use_stdout, abort_on_error],
- Options = [expand_sh_flag(V)
- || V <- proplists:compact(Options0 ++ DefaultOptions)],
-
- ErrorHandler = proplists:get_value(error_handler, Options),
- OutputHandler = proplists:get_value(output_handler, Options),
-
- Command = patch_on_windows(Command0, proplists:get_value(env, Options, [])),
- PortSettings = proplists:get_all_values(port_settings, Options) ++
- [exit_status, {line, 16384}, use_stdio, stderr_to_stdout, hide],
- ?DEBUG("Port Cmd: ~p\nPort Opts: ~p\n", [Command, PortSettings]),
- Port = open_port({spawn, Command}, PortSettings),
-
- case sh_loop(Port, OutputHandler, []) of
- {ok, _Output} = Ok ->
- Ok;
- {error, {_Rc, _Output}=Err} ->
- ErrorHandler(Command, Err)
- end.
-
-find_files(Dir, Regex) ->
- find_files(Dir, Regex, true).
-
-find_files(Dir, Regex, Recursive) ->
- filelib:fold_files(Dir, Regex, Recursive,
- fun(F, Acc) -> [F | Acc] end, []).
-
-now_str() ->
- {{Year, Month, Day}, {Hour, Minute, Second}} = calendar:local_time(),
- lists:flatten(io_lib:format("~4b/~2..0b/~2..0b ~2..0b:~2..0b:~2..0b",
- [Year, Month, Day, Hour, Minute, Second])).
-
-%% TODO: filelib:ensure_dir/1 corrected in R13B04. Remove when we drop
-%% support for OTP releases older than R13B04.
-ensure_dir(Path) ->
- case filelib:ensure_dir(Path) of
- ok ->
- ok;
- {error,eexist} ->
- ok;
- Error ->
- Error
- end.
-
--spec abort() -> no_return().
-abort() ->
- throw(rebar_abort).
-
--spec abort(string(), [term()]) -> no_return().
-abort(String, Args) ->
- ?ERROR(String, Args),
- abort().
-
-%% TODO: Rename emulate_escript_foldl to escript_foldl and remove
-%% this function when the time is right. escript:foldl/3 was an
-%% undocumented exported fun and has been removed in R14.
-escript_foldl(Fun, Acc, File) ->
- {module, zip} = code:ensure_loaded(zip),
- case erlang:function_exported(zip, foldl, 3) of
- true ->
- emulate_escript_foldl(Fun, Acc, File);
- false ->
- escript:foldl(Fun, Acc, File)
- end.
-
-find_executable(Name) ->
- case os:find_executable(Name) of
- false -> false;
- Path ->
- "\"" ++ filename:nativename(Path) ++ "\""
- end.
-
-%% Helper function for checking values and aborting when needed
-prop_check(true, _, _) -> true;
-prop_check(false, Msg, Args) -> ?ABORT(Msg, Args).
-
-%% Convert all the entries in the code path to absolute paths.
-expand_code_path() ->
- CodePath = lists:foldl(fun(Path, Acc) ->
- [filename:absname(Path) | Acc]
- end, [], code:get_path()),
- code:set_path(lists:reverse(CodePath)).
-
-%%
-%% Given env. variable FOO we want to expand all references to
-%% it in InStr. References can have two forms: $FOO and ${FOO}
-%% The end of form $FOO is delimited with whitespace or eol
-%%
-expand_env_variable(InStr, VarName, RawVarValue) ->
- case string:chr(InStr, $$) of
- 0 ->
- %% No variables to expand
- InStr;
- _ ->
- ReOpts = [global, unicode, {return, list}],
- VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts),
- %% Use a regex to match/replace:
- %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO}
- RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]),
- re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts)
- end.
-
-vcs_vsn(Config, Vsn, Dir) ->
- Key = {Vsn, Dir},
- Cache = rebar_config:get_xconf(Config, vsn_cache),
- case dict:find(Key, Cache) of
- error ->
- VsnString = vcs_vsn_1(Vsn, Dir),
- Cache1 = dict:store(Key, VsnString, Cache),
- Config1 = rebar_config:set_xconf(Config, vsn_cache, Cache1),
- {Config1, VsnString};
- {ok, VsnString} ->
- {Config, VsnString}
- end.
-
-get_deprecated_global(Config, OldOpt, NewOpt, When) ->
- get_deprecated_global(Config, OldOpt, NewOpt, undefined, When).
-
-get_deprecated_global(Config, OldOpt, NewOpt, Default, When) ->
- get_deprecated_3(fun rebar_config:get_global/3,
- Config, OldOpt, NewOpt, Default, When).
-
-get_experimental_global(Config, Opt, Default) ->
- get_experimental_3(fun rebar_config:get_global/3, Config, Opt, Default).
-
-get_experimental_local(Config, Opt, Default) ->
- get_experimental_3(fun rebar_config:get_local/3, Config, Opt, Default).
-
-get_deprecated_list(Config, OldOpt, NewOpt, When) ->
- get_deprecated_list(Config, OldOpt, NewOpt, undefined, When).
-
-get_deprecated_list(Config, OldOpt, NewOpt, Default, When) ->
- get_deprecated_3(fun rebar_config:get_list/3,
- Config, OldOpt, NewOpt, Default, When).
-
-get_deprecated_local(Config, OldOpt, NewOpt, When) ->
- get_deprecated_local(Config, OldOpt, NewOpt, undefined, When).
-
-get_deprecated_local(Config, OldOpt, NewOpt, Default, When) ->
- get_deprecated_3(fun rebar_config:get_local/3,
- Config, OldOpt, NewOpt, Default, When).
-
-deprecated(Old, New, Opts, When) when is_list(Opts) ->
- case lists:member(Old, Opts) of
- true ->
- deprecated(Old, New, When);
- false ->
- ok
- end;
-deprecated(Old, New, Config, When) ->
- case rebar_config:get(Config, Old, undefined) of
- undefined ->
- ok;
- _ ->
- deprecated(Old, New, When)
- end.
-
-deprecated(Old, New, When) ->
- io:format(
- <<"WARNING: deprecated ~p option used~n"
- "Option '~p' has been deprecated~n"
- "in favor of '~p'.~n"
- "'~p' will be removed ~s.~n~n">>,
- [Old, Old, New, Old, When]).
-
--spec delayed_halt(integer()) -> no_return().
-delayed_halt(Code) ->
- %% Work around buffer flushing issue in erlang:halt if OTP older
- %% than R15B01.
- %% TODO: remove workaround once we require R15B01 or newer
- %% R15B01 introduced erlang:halt/2
- case erlang:is_builtin(erlang, halt, 2) of
- true ->
- halt(Code);
- false ->
- case os:type() of
- {win32, nt} ->
- timer:sleep(100),
- halt(Code);
- _ ->
- halt(Code),
- %% workaround to delay exit until all output is written
- receive after infinity -> ok end
- end
- end.
-
-%% @doc Return list of erl_opts
--spec erl_opts(rebar_config:config()) -> list().
-erl_opts(Config) ->
- RawErlOpts = filter_defines(rebar_config:get(Config, erl_opts, []), []),
- Defines = [{d, list_to_atom(D)} ||
- D <- rebar_config:get_xconf(Config, defines, [])],
- Opts = Defines ++ RawErlOpts,
- case proplists:is_defined(no_debug_info, Opts) of
- true ->
- [O || O <- Opts, O =/= no_debug_info];
- false ->
- [debug_info|Opts]
- end.
-
--spec src_dirs([string()]) -> [file:filename(), ...].
-src_dirs([]) ->
- ["src"];
-src_dirs(SrcDirs) ->
- SrcDirs.
-
-ebin_dir() ->
- filename:join(get_cwd(), "ebin").
-
-processing_base_dir(Config) ->
- Cwd = rebar_utils:get_cwd(),
- processing_base_dir(Config, Cwd).
-
-processing_base_dir(Config, Dir) ->
- Dir =:= rebar_config:get_xconf(Config, base_dir).
-
-%% ====================================================================
-%% Internal functions
-%% ====================================================================
-
-get_deprecated_3(Get, Config, OldOpt, NewOpt, Default, When) ->
- case Get(Config, NewOpt, Default) of
- Default ->
- case Get(Config, OldOpt, Default) of
- Default ->
- Default;
- Old ->
- deprecated(OldOpt, NewOpt, When),
- Old
- end;
- New ->
- New
- end.
-
-get_experimental_3(Get, Config, Opt, Default) ->
- Val = Get(Config, Opt, Default),
- case Val of
- Default ->
- Default;
- Val ->
- ?CONSOLE("NOTICE: Using experimental option '~p'~n", [Opt]),
- Val
- end.
-
-%% We do the shell variable substitution ourselves on Windows and hope that the
-%% command doesn't use any other shell magic.
-patch_on_windows(Cmd, Env) ->
- case os:type() of
- {win32,nt} ->
- Cmd1 = "cmd /q /c "
- ++ lists:foldl(fun({Key, Value}, Acc) ->
- expand_env_variable(Acc, Key, Value)
- end, Cmd, Env),
- %% Remove left-over vars
- re:replace(Cmd1, "\\\$\\w+|\\\${\\w+}", "",
- [global, {return, list}]);
- _ ->
- Cmd
- end.
-
-expand_sh_flag(return_on_error) ->
- {error_handler,
- fun(_Command, Err) ->
- {error, Err}
- end};
-expand_sh_flag({abort_on_error, Message}) ->
- {error_handler,
- log_msg_and_abort(Message)};
-expand_sh_flag(abort_on_error) ->
- {error_handler,
- fun log_and_abort/2};
-expand_sh_flag(use_stdout) ->
- {output_handler,
- fun(Line, Acc) ->
- ?CONSOLE("~s", [Line]),
- [Line | Acc]
- end};
-expand_sh_flag({use_stdout, false}) ->
- {output_handler,
- fun(Line, Acc) ->
- [Line | Acc]
- end};
-expand_sh_flag({cd, _CdArg} = Cd) ->
- {port_settings, Cd};
-expand_sh_flag({env, _EnvArg} = Env) ->
- {port_settings, Env}.
-
--type err_handler() :: fun((string(), {integer(), string()}) -> no_return()).
--spec log_msg_and_abort(string()) -> err_handler().
-log_msg_and_abort(Message) ->
- fun(_Command, {_Rc, _Output}) ->
- ?ABORT(Message, [])
- end.
-
--spec log_and_abort(string(), {integer(), string()}) -> no_return().
-log_and_abort(Command, {Rc, Output}) ->
- ?ABORT("~s failed with error: ~w and output:~n~s~n",
- [Command, Rc, Output]).
-
-sh_loop(Port, Fun, Acc) ->
- receive
- {Port, {data, {eol, Line}}} ->
- sh_loop(Port, Fun, Fun(Line ++ "\n", Acc));
- {Port, {data, {noeol, Line}}} ->
- sh_loop(Port, Fun, Fun(Line, Acc));
- {Port, {exit_status, 0}} ->
- {ok, lists:flatten(lists:reverse(Acc))};
- {Port, {exit_status, Rc}} ->
- {error, {Rc, lists:flatten(lists:reverse(Acc))}}
- end.
-
-beam_to_mod(Dir, Filename) ->
- [Dir | Rest] = filename:split(Filename),
- list_to_atom(filename:basename(string:join(Rest, "."), ".beam")).
-
-erl_to_mod(Filename) ->
- list_to_atom(filename:rootname(filename:basename(Filename))).
-
-beams(Dir) ->
- filelib:fold_files(Dir, ".*\.beam\$", true,
- fun(F, Acc) -> [F | Acc] end, []).
-
-emulate_escript_foldl(Fun, Acc, File) ->
- case escript:extract(File, [compile_source]) of
- {ok, [_Shebang, _Comment, _EmuArgs, Body]} ->
- case Body of
- {source, BeamCode} ->
- GetInfo = fun() -> file:read_file_info(File) end,
- GetBin = fun() -> BeamCode end,
- {ok, Fun(".", GetInfo, GetBin, Acc)};
- {beam, BeamCode} ->
- GetInfo = fun() -> file:read_file_info(File) end,
- GetBin = fun() -> BeamCode end,
- {ok, Fun(".", GetInfo, GetBin, Acc)};
- {archive, ArchiveBin} ->
- zip:foldl(Fun, Acc, {File, ArchiveBin})
- end;
- {error, _} = Error ->
- Error
- end.
-
-vcs_vsn_1(Vcs, Dir) ->
- case vcs_vsn_cmd(Vcs) of
- {plain, VsnString} ->
- VsnString;
- {cmd, CmdString} ->
- vcs_vsn_invoke(CmdString, Dir);
- unknown ->
- ?ABORT("vcs_vsn: Unknown vsn format: ~p\n", [Vcs]);
- Cmd ->
- %% If there is a valid VCS directory in the application directory,
- %% use that version info
- Extension = lists:concat([".", Vcs]),
- case filelib:is_dir(filename:join(Dir, Extension)) of
- true ->
- ?DEBUG("vcs_vsn: Primary vcs used for ~s\n", [Dir]),
- vcs_vsn_invoke(Cmd, Dir);
- false ->
- %% No VCS directory found for the app. Depending on source
- %% tree structure, there may be one higher up, but that can
- %% yield unexpected results when used with deps. So, we
- %% fallback to searching for a priv/vsn.Vcs file.
- VsnFile = filename:join([Dir, "priv", "vsn" ++ Extension]),
- case file:read_file(VsnFile) of
- {ok, VsnBin} ->
- ?DEBUG("vcs_vsn: Read ~s from priv/vsn.~p\n",
- [VsnBin, Vcs]),
- string:strip(binary_to_list(VsnBin), right, $\n);
- {error, enoent} ->
- ?DEBUG("vcs_vsn: Fallback to vcs for ~s\n", [Dir]),
- vcs_vsn_invoke(Cmd, Dir)
- end
- end
- end.
-
-vcs_vsn_cmd(git) -> "git describe --always --tags";
-vcs_vsn_cmd(hg) -> "hg identify -i";
-vcs_vsn_cmd(bzr) -> "bzr revno";
-vcs_vsn_cmd(svn) -> "svnversion";
-vcs_vsn_cmd(fossil) -> "fossil info";
-vcs_vsn_cmd({cmd, _Cmd}=Custom) -> Custom;
-vcs_vsn_cmd(Version) when is_list(Version) -> {plain, Version};
-vcs_vsn_cmd(_) -> unknown.
-
-vcs_vsn_invoke(Cmd, Dir) ->
- {ok, VsnString} = rebar_utils:sh(Cmd, [{cd, Dir}, {use_stdout, false}]),
- string:strip(VsnString, right, $\n).
-
-%%
-%% Filter a list of erl_opts platform_define options such that only
-%% those which match the provided architecture regex are returned.
-%%
-filter_defines([], Acc) ->
- lists:reverse(Acc);
-filter_defines([{platform_define, ArchRegex, Key} | Rest], Acc) ->
- case rebar_utils:is_arch(ArchRegex) of
- true ->
- filter_defines(Rest, [{d, Key} | Acc]);
- false ->
- filter_defines(Rest, Acc)
- end;
-filter_defines([{platform_define, ArchRegex, Key, Value} | Rest], Acc) ->
- case rebar_utils:is_arch(ArchRegex) of
- true ->
- filter_defines(Rest, [{d, Key, Value} | Acc]);
- false ->
- filter_defines(Rest, Acc)
- end;
-filter_defines([Opt | Rest], Acc) ->
- filter_defines(Rest, [Opt | Acc]).
diff --git a/src/rebar/src/rebar_xref.erl b/src/rebar/src/rebar_xref.erl
deleted file mode 100644
index eaf6d03de..000000000
--- a/src/rebar/src/rebar_xref.erl
+++ /dev/null
@@ -1,287 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%%
-%% -------------------------------------------------------------------
-
-%% -------------------------------------------------------------------
-%% This module borrows heavily from http://github.com/etnt/exrefcheck project as
-%% written by Torbjorn Tornkvist <tobbe@kreditor.se>, Daniel Luna
-%% <daniel@lunas.se> and others.
-%% -------------------------------------------------------------------
--module(rebar_xref).
-
--include("rebar.hrl").
-
--export([xref/2]).
-
-%% for internal use only
--export([info/2]).
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-xref(Config, _) ->
- %% Spin up xref
- {ok, _} = xref:start(xref),
- ok = xref:set_library_path(xref, code_path(Config)),
-
- xref:set_default(xref, [{warnings,
- rebar_config:get(Config, xref_warnings, false)},
- {verbose, rebar_config:is_verbose(Config)}]),
-
- {ok, _} = xref:add_directory(xref, "ebin"),
-
- %% Save the code path prior to doing anything
- OrigPath = code:get_path(),
- true = code:add_path(rebar_utils:ebin_dir()),
-
- %% Get list of xref checks we want to run
- ConfXrefChecks = rebar_config:get(Config, xref_checks,
- [exports_not_used,
- undefined_function_calls]),
-
- SupportedXrefs = [undefined_function_calls, undefined_functions,
- locals_not_used, exports_not_used,
- deprecated_function_calls, deprecated_functions],
-
- XrefChecks = sets:to_list(sets:intersection(
- sets:from_list(SupportedXrefs),
- sets:from_list(ConfXrefChecks))),
-
- %% Run xref checks
- XrefNoWarn = xref_checks(XrefChecks),
-
- %% Run custom queries
- QueryChecks = rebar_config:get(Config, xref_queries, []),
- QueryNoWarn = lists:all(fun check_query/1, QueryChecks),
-
- %% Restore the original code path
- true = code:set_path(OrigPath),
-
- %% Stop xref
- stopped = xref:stop(xref),
-
- case lists:member(false, [XrefNoWarn, QueryNoWarn]) of
- true ->
- ?FAIL;
- false ->
- ok
- end.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-info(help, xref) ->
- ?CONSOLE(
- "Run cross reference analysis.~n"
- "~n"
- "Valid rebar.config options:~n"
- " ~p~n"
- " ~p~n"
- " ~p~n",
- [
- {xref_warnings, false},
- {xref_checks, [undefined_function_calls, undefined_functions,
- locals_not_used, exports_not_used,
- deprecated_function_calls, deprecated_functions]},
- {xref_queries,
- [{"(xc - uc) || (xu - x - b"
- " - (\"mod\":\".*foo\"/\"4\"))",[]}]}
- ]).
-
-xref_checks(XrefChecks) ->
- XrefWarnCount = lists:foldl(fun run_xref_check/2, 0, XrefChecks),
- XrefWarnCount =:= 0.
-
-run_xref_check(XrefCheck, Acc) ->
- {ok, Results} = xref:analyze(xref, XrefCheck),
- FilteredResults =filter_xref_results(XrefCheck, Results),
- lists:foreach(fun(Res) ->
- display_xref_result(XrefCheck, Res)
- end,
- FilteredResults),
- Acc + length(FilteredResults).
-
-check_query({Query, Value}) ->
- {ok, Answer} = xref:q(xref, Query),
- case Answer =:= Value of
- false ->
- ?CONSOLE("Query ~s~n answer ~p~n did not match ~p~n",
- [Query, Answer, Value]),
- false;
- _ ->
- true
- end.
-
-code_path(Config) ->
- %% Slight hack to ensure that sub_dirs get properly included
- %% in code path for xref -- otherwise one gets a lot of undefined
- %% functions, even though those functions are present as part
- %% of compilation. H/t to @dluna. Long term we should tie more
- %% properly into the overall compile code path if possible.
- BaseDir = rebar_config:get_xconf(Config, base_dir),
- [P || P <- code:get_path() ++
- [filename:join(BaseDir, filename:join(SubDir, "ebin"))
- || SubDir <- rebar_config:get(Config, sub_dirs, [])],
- filelib:is_dir(P)].
-
-%%
-%% Ignore behaviour functions, and explicitly marked functions
-%%
-%% Functions can be ignored by using
-%% -ignore_xref([{F, A}, {M, F, A}...]).
-
-get_xref_ignorelist(Mod, XrefCheck) ->
- %% Get ignore_xref attribute and combine them in one list
- Attributes =
- try
- Mod:module_info(attributes)
- catch
- _Class:_Error -> []
- end,
-
- IgnoreXref = keyall(ignore_xref, Attributes),
-
- BehaviourCallbacks = get_behaviour_callbacks(XrefCheck, Attributes),
-
- %% And create a flat {M,F,A} list
- lists:foldl(
- fun({F, A}, Acc) -> [{Mod,F,A} | Acc];
- ({M, F, A}, Acc) -> [{M,F,A} | Acc]
- end, [], lists:flatten([IgnoreXref, BehaviourCallbacks])).
-
-keyall(Key, List) ->
- lists:flatmap(fun({K, L}) when Key =:= K -> L; (_) -> [] end, List).
-
-get_behaviour_callbacks(exports_not_used, Attributes) ->
- [B:behaviour_info(callbacks) || B <- keyall(behaviour, Attributes)];
-get_behaviour_callbacks(_XrefCheck, _Attributes) ->
- [].
-
-parse_xref_result({_, MFAt}) -> MFAt;
-parse_xref_result(MFAt) -> MFAt.
-
-filter_xref_results(XrefCheck, XrefResults) ->
- SearchModules = lists:usort(
- lists:map(
- fun({Mt,_Ft,_At}) -> Mt;
- ({{Ms,_Fs,_As},{_Mt,_Ft,_At}}) -> Ms;
- (_) -> undefined
- end, XrefResults)),
-
- Ignores = lists:flatmap(fun(Module) ->
- get_xref_ignorelist(Module, XrefCheck)
- end, SearchModules),
-
- [Result || Result <- XrefResults,
- not lists:member(parse_xref_result(Result), Ignores)].
-
-display_xref_result(Type, XrefResult) ->
- { Source, SMFA, TMFA } = case XrefResult of
- {MFASource, MFATarget} ->
- {format_mfa_source(MFASource),
- format_mfa(MFASource),
- format_mfa(MFATarget)};
- MFATarget ->
- {format_mfa_source(MFATarget),
- format_mfa(MFATarget),
- undefined}
- end,
- case Type of
- undefined_function_calls ->
- ?CONSOLE("~sWarning: ~s calls undefined function ~s (Xref)\n",
- [Source, SMFA, TMFA]);
- undefined_functions ->
- ?CONSOLE("~sWarning: ~s is undefined function (Xref)\n",
- [Source, SMFA]);
- locals_not_used ->
- ?CONSOLE("~sWarning: ~s is unused local function (Xref)\n",
- [Source, SMFA]);
- exports_not_used ->
- ?CONSOLE("~sWarning: ~s is unused export (Xref)\n",
- [Source, SMFA]);
- deprecated_function_calls ->
- ?CONSOLE("~sWarning: ~s calls deprecated function ~s (Xref)\n",
- [Source, SMFA, TMFA]);
- deprecated_functions ->
- ?CONSOLE("~sWarning: ~s is deprecated function (Xref)\n",
- [Source, SMFA]);
- Other ->
- ?CONSOLE("~sWarning: ~s - ~s xref check: ~s (Xref)\n",
- [Source, SMFA, TMFA, Other])
- end.
-
-format_mfa({M, F, A}) ->
- ?FMT("~s:~s/~w", [M, F, A]).
-
-format_mfa_source(MFA) ->
- case find_mfa_source(MFA) of
- {module_not_found, function_not_found} -> "";
- {Source, function_not_found} -> ?FMT("~s: ", [Source]);
- {Source, Line} -> ?FMT("~s:~w: ", [Source, Line])
- end.
-
-%%
-%% Extract an element from a tuple, or undefined if N > tuple size
-%%
-safe_element(N, Tuple) ->
- case catch(element(N, Tuple)) of
- {'EXIT', {badarg, _}} ->
- undefined;
- Value ->
- Value
- end.
-
-%%
-%% Given a MFA, find the file and LOC where it's defined. Note that
-%% xref doesn't work if there is no abstract_code, so we can avoid
-%% being too paranoid here.
-%%
-find_mfa_source({M, F, A}) ->
- case code:get_object_code(M) of
- error -> {module_not_found, function_not_found};
- {M, Bin, _} -> find_function_source(M,F,A,Bin)
- end.
-
-find_function_source(M, F, A, Bin) ->
- AbstractCode = beam_lib:chunks(Bin, [abstract_code]),
- {ok, {M, [{abstract_code, {raw_abstract_v1, Code}}]}} = AbstractCode,
- %% Extract the original source filename from the abstract code
- [{attribute, 1, file, {Source, _}} | _] = Code,
- %% Extract the line number for a given function def
- Fn = [E || E <- Code,
- safe_element(1, E) == function,
- safe_element(3, E) == F,
- safe_element(4, E) == A],
- case Fn of
- [{function, Line, F, _, _}] -> {Source, Line};
- %% do not crash if functions are exported, even though they
- %% are not in the source.
- %% parameterized modules add new/1 and instance/1 for example.
- [] -> {Source, function_not_found}
- end.
diff --git a/src/rebar/test/rebar_eunit_tests.erl b/src/rebar/test/rebar_eunit_tests.erl
deleted file mode 100644
index 61a9bbf15..000000000
--- a/src/rebar/test/rebar_eunit_tests.erl
+++ /dev/null
@@ -1,434 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009, 2010 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-%% @author Chris Bernard <cebernard@gmail.com>
-%% @doc This tests functionality provided by the rebar command 'eunit'.
-%% @copyright 2009, 2010 Dave Smith
-%% -------------------------------------------------------------------
--module(rebar_eunit_tests).
-
--compile(export_all).
-
--include_lib("eunit/include/eunit.hrl").
-
-%% Assuming this test is run inside the rebar 'eunit'
-%% command, the current working directory will be '.eunit'
--define(REBAR_SCRIPT, "../rebar").
-
--define(TMP_DIR, "tmp_eunit/").
-
-%% ====================================================================
-%% Rebar EUnit and Cover Tests
-%% ====================================================================
-
-eunit_test_() ->
- {"Ensure EUnit runs with tests in a 'test' dir and no defined suite",
- setup, fun() -> setup_basic_project(), rebar("-v eunit") end,
- fun teardown/1,
- fun(RebarOut) ->
- [{"Tests in 'test' directory are found and run",
- ?_assert(string:str(RebarOut, "myapp_mymod_tests:") =/= 0)},
-
- {"Tests in 'src' directory are found and run",
- ?_assert(string:str(RebarOut, "myapp_mymod:") =/= 0)},
-
- {"Tests are only run once",
- ?_assert(string:str(RebarOut, "All 2 tests passed") =/= 0)}]
- end}.
-
-eunit_with_suites_and_tests_test_() ->
- [{"Ensure EUnit runs selected suites",
- setup, fun() ->
- setup_project_with_multiple_modules(),
- rebar("-v eunit suites=myapp_mymod2")
- end,
- fun teardown/1,
- fun(RebarOut) ->
- [{"Selected suite tests in 'test' directory are found and run",
- ?_assert(string:str(RebarOut, "myapp_mymod2_tests:") =/= 0)},
-
- {"Selected suite tests in 'src' directory are found and run",
- ?_assert(string:str(RebarOut, "myapp_mymod2:") =/= 0)},
-
- {"Unselected suite tests in 'test' directory are not run",
- ?_assert(string:str(RebarOut, "myapp_mymod_tests:") =:= 0)},
-
- {"Unselected suite tests in 'src' directory are not run",
- ?_assert(string:str(RebarOut, "myapp_mymod:") =:= 0)},
-
- {"Selected suite tests are only run once",
- ?_assert(string:str(RebarOut, "All 4 tests passed") =/= 0)}]
- end},
- {"Ensure EUnit runs selected _tests suites",
- setup, fun() ->
- setup_project_with_multiple_modules(),
- rebar("-v eunit suites=myapp_mymod2_tests")
- end,
- fun teardown/1,
- fun(RebarOut) ->
- [{"Selected suite tests in 'test' directory are found and run",
- ?_assert(string:str(RebarOut, "myapp_mymod2_tests:") =/= 0)},
-
- {"Selected suite tests in 'src' directory are not run",
- ?_assert(string:str(RebarOut, "myapp_mymod2:") =:= 0)},
-
- {"Unselected suite tests in 'test' directory are not run",
- ?_assert(string:str(RebarOut, "myapp_mymod_tests:") =:= 0)},
-
- {"Unselected suite tests in 'src' directory are not run",
- ?_assert(string:str(RebarOut, "myapp_mymod:") =:= 0)},
-
- {"Selected suite tests are only run once",
- ?_assert(string:str(RebarOut, "All 2 tests passed") =/= 0)}]
- end},
- {"Ensure EUnit runs a specific test defined in a selected suite",
- setup, fun() ->
- setup_project_with_multiple_modules(),
- rebar("-v eunit suites=myapp_mymod2 tests=myprivate2")
- end,
- fun teardown/1,
- fun(RebarOut) ->
- [{"Selected suite tests are found and run",
- ?_assert(string:str(RebarOut,
- "myapp_mymod2:myprivate2_test/0") =/= 0)},
-
- {"Selected suite tests is run once",
- ?_assert(string:str(RebarOut, "Test passed") =/= 0)}]
- end},
- {"Ensure EUnit runs a specific generator test defined in a selected suite",
- setup, fun() ->
- setup_project_with_multiple_modules(),
- rebar("-v eunit suites=myapp_mymod3 tests=mygenerator")
- end,
- fun teardown/1,
- fun(RebarOut) ->
- [{"Selected suite's generator test is found and run",
- ?_assert(string:str(RebarOut,
- "myapp_mymod3:mygenerator_test_/0") =/= 0)},
-
- {"Selected suite's generator test raises an error",
- ?_assert(string:str(RebarOut,
- "assertEqual_failed") =/= 0)},
-
- {"Selected suite tests is run once",
- ?_assert(string:str(RebarOut, "Failed: 1.") =/= 0)}]
- end},
- {"Ensure EUnit runs specific tests defined in selected suites",
- setup, fun() ->
- setup_project_with_multiple_modules(),
- rebar("-v eunit suites=myapp_mymod,myapp_mymod2"
- " tests=myprivate,myfunc2")
- end,
- fun teardown/1,
- fun(RebarOut) ->
- [{"Selected suite tests are found and run",
- [?_assert(string:str(RebarOut,
- "myapp_mymod:myprivate_test/0") =/= 0),
- ?_assert(string:str(RebarOut,
- "myapp_mymod2:myprivate2_test/0") =/= 0),
- ?_assert(
- string:str(RebarOut,
- "myapp_mymod2_tests:myfunc2_test/0") =/= 0)]},
-
- {"Selected suite tests are run once",
- ?_assert(string:str(RebarOut, "All 3 tests passed") =/= 0)}]
- end},
- {"Ensure EUnit runs specific test in a _tests suite",
- setup,
- fun() ->
- setup_project_with_multiple_modules(),
- rebar("-v eunit suites=myapp_mymod2_tests tests=common_name_test")
- end,
- fun teardown/1,
- fun(RebarOut) ->
- [{"Only selected suite tests are found and run",
- [?_assert(string:str(RebarOut,
- "myapp_mymod2:common_name_test/0") =:= 0),
- ?_assert(string:str(RebarOut,
- "myapp_mymod2_tests:common_name_test/0")
- =/= 0)]},
-
- {"Selected suite tests is run once",
- ?_assert(string:str(RebarOut, "Test passed") =/= 0)}]
- end},
- {"Ensure EUnit runs a specific test without a specified suite",
- setup,
- fun() ->
- setup_project_with_multiple_modules(),
- rebar("-v eunit tests=myprivate")
- end,
- fun teardown/1,
- fun(RebarOut) ->
- [{"Only selected suite tests are found and run",
- [?_assert(string:str(RebarOut,
- "myapp_mymod:myprivate_test/0") =/= 0),
- ?_assert(string:str(RebarOut,
- "myapp_mymod2:myprivate2_test/0")
- =/= 0)]},
-
- {"Selected suite tests is run once",
- ?_assert(string:str(RebarOut, "All 2 tests passed") =/= 0)}]
- end}].
-
-cover_test_() ->
- {"Ensure Cover runs with tests in a test dir and no defined suite",
- setup, fun() -> setup_cover_project(), rebar("-v eunit") end,
- fun teardown/1,
-
- fun(RebarOut) ->
- [{"Error messages are not present",
- ?_assert(string:str(RebarOut, "Cover analyze failed for") =:= 0)},
-
- {"All cover reports are generated",
- assert_files_in("the temporary eunit directory",
- expected_cover_generated_files())},
-
- {"Only production modules get coverage reports",
- assert_files_not_in("the temporary eunit directory",
- [".eunit/myapp_mymod_tests.COVER.html"])}]
- end}.
-
-cover_with_suite_test_() ->
- {"Ensure Cover runs with Tests in a test dir and a test suite",
- setup,
- fun() ->
- setup_cover_project_with_suite(),
- rebar("-v eunit suites=mysuite")
- end,
- fun teardown/1,
-
- fun(RebarOut) ->
- [{"Error messages are not present",
- ?_assert(string:str(RebarOut, "Cover analyze failed for") =:= 0)},
-
- {"Cover reports are generated for module",
- assert_files_in("the temporary eunit directory",
- [".eunit/index.html",
- ".eunit/mysuite.COVER.html"])},
-
- {"Only production modules get coverage reports",
- assert_files_not_in("the temporary eunit directory",
- [".eunit/myapp_app.COVER.html",
- ".eunit/myapp_mymod.COVER.html",
- ".eunit/myapp_sup.COVER.html",
- ".eunit/myapp_mymod_tests.COVER.html"])}]
- end}.
-
-expected_cover_generated_files() ->
- [".eunit/index.html",
- ".eunit/myapp_app.COVER.html",
- ".eunit/myapp_mymod.COVER.html",
- ".eunit/myapp_sup.COVER.html"].
-
-cover_coverage_test_() ->
- {"Coverage is accurately calculated",
- setup, fun() -> setup_cover_project(), rebar("-v eunit") end,
- fun teardown/1,
-
- [{"Modules that include the EUnit header can still have 100% coverage",
- %% cover notices the implicit EUnit test/0 func that never gets
- %% called during eunit:test(TestRepresentation), so NotCounted
- %% needs to be decremented in this case.
- assert_full_coverage("myapp_mymod")}]}.
-
-%% ====================================================================
-%% Environment and Setup Tests
-%% ====================================================================
-
-environment_test_() ->
- {"Sanity check the testing environment",
- setup, fun make_tmp_dir/0, fun remove_tmp_dir/1,
-
- [{"Ensure a test project can be created",
- ?_assert(filelib:is_dir(?TMP_DIR))},
-
- {"Ensure the rebar script can be found, copied, and run",
- [?_assert(filelib:is_regular(?REBAR_SCRIPT)),
- fun assert_rebar_runs/0]}]}.
-
-assert_rebar_runs() ->
- prepare_rebar_script(),
- ?assert(string:str(os:cmd(filename:nativename("./" ++ ?TMP_DIR ++ "rebar")),
- "No command to run specified!") =/= 0).
-
-basic_setup_test_() ->
- {"Create a simple project with a 'test' directory, a test, and a module",
- setup, fun setup_basic_project/0, fun teardown/1,
-
- %% Test the setup function
- assert_dirs_in("Basic Project",
- ["src", "ebin", "test"]) ++
- assert_files_in("Basic Project",
- ["test/myapp_mymod_tests.erl",
- "src/myapp_mymod.erl"])}.
-
-%% ====================================================================
-%% Setup and Teardown
-%% ====================================================================
-
--define(myapp_mymod,
- ["-module(myapp_mymod).\n",
- "-export([myfunc/0]).\n",
- "-include_lib(\"eunit/include/eunit.hrl\").\n",
- "myfunc() -> ok.\n",
- "myprivate_test() -> ?assert(true).\n"]).
-
--define(myapp_mymod_tests,
- ["-module(myapp_mymod_tests).\n",
- "-compile([export_all]).\n",
- "-include_lib(\"eunit/include/eunit.hrl\").\n",
- "myfunc_test() -> ?assertMatch(ok, myapp_mymod:myfunc()).\n"]).
-
--define(myapp_mymod2,
- ["-module(myapp_mymod2).\n",
- "-export([myfunc2/0]).\n",
- "-include_lib(\"eunit/include/eunit.hrl\").\n",
- "myfunc2() -> ok.\n",
- "myprivate2_test() -> ?assert(true).\n",
- "common_name_test() -> ?assert(true).\n"]).
-
--define(myapp_mymod2_tests,
- ["-module(myapp_mymod2_tests).\n",
- "-compile([export_all]).\n",
- "-include_lib(\"eunit/include/eunit.hrl\").\n",
- "myfunc2_test() -> ?assertMatch(ok, myapp_mymod2:myfunc2()).\n",
- "common_name_test() -> ?assert(true).\n"]).
-
--define(myapp_mymod3,
- ["-module(myapp_mymod3).\n",
- "-export([myfunc3/0]).\n",
- "-include_lib(\"eunit/include/eunit.hrl\").\n",
- "myfunc3() -> ok.\n",
- "mygenerator_test_() -> [?_assertEqual(true, false)].\n"]).
-
--define(mysuite,
- ["-module(mysuite).\n",
- "-export([all_test_/0]).\n",
- "-include_lib(\"eunit/include/eunit.hrl\").\n",
- "all_test_() -> [myapp_mymod_defined_in_mysuite_tests].\n"]).
-
--define(myapp_mymod_defined_in_mysuite_tests,
- ["-module(myapp_mymod_defined_in_mysuite_tests).\n",
- "-compile([export_all]).\n",
- "-include_lib(\"eunit/include/eunit.hrl\").\n",
- "myfunc_test() -> ?assertMatch(ok, myapp_mymod:myfunc()).\n"]).
-
-make_tmp_dir() ->
- case file:make_dir(?TMP_DIR) of
- ok ->
- ok;
- {error, eexist} ->
- remove_tmp_dir(),
- make_tmp_dir();
- Error ->
- throw(Error)
- end.
-
-setup_environment() ->
- ok = make_tmp_dir(),
- prepare_rebar_script(),
- ok = file:set_cwd(?TMP_DIR).
-
-setup_basic_project() ->
- setup_environment(),
- rebar("create-app appid=myapp"),
- ok = file:make_dir("ebin"),
- ok = file:make_dir("test"),
- ok = file:write_file("test/myapp_mymod_tests.erl", ?myapp_mymod_tests),
- ok = file:write_file("src/myapp_mymod.erl", ?myapp_mymod).
-
-setup_project_with_multiple_modules() ->
- setup_basic_project(),
- ok = file:write_file("test/myapp_mymod2_tests.erl", ?myapp_mymod2_tests),
- ok = file:write_file("src/myapp_mymod2.erl", ?myapp_mymod2),
- ok = file:write_file("src/myapp_mymod3.erl", ?myapp_mymod3).
-
-setup_cover_project() ->
- setup_basic_project(),
- ok = file:write_file("rebar.config", "{cover_enabled, true}.\n").
-
-setup_cover_project_with_suite() ->
- setup_cover_project(),
- ok = file:write_file("test/mysuite.erl", ?mysuite),
- ok = file:write_file("test/myapp_mymod_defined_in_mysuite_tests.erl",
- ?myapp_mymod_defined_in_mysuite_tests).
-
-teardown(_) ->
- ok = file:set_cwd(".."),
- ok = remove_tmp_dir().
-
-remove_tmp_dir() ->
- remove_tmp_dir(arg_for_eunit).
-
-remove_tmp_dir(_) ->
- ok = rebar_file_utils:rm_rf(?TMP_DIR).
-
-%% ====================================================================
-%% Helper Functions
-%% ====================================================================
-
-prepare_rebar_script() ->
- Rebar = ?TMP_DIR ++ "rebar",
- {ok, _} = file:copy(?REBAR_SCRIPT, Rebar),
- case os:type() of
- {unix, _} ->
- [] = os:cmd("chmod u+x " ++ Rebar);
- {win32, _} ->
- {ok, _} = file:copy(?REBAR_SCRIPT ++ ".cmd",
- ?TMP_DIR ++ "rebar.cmd")
- end.
-
-rebar() ->
- rebar([]).
-
-rebar(Args) when is_list(Args) ->
- Out = os:cmd(filename:nativename("./rebar") ++ " " ++ Args),
- %% ?debugMsg("**** Begin"), ?debugMsg(Out), ?debugMsg("**** End"),
- Out.
-
-assert_dirs_in(Name, [Dir|T]) ->
- [{Name ++ " has directory: " ++ Dir, ?_assert(filelib:is_dir(Dir))} |
- assert_dirs_in(Name, T)];
-assert_dirs_in(_, []) -> [].
-
-assert_files_in(Name, [File|T]) ->
- [{Name ++ " has file: " ++ File, ?_assert(filelib:is_regular(File))} |
- assert_files_in(Name, T)];
-assert_files_in(_, []) -> [].
-
-assert_files_not_in(Name, [File|T]) ->
- [{Name ++ " does not have file: " ++ File,
- ?_assertNot(filelib:is_regular(File))} | assert_files_not_in(Name, T)];
-assert_files_not_in(_, []) -> [].
-
-assert_full_coverage(Mod) ->
- fun() ->
- {ok, F} = file:read_file(".eunit/index.html"),
- Result = [X || X <- string:tokens(binary_to_list(F), "\n"),
- string:str(X, Mod) =/= 0,
- string:str(X, "100%") =/= 0],
- ?assert(length(Result) =:= 1)
- end.
diff --git a/src/rebar/test/rebar_file_utils_tests.erl b/src/rebar/test/rebar_file_utils_tests.erl
deleted file mode 100644
index 26a6f9f3c..000000000
--- a/src/rebar/test/rebar_file_utils_tests.erl
+++ /dev/null
@@ -1,278 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% rebar: Erlang Build Tools
-%%
-%% Copyright (c) 2009, 2010 Dave Smith (dizzyd@dizzyd.com)
-%%
-%% Permission is hereby granted, free of charge, to any person obtaining a copy
-%% of this software and associated documentation files (the "Software"), to deal
-%% in the Software without restriction, including without limitation the rights
-%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-%% copies of the Software, and to permit persons to whom the Software is
-%% furnished to do so, subject to the following conditions:
-%%
-%% The above copyright notice and this permission notice shall be included in
-%% all copies or substantial portions of the Software.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-%% THE SOFTWARE.
-%% -------------------------------------------------------------------
-%% @author Juhani Rankimies <juhani@juranki.com>
-%% @doc Tests functionality of rebar_file_utils module.
-%% @copyright 2009, 2010 Dave Smith
-%% -------------------------------------------------------------------
--module(rebar_file_utils_tests).
-
--compile(export_all).
-
--include_lib("eunit/include/eunit.hrl").
-
--define(TMP_DIR, "tmp_file_utils").
--define(DIR_TREE, [{d,"source",[{f,"file1"},
- {f,"file2"}]},
- {d,"dest",[]}]).
--define(FILE_CONTENT, <<"1234567890">>).
-
-%% ====================================================================
-%% delete_each tests
-%% ====================================================================
-
-delete_bogus_test_() ->
- {"delete_each survives nonexisting files",
- [?_assertMatch(ok, rebar_file_utils:delete_each(["bogus"])),
- ?_assertMatch(ok, rebar_file_utils:delete_each(["bogus1","bogus2"]))]}.
-
-delete_each_test_() ->
- {"delete_each removes files",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:delete_each(file_list())
- end,
- fun teardown/1,
- [assert_files_not_in("source", file_list())]}.
-
-%% ====================================================================
-%% rm_rf tests
-%% ====================================================================
-
-rm_rf_wildcard_test_() ->
- {"rm_rf removes files based on wildcard spec",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:rm_rf(filename:join([?TMP_DIR,"source","file*"]))
- end,
- fun teardown/1,
- [assert_files_not_in("source", file_list())]}.
-
-rm_rf_dir_test_() ->
- {"rm_rf removes directory tree",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:rm_rf(filename:join([?TMP_DIR,"source"]))
- end,
- fun teardown/1,
- [?_assertNot(filelib:is_dir(filename:join([?TMP_DIR,"source"])))]}.
-
-%% ====================================================================
-%% cp_r tests
-%% ====================================================================
-
-cp_r_file_to_file_test_() ->
- {"cp_r copies a file to file",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:cp_r([filename:join([?TMP_DIR,"source","file1"])],
- filename:join([?TMP_DIR,"dest","new_file"]))
- end,
- fun teardown/1,
- [?_assert(filelib:is_regular(filename:join([?TMP_DIR,"dest","new_file"])))]}.
-
-cp_r_file_to_dir_test_() ->
- {"cp_r copies a file to directory",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:cp_r([filename:join([?TMP_DIR,"source","file1"])],
- filename:join([?TMP_DIR,"dest"]))
- end,
- fun teardown/1,
- [?_assert(filelib:is_regular(filename:join([?TMP_DIR,"dest","file1"])))]}.
-
-cp_r_dir_to_dir_test_() ->
- {"cp_r copies a directory to directory",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:cp_r([filename:join([?TMP_DIR,"source"])],
- filename:join([?TMP_DIR,"dest"]))
- end,
- fun teardown/1,
- [?_assert(filelib:is_dir(filename:join([?TMP_DIR,"dest","source"]))),
- assert_files_in("dest/source",
- [filename:join([?TMP_DIR,"dest","source",F]) ||
- F <- ["file1","file2"]])]}.
-
-cp_r_wildcard_file_to_dir_test_() ->
- {"cp_r copies wildcard files to directory",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:cp_r([filename:join([?TMP_DIR,"source","*1"])],
- filename:join([?TMP_DIR,"dest"]))
- end,
- fun teardown/1,
- [?_assert(filelib:is_regular(filename:join([?TMP_DIR,"dest","file1"])))]}.
-
-cp_r_wildcard_dir_to_dir_test_() ->
- {"cp_r copies wildcard directory to directory",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:cp_r([filename:join([?TMP_DIR,"sour*"])],
- filename:join([?TMP_DIR,"dest"]))
- end,
- fun teardown/1,
- [?_assert(filelib:is_dir(filename:join([?TMP_DIR,"dest","source"]))),
- assert_files_in("dest/source",
- [filename:join([?TMP_DIR,"dest","source",F]) ||
- F <- ["file1","file2"]])]}.
-
-cp_r_overwrite_file_test_() ->
- {"cp_r overwrites destination file",
- setup,
- fun() ->
- setup(),
- ok = file:write_file(filename:join([?TMP_DIR,"dest","file1"]),
- <<"test">>),
- rebar_file_utils:cp_r([filename:join([?TMP_DIR,"source","file1"])],
- filename:join([?TMP_DIR,"dest"]))
- end,
- fun teardown/1,
- [?_assertMatch({ok,?FILE_CONTENT},
- file:read_file(
- filename:join([?TMP_DIR,"dest","file1"])))]}.
-
-cp_r_overwrite_dir_test_() ->
- {"cp_r overwrites destination file (xcopy case on win32)",
- setup,
- fun() ->
- setup(),
- ok = file:make_dir(filename:join([?TMP_DIR,"dest","source"])),
- ok = file:write_file(
- filename:join([?TMP_DIR,"dest","source","file1"]),
- <<"test">>),
- rebar_file_utils:cp_r([filename:join([?TMP_DIR,"source"])],
- filename:join([?TMP_DIR,"dest"]))
- end,
- fun teardown/1,
- [?_assertMatch({ok,?FILE_CONTENT},
- file:read_file(
- filename:join([?TMP_DIR,"dest","source","file1"])))]}.
-
-cp_r_overwrite_file_fail_test_() ->
- {"cp_r fails to fs permission errors (file:copy/2 case on win32)",
- setup,
- fun() ->
- setup(),
- ok = file:write_file(
- filename:join([?TMP_DIR,"dest","file1"]),<<"test">>),
- ok = file:change_mode(
- filename:join([?TMP_DIR,"dest","file1"]),0)
- end,
- fun teardown/1,
- [?_assertError({badmatch,_},
- rebar_file_utils:cp_r(
- [filename:join([?TMP_DIR,"source","file1"])],
- filename:join([?TMP_DIR,"dest"])))]}.
-
-cp_r_overwrite_dir_fail_test_() ->
- {"cp_r fails to fs permission error (xcopy case on win32)",
- setup,
- fun() ->
- setup(),
- ok = file:make_dir(
- filename:join([?TMP_DIR,"dest","source"])),
- ok = file:write_file(
- filename:join([?TMP_DIR,"dest","source","file1"]),
- <<"test">>),
- ok = file:change_mode(
- filename:join([?TMP_DIR,"dest","source","file1"]),0)
- end,
- fun teardown/1,
- [?_assertError({badmatch,_},
- rebar_file_utils:cp_r(
- [filename:join([?TMP_DIR,"source"])],
- filename:join([?TMP_DIR,"dest"])))]}.
-
-mv_file_test_() ->
- {"move a file to folder",
- setup,
- fun() ->
- setup(),
- rebar_file_utils:mv(filename:join([?TMP_DIR,"source","file1"]),
- filename:join([?TMP_DIR,"dest"]))
- end,
- fun teardown/1,
- [?_assert(filelib:is_regular(filename:join([?TMP_DIR,"dest","file1"]))),
- ?_assertNot(filelib:is_regular(
- filename:join([?TMP_DIR,"source","file1"])))]}.
-
-%% ====================================================================
-%% Utilities
-%% ====================================================================
-
-file_list() ->
- [filename:join([?TMP_DIR,"source",F]) || F <- ["file1","file2"]].
-
-%% ====================================================================
-%% Setup and Teardown
-%% ====================================================================
-
-setup() ->
- file:make_dir(?TMP_DIR),
- make_dir_tree(?TMP_DIR,?DIR_TREE).
-
-make_dir_tree(Parent, [{d,Dir,Contents} | Rest]) ->
- NewDir = filename:join(Parent,Dir),
- ok = file:make_dir(NewDir),
- ok = make_dir_tree(NewDir,Contents),
- ok = make_dir_tree(Parent,Rest);
-make_dir_tree(Parent, [{f,File} | Rest]) ->
- ok = file:write_file(filename:join(Parent,File),?FILE_CONTENT),
- ok = make_dir_tree(Parent,Rest);
-make_dir_tree(_,[]) ->
- ok.
-
-teardown(_) ->
- case os:type() of
- {unix, _} ->
- os:cmd("rm -rf " ++ ?TMP_DIR ++ " 2>/dev/null");
- {win32, _} ->
- os:cmd("rmdir /S /Q " ++ filename:nativename(?TMP_DIR))
- end.
-
-%% ====================================================================
-%% Assert helpers
-%% ====================================================================
-
-assert_files_in(Name, [File|T]) ->
- [{Name ++ " has file: " ++ File, ?_assert(filelib:is_regular(File))} |
- assert_files_in(Name, T)];
-assert_files_in(_, []) -> [].
-
-assert_files_not_in(Name, [File|T]) ->
- [{Name ++ " does not have file: " ++ File,
- ?_assertNot(filelib:is_regular(File))} |
- assert_files_not_in(Name, T)];
-assert_files_not_in(_, []) -> [].
diff --git a/src/rebar/test/rebar_xref_eunit.erl b/src/rebar/test/rebar_xref_eunit.erl
deleted file mode 100644
index 45ec28368..000000000
--- a/src/rebar/test/rebar_xref_eunit.erl
+++ /dev/null
@@ -1,203 +0,0 @@
--module(rebar_xref_eunit).
-
--compile(export_all).
-
--include_lib("eunit/include/eunit.hrl").
-
--define(REBAR_SCRIPT, "../rebar").
-
--define(TMP_DIR, "tmp_xref_eunit/").
-
-xref_test_() ->
- {"Test the various xref warnings",
- setup, fun() -> setup_project(false), rebar("compile"), rebar("skip_deps=true xref") end,
- fun teardown/1,
- fun(RebarOut) ->
- [
- {"Undefined function", ?_assert(string:str(RebarOut,
- "myapp_somemod:notavailable/1 is undefined function") =/= 0)},
- {"Undefined function call", ?_assert(string:str(RebarOut,
- "myapp_othermod:somefunc/0 calls undefined function myapp_somemod:notavailable/1") =/= 0)},
- {"Deprecated function", ?_assert(string:str(RebarOut,
- "myapp_mymod:fdeprecated/0 is deprecated function") =/= 0)},
- {"Deprecated function call", ?_assert(string:str(RebarOut,
- "myapp_othermod:somefunc/0 calls deprecated function myapp_mymod:fdeprecated/0") =/= 0)},
- {"Unused local", ?_assert(string:str(RebarOut,
- "myapp_mymod:localfunc2/0 is unused local function") =/= 0)},
- {"Unused export 1", ?_assert(string:str(RebarOut,
- "myapp_behaviour1:behaviour_info/1 is unused export") =/= 0)},
- {"Unused export 2", ?_assert(string:str(RebarOut,
- "myapp_behaviour2:behaviour_info/1 is unused export") =/= 0)},
- {"Unused export 3", ?_assert(string:str(RebarOut,
- "myapp_mymod:other2/1 is unused export") =/= 0)},
- {"Unused export 4", ?_assert(string:str(RebarOut,
- "myapp_othermod:somefunc/0 is unused export") =/= 0)},
- {"Suppressed behaviour export 1", ?_assert(string:str(RebarOut,
- "myapp_mymod:bh1_a/1 is unused export") =:= 0)},
- {"Suppressed behaviour export 2", ?_assert(string:str(RebarOut,
- "myapp_mymod:bh1_b/1 is unused export") =:= 0)},
- {"Suppressed behaviour export 3", ?_assert(string:str(RebarOut,
- "myapp_mymod:bh2_a/1 is unused export") =:= 0)},
- {"Suppressed behaviour export 4", ?_assert(string:str(RebarOut,
- "myapp_mymod:bh2_b/1 is unused export") =:= 0)}
- ]
- end}.
-
-xref_ignore_test_() ->
- {"Test the suppression of xref warnings",
- setup, fun() -> setup_project(ignore_xref), rebar("compile"), rebar("skip_deps=true xref") end,
- fun teardown/1,
- fun(RebarOut) ->
- [
- {"Undefined function can not be suppressed.", ?_assert(string:str(RebarOut,
- "myapp_somemod:notavailable/1 is undefined function") =/= 0)},
- {"Supppressed undefined function call", ?_assert(string:str(RebarOut,
- "myapp_othermod:somefunc/0 calls undefined function myapp_somemod:notavailable/1") =:= 0)},
- {"Supppressed deprecated function", ?_assert(string:str(RebarOut,
- "myapp_mymod:fdeprecated/0 is deprecated function") =:= 0)},
- {"Supppressed deprecated function call", ?_assert(string:str(RebarOut,
- "myapp_othermod:somefunc/0 calls deprecated function myapp_mymod:fdeprecated/0") =:= 0)},
- {"Supppressed unused local", ?_assert(string:str(RebarOut,
- "myapp_mymod:localfunc2/0 is unused local function") =:= 0)},
- {"Supppressed unused export 1", ?_assert(string:str(RebarOut,
- "myapp_behaviour1:behaviour_info/1 is unused export") =:= 0)},
- {"Supppressed unused export 2", ?_assert(string:str(RebarOut,
- "myapp_behaviour2:behaviour_info/1 is unused export") =:= 0)},
- {"Supppressed unused export 3", ?_assert(string:str(RebarOut,
- "myapp_mymod:other2/1 is unused export") =:= 0)},
- {"Supppressed unused export 4", ?_assert(string:str(RebarOut,
- "myapp_othermod:somefunc/0 is unused export") =:= 0)},
- {"Suppressed behaviour export 1", ?_assert(string:str(RebarOut,
- "myapp_mymod:bh1_a/1 is unused export") =:= 0)},
- {"Suppressed behaviour export 2", ?_assert(string:str(RebarOut,
- "myapp_mymod:bh1_b/1 is unused export") =:= 0)},
- {"Suppressed behaviour export 3", ?_assert(string:str(RebarOut,
- "myapp_mymod:bh2_a/1 is unused export") =:= 0)},
- {"Suppressed behaviour export 4", ?_assert(string:str(RebarOut,
- "myapp_mymod:bh2_b/1 is unused export") =:= 0)}
- ]
-
- end}.
-
-
-%% ====================================================================
-%% Setup and Teardown
-%% ====================================================================
-
--define(myapp_behaviour1,
- ["-module(myapp_behaviour1).\n",
- "-export([behaviour_info/1]).\n"]).
--define(myapp_behaviour1_body,
- ["behaviour_info(callbacks) -> [{bh1_a,1},{bh1_b,1}];\n",
- "behaviour_info(_Other) -> undefined.\n"]).
--define(myapp_behaviour1_ignorexref,
- ["-ignore_xref({behaviour_info,1}).\n"]).
-
--define(myapp_behaviour2,
- ["-module(myapp_behaviour2).\n",
- "-export([behaviour_info/1]).\n"]).
--define(myapp_behaviour2_body,
- ["behaviour_info(callbacks) -> [{bh2_a,1},{bh2_b,1}];\n",
- "behaviour_info(_Other) -> undefined.\n"]).
--define(myapp_behaviour2_ignorexref,
- ["-ignore_xref({behaviour_info,1}).\n"]).
-
--define(myapp_mymod,
- ["-module(myapp_mymod).\n",
- "-export([bh1_a/1,bh1_b/1,bh2_a/1,bh2_b/1,other1/1,other2/1,fdeprecated/0]).\n",
- "-behaviour(myapp_behaviour1).\n", % 2 behaviours
- "-behaviour(myapp_behaviour2).\n",
- "-deprecated({fdeprecated,0}).\n"]). % deprecated function
--define(myapp_mymod_body,
- ["bh1_a(A) -> localfunc1(bh1_a, A).\n", % behaviour functions
- "bh1_b(A) -> localfunc1(bh1_b, A).\n",
- "bh2_a(A) -> localfunc1(bh2_a, A).\n",
- "bh2_b(A) -> localfunc1(bh2_b, A).\n",
- "other1(A) -> localfunc1(other1, A).\n", % regular exported functions
- "other2(A) -> localfunc1(other2, A).\n",
- "localfunc1(A, B) -> {A, B}.\n", % used local
- "localfunc2() -> ok.\n", % unused local
- "fdeprecated() -> ok.\n" % deprecated function
- ]).
--define(myapp_mymod_ignorexref,
- ["-ignore_xref([{other2,1},{localfunc2,0},{fdeprecated,0}]).\n"]).
-
-
-
--define(myapp_othermod,
- ["-module(myapp_othermod).\n",
- "-export([somefunc/0]).\n"]).
--define(myapp_othermod_body,
- ["somefunc() ->\n",
- " myapp_mymod:other1(arg),\n",
- " myapp_somemod:notavailable(arg),\n",
- " myapp_mymod:fdeprecated().\n"
- ]).
--define(myapp_othermod_ignorexref,
- ["-ignore_xref([{myapp_somemod,notavailable,1},{somefunc,0}]).\n",
- "-ignore_xref({myapp_mymod,fdeprecated,0}).\n"]).
-
-
--define(myapp_rebarconfig,
- ["{erl_opts, [debug_info]}.\n",
- "{xref_checks, [deprecated_function_calls,deprecated_functions,\n",
- " undefined_function_calls,undefined_functions,\n",
- " exports_not_used,locals_not_used]}.\n"
- ]).
-
-setup_environment() ->
- ok = file:make_dir(?TMP_DIR),
- prepare_rebar_script(),
- ok = file:set_cwd(?TMP_DIR).
-
-prepare_project() ->
- setup_environment(),
- rebar("create-app appid=myapp"),
- ok = file:make_dir("ebin").
-
-setup_project(ignore_xref) ->
- prepare_project(),
- ok = file:write_file("src/myapp_behaviour1.erl", ?myapp_behaviour1 ++ ?myapp_behaviour1_ignorexref ++ ?myapp_behaviour1_body),
- ok = file:write_file("src/myapp_behaviour2.erl", ?myapp_behaviour2 ++ ?myapp_behaviour2_ignorexref++ ?myapp_behaviour2_body),
- ok = file:write_file("src/myapp_mymod.erl", ?myapp_mymod ++ ?myapp_mymod_ignorexref ++ ?myapp_mymod_body),
- ok = file:write_file("src/myapp_othermod.erl", ?myapp_othermod ++ ?myapp_othermod_ignorexref ++ ?myapp_othermod_body),
- ok = file:write_file("rebar.config", ?myapp_rebarconfig);
-
-setup_project(_) ->
- prepare_project(),
- ok = file:write_file("src/myapp_behaviour1.erl", ?myapp_behaviour1 ++ ?myapp_behaviour1_body),
- ok = file:write_file("src/myapp_behaviour2.erl", ?myapp_behaviour2 ++ ?myapp_behaviour2_body),
- ok = file:write_file("src/myapp_mymod.erl", ?myapp_mymod ++ ?myapp_mymod_body),
- ok = file:write_file("src/myapp_othermod.erl", ?myapp_othermod ++ ?myapp_othermod_body),
- ok = file:write_file("rebar.config", ?myapp_rebarconfig).
-
-
-teardown(_) ->
- ok = file:set_cwd(".."),
- ok = remove_tmp_dir().
-
-remove_tmp_dir() ->
- ok = rebar_file_utils:rm_rf(?TMP_DIR).
-
-%% ====================================================================
-%% Helper Functions
-%% ====================================================================
-
-prepare_rebar_script() ->
- Rebar = ?TMP_DIR ++ "rebar",
- {ok, _} = file:copy(?REBAR_SCRIPT, Rebar),
- case os:type() of
- {unix, _} ->
- [] = os:cmd("chmod u+x " ++ Rebar);
- {win32, _} ->
- {ok, _} = file:copy(?REBAR_SCRIPT ++ ".bat",
- ?TMP_DIR ++ "rebar.bat")
- end.
-
-rebar() ->
- rebar([]).
-
-rebar(Args) when is_list(Args) ->
- Out = os:cmd(filename:nativename("./rebar") ++ " " ++ Args),
- %% ?debugMsg("**** Begin"), ?debugMsg(Out), ?debugMsg("**** End"),
- Out.
diff --git a/src/rebar/test/upgrade_project/README.md b/src/rebar/test/upgrade_project/README.md
deleted file mode 100644
index 8df538354..000000000
--- a/src/rebar/test/upgrade_project/README.md
+++ /dev/null
@@ -1,40 +0,0 @@
-#### Building version 0.1
- rebar compile
- rebar generate
- mv rel/dummy rel/dummy_0.1
- rebar clean
- # start the release:
- cd rel/dummy_0.1
- bin/dummy console
-
- erl> dummy_server:get_state().
- erl> dummy_server:set_state(123).
- erl> dummy_server:get_state().
-
-#### Building version 0.2
-
- # Now, in another terminal we prepare an upgrade..
-
- # change release version numbers from 0.1 to 0.2 in
- $EDITOR apps/dummy/src/dummy.app.src
- $EDITOR rel/reltool.config
-
- rebar compile
- rebar generate
- # previous_release path is relative to your rel directory
- rebar generate-appups previous_release=dummy_0.1
- rebar generate-upgrade previous_release=dummy_0.1
- tar -zvtf rel/dummy_0.2.tar.gz
-
-
-#### Deploying with release_handler
- mv rel/dummy_0.2.tar.gz rel/dummy_0.1/releases/
-
- # Now use release_handler in the running erlang console for the deploy:
-
- erl> release_handler:unpack_release("dummy_0.2").
- erl> release_handler:install_release("0.2").
- erl> release_handler:make_permanent("0.2").
-
- erl> release_handler:which_releases().
- erl> dummy_server:get_state().
diff --git a/src/rebar/test/upgrade_project/apps/dummy/src/dummy.app.src b/src/rebar/test/upgrade_project/apps/dummy/src/dummy.app.src
deleted file mode 100644
index dd06752d0..000000000
--- a/src/rebar/test/upgrade_project/apps/dummy/src/dummy.app.src
+++ /dev/null
@@ -1,9 +0,0 @@
-{application, dummy, [
- {description, "a dummy app"},
- {vsn, "0.1"},
- {registered, [
- dummy_app
- ]},
- {mod, {dummy_app, []}},
- {applications, [kernel, stdlib, sasl]}
-]}.
diff --git a/src/rebar/test/upgrade_project/apps/dummy/src/dummy_app.erl b/src/rebar/test/upgrade_project/apps/dummy/src/dummy_app.erl
deleted file mode 100644
index 51363b363..000000000
--- a/src/rebar/test/upgrade_project/apps/dummy/src/dummy_app.erl
+++ /dev/null
@@ -1,9 +0,0 @@
--module(dummy_app).
--behaviour(application).
-
--export([start/2, stop/1]).
-
-start(_,_) ->
- dummy_sup:start_link().
-
-stop(_) -> ok.
diff --git a/src/rebar/test/upgrade_project/apps/dummy/src/dummy_server.erl b/src/rebar/test/upgrade_project/apps/dummy/src/dummy_server.erl
deleted file mode 100644
index 382251eba..000000000
--- a/src/rebar/test/upgrade_project/apps/dummy/src/dummy_server.erl
+++ /dev/null
@@ -1,56 +0,0 @@
--module(dummy_server).
--behaviour(gen_server).
-
--export([start_link/0, set_state/1, get_state/0]).
-
--export([init/1,
- handle_call/3,
- handle_cast/2,
- handle_info/2,
- terminate/2,
- code_change/3]).
-
-%%
-
-start_link() ->
- gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
-
-set_state(What) ->
- gen_server:call(?MODULE, {set_state, What}).
-
-get_state() ->
- gen_server:call(?MODULE, get_state).
-
-
-%%
-
-init([]) ->
- say("init, setting state to 0", []),
- {ok, 0}.
-
-
-handle_call({set_state, NewState}, _From, _State) ->
- {reply, {ok, NewState}, NewState};
-
-handle_call(get_state, _From, State) ->
- {reply, State, State}.
-
-handle_cast('__not_implemented', State) ->
- {noreply, State}.
-
-handle_info(_Info, State) ->
- say("info ~p, ~p.", [_Info, State]),
- {noreply, State}.
-
-terminate(_Reason, _State) ->
- say("terminate ~p, ~p", [_Reason, _State]),
- ok.
-
-code_change(_OldVsn, State, _Extra) ->
- say("code_change ~p, ~p, ~p", [_OldVsn, State, _Extra]),
- {ok, State}.
-
-%% Internal
-
-say(Format, Data) ->
- io:format("~p:~p: ~s~n", [?MODULE, self(), io_lib:format(Format, Data)]).
diff --git a/src/rebar/test/upgrade_project/apps/dummy/src/dummy_sup.erl b/src/rebar/test/upgrade_project/apps/dummy/src/dummy_sup.erl
deleted file mode 100644
index b5617c76b..000000000
--- a/src/rebar/test/upgrade_project/apps/dummy/src/dummy_sup.erl
+++ /dev/null
@@ -1,15 +0,0 @@
--module(dummy_sup).
--behaviour(supervisor).
-
--export([start_link/0]).
--export([init/1]).
-
-start_link() ->
- supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-
-init([]) ->
- Dummy = {dummy_server,
- {dummy_server, start_link, []},
- permanent, 5000, worker, [dummy_server]},
-
- {ok, {{one_for_one, 10, 10}, [Dummy]}}.
diff --git a/src/rebar/test/upgrade_project/rebar.config b/src/rebar/test/upgrade_project/rebar.config
deleted file mode 100644
index 11b5b9aca..000000000
--- a/src/rebar/test/upgrade_project/rebar.config
+++ /dev/null
@@ -1,4 +0,0 @@
-{sub_dirs, [
- "apps/dummy",
- "rel"
-]}.
diff --git a/src/rebar/test/upgrade_project/rel/files/dummy b/src/rebar/test/upgrade_project/rel/files/dummy
deleted file mode 100755
index c2ef25859..000000000
--- a/src/rebar/test/upgrade_project/rel/files/dummy
+++ /dev/null
@@ -1,347 +0,0 @@
-#!/bin/sh
-# -*- tab-width:4;indent-tabs-mode:nil -*-
-# ex: ts=4 sw=4 et
-
-# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
-if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
- POSIX_SHELL="true"
- export POSIX_SHELL
- # To support 'whoami' add /usr/ucb to path
- PATH=/usr/ucb:$PATH
- export PATH
- exec /usr/bin/ksh $0 "$@"
-fi
-
-# clear it so if we invoke other scripts, they run as ksh
-unset POSIX_SHELL
-
-RUNNER_SCRIPT_DIR=$(cd ${0%/*} && pwd -P)
-
-CALLER_DIR=$PWD
-
-RUNNER_BASE_DIR=${RUNNER_SCRIPT_DIR%/*}
-RUNNER_ETC_DIR=$RUNNER_BASE_DIR/etc
-# Note the trailing slash on $PIPE_DIR/
-PIPE_DIR=/tmp/$RUNNER_BASE_DIR/
-RUNNER_USER=
-WHOAMI=$(whoami)
-
-# Make sure this script is running as the appropriate user
-if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
- type sudo > /dev/null 2>&1
- if [ $? -ne 0 ]; then
- echo "sudo doesn't appear to be installed and your EUID isn't $RUNNER_USER" 1>&2
- exit 1
- fi
- echo "Attempting to restart script through sudo -H -u $RUNNER_USER" >&2
- exec sudo -H -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
-fi
-
-# Identify the script name
-SCRIPT=`basename $0`
-
-# Parse out release and erts info
-START_ERL=`cat $RUNNER_BASE_DIR/releases/start_erl.data`
-ERTS_VSN=${START_ERL% *}
-APP_VSN=${START_ERL#* }
-
-# Use $CWD/vm.args if exists, otherwise releases/APP_VSN/vm.args, or
-# else etc/vm.args
-if [ -e "$CALLER_DIR/vm.args" ]; then
- VMARGS_PATH=$CALLER_DIR/vm.args
- USE_DIR=$CALLER_DIR
-else
- USE_DIR=$RUNNER_BASE_DIR
- if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" ]; then
- VMARGS_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args"
- else
- VMARGS_PATH="$RUNNER_ETC_DIR/vm.args"
- fi
-fi
-
-RUNNER_LOG_DIR=$USE_DIR/log
-# Make sure log directory exists
-mkdir -p $RUNNER_LOG_DIR
-
-# Use releases/VSN/sys.config if it exists otherwise use etc/app.config
-if [ -e "$USE_DIR/sys.config" ]; then
- CONFIG_PATH="$USE_DIR/sys.config"
-else
- if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config" ]; then
- CONFIG_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config"
- else
- CONFIG_PATH="$RUNNER_ETC_DIR/app.config"
- fi
-fi
-
-# Extract the target node name from node.args
-NAME_ARG=`egrep '^\-s?name' $VMARGS_PATH`
-if [ -z "$NAME_ARG" ]; then
- echo "vm.args needs to have either -name or -sname parameter."
- exit 1
-fi
-
-# Extract the name type and name from the NAME_ARG for REMSH
-REMSH_TYPE=`echo $NAME_ARG | awk '{print $1}'`
-REMSH_NAME=`echo $NAME_ARG | awk '{print $2}'`
-
-# Note the `date +%s`, used to allow multiple remsh to the same node
-# transparently
-REMSH_NAME_ARG="$REMSH_TYPE remsh`date +%s`@`echo $REMSH_NAME | awk -F@ '{print $2}'`"
-REMSH_REMSH_ARG="-remsh $REMSH_NAME"
-
-# Extract the target cookie
-COOKIE_ARG=`grep '^\-setcookie' $VMARGS_PATH`
-if [ -z "$COOKIE_ARG" ]; then
- echo "vm.args needs to have a -setcookie parameter."
- exit 1
-fi
-
-# Make sure CWD is set to the right dir
-cd $USE_DIR
-
-# Make sure log directory exists
-mkdir -p $USE_DIR/log
-
-# Add ERTS bin dir to our path
-ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin
-
-# Setup command to control the node
-NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"
-
-# Setup remote shell command to control node
-REMSH="$ERTS_PATH/erl $REMSH_NAME_ARG $REMSH_REMSH_ARG $COOKIE_ARG"
-
-# Common functions
-
-# Ping node without allowing nodetool to take stdin
-ping_node() {
- $NODETOOL ping < /dev/null
-}
-
-# Set the PID global variable, return 1 on error
-get_pid() {
- PID=`$NODETOOL getpid < /dev/null`
- ES=$?
- if [ "$ES" -ne 0 ]; then
- echo "Node is not running!"
- return 1
- fi
-
- # don't allow empty or init pid's
- if [ -z $PID ] || [ "$PID" -le 1 ]; then
- return 1
- fi
-
- return 0
-}
-
-# Check the first argument for instructions
-case "$1" in
- start|start_boot)
- # Make sure there is not already a node running
- RES=`ping_node`
- if [ "$RES" = "pong" ]; then
- echo "Node is already running!"
- exit 1
- fi
- case "$1" in
- start)
- shift
- START_OPTION="console"
- HEART_OPTION="start"
- ;;
- start_boot)
- shift
- START_OPTION="console_boot"
- HEART_OPTION="start_boot"
- ;;
- esac
- RUN_PARAM=$(printf "\'%s\' " "$@")
- HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT $HEART_OPTION $RUN_PARAM"
- export HEART_COMMAND
- mkdir -p $PIPE_DIR
- $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT $START_OPTION $RUN_PARAM" 2>&1
- ;;
-
- stop)
- # Wait for the node to completely stop...
- case `uname -s` in
- Darwin)
- # Make sure we explicitly set this because iTerm.app doesn't for
- # some reason.
- COMMAND_MODE=unix2003
- esac
-
- # Get the PID from nodetool
- get_pid
- GPR=$?
- if [ "$GPR" -ne 0 ] || [ -z $PID ]; then
- exit $GPR
- fi
-
- # Tell nodetool to initiate a stop
- $NODETOOL stop
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
-
- # Wait for the node to completely stop...
- while `kill -s 0 $PID 2>/dev/null`
- do
- sleep 1
- done
- ;;
-
- restart)
- ## Restart the VM without exiting the process
- $NODETOOL restart
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
- ;;
-
- reboot)
- ## Restart the VM completely (uses heart to restart it)
- $NODETOOL reboot
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
- ;;
-
- ping)
- ## See if the VM is alive
- ping_node
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
- ;;
-
- attach)
- # Make sure a node is running
- ping_node
- ES=$?
- if [ "$ES" -ne 0 ]; then
- echo "Node is not running!"
- exit $ES
- fi
-
- shift
- exec $ERTS_PATH/to_erl $PIPE_DIR
- ;;
-
- remote_console)
- # Make sure a node is running
- ping_node
- ES=$?
- if [ "$ES" -ne 0 ]; then
- echo "Node is not running!"
- exit $ES
- fi
-
- shift
- exec $REMSH
- ;;
-
- upgrade)
- if [ -z "$2" ]; then
- echo "Missing upgrade package argument"
- echo "Usage: $SCRIPT upgrade {package base name}"
- echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
- exit 1
- fi
-
- # Make sure a node IS running
- ping_node
- ES=$?
- if [ "$ES" -ne 0 ]; then
- echo "Node is not running!"
- exit $ES
- fi
-
- node_name=`echo $NAME_ARG | awk '{print $2}'`
- erlang_cookie=`echo $COOKIE_ARG | awk '{print $2}'`
-
- $ERTS_PATH/escript $RUNNER_BASE_DIR/bin/install_upgrade.escript $node_name $erlang_cookie $2
- ;;
-
- console|console_clean|console_boot)
- # .boot file typically just $SCRIPT (ie, the app name)
- # however, for debugging, sometimes start_clean.boot is useful.
- # For e.g. 'setup', one may even want to name another boot script.
- case "$1" in
- console) BOOTFILE=$SCRIPT ;;
- console_clean) BOOTFILE=start_clean ;;
- console_boot)
- shift
- BOOTFILE="$1"
- shift
- ;;
- esac
- # Setup beam-required vars
- ROOTDIR=$RUNNER_BASE_DIR
- BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
- EMU=beam
- PROGNAME=`echo $0 | sed 's/.*\\///'`
- CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH"
- export EMU
- export ROOTDIR
- export BINDIR
- export PROGNAME
-
- # Dump environment info for logging purposes
- echo "Exec: $CMD" -- ${1+"$@"}
- echo "Root: $ROOTDIR"
-
- # Log the startup
- logger -t "$SCRIPT[$$]" "Starting up"
-
- # Start the VM
- exec $CMD -- ${1+"$@"}
- ;;
-
- foreground)
- # start up the release in the foreground for use by runit
- # or other supervision services
-
- BOOTFILE=$SCRIPT
- FOREGROUNDOPTIONS="-noinput +Bd"
-
- # Setup beam-required vars
- ROOTDIR=$RUNNER_BASE_DIR
- BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
- EMU=beam
- PROGNAME=`echo $0 | sed 's/.*\///'`
- CMD="$BINDIR/erlexec $FOREGROUNDOPTIONS -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -config $CONFIG_PATH -args_file $VMARGS_PATH"
- export EMU
- export ROOTDIR
- export BINDIR
- export PROGNAME
-
- # Dump environment info for logging purposes
- echo "Exec: $CMD" -- ${1+"$@"}
- echo "Root: $ROOTDIR"
-
- # Start the VM
- exec $CMD -- ${1+"$@"}
- ;;
- getpid)
- # Get the PID from nodetool
- get_pid
- ES=$?
- if [ "$ES" -ne 0 ] || [ -z $PID ]; then
- exit $ES
- fi
- echo $PID
- ;;
- *)
- echo "Usage: $SCRIPT {start|start_boot <file>|foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot <file>|attach|remote_console|upgrade}"
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/src/rebar/test/upgrade_project/rel/files/erl b/src/rebar/test/upgrade_project/rel/files/erl
deleted file mode 100755
index f4c63afbb..000000000
--- a/src/rebar/test/upgrade_project/rel/files/erl
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
-if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
- POSIX_SHELL="true"
- export POSIX_SHELL
- exec /usr/bin/ksh $0 "$@"
-fi
-
-# clear it so if we invoke other scripts, they run as ksh as well
-unset POSIX_SHELL
-
-## This script replaces the default "erl" in erts-VSN/bin. This is
-## necessary as escript depends on erl and in turn, erl depends on
-## having access to a bootscript (start.boot). Note that this script
-## is ONLY invoked as a side-effect of running escript -- the embedded
-## node bypasses erl and uses erlexec directly (as it should).
-##
-## Note that this script makes the assumption that there is a
-## start_clean.boot file available in $ROOTDIR/release/VSN.
-
-# Determine the abspath of where this script is executing from.
-ERTS_BIN_DIR=$(cd ${0%/*} && pwd -P)
-
-# Now determine the root directory -- this script runs from erts-VSN/bin,
-# so we simply need to strip off two dirs from the end of the ERTS_BIN_DIR
-# path.
-ROOTDIR=${ERTS_BIN_DIR%/*/*}
-
-# Parse out release and erts info
-START_ERL=`cat $ROOTDIR/releases/start_erl.data`
-ERTS_VSN=${START_ERL% *}
-APP_VSN=${START_ERL#* }
-
-BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
-EMU=beam
-PROGNAME=`echo $0 | sed 's/.*\\///'`
-CMD="$BINDIR/erlexec"
-export EMU
-export ROOTDIR
-export BINDIR
-export PROGNAME
-
-exec $CMD -boot $ROOTDIR/releases/$APP_VSN/start_clean ${1+"$@"}
diff --git a/src/rebar/test/upgrade_project/rel/files/nodetool b/src/rebar/test/upgrade_project/rel/files/nodetool
deleted file mode 100644
index ce06c6a8d..000000000
--- a/src/rebar/test/upgrade_project/rel/files/nodetool
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/usr/bin/env escript
-%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ft=erlang ts=4 sw=4 et
-%% -------------------------------------------------------------------
-%%
-%% nodetool: Helper Script for interacting with live nodes
-%%
-%% -------------------------------------------------------------------
-main(Args) ->
- ok = start_epmd(),
- %% Extract the args
- {RestArgs, TargetNode} = process_args(Args, [], undefined),
-
- %% any commands that don't need a running node
- case RestArgs of
- ["chkconfig", File] ->
- case file:consult(File) of
- {ok, _} ->
- io:format("ok\n"),
- halt(0);
- {error, {Line, Mod, Term}} ->
- io:format(standard_error, ["Error on line ",
- file:format_error({Line, Mod, Term}), "\n"], []),
- halt(1);
- {error, R} ->
- io:format(standard_error, ["Error reading config file: ",
- file:format_error(R), "\n"], []),
- halt(1)
- end;
- _ ->
- ok
- end,
-
- %% See if the node is currently running -- if it's not, we'll bail
- case {net_kernel:hidden_connect_node(TargetNode),
- net_adm:ping(TargetNode)} of
- {true, pong} ->
- ok;
- {false,pong} ->
- io:format("Failed to connect to node ~p .\n", [TargetNode]),
- halt(1);
- {_, pang} ->
- io:format("Node ~p not responding to pings.\n", [TargetNode]),
- halt(1)
- end,
-
- case RestArgs of
- ["getpid"] ->
- io:format("~p\n",
- [list_to_integer(rpc:call(TargetNode, os, getpid, []))]);
- ["ping"] ->
- %% If we got this far, the node already responsed to a
- %% ping, so just dump a "pong"
- io:format("pong\n");
- ["stop"] ->
- io:format("~p\n", [rpc:call(TargetNode, init, stop, [], 60000)]);
- ["restart"] ->
- io:format("~p\n", [rpc:call(TargetNode, init, restart, [], 60000)]);
- ["reboot"] ->
- io:format("~p\n", [rpc:call(TargetNode, init, reboot, [], 60000)]);
- ["rpc", Module, Function | RpcArgs] ->
- case rpc:call(TargetNode,
- list_to_atom(Module),
- list_to_atom(Function),
- [RpcArgs], 60000) of
- ok ->
- ok;
- {badrpc, Reason} ->
- io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
- halt(1);
- _ ->
- halt(1)
- end;
- ["rpc_infinity", Module, Function | RpcArgs] ->
- case rpc:call(TargetNode,
- list_to_atom(Module),
- list_to_atom(Function),
- [RpcArgs], infinity) of
- ok ->
- ok;
- {badrpc, Reason} ->
- io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
- halt(1);
- _ ->
- halt(1)
- end;
- ["rpcterms", Module, Function, ArgsAsString] ->
- case rpc:call(TargetNode,
- list_to_atom(Module),
- list_to_atom(Function),
- consult(ArgsAsString), 60000) of
- {badrpc, Reason} ->
- io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]),
- halt(1);
- Other ->
- io:format("~p\n", [Other])
- end;
- Other ->
- io:format("Other: ~p\n", [Other]),
- io:format("Usage: nodetool {chkconfig|getpid|ping|stop|restart|reboot|rpc|rpc_infinity|rpcterms}\n")
- end,
- net_kernel:stop().
-
-process_args([], Acc, TargetNode) ->
- {lists:reverse(Acc), TargetNode};
-process_args(["-setcookie", Cookie | Rest], Acc, TargetNode) ->
- erlang:set_cookie(node(), list_to_atom(Cookie)),
- process_args(Rest, Acc, TargetNode);
-process_args(["-name", TargetName | Rest], Acc, _) ->
- ThisNode = append_node_suffix(TargetName, "_maint_"),
- {ok, _} = net_kernel:start([ThisNode, longnames]),
- process_args(Rest, Acc, nodename(TargetName));
-process_args(["-sname", TargetName | Rest], Acc, _) ->
- ThisNode = append_node_suffix(TargetName, "_maint_"),
- {ok, _} = net_kernel:start([ThisNode, shortnames]),
- process_args(Rest, Acc, nodename(TargetName));
-process_args([Arg | Rest], Acc, Opts) ->
- process_args(Rest, [Arg | Acc], Opts).
-
-
-start_epmd() ->
- [] = os:cmd(epmd_path() ++ " -daemon"),
- ok.
-
-epmd_path() ->
- ErtsBinDir = filename:dirname(escript:script_name()),
- Name = "epmd",
- case os:find_executable(Name, ErtsBinDir) of
- false ->
- case os:find_executable(Name) of
- false ->
- io:format("Could not find epmd.~n"),
- halt(1);
- GlobalEpmd ->
- GlobalEpmd
- end;
- Epmd ->
- Epmd
- end.
-
-
-nodename(Name) ->
- case string:tokens(Name, "@") of
- [_Node, _Host] ->
- list_to_atom(Name);
- [Node] ->
- [_, Host] = string:tokens(atom_to_list(node()), "@"),
- list_to_atom(lists:concat([Node, "@", Host]))
- end.
-
-append_node_suffix(Name, Suffix) ->
- case string:tokens(Name, "@") of
- [Node, Host] ->
- list_to_atom(lists:concat([Node, Suffix, os:getpid(), "@", Host]));
- [Node] ->
- list_to_atom(lists:concat([Node, Suffix, os:getpid()]))
- end.
-
-
-%%
-%% Given a string or binary, parse it into a list of terms, ala file:consult/0
-%%
-consult(Str) when is_list(Str) ->
- consult([], Str, []);
-consult(Bin) when is_binary(Bin)->
- consult([], binary_to_list(Bin), []).
-
-consult(Cont, Str, Acc) ->
- case erl_scan:tokens(Cont, Str, 0) of
- {done, Result, Remaining} ->
- case Result of
- {ok, Tokens, _} ->
- {ok, Term} = erl_parse:parse_term(Tokens),
- consult([], Remaining, [Term | Acc]);
- {eof, _Other} ->
- lists:reverse(Acc);
- {error, Info, _} ->
- {error, Info}
- end;
- {more, Cont1} ->
- consult(Cont1, eof, Acc)
- end.
diff --git a/src/rebar/test/upgrade_project/rel/files/sys.config b/src/rebar/test/upgrade_project/rel/files/sys.config
deleted file mode 100644
index 3b7f6bd1d..000000000
--- a/src/rebar/test/upgrade_project/rel/files/sys.config
+++ /dev/null
@@ -1,11 +0,0 @@
-[
- %% SASL config
- {sasl, [
- {sasl_error_logger, {file, "log/sasl-error.log"}},
- {errlog_type, error},
- {error_logger_mf_dir, "log/sasl"}, % Log directory
- {error_logger_mf_maxbytes, 10485760}, % 10 MB max file size
- {error_logger_mf_maxfiles, 5} % 5 files max
- ]}
-].
-
diff --git a/src/rebar/test/upgrade_project/rel/files/vm.args b/src/rebar/test/upgrade_project/rel/files/vm.args
deleted file mode 100644
index a9aeb643b..000000000
--- a/src/rebar/test/upgrade_project/rel/files/vm.args
+++ /dev/null
@@ -1,19 +0,0 @@
-## Name of the node
--name dummy@127.0.0.1
-
-## Cookie for distributed erlang
--setcookie dummy
-
-## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
-## (Disabled by default..use with caution!)
-##-heart
-
-## Enable kernel poll and a few async threads
-##+K true
-##+A 5
-
-## Increase number of concurrent ports/sockets
-##-env ERL_MAX_PORTS 4096
-
-## Tweak GC to run more often
-##-env ERL_FULLSWEEP_AFTER 10
diff --git a/src/rebar/test/upgrade_project/rel/reltool.config b/src/rebar/test/upgrade_project/rel/reltool.config
deleted file mode 100644
index b691c77e7..000000000
--- a/src/rebar/test/upgrade_project/rel/reltool.config
+++ /dev/null
@@ -1,27 +0,0 @@
-{sys, [
- {lib_dirs, ["../apps"]},
- {rel, "dummy", "0.1", [
- kernel,
- stdlib,
- sasl,
- dummy
- ]},
- {rel, "start_clean", "", [kernel, stdlib]},
- {boot_rel, "dummy"},
- {profile, embedded},
- {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)"]},
- {excl_archive_filters, [".*"]},
-
- {app, hipe, [{incl_cond, exclude}]},
-
- {app, dummy, [{incl_cond, include}]}
-]}.
-
-{overlay, [
- {mkdir, "log/sasl"},
- {copy, "files/erl", "{{erts_vsn}}/bin/erl"},
- {copy, "files/nodetool", "{{erts_vsn}}/bin/nodetool"},
- {copy, "files/dummy", "bin/dummy"},
- {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
- {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"}
- ]}.
diff --git a/src/rexi/.gitignore b/src/rexi/.gitignore
deleted file mode 100644
index 4f2f0404d..000000000
--- a/src/rexi/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# building
-ebin
-.eunit
-logs
-*.spec
-deps
-*.beam
-
diff --git a/src/rexi/Makefile.am b/src/rexi/Makefile.am
deleted file mode 100644
index e6586277d..000000000
--- a/src/rexi/Makefile.am
+++ /dev/null
@@ -1,48 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-rexiebindir = $(localerlanglibdir)/rexi/ebin
-
-rexiebin_DATA = $(compiled_files)
-
-source_files = \
- src/rexi.app.src \
- src/rexi.erl \
- src/rexi_app.erl \
- src/rexi_gov_manager.erl \
- src/rexi_governor.erl \
- src/rexi_monitor.erl \
- src/rexi_server.erl \
- src/rexi_sup.erl \
- src/rexi_utils.erl
-
-compiled_files = \
- ebin/rexi.app \
- ebin/rexi.beam \
- ebin/rexi_app.beam \
- ebin/rexi_gov_manager.beam \
- ebin/rexi_governor.beam \
- ebin/rexi_monitor.beam \
- ebin/rexi_server.beam \
- ebin/rexi_sup.beam \
- ebin/rexi_utils.beam
-
-EXTRA_DIST = $(source_files)
-CLEANFILES = $(compiled_files)
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" < $< > $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/rexi/src/rexi.app.src b/src/rexi/src/rexi.app.src
index c9af9d06a..0691edd67 100644
--- a/src/rexi/src/rexi.app.src
+++ b/src/rexi/src/rexi.app.src
@@ -12,7 +12,7 @@
{application, rexi, [
{description, "Lightweight RPC server"},
- {vsn, "%version%"},
+ {vsn, git},
{modules, [
rexi,
rexi_app,
diff --git a/src/snappy/Makefile.am b/src/snappy/Makefile.am
deleted file mode 100644
index baa4f6803..000000000
--- a/src/snappy/Makefile.am
+++ /dev/null
@@ -1,40 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-SUBDIRS = c_src
-
-snappyebindir = $(localerlanglibdir)/snappy-1.0.5/ebin
-
-snappy_file_collection = \
- src/snappy.app.in \
- src/snappy.erl
-
-snappyebin_make_generated_file_list = \
- ebin/snappy.app \
- ebin/snappy.beam
-
-snappyebin_DATA = \
- $(snappyebin_make_generated_file_list)
-
-EXTRA_DIST = \
- $(snappy_file_collection)
-
-CLEANFILES = \
- $(snappyebin_make_generated_file_list)
-
-ebin/%.app: src/%.app.in
- @mkdir -p ebin/
- cp $< $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -o ebin/ $(ERLC_FLAGS) $<
diff --git a/src/snappy/c_src/Makefile.am b/src/snappy/c_src/Makefile.am
deleted file mode 100644
index 3a5d6cd90..000000000
--- a/src/snappy/c_src/Makefile.am
+++ /dev/null
@@ -1,58 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-snappyprivdir = $(localerlanglibdir)/snappy-1.0.5/priv
-
-snappy_cxx_srcs = \
- snappy_nif.cc \
- google-snappy/snappy.cc \
- google-snappy/snappy-sinksource.cc \
- google-snappy/snappy-stubs-internal.cc
-
-snappy_cxx_hdrs = \
- erl_nif_compat.h \
- google-snappy/snappy.h \
- google-snappy/snappy-internal.h \
- google-snappy/snappy-sinksource.h \
- google-snappy/snappy-stubs-internal.h \
- google-snappy/snappy-stubs-public.h.in
-
-EXTRA_DIST = \
- google-snappy/AUTHORS \
- google-snappy/COPYING \
- $(snappy_cxx_hdrs)
-
-CLEANFILES = \
- ../priv/snappy_nif.so
-
-if USE_OTP_NIFS
-snappypriv_LTLIBRARIES = snappy_nif.la
-snappy_nif_la_SOURCES = $(snappy_cxx_srcs)
-snappy_nif_la_CXXFLAGS = $(ERLANG_FLAGS)
-snappy_nif_la_LDFLAGS = -module -avoid-version
-
-if WINDOWS
-snappy_nif_la_LDFLAGS += -no-undefined
-snappy_nif_la_CXXFLAGS += -EHsc -Ox
-SNAPPY_SO_NAME = snappy_nif.dll
-else
-SNAPPY_SO_NAME = snappy_nif.so
-endif
-
-
-# This is purely to enable ./utils/run
-../priv/$(SNAPPY_SO_NAME): snappy_nif.la
- @mkdir -p ../priv
- cp .libs/$(SNAPPY_SO_NAME) $@
-
-all: ../priv/$(SNAPPY_SO_NAME)
-endif
diff --git a/src/snappy/src/snappy.app.in b/src/snappy/src/snappy.app.src
index 25d37b5ea..9f3f9a3be 100644
--- a/src/snappy/src/snappy.app.in
+++ b/src/snappy/src/snappy.app.src
@@ -1,7 +1,7 @@
{application, snappy,
[
{description, "snappy compressor/decompressor Erlang NIF wrapper"},
- {vsn, "1.0.5"},
+ {vsn, git},
{registered, []},
{applications, [
kernel,
diff --git a/src/twig/.gitignore b/src/twig/.gitignore
deleted file mode 100644
index 6308d7c6c..000000000
--- a/src/twig/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-ebin
-src/.*.swp
-.project
diff --git a/src/twig/Makefile.am b/src/twig/Makefile.am
deleted file mode 100644
index 8832ce1aa..000000000
--- a/src/twig/Makefile.am
+++ /dev/null
@@ -1,49 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy
-## of the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-twigebindir = $(localerlanglibdir)/twig/ebin
-
-twigebin_DATA = $(compiled_files)
-
-include_files = \
- twig_int.hrl
-
-source_files = \
- src/twig.app.src \
- src/twig.erl \
- src/twig_app.erl \
- src/twig_event_handler.erl \
- src/twig_monitor.erl \
- src/twig_sup.erl \
- src/twig_util.erl \
- src/trunc_io.erl
-
-compiled_files = \
- ebin/twig.app \
- ebin/twig.beam \
- ebin/twig_app.beam \
- ebin/twig_event_handler.beam \
- ebin/twig_monitor.beam \
- ebin/twig_sup.beam \
- ebin/twig_util.beam \
- ebin/trunc_io.beam
-
-EXTRA_DIST = $(include_files) $(source_files)
-CLEANFILES = $(compiled_files)
-
-ebin/%.app: src/%.app.src
- @mkdir -p ebin/
- sed -e "s|%version%|@version@|g" < $< > $@
-
-ebin/%.beam: src/%.erl
- @mkdir -p ebin/
- $(ERLC) -Wall -I$(top_srcdir)/src -o ebin/ $(ERLC_FLAGS) $<
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index 7c70a5a28..000000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-SUBDIRS = bench etap javascript view_server
-EXTRA_DIST = random_port.ini
-
diff --git a/test/bench/Makefile.am b/test/bench/Makefile.am
deleted file mode 100644
index ce39c4b0a..000000000
--- a/test/bench/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-EXTRA_DIST = benchbulk.sh bench_marks.js run.tpl
-
-noinst_SCRIPTS = run
-CLEANFILES = run
-
-run: run.tpl
- sed -e "s|%abs_top_srcdir%|$(abs_top_srcdir)|" \
- -e "s|%abs_top_builddir%|$(abs_top_builddir)|" \
- < $< > $@
- chmod +x $@
diff --git a/test/etap/Makefile.am b/test/etap/Makefile.am
deleted file mode 100644
index c0928056e..000000000
--- a/test/etap/Makefile.am
+++ /dev/null
@@ -1,96 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-noinst_SCRIPTS = run
-noinst_DATA = etap.beam test_util.beam test_web.beam
-
-noinst_PROGRAMS = test_cfg_register
-test_cfg_register_SOURCES = test_cfg_register.c
-test_cfg_register_CFLAGS = -D_BSD_SOURCE
-
-%.beam: %.erl
- $(ERLC) $<
-
-run: run.tpl
- sed -e "s|%abs_top_srcdir%|@abs_top_srcdir@|g" \
- -e "s|%abs_top_builddir%|@abs_top_builddir@|g" > \
- $@ < $<
- chmod +x $@
-
-# @@ wildcards are NOT portable, please replace with clean-local rules
-CLEANFILES = run *.beam
-DISTCLEANFILES = temp.*
-
-EXTRA_DIST = \
- run.tpl \
- test_web.erl \
- 001-load.t \
- 002-icu-driver.t \
- 010-file-basics.t \
- 011-file-headers.t \
- 020-btree-basics.t \
- 021-btree-reductions.t \
- 030-doc-from-json.t \
- 031-doc-to-json.t \
- 040-util.t \
- 041-uuid-gen-id.ini \
- 041-uuid-gen-seq.ini \
- 041-uuid-gen-utc.ini \
- 041-uuid-gen.t \
- 042-work-queue.t \
- 050-stream.t \
- 060-kt-merging.t \
- 061-kt-missing-leaves.t \
- 062-kt-remove-leaves.t \
- 063-kt-get-leaves.t \
- 064-kt-counting.t \
- 065-kt-stemming.t \
- 070-couch-db.t \
- 072-cleanup.t \
- 073-changes.t \
- 074-doc-update-conflicts.t \
- 075-auth-cache.t \
- 076-file-compression.t \
- 080-config-get-set.t \
- 081-config-override.1.ini \
- 081-config-override.2.ini \
- 081-config-override.t \
- 082-config-register.t \
- 083-config-no-files.t \
- 090-task-status.t \
- 100-ref-counter.t \
- 120-stats-collect.t \
- 121-stats-aggregates.cfg \
- 121-stats-aggregates.ini \
- 121-stats-aggregates.t \
- 130-attachments-md5.t \
- 140-attachment-comp.t \
- 150-invalid-view-seq.t \
- 160-vhosts.t \
- 170-os-daemons.es \
- 170-os-daemons.t \
- 171-os-daemons-config.es \
- 171-os-daemons-config.t \
- 172-os-daemon-errors.1.sh \
- 172-os-daemon-errors.2.sh \
- 172-os-daemon-errors.3.sh \
- 172-os-daemon-errors.4.sh \
- 172-os-daemon-errors.t \
- 173-os-daemon-cfg-register.t \
- 180-http-proxy.ini \
- 180-http-proxy.t \
- 190-json-stream-parse.t \
- 200-view-group-no-db-leaks.t \
- 201-view-group-shutdown.t \
- 210-os-proc-pool.t \
- 220-compaction-daemon.t \
- 231-cors.t
diff --git a/test/javascript/Makefile.am b/test/javascript/Makefile.am
deleted file mode 100644
index d7367e0d2..000000000
--- a/test/javascript/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-EXTRA_DIST = \
- cli_runner.js \
- couch_http.js \
- run.tpl
-
-noinst_SCRIPTS = run
-CLEANFILES = run
-
-run: run.tpl
- sed -e "s|%abs_top_srcdir%|$(abs_top_srcdir)|" \
- -e "s|%abs_top_builddir%|$(abs_top_builddir)|" \
- -e "s|%localstaterundir%|$(abs_top_builddir)/tmp/run|g" \
- < $< > $@
- chmod +x $@
diff --git a/test/view_server/Makefile.am b/test/view_server/Makefile.am
deleted file mode 100644
index 11e7feb4f..000000000
--- a/test/view_server/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-EXTRA_DIST = \
- query_server_spec.rb \
- run_native_process.es
diff --git a/utils/Makefile.am b/utils/Makefile.am
deleted file mode 100644
index eb8ec4335..000000000
--- a/utils/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-noinst_SCRIPTS = run
-
-CLEANFILES = $(noinst_SCRIPTS)
-
-transform = @program_transform_name@
-couchdb_command_name = `echo couchdb | sed '$(transform)'`
-
-run: ../bin/couchdb.tpl
- sed -e "s|%ERL%|$(ERL)|g" \
- -e "s|%ICU_CONFIG%|$(ICU_CONFIG)|g" \
- -e "s|%bindir%|$(abs_top_builddir)/bin|g" \
- -e "s|%defaultini%|default_dev.ini|g" \
- -e "s|%localini%|local_dev.ini|g" \
- -e "s|%localerlanglibdir%|$(abs_top_builddir)\/src|g" \
- -e "s|%localconfdir%|$(abs_top_builddir)/etc/couchdb|g" \
- -e "s|%localstatelogdir%|$(abs_top_builddir)/tmp/log|g" \
- -e "s|%localstatelibdir%|$(abs_top_builddir)/tmp/lib|g" \
- -e "s|%localstatedir%|$(abs_top_builddir)/tmp|g" \
- -e "s|%bug_uri%|@bug_uri@|g" \
- -e "s|%package_author_address%|@package_author_address@|g" \
- -e "s|%package_author_name%|@package_author_name@|g" \
- -e "s|%package_name%|@package_name@|g" \
- -e "s|%version%|@version@|g" \
- -e "s|%couchdb_command_name%|$(couchdb_command_name)|g" > \
- $@ < $<
- chmod +x $@
diff --git a/var/Makefile.am b/var/Makefile.am
deleted file mode 100644
index 901ab2b7c..000000000
--- a/var/Makefile.am
+++ /dev/null
@@ -1,23 +0,0 @@
-## Licensed under the Apache License, Version 2.0 (the "License"); you may not
-## use this file except in compliance with the License. You may obtain a copy of
-## the License at
-##
-## http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-## License for the specific language governing permissions and limitations under
-## the License.
-
-install-data-hook:
- if test ! "$(mkdir_p)" = ""; then \
- $(mkdir_p) "$(DESTDIR)$(localstatelibdir)"; \
- $(mkdir_p) "$(DESTDIR)$(localstatelogdir)"; \
- $(mkdir_p) "$(DESTDIR)$(localstaterundir)"; \
- else \
- echo "WARNING: You may have to create these directories by hand."; \
- mkdir -p "$(DESTDIR)$(localstatelibdir)"; \
- mkdir -p "$(DESTDIR)$(localstatelogdir)"; \
- mkdir -p "$(DESTDIR)$(localstaterundir)"; \
- fi