Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
804db89e99 | ||
|
97c0e95ba1 | ||
|
c3d77ebda6 | ||
|
f52a72f05f | ||
|
d95db754dd | ||
|
2b3f6c608c | ||
|
915ee4c8e4 | ||
|
8a2757da9c | ||
|
4d6c5fc2f0 | ||
|
4d9f3c57db | ||
|
a537e470a7 | ||
|
2a260a7b1f | ||
|
5814a86de3 | ||
|
65089ff906 | ||
|
0c0b0d4175 | ||
|
ec50daad4d | ||
|
42babe1cbe | ||
|
17155b605c | ||
|
9339c89dc5 | ||
|
a19a584c26 | ||
|
6e33339f57 | ||
|
a25d24109d | ||
|
038e536333 | ||
|
776b74cd43 | ||
|
48af4311e1 | ||
|
b29a014600 | ||
|
40b934e12e | ||
|
b2ff9924a2 | ||
|
0648829759 | ||
|
af15b59238 | ||
|
714c2005a9 | ||
|
210f4e36c3 | ||
|
1374258d92 | ||
|
2844867fbf | ||
|
ba87b61fb9 | ||
|
ccc495bdd8 | ||
|
027efcc773 | ||
|
f16f160235 | ||
|
65860ee64e | ||
|
553c57cc8a | ||
|
1cc7cddf13 | ||
|
dbaf4f9156 | ||
|
32804a4c55 | ||
|
6ba0367577 | ||
|
6601a50ee7 | ||
|
bbc5a58a5d |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,2 +1,8 @@
|
||||
/basho-rebar-RELEASE-1-327-g90058c7.tar.gz
|
||||
/basho-rebar-RELEASE-1-821-g635d1a9.tar.gz
|
||||
/basho-rebar-2.0.0-0-g1c98f6c.tar.gz
|
||||
/basho-rebar-2.1.0-pre-0-gebb474b.tar.gz
|
||||
/rebar-5dea85db1b697466586877bed133748bd80fa180.tar.gz
|
||||
/rebar-365ac649dc818619757f96a699ddb174f004cff9.tar.gz
|
||||
/rebar-2.6.1.tar.gz
|
||||
/rebar-2.6.4.tar.gz
|
||||
|
@ -1,48 +1,95 @@
|
||||
%global realname rebar
|
||||
%global upstream basho
|
||||
%global upstream rebar
|
||||
%global debug_package %{nil}
|
||||
%global git_tag 635d1a9
|
||||
%global patchnumber 821
|
||||
|
||||
# Set this to true when starting a rebuild of the whole erlang stack. There's
|
||||
# a cyclical dependency between erlang-rebar and erlang-getopt so this package
|
||||
# (rebar) needs to get built first in bootstrap mode.
|
||||
%global need_bootstrap_set 0
|
||||
|
||||
%{!?need_bootstrap: %global need_bootstrap %{need_bootstrap_set}}
|
||||
|
||||
|
||||
Name: erlang-%{realname}
|
||||
Version: 2
|
||||
Release: 6.20120514git%{git_tag}%{?dist}
|
||||
Version: 2.6.4
|
||||
Release: 7%{?dist}
|
||||
Summary: Erlang Build Tools
|
||||
Group: Development/Tools
|
||||
License: MIT
|
||||
URL: https://github.com/basho/rebar
|
||||
# wget --no-check-certificate --content-disposition https://github.com/basho/rebar/zipball/635d1a9
|
||||
Source0: %{upstream}-%{realname}-RELEASE-1-%{patchnumber}-g%{git_tag}.tar.gz
|
||||
URL: https://github.com/%{upstream}/%{realname}
|
||||
Source0: https://github.com/%{upstream}/%{realname}/archive/%{version}/%{realname}-%{version}.tar.gz
|
||||
Source1: rebar.escript
|
||||
Patch1: rebar-0001-No-need-to-create-bundle.patch
|
||||
# Fedora/EPEL-specific
|
||||
Patch1: rebar-0001-Load-templates-from-the-filesystem-first.patch
|
||||
# Fedora/EPEL-specific
|
||||
Patch2: rebar-0002-Remove-bundled-mustache.patch
|
||||
# The bundled getopt is necessary to do the initial bootstrap since
|
||||
# erlang-getopt requires erlang-rebar to build and vice versa.
|
||||
# Fedora/EPEL-specific
|
||||
Patch3: rebar-0003-Remove-bundled-getopt.patch
|
||||
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
||||
BuildRequires: erlang-erts >= R13B-03
|
||||
# Will be proposed for inclusion
|
||||
Patch4: rebar-0004-Allow-discarding-building-ports.patch
|
||||
# Fedora/EPEL-specific - we're using at least R16B03
|
||||
Patch5: rebar-0005-Remove-any-traces-of-long-time-obsolete-escript-fold.patch
|
||||
Patch6: rebar-0006-remove-abnfc.patch
|
||||
Patch7: rebar-0007-Remove-support-for-gpb-compiler.patch
|
||||
# Fedora/EPEL-specific - we're using at least R16B03
|
||||
Patch8: rebar-0008-Remove-pre-R15B02-workaround.patch
|
||||
# Fedora/EPEL-specific - keep until we dump R16B03-1 and 17.x.y entirely
|
||||
Patch9: rebar-0009-No-such-function-erlang-timestamp-0.patch
|
||||
# Fedora/EPEL-specific - allow vsn variable override
|
||||
Patch10: rebar-0010-Try-shell-variable-VSN-first.patch
|
||||
# Fedora/EPEL-specific - allow overriding missind deps error (versions
|
||||
# mismatch)
|
||||
Patch11: rebar-0011-Allow-ignoring-missing-deps.patch
|
||||
|
||||
%if 0%{?need_bootstrap} < 1
|
||||
BuildRequires: erlang-rebar
|
||||
# FIXME remove later and revisit getopt<->rebar bootstrapping
|
||||
BuildRequires: erlang-getopt
|
||||
%else
|
||||
BuildRequires: erlang-asn1
|
||||
BuildRequires: erlang-common_test
|
||||
BuildRequires: erlang-compiler
|
||||
BuildRequires: erlang-crypto
|
||||
BuildRequires: erlang-dialyzer
|
||||
BuildRequires: erlang-diameter
|
||||
BuildRequires: erlang-edoc
|
||||
BuildRequires: erlang-eflame
|
||||
BuildRequires: erlang-erl_interface
|
||||
BuildRequires: erlang-erlydtl
|
||||
BuildRequires: erlang-erts
|
||||
BuildRequires: erlang-eunit
|
||||
BuildRequires: erlang-getopt
|
||||
BuildRequires: erlang-kernel
|
||||
BuildRequires: erlang-lfe
|
||||
BuildRequires: erlang-mustache
|
||||
BuildRequires: erlang-neotoma
|
||||
BuildRequires: erlang-parsetools
|
||||
BuildRequires: erlang-protobuffs
|
||||
BuildRequires: erlang-reltool
|
||||
#Requires: erlang-abnfc
|
||||
Requires: erlang-asn1
|
||||
Requires: erlang-compiler
|
||||
Requires: erlang-crypto
|
||||
Requires: erlang-dialyzer
|
||||
Requires: erlang-edoc
|
||||
Requires: erlang-erlydtl
|
||||
Requires: erlang-erts
|
||||
Requires: erlang-eunit
|
||||
Requires: erlang-getopt
|
||||
Requires: erlang-kernel
|
||||
Requires: erlang-lfe
|
||||
Requires: erlang-mustache
|
||||
Requires: erlang-neotoma
|
||||
Requires: erlang-protobuffs
|
||||
Requires: erlang-reltool
|
||||
Requires: erlang-snmp
|
||||
Requires: erlang-stdlib
|
||||
Requires: erlang-syntax_tools
|
||||
Requires: erlang-tools
|
||||
BuildRequires: erlang-rpm-macros
|
||||
BuildRequires: erlang-sasl
|
||||
BuildRequires: erlang-snmp
|
||||
BuildRequires: erlang-stdlib
|
||||
BuildRequires: erlang-syntax_tools
|
||||
BuildRequires: erlang-tools
|
||||
%endif
|
||||
|
||||
# FIXME wip
|
||||
#Requires: erlang-abnfc%{?_isa}
|
||||
#Requires: erlang-gpb%{?_isa}
|
||||
|
||||
# This one cannot be picked up automatically
|
||||
# See https://bugzilla.redhat.com/960079
|
||||
Requires: erlang-common_test%{?_isa}
|
||||
# Requires for port compiling - no direct references in Rebar's src/*.erl files
|
||||
Requires: erlang-erl_interface%{?_isa}
|
||||
# This one cannot be picked up automatically
|
||||
# See https://bugzilla.redhat.com/960079
|
||||
Requires: erlang-parsetools%{?_isa}
|
||||
|
||||
Requires: erlang-rpm-macros >= 0.2.4
|
||||
Provides: %{realname} = %{version}-%{release}
|
||||
|
||||
|
||||
@ -51,39 +98,171 @@ Erlang Build Tools.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -n %{upstream}-%{realname}-%{git_tag}
|
||||
%patch1 -p1 -b .no_bundle
|
||||
%setup -q -n %{realname}-%{version}
|
||||
%patch1 -p1 -b .load_templates_from_fs
|
||||
%patch2 -p1 -b .remove_bundled_mustache
|
||||
%if 0%{?need_bootstrap} < 1
|
||||
%patch3 -p1 -b .remove_bundled_getopt
|
||||
%endif
|
||||
%patch4 -p1 -b .allow_discarding_ports
|
||||
%patch5 -p1 -b .remove_escript_foldl_3
|
||||
%patch6 -p1 -b .remove_abnfc
|
||||
%patch7 -p1 -b .remove_gpb
|
||||
%patch8 -p1 -b .remove_pre_R15B02
|
||||
%patch9 -p1 -b .erlang_timestamp_0
|
||||
%patch10 -p1 -b .vsn_override
|
||||
%patch11 -p1 -b .skip_deps_checking
|
||||
|
||||
|
||||
%build
|
||||
%if 0%{?need_bootstrap} < 1
|
||||
%{erlang_compile}
|
||||
%else
|
||||
./bootstrap
|
||||
./rebar compile -v
|
||||
%endif
|
||||
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
install -D -p -m 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/rebar
|
||||
mkdir -p $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/ebin
|
||||
mkdir -p $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/include
|
||||
install -m 644 ebin/%{realname}.app $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/ebin
|
||||
install -m 644 ebin/*.beam $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/ebin
|
||||
install -m 644 include/*.hrl $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/include
|
||||
cp -a priv $RPM_BUILD_ROOT%{_libdir}/erlang/lib/%{realname}-%{version}/
|
||||
%{erlang_install}
|
||||
# Install rebar script itself
|
||||
install -D -p -m 0755 %{SOURCE1} %{buildroot}%{_bindir}/rebar
|
||||
# Copy the contents of priv folder
|
||||
cp -a priv %{buildroot}%{_erllibdir}/%{realname}-%{version}/
|
||||
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
%check
|
||||
%if 0%{?need_bootstrap} < 1
|
||||
# For using during tests
|
||||
install -D -p -m 0755 %{SOURCE1} ./rebar
|
||||
sed -i -e "s,-noshell -noinput,-noshell -noinput -pa .,g" ./rebar
|
||||
%{rebar_eunit}
|
||||
%endif
|
||||
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc THANKS rebar.config.sample
|
||||
%doc README.md THANKS rebar.config.sample
|
||||
%license LICENSE
|
||||
%{_bindir}/rebar
|
||||
%{_libdir}/erlang/lib/%{realname}-%{version}
|
||||
%{erlang_appdir}/
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.4-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.4-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||
|
||||
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.4-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
||||
|
||||
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.4-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||
|
||||
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.4-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
|
||||
|
||||
* Thu Sep 1 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.4-2
|
||||
- Ver. 2.6.4 (rhbz#1350988)
|
||||
- Re-enable upstream behaviour for get-deps (rhbz#999054)
|
||||
- Added erlang-eflame dependency
|
||||
|
||||
* Thu Sep 1 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.4-1
|
||||
- Bootstrap ver. 2.6.4 (rhbz#1350988)
|
||||
- Re-enable upstream behaviour for get-deps (rhbz#999054)
|
||||
- Added erlang-eflame dependency
|
||||
|
||||
* Tue Mar 15 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.1-10
|
||||
- Fixed tests
|
||||
- Fixed incompatibility with a newest erlang-mustache
|
||||
|
||||
* Mon Mar 7 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.1-9
|
||||
- Allow skipping check for apps (not recommended for the end users - we'll use
|
||||
it only during rpm building so we won't introduce this functionality
|
||||
officially).
|
||||
|
||||
* Sun Mar 6 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.1-8
|
||||
- Allow VSN override using shell environment variable of the same name.
|
||||
|
||||
* Thu Mar 3 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.1-7
|
||||
- Re-add erlang-diameter as a BuildRequires again
|
||||
|
||||
* Wed Mar 2 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.1-6
|
||||
- Disable gbp properly
|
||||
|
||||
* Wed Mar 2 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.1-5
|
||||
- Fix dependency issues mentioned by automatic dependency checker
|
||||
|
||||
* Tue Mar 1 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.1-4
|
||||
- Add (Build)Requires which weren't picked up automatically
|
||||
|
||||
* Tue Mar 1 2016 Peter Lemenkov <lemenkov@gmail.com> - 2.6.1-3
|
||||
- Use autogenerated dependency list
|
||||
|
||||
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.1-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||
|
||||
* Thu Dec 31 2015 Filip Andres <filip@andresovi.net> - 2.6.1-1
|
||||
- Update to 2.6.1
|
||||
|
||||
* Fri Jul 03 2015 Filip Andres <filip@andresovi.net> - 2.6.0-1
|
||||
- Update to 2.6.0
|
||||
|
||||
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1.0-0.10
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
|
||||
|
||||
* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1.0-0.9
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
|
||||
|
||||
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1.0-0.8
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
|
||||
|
||||
* Sat Mar 8 2014 Sam Kottler <skottler@fedoraproject.org> - 2.1.0-0.7
|
||||
- Add bootstrap variable and necessary conditionals for building without external getopt
|
||||
|
||||
* Sun Sep 01 2013 Peter Lemenkov <lemenkov@gmail.com> - 2.1.0-0.5
|
||||
- Added missing runtime requirements
|
||||
|
||||
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1.0-0.5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
|
||||
|
||||
* Tue Mar 12 2013 Peter Lemenkov <lemenkov@gmail.com> - 2.1.0-0.4
|
||||
- backported fix for ErlyDTL templates compilation
|
||||
|
||||
* Wed Mar 06 2013 Peter Lemenkov <lemenkov@gmail.com> - 2.1.0-0.3
|
||||
- Don't bootstrap anymore - use rebar for building rebar
|
||||
|
||||
* Sun Mar 03 2013 Peter Lemenkov <lemenkov@gmail.com> - 2.1.0-0.2
|
||||
- Backported fix for suppress building *.so libraries everytime
|
||||
|
||||
* Sat Mar 02 2013 Peter Lemenkov <lemenkov@gmail.com> - 2.1.0-0.1
|
||||
- Ver. 2.1.0-pre
|
||||
- Remove R12B-related patches (EL5-related)
|
||||
|
||||
* Wed Feb 13 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.0-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
|
||||
|
||||
* Tue Dec 18 2012 Peter Lemenkov <lemenkov@gmail.com> - 2.0.0-3
|
||||
- Fix templates
|
||||
|
||||
* Wed Jul 18 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
|
||||
|
||||
* Tue Jun 05 2012 Peter Lemenkov <lemenkov@gmail.com> - 2.0.0-1
|
||||
- Ver. 2.0.0
|
||||
|
||||
* Tue May 22 2012 Peter Lemenkov <lemenkov@gmail.com> - 2-9.20120514git635d1a9
|
||||
- Fix building in EL6 and Fedora
|
||||
|
||||
* Mon May 21 2012 Peter Lemenkov <lemenkov@gmail.com> - 2-8.20120514git635d1a9
|
||||
- Explicitly list erlang-erl_interface as a dependency
|
||||
- Fixed EPEL5 dependencies
|
||||
|
||||
* Sun May 20 2012 Peter Lemenkov <lemenkov@gmail.com> - 2-7.20120514git635d1a9
|
||||
- Enable building on EL5 (remove erlydtl-related stuff on el5)
|
||||
- Remove abnfc-related stff until we package it
|
||||
|
||||
* Wed May 16 2012 Peter Lemenkov <lemenkov@gmail.com> - 2-6.20120514git635d1a9
|
||||
- Updated to the latest git snapshot
|
||||
|
||||
|
25
rebar-0001-Load-templates-from-the-filesystem-first.patch
Normal file
25
rebar-0001-Load-templates-from-the-filesystem-first.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Mon, 4 Mar 2013 19:03:03 +0400
|
||||
Subject: [PATCH] Load templates from the filesystem first.
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
|
||||
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
|
||||
index 085ac1c..7e8554e 100644
|
||||
--- a/src/rebar_templater.erl
|
||||
+++ b/src/rebar_templater.erl
|
||||
@@ -241,12 +241,13 @@ find_escript_templates(Files) ->
|
||||
re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match].
|
||||
|
||||
find_disk_templates(Config) ->
|
||||
+ BaseTemplates = rebar_utils:find_files(code:priv_dir(rebar) ++ "/templates", ?TEMPLATE_RE),
|
||||
OtherTemplates = find_other_templates(Config),
|
||||
HomeTemplates = filename:join([os:getenv("HOME"), ".rebar", "templates"]),
|
||||
HomeFiles = rebar_utils:find_files_by_ext(HomeTemplates, ".template"),
|
||||
Recursive = rebar_config:is_recursive(Config),
|
||||
LocalFiles = rebar_utils:find_files_by_ext(".", ".template", Recursive),
|
||||
- [{file, F} || F <- OtherTemplates ++ HomeFiles ++ LocalFiles].
|
||||
+ [{file, F} || F <- BaseTemplates ++ OtherTemplates ++ HomeFiles ++ LocalFiles].
|
||||
|
||||
find_other_templates(Config) ->
|
||||
case rebar_config:get_global(Config, template_dir, undefined) of
|
@ -1,64 +0,0 @@
|
||||
From 6d7b6dca598f26fa5b46561b851e6b8286a50662 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Tue, 28 Sep 2010 23:04:36 +0400
|
||||
Subject: [PATCH 1/3] No need to create bundle
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
---
|
||||
bootstrap | 40 ----------------------------------------
|
||||
1 file changed, 40 deletions(-)
|
||||
|
||||
diff --git a/bootstrap b/bootstrap
|
||||
index e86ad8e..c4992a7 100755
|
||||
--- a/bootstrap
|
||||
+++ b/bootstrap
|
||||
@@ -52,46 +52,6 @@ main(Args) ->
|
||||
%% Run rebar to do proper .app validation and such
|
||||
rebar:main(["compile"] ++ Args),
|
||||
|
||||
- %% Read the contents of the files in ebin and templates; note that we
|
||||
- %% place all the beam files at the top level of the code archive so
|
||||
- %% that code loading works properly.
|
||||
- Files = load_files("*", "ebin") ++ load_files("priv/templates/*", "."),
|
||||
-
|
||||
- case zip:create("mem", Files, [memory]) of
|
||||
- {ok, {"mem", ZipBin}} ->
|
||||
- %% Archive was successfully created. Prefix that binary with our
|
||||
- %% header and write to "rebar" file.
|
||||
- %% Without -noshell -noinput escript consumes all input that would
|
||||
- %% otherwise go to the shell for the next command.
|
||||
- Script = <<"#!/usr/bin/env escript\n%%! -noshell -noinput\n",
|
||||
- ZipBin/binary>>,
|
||||
- case file:write_file("rebar", Script) of
|
||||
- ok ->
|
||||
- ok;
|
||||
- {error, WriteError} ->
|
||||
- io:format("Failed to write rebar script: ~p\n",
|
||||
- [WriteError]),
|
||||
- halt(1)
|
||||
- end;
|
||||
- {error, ZipError} ->
|
||||
- io:format("Failed to construct rebar script archive: ~p\n",
|
||||
- [ZipError]),
|
||||
- halt(1)
|
||||
- end,
|
||||
-
|
||||
- %% 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"
|
||||
--
|
||||
1.7.10.1
|
||||
|
@ -1,35 +1,26 @@
|
||||
From 844182030976e868e7cd6aa67e891d55db749a65 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Sat, 20 Nov 2010 16:36:45 +0300
|
||||
Subject: [PATCH 2/3] Remove bundled mustache
|
||||
From: Filip Andres <filip@andresovi.net>
|
||||
Date: Fri, 3 Jul 2015 10:46:48 +0200
|
||||
Subject: [PATCH] Remove bundled mustache
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
---
|
||||
ebin/rebar.app | 3 +-
|
||||
src/mustache.erl | 234 ------------------------------------------------------
|
||||
2 files changed, 1 insertion(+), 236 deletions(-)
|
||||
delete mode 100644 src/mustache.erl
|
||||
|
||||
diff --git a/ebin/rebar.app b/ebin/rebar.app
|
||||
index 0c6e4c3..0836c7c 100644
|
||||
index 9449e1e..d3f8e42 100644
|
||||
--- a/ebin/rebar.app
|
||||
+++ b/ebin/rebar.app
|
||||
@@ -35,8 +35,7 @@
|
||||
rebar_upgrade,
|
||||
rebar_utils,
|
||||
@@ -45,7 +45,6 @@
|
||||
rebar_xref,
|
||||
- getopt,
|
||||
- mustache ]},
|
||||
+ getopt ]},
|
||||
rebar_metacmds,
|
||||
rebar_getopt,
|
||||
- rebar_mustache,
|
||||
rmemo,
|
||||
rebar_rand_compat ]},
|
||||
{registered, []},
|
||||
{applications, [kernel,
|
||||
stdlib,
|
||||
diff --git a/src/mustache.erl b/src/mustache.erl
|
||||
diff --git a/src/rebar_mustache.erl b/src/rebar_mustache.erl
|
||||
deleted file mode 100644
|
||||
index ac501a0..0000000
|
||||
--- a/src/mustache.erl
|
||||
index 9016c0f..0000000
|
||||
--- a/src/rebar_mustache.erl
|
||||
+++ /dev/null
|
||||
@@ -1,234 +0,0 @@
|
||||
@@ -1,230 +0,0 @@
|
||||
-%% The MIT License
|
||||
-%%
|
||||
-%% Copyright (c) 2009 Tom Preston-Werner <tom@mojombo.com>
|
||||
@ -55,7 +46,7 @@ index ac501a0..0000000
|
||||
-%% See the README at http://github.com/mojombo/mustache.erl for additional
|
||||
-%% documentation and usage examples.
|
||||
-
|
||||
--module(mustache). %% v0.1.0
|
||||
--module(rebar_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]).
|
||||
-
|
||||
@ -63,9 +54,7 @@ index ac501a0..0000000
|
||||
- section_re = undefined,
|
||||
- tag_re = undefined}).
|
||||
-
|
||||
--ifdef(TEST).
|
||||
--include_lib("eunit/include/eunit.hrl").
|
||||
--endif.
|
||||
--define(MUSTACHE_STR, "rebar_mustache").
|
||||
-
|
||||
-compile(Body) when is_list(Body) ->
|
||||
- State = #mstate{},
|
||||
@ -144,10 +133,10 @@ index ac501a0..0000000
|
||||
- Mod = State#mstate.mod,
|
||||
- Result = compiler(Content, State),
|
||||
- "fun() -> " ++
|
||||
- "case mustache:get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
|
||||
- "true -> " ++
|
||||
- "case " ++ ?MUSTACHE_STR ++ ":get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
|
||||
- "\"true\" -> " ++
|
||||
- Result ++ "; " ++
|
||||
- "false -> " ++
|
||||
- "\"false\" -> " ++
|
||||
- "[]; " ++
|
||||
- "List when is_list(List) -> " ++
|
||||
- "[fun(Ctx) -> " ++ Result ++ " end(dict:merge(CFun, SubCtx, Ctx)) || SubCtx <- List]; " ++
|
||||
@ -179,16 +168,28 @@ index ac501a0..0000000
|
||||
-
|
||||
-compile_tag(none, Content, State) ->
|
||||
- Mod = State#mstate.mod,
|
||||
- "mustache:escape(mustache:get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ "))";
|
||||
- ?MUSTACHE_STR ++ ":escape(" ++ ?MUSTACHE_STR ++ ":get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ "))";
|
||||
-compile_tag("{", Content, State) ->
|
||||
- Mod = State#mstate.mod,
|
||||
- "mustache:get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ ")";
|
||||
- ?MUSTACHE_STR ++ ":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) ->
|
||||
- ModPath = code:which(Mod),
|
||||
- re:replace(ModPath, "\.beam$", ".mustache", [{return, list}]).
|
||||
- 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),
|
||||
@ -250,20 +251,17 @@ index ac501a0..0000000
|
||||
-start([T]) ->
|
||||
- Out = render(list_to_atom(T)),
|
||||
- io:format(Out ++ "~n", []).
|
||||
-
|
||||
--ifdef(TEST).
|
||||
-
|
||||
-simple_test() ->
|
||||
- Ctx = dict:from_list([{name, "world"}]),
|
||||
- Result = render("Hello {{name}}!", Ctx),
|
||||
- ?assertEqual("Hello world!", Result).
|
||||
-
|
||||
-integer_values_too_test() ->
|
||||
- Ctx = dict:from_list([{name, "Chris"}, {value, 10000}]),
|
||||
- Result = render("Hello {{name}}~nYou have just won ${{value}}!", Ctx),
|
||||
- ?assertEqual("Hello Chris~nYou have just won $10000!", Result).
|
||||
-
|
||||
--endif.
|
||||
--
|
||||
1.7.10.1
|
||||
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
|
||||
index 7e8554e..2d20e86 100644
|
||||
--- a/src/rebar_templater.erl
|
||||
+++ b/src/rebar_templater.erl
|
||||
@@ -102,8 +102,7 @@ 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),
|
||||
- rebar_mustache:render(Str1, Context).
|
||||
+ mustache:render(Str0, Context).
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
|
@ -1,35 +1,48 @@
|
||||
From 0915eb1978ebca6d0f89421203d5be6d6b4fdd86 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Sat, 20 Nov 2010 16:40:15 +0300
|
||||
Subject: [PATCH 3/3] Remove bundled getopt
|
||||
From: Filip Andres <filip@andresovi.net>
|
||||
Date: Fri, 3 Jul 2015 10:56:26 +0200
|
||||
Subject: [PATCH] Remove bundled getopt
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
---
|
||||
ebin/rebar.app | 3 +-
|
||||
src/getopt.erl | 621 --------------------------------------------------------
|
||||
2 files changed, 1 insertion(+), 623 deletions(-)
|
||||
delete mode 100644 src/getopt.erl
|
||||
|
||||
diff --git a/ebin/rebar.app b/ebin/rebar.app
|
||||
index 0836c7c..a9dc46d 100644
|
||||
index d3f8e42..986f12f 100644
|
||||
--- a/ebin/rebar.app
|
||||
+++ b/ebin/rebar.app
|
||||
@@ -34,8 +34,7 @@
|
||||
rebar_templater,
|
||||
rebar_upgrade,
|
||||
@@ -44,7 +44,6 @@
|
||||
rebar_utils,
|
||||
- rebar_xref,
|
||||
- getopt ]},
|
||||
+ rebar_xref]},
|
||||
rebar_xref,
|
||||
rebar_metacmds,
|
||||
- rebar_getopt,
|
||||
rmemo,
|
||||
rebar_rand_compat ]},
|
||||
{registered, []},
|
||||
{applications, [kernel,
|
||||
stdlib,
|
||||
diff --git a/src/getopt.erl b/src/getopt.erl
|
||||
diff --git a/src/rebar.erl b/src/rebar.erl
|
||||
index 2eb608d..91593c2 100644
|
||||
--- a/src/rebar.erl
|
||||
+++ b/src/rebar.erl
|
||||
@@ -236,7 +236,7 @@ run_aux(BaseConfig, Commands) ->
|
||||
%%
|
||||
help() ->
|
||||
OptSpecList = option_spec_list(),
|
||||
- rebar_getopt:usage(OptSpecList, "rebar",
|
||||
+ getopt:usage(OptSpecList, "rebar",
|
||||
"[var=value,...] <command,...>",
|
||||
[{"var=value", "rebar global variables (e.g. force=1)"},
|
||||
{"command", "Command to run (e.g. compile)"}]),
|
||||
@@ -301,7 +301,7 @@ help() ->
|
||||
parse_args(RawArgs) ->
|
||||
%% Parse getopt options
|
||||
OptSpecList = option_spec_list(),
|
||||
- case rebar_getopt:parse(OptSpecList, RawArgs) of
|
||||
+ case getopt:parse(OptSpecList, RawArgs) of
|
||||
{ok, Args} ->
|
||||
Args;
|
||||
{error, {Reason, Data}} ->
|
||||
diff --git a/src/rebar_getopt.erl b/src/rebar_getopt.erl
|
||||
deleted file mode 100644
|
||||
index 175b7a5..0000000
|
||||
--- a/src/getopt.erl
|
||||
index 79b871d..0000000
|
||||
--- a/src/rebar_getopt.erl
|
||||
+++ /dev/null
|
||||
@@ -1,621 +0,0 @@
|
||||
@@ -1,914 +0,0 @@
|
||||
-%%%-------------------------------------------------------------------
|
||||
-%%% @author Juan Jose Comellas <juanjo@comellas.org>
|
||||
-%%% @copyright (C) 2009 Juan Jose Comellas
|
||||
@ -40,22 +53,15 @@ index 175b7a5..0000000
|
||||
-%%% 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).
|
||||
--module(rebar_getopt).
|
||||
--author('juanjo@comellas.org').
|
||||
-
|
||||
--export([parse/2, usage/2, usage/3, usage/4]).
|
||||
--export([parse/2, check/2, parse_and_check/2, format_error/2,
|
||||
- usage/2, usage/3, usage/4, tokenize/1]).
|
||||
--export([usage_cmd_line/2]).
|
||||
-
|
||||
--export_type([arg_type/0,
|
||||
- arg_value/0,
|
||||
- arg_spec/0,
|
||||
- simple_option/0,
|
||||
- compound_option/0,
|
||||
- option/0,
|
||||
- option_spec/0]).
|
||||
-
|
||||
--define(TAB_LENGTH, 8).
|
||||
-%% Indentation of the help messages in number of tabs.
|
||||
--define(INDENTATION, 3).
|
||||
--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).
|
||||
@ -65,7 +71,8 @@ index 175b7a5..0000000
|
||||
--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'.
|
||||
@ -88,19 +95,65 @@ index 175b7a5..0000000
|
||||
-%% 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. Additionally perform check if all required options (the ones
|
||||
-%% without default values) are present. The function is a combination of
|
||||
-%% two calls: parse/2 and check/2.
|
||||
--spec parse_and_check([option_spec()], string() | [string()]) ->
|
||||
- {ok, {[option()], [string()]}} | {error, {Reason :: atom(), Data :: term()}}.
|
||||
-parse_and_check(OptSpecList, CmdLine) when is_list(OptSpecList), is_list(CmdLine) ->
|
||||
- case parse(OptSpecList, CmdLine) of
|
||||
- {ok, {Opts, _}} = Result ->
|
||||
- case check(OptSpecList, Opts) of
|
||||
- ok -> Result;
|
||||
- Error -> Error
|
||||
- end;
|
||||
- Error ->
|
||||
- Error
|
||||
- end.
|
||||
-
|
||||
-%% @doc Check the parsed command line arguments returning ok if all required
|
||||
-%% options (i.e. that don't have defaults) are present, and returning
|
||||
-%% error otherwise.
|
||||
--spec check([option_spec()], [option()]) ->
|
||||
- ok | {error, {Reason :: atom(), Option :: atom()}}.
|
||||
-check(OptSpecList, ParsedOpts) when is_list(OptSpecList), is_list(ParsedOpts) ->
|
||||
- try
|
||||
- RequiredOpts = [Name || {Name, _, _, Arg, _} <- OptSpecList,
|
||||
- not is_tuple(Arg) andalso Arg =/= undefined],
|
||||
- lists:foreach(fun (Option) ->
|
||||
- case proplists:is_defined(Option, ParsedOpts) of
|
||||
- true ->
|
||||
- ok;
|
||||
- false ->
|
||||
- throw({error, {missing_required_option, Option}})
|
||||
- end
|
||||
- end, RequiredOpts)
|
||||
- catch
|
||||
- _:Error ->
|
||||
- Error
|
||||
- end.
|
||||
-
|
||||
-
|
||||
-%% @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) ->
|
||||
- {ok, {[option()], [string()]}} | {error, {Reason :: atom(), Data :: term()}}.
|
||||
-parse(OptSpecList, CmdLine) when is_list(CmdLine) ->
|
||||
- try
|
||||
- Args = if
|
||||
- is_integer(hd(CmdLine)) ->
|
||||
- string:tokens(CmdLine, " \t\n");
|
||||
- true ->
|
||||
- CmdLine
|
||||
- is_integer(hd(CmdLine)) -> tokenize(CmdLine);
|
||||
- true -> CmdLine
|
||||
- end,
|
||||
- parse(OptSpecList, [], [], 0, Args)
|
||||
- catch
|
||||
@ -135,6 +188,24 @@ index 175b7a5..0000000
|
||||
- {ok, {lists:reverse(append_default_options(OptSpecList, OptAcc)), lists:reverse(ArgAcc)}}.
|
||||
-
|
||||
-
|
||||
-%% @doc Format the error code returned by prior call to parse/2 or check/2.
|
||||
--spec format_error([option_spec()], {error, {Reason :: atom(), Data :: term()}} |
|
||||
- {Reason :: term(), Data :: term()}) -> string().
|
||||
-format_error(OptSpecList, {error, Reason}) ->
|
||||
- format_error(OptSpecList, Reason);
|
||||
-format_error(OptSpecList, {missing_required_option, Name}) ->
|
||||
- {_Name, Short, Long, _Type, _Help} = lists:keyfind(Name, 1, OptSpecList),
|
||||
- lists:flatten(["missing required option: -", [Short], " (", to_string(Long), ")"]);
|
||||
-format_error(_OptSpecList, {invalid_option, OptStr}) ->
|
||||
- lists:flatten(["invalid option: ", to_string(OptStr)]);
|
||||
-format_error(_OptSpecList, {invalid_option_arg, {Name, Arg}}) ->
|
||||
- lists:flatten(["option \'", to_string(Name) ++ "\' has invalid argument: ", to_string(Arg)]);
|
||||
-format_error(_OptSpecList, {invalid_option_arg, OptStr}) ->
|
||||
- lists:flatten(["invalid option argument: ", to_string(OptStr)]);
|
||||
-format_error(_OptSpecList, {Reason, Data}) ->
|
||||
- lists:flatten([to_string(Reason), " ", to_string(Data)]).
|
||||
-
|
||||
-
|
||||
-%% @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:
|
||||
@ -509,8 +580,8 @@ index 175b7a5..0000000
|
||||
-%% 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, "Usage: ~s~s~n~n~s~n",
|
||||
- [ProgramName, usage_cmd_line(OptSpecList), usage_options(OptSpecList)]);
|
||||
- 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.
|
||||
@ -521,10 +592,10 @@ index 175b7a5..0000000
|
||||
-%% @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()], string(), string(), output_stream() | [{string(), string()}]) -> ok.
|
||||
--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, "Usage: ~s~s ~s~n~n~s~n",
|
||||
- [ProgramName, usage_cmd_line(OptSpecList), CmdLineTail, usage_options(OptSpecList)]);
|
||||
- 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
|
||||
@ -537,120 +608,352 @@ index 175b7a5..0000000
|
||||
-%% 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()], string(), string(), [{string(), string()}], output_stream()) -> ok.
|
||||
--spec usage([option_spec()], ProgramName :: string(), CmdLineTail :: string(),
|
||||
- [{OptionName :: string(), Help :: string()}], output_stream()) -> ok.
|
||||
-usage(OptSpecList, ProgramName, CmdLineTail, OptionsTail, OutputStream) ->
|
||||
- UsageOptions = lists:foldl(
|
||||
- fun ({Prefix, Help}, Acc) ->
|
||||
- add_option_help(Prefix, Help, Acc)
|
||||
- end, usage_options_reverse(OptSpecList, []), OptionsTail),
|
||||
- io:format(OutputStream, "Usage: ~s~s ~s~n~n~s~n",
|
||||
- [ProgramName, usage_cmd_line(OptSpecList), CmdLineTail,
|
||||
- lists:flatten(lists:reverse(UsageOptions))]).
|
||||
- io:format(OutputStream, "~s~n~n~s~n",
|
||||
- [usage_cmd_line(ProgramName, OptSpecList, CmdLineTail), usage_options(OptSpecList, OptionsTail)]).
|
||||
-
|
||||
-
|
||||
-%% @doc Return a string with the syntax for the command line options and
|
||||
-%% arguments.
|
||||
--spec usage_cmd_line([option_spec()]) -> string().
|
||||
-usage_cmd_line(OptSpecList) ->
|
||||
- usage_cmd_line(OptSpecList, []).
|
||||
--spec usage_cmd_line(ProgramName :: string(), [option_spec()]) -> iolist().
|
||||
-usage_cmd_line(ProgramName, OptSpecList) ->
|
||||
- usage_cmd_line(ProgramName, OptSpecList, "").
|
||||
-
|
||||
-usage_cmd_line([{Name, Short, Long, ArgSpec, _Help} | Tail], Acc) ->
|
||||
- CmdLine =
|
||||
- case ArgSpec of
|
||||
- undefined ->
|
||||
--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
|
||||
- %% For options with short form and no argument.
|
||||
- Short =/= undefined ->
|
||||
- [$\s, $[, $-, Short, $]];
|
||||
- %% For options with only long form and no argument.
|
||||
- Long =/= undefined ->
|
||||
- [$\s, $[, $-, $-, Long, $]];
|
||||
- (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 ->
|
||||
- [$\s, $[, $-, Short, $\s, $<, atom_to_list(Name), $>, $]];
|
||||
- Short =/= undefined -> [$[, $-, Short, $\s, $<, atom_to_list(Name), $>, $]];
|
||||
- %% For options with only long form and argument.
|
||||
- Long =/= undefined ->
|
||||
- [$\s, $[, $-, $-, Long, $\s, $<, atom_to_list(Name), $>, $]];
|
||||
- Long =/= undefined -> [$[, $-, $-, Long, $\s, $<, atom_to_list(Name), $>, $]];
|
||||
- %% For options with neither short nor long form and argument.
|
||||
- true ->
|
||||
- [$\s, $<, atom_to_list(Name), $>]
|
||||
- end
|
||||
- end,
|
||||
- usage_cmd_line(Tail, [CmdLine | Acc]);
|
||||
-usage_cmd_line([], Acc) ->
|
||||
- lists:flatten(lists:reverse(Acc)).
|
||||
- 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 string with the help message for each of the options and
|
||||
-%% arguments.
|
||||
--spec usage_options([option_spec()]) -> string().
|
||||
-%% @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) ->
|
||||
- lists:flatten(lists:reverse(usage_options_reverse(OptSpecList, []))).
|
||||
- usage_options(OptSpecList, []).
|
||||
-
|
||||
-usage_options_reverse([{Name, Short, Long, _ArgSpec, Help} | Tail], Acc) ->
|
||||
- Prefix =
|
||||
- case Long of
|
||||
- undefined ->
|
||||
- case Short of
|
||||
-
|
||||
-%% @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).
|
||||
- undefined ->
|
||||
- [$<, atom_to_list(Name), $>];
|
||||
- "<" ++ atom_to_list(Name) ++ ">";
|
||||
-usage_option_text({_Name, Short, undefined, _ArgSpec, _Help}) ->
|
||||
- %% Only short form.
|
||||
- _ ->
|
||||
- [$-, Short]
|
||||
- end;
|
||||
- _ ->
|
||||
- case Short of
|
||||
- [$-, Short];
|
||||
-usage_option_text({_Name, undefined, Long, _ArgSpec, _Help}) ->
|
||||
- %% Only long form.
|
||||
- undefined ->
|
||||
- [$-, $- | 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 Length 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);
|
||||
- _ ->
|
||||
- [$-, Short, $,, $\s, $-, $- | Long]
|
||||
- end
|
||||
- {[], CurrentLineAcc}
|
||||
- end,
|
||||
- usage_options_reverse(Tail, add_option_help(Prefix, Help, Acc));
|
||||
-usage_options_reverse([], Acc) ->
|
||||
- Acc.
|
||||
- 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).
|
||||
-
|
||||
-
|
||||
-%% @doc Add the help message corresponding to an option specification to a list
|
||||
-%% with the correct indentation.
|
||||
--spec add_option_help(Prefix :: string(), Help :: string(), Acc :: string()) -> string().
|
||||
-add_option_help(Prefix, Help, Acc) when is_list(Help), Help =/= [] ->
|
||||
- FlatPrefix = lists:flatten(Prefix),
|
||||
- case ((?INDENTATION * ?TAB_LENGTH) - 2 - length(FlatPrefix)) of
|
||||
- TabSize when TabSize > 0 ->
|
||||
- Tab = lists:duplicate(ceiling(TabSize / ?TAB_LENGTH), $\t),
|
||||
- [[$\s, $\s, FlatPrefix, Tab, Help, $\n] | Acc];
|
||||
- _ ->
|
||||
- % The indentation for the option description is 3 tabs (i.e. 24 characters)
|
||||
- % IMPORTANT: Change the number of tabs below if you change the
|
||||
- % value of the INDENTATION macro.
|
||||
- [[$\t, $\t, $\t, Help, $\n], [$\s, $\s, FlatPrefix, $\n] | Acc]
|
||||
- end;
|
||||
-add_option_help(_Opt, _Prefix, Acc) ->
|
||||
- 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) ->
|
||||
- lists:flatten(io_lib:format("~w", [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, [], []).
|
||||
-
|
||||
-%% @doc Return the smallest integral value not less than the argument.
|
||||
--spec ceiling(float()) -> integer().
|
||||
-ceiling(X) ->
|
||||
- T = erlang:trunc(X),
|
||||
- case (X - T) of
|
||||
- % Neg when Neg < 0 ->
|
||||
- % T;
|
||||
- Pos when Pos > 0 ->
|
||||
- T + 1;
|
||||
- _ ->
|
||||
- T
|
||||
--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.
|
||||
--
|
||||
1.7.10.1
|
||||
|
||||
-
|
||||
--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() -> 0..?LINE_LENGTH.
|
||||
-line_length() ->
|
||||
- case io:columns() of
|
||||
- {ok, Columns} when Columns < ?LINE_LENGTH ->
|
||||
- Columns - 1;
|
||||
- _ ->
|
||||
- ?LINE_LENGTH
|
||||
- end.
|
||||
-
|
||||
-
|
||||
--spec to_string(term()) -> string().
|
||||
-to_string(List) when is_list(List) ->
|
||||
- case io_lib:printable_list(List) of
|
||||
- true -> List;
|
||||
- false -> io_lib:format("~p", [List])
|
||||
- end;
|
||||
-to_string(Atom) when is_atom(Atom) ->
|
||||
- atom_to_list(Atom);
|
||||
-to_string(Value) ->
|
||||
- io_lib:format("~p", [Value]).
|
||||
|
26
rebar-0004-Allow-discarding-building-ports.patch
Normal file
26
rebar-0004-Allow-discarding-building-ports.patch
Normal file
@ -0,0 +1,26 @@
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Tue, 5 Jun 2012 15:10:12 +0400
|
||||
Subject: [PATCH] Allow discarding building ports
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
|
||||
Conflicts:
|
||||
src/rebar_port_compiler.erl
|
||||
|
||||
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
|
||||
index 9679c80..0ba9e84 100644
|
||||
--- a/src/rebar_port_compiler.erl
|
||||
+++ b/src/rebar_port_compiler.erl
|
||||
@@ -348,6 +348,12 @@ get_specs(Config, AppFile) ->
|
||||
%% No spec provided. Construct a spec
|
||||
%% from old-school so_name and sources
|
||||
[port_spec_from_legacy(Config, AppFile)];
|
||||
+ [{null,[]}] ->
|
||||
+ [];
|
||||
+ [null] ->
|
||||
+ [];
|
||||
+ [skip] ->
|
||||
+ [];
|
||||
PortSpecs ->
|
||||
Filtered = filter_port_specs(PortSpecs),
|
||||
OsType = os:type(),
|
@ -0,0 +1,24 @@
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Sat, 2 Mar 2013 13:35:36 +0400
|
||||
Subject: [PATCH] Remove any traces of long-time obsolete escript:foldl/3
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
|
||||
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
|
||||
index a5cc0ff..5947277 100644
|
||||
--- a/src/rebar_utils.erl
|
||||
+++ b/src/rebar_utils.erl
|
||||
@@ -225,12 +225,7 @@ abort(String, Args) ->
|
||||
%% 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.
|
||||
+ emulate_escript_foldl(Fun, Acc, File).
|
||||
|
||||
find_executable(Name) ->
|
||||
case os:find_executable(Name) of
|
166
rebar-0006-remove-abnfc.patch
Normal file
166
rebar-0006-remove-abnfc.patch
Normal file
@ -0,0 +1,166 @@
|
||||
From: Filip Andres <filip@andresovi.net>
|
||||
Date: Mon, 29 Jun 2015 14:05:01 +0200
|
||||
Subject: [PATCH] remove abnfc
|
||||
|
||||
|
||||
diff --git a/ebin/rebar.app b/ebin/rebar.app
|
||||
index 986f12f..167dad8 100644
|
||||
--- a/ebin/rebar.app
|
||||
+++ b/ebin/rebar.app
|
||||
@@ -5,7 +5,6 @@
|
||||
[{description, "Rebar: Erlang Build Tool"},
|
||||
{vsn, "2.6.4"},
|
||||
{modules, [ rebar,
|
||||
- rebar_abnfc_compiler,
|
||||
rebar_app_utils,
|
||||
rebar_appups,
|
||||
rebar_asn1_compiler,
|
||||
@@ -82,7 +81,6 @@
|
||||
%% Dir specific processing modules
|
||||
{modules, [
|
||||
{app_dir, [
|
||||
- rebar_abnfc_compiler,
|
||||
rebar_proto_compiler,
|
||||
rebar_protobuffs_compiler,
|
||||
rebar_proto_gpb_compiler,
|
||||
diff --git a/rebar.config b/rebar.config
|
||||
index eda5a2c..7d0870e 100644
|
||||
--- a/rebar.config
|
||||
+++ b/rebar.config
|
||||
@@ -20,7 +20,6 @@
|
||||
- (\"escript\":\"foldl\"/\"3\")
|
||||
- (\"eunit_test\":\"function_wrapper\"/\"2\")
|
||||
- (\"eflame\":\"apply\"/\"5\")
|
||||
- - (\"abnfc\":\"file\"/\"2\")
|
||||
- (\"erlydtl\":\"compile\"/\"3\")
|
||||
- (\"lfe_comp\":\"file\"/\"2\")
|
||||
- (\"neotoma\":\"file\"/\"2\")
|
||||
diff --git a/src/rebar_abnfc_compiler.erl b/src/rebar_abnfc_compiler.erl
|
||||
deleted file mode 100644
|
||||
index 37731b5..0000000
|
||||
--- a/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.
|
174
rebar-0007-Remove-support-for-gpb-compiler.patch
Normal file
174
rebar-0007-Remove-support-for-gpb-compiler.patch
Normal file
@ -0,0 +1,174 @@
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Wed, 2 Mar 2016 15:03:13 +0300
|
||||
Subject: [PATCH] Remove support for gpb compiler
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
|
||||
diff --git a/ebin/rebar.app b/ebin/rebar.app
|
||||
index 167dad8..e22ad72 100644
|
||||
--- a/ebin/rebar.app
|
||||
+++ b/ebin/rebar.app
|
||||
@@ -31,7 +31,6 @@
|
||||
rebar_port_compiler,
|
||||
rebar_proto_compiler,
|
||||
rebar_protobuffs_compiler,
|
||||
- rebar_proto_gpb_compiler,
|
||||
rebar_qc,
|
||||
rebar_rel_utils,
|
||||
rebar_reltool,
|
||||
@@ -83,7 +82,6 @@
|
||||
{app_dir, [
|
||||
rebar_proto_compiler,
|
||||
rebar_protobuffs_compiler,
|
||||
- rebar_proto_gpb_compiler,
|
||||
rebar_neotoma_compiler,
|
||||
rebar_asn1_compiler,
|
||||
rebar_dia_compiler,
|
||||
diff --git a/src/rebar_proto_gpb_compiler.erl b/src/rebar_proto_gpb_compiler.erl
|
||||
deleted file mode 100644
|
||||
index c528a4a..0000000
|
||||
--- a/src/rebar_proto_gpb_compiler.erl
|
||||
+++ /dev/null
|
||||
@@ -1,142 +0,0 @@
|
||||
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
|
||||
-%% ex: ts=4 sw=4 et
|
||||
-%% -------------------------------------------------------------------
|
||||
-%%
|
||||
-%% rebar: Erlang Build Tools
|
||||
-%%
|
||||
-%% Copyright (c) 2014 Tomas Abrahamsson (tomas.abrahamsson@gmail.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_proto_gpb_compiler).
|
||||
-
|
||||
--export([key/0,
|
||||
- proto_compile/3,
|
||||
- proto_clean/3]).
|
||||
-
|
||||
-%% for internal use only
|
||||
--export([proto_info/2]).
|
||||
-
|
||||
--include("rebar.hrl").
|
||||
-
|
||||
-%% ===================================================================
|
||||
-%% Public API
|
||||
-%% ===================================================================
|
||||
-
|
||||
-key() ->
|
||||
- gpb.
|
||||
-
|
||||
-proto_compile(Config, _AppFile, Files) ->
|
||||
- %% Check for gpb library -- if it's not present, fail
|
||||
- %% since we have.proto files that need building
|
||||
- case gpb_is_present() of
|
||||
- true ->
|
||||
- GpbOpts = user_gpb_opts(Config),
|
||||
- Targets = [filename:join("src", target_filename(F, GpbOpts))
|
||||
- || F <- Files],
|
||||
- rebar_base_compiler:run(Config, [],
|
||||
- lists:zip(Files, Targets),
|
||||
- fun compile_gpb/3,
|
||||
- [{check_last_mod, true}]);
|
||||
- false ->
|
||||
- ?ERROR("The gpb library is not present in code path!\n", []),
|
||||
- ?FAIL
|
||||
- end.
|
||||
-
|
||||
-target_filename(ProtoFileName, GpbOpts) ->
|
||||
- ModulePrefix = proplists:get_value(module_name_prefix, GpbOpts, ""),
|
||||
- ModuleSuffix = proplists:get_value(module_name_suffix, GpbOpts, ""),
|
||||
- Base = filename:basename(ProtoFileName, ".proto"),
|
||||
- ModulePrefix ++ Base ++ ModuleSuffix ++ ".erl".
|
||||
-
|
||||
-proto_clean(Config, _AppFile, ProtoFiles) ->
|
||||
- GpbOpts = user_gpb_opts(Config) ++ default_dest_opts(),
|
||||
- rebar_file_utils:delete_each(
|
||||
- [beam_file(F, GpbOpts) || F <- ProtoFiles]
|
||||
- ++ [erl_file(F, GpbOpts) || F <- ProtoFiles]
|
||||
- ++ [hrl_file(F, GpbOpts) || F <- ProtoFiles]),
|
||||
- ok.
|
||||
-
|
||||
-%% ===================================================================
|
||||
-%% Internal functions
|
||||
-%% ===================================================================
|
||||
-
|
||||
-proto_info(help, compile) ->
|
||||
- ?CONSOLE(
|
||||
- " gpb_opts is passed as options to gpb_compile:file/2.~n"
|
||||
- " erl_opts is used when compiling the generated erlang files,~n"
|
||||
- " so you might want to add an include path to gpb here,~n"
|
||||
- " for gpb.hrl, or else use the include_as_lib gpb_opts option,~n"
|
||||
- " or the defs_as_proplists gpb_opts option.~n",
|
||||
- []);
|
||||
-proto_info(help, clean) ->
|
||||
- ?CONSOLE("", []).
|
||||
-
|
||||
-gpb_is_present() ->
|
||||
- code:which(gpb) =/= non_existing.
|
||||
-
|
||||
-user_gpb_opts(Config) ->
|
||||
- rebar_config:get_local(Config, gpb_opts, []).
|
||||
-
|
||||
-default_dest_opts() ->
|
||||
- [{o_erl, "src"}, {o_hrl, "include"}].
|
||||
-
|
||||
-compile_gpb(Source, _Target, Config) ->
|
||||
- SourceFullPath = filename:absname(Source),
|
||||
- GpbOpts = user_gpb_opts(Config) ++ default_dest_opts()
|
||||
- ++ default_include_opts(SourceFullPath),
|
||||
- ok = filelib:ensure_dir(filename:join("ebin", "dummy")),
|
||||
- ok = filelib:ensure_dir(filename:join("include", "dummy")),
|
||||
- case gpb_compile:file(SourceFullPath, GpbOpts) of
|
||||
- ok ->
|
||||
- ok;
|
||||
- {error, Reason} ->
|
||||
- ReasonStr = gpb_compile:format_error(Reason),
|
||||
- ?ERROR("Failed to compile ~s: ~s~n", [SourceFullPath, ReasonStr]),
|
||||
- ?FAIL
|
||||
- end.
|
||||
-
|
||||
-default_include_opts(SourceFullPath) ->
|
||||
- [{i,filename:dirname(SourceFullPath)}].
|
||||
-
|
||||
-beam_file(ProtoFile, GpbOpts) ->
|
||||
- proto_filename_to_path("ebin", ProtoFile, ".beam", GpbOpts).
|
||||
-
|
||||
-erl_file(ProtoFile, GpbOpts) ->
|
||||
- ErlOutDir = get_erl_outdir(GpbOpts),
|
||||
- proto_filename_to_path(ErlOutDir, ProtoFile, ".erl", GpbOpts).
|
||||
-
|
||||
-hrl_file(ProtoFile, GpbOpts) ->
|
||||
- HrlOutDir = get_hrl_outdir(GpbOpts),
|
||||
- proto_filename_to_path(HrlOutDir, ProtoFile, ".hrl", GpbOpts).
|
||||
-
|
||||
-proto_filename_to_path(Dir, ProtoFile, NewExt, GpbOpts) ->
|
||||
- BaseNoExt = filename:basename(ProtoFile, ".proto"),
|
||||
- Prefix = proplists:get_value(module_name_prefix, GpbOpts, ""),
|
||||
- Suffix = proplists:get_value(module_name_suffix, GpbOpts, ""),
|
||||
- filename:join([Dir, Prefix ++ BaseNoExt ++ Suffix ++ NewExt]).
|
||||
-
|
||||
-get_erl_outdir(Opts) ->
|
||||
- proplists:get_value(o_erl, Opts, get_outdir(Opts)).
|
||||
-
|
||||
-get_hrl_outdir(Opts) ->
|
||||
- proplists:get_value(o_hrl, Opts, get_outdir(Opts)).
|
||||
-
|
||||
-get_outdir(Opts) ->
|
||||
- proplists:get_value(o, Opts, ".").
|
55
rebar-0008-Remove-pre-R15B02-workaround.patch
Normal file
55
rebar-0008-Remove-pre-R15B02-workaround.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Wed, 2 Mar 2016 15:10:20 +0300
|
||||
Subject: [PATCH] Remove pre-R15B02 workaround
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
|
||||
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
|
||||
index f4d7b76..63f8c31 100644
|
||||
--- a/src/rebar_eunit.erl
|
||||
+++ b/src/rebar_eunit.erl
|
||||
@@ -436,18 +436,6 @@ get_beam_test_exports(ModuleStr) ->
|
||||
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]),
|
||||
@@ -456,23 +444,15 @@ make_test_primitives(RawTests) ->
|
||||
case re:run(FNameStr, "_test_") of
|
||||
nomatch ->
|
||||
%% Normal test
|
||||
- MakePrimitive(test, M, F2);
|
||||
+ {test, M, F2};
|
||||
_ ->
|
||||
%% Generator
|
||||
- MakePrimitive(generator, M, F2)
|
||||
+ {generator, M, F2}
|
||||
end,
|
||||
[eunit_module_suite(M, 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)}.
|
||||
-
|
||||
% Add a test group for eunit_surefire to be able to deduce the testsuite.
|
||||
% Calling eunit:test({module, M}) does exactly this as well.
|
||||
eunit_module_suite(M, X) ->
|
22
rebar-0009-No-such-function-erlang-timestamp-0.patch
Normal file
22
rebar-0009-No-such-function-erlang-timestamp-0.patch
Normal file
@ -0,0 +1,22 @@
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Wed, 2 Mar 2016 13:52:44 +0300
|
||||
Subject: [PATCH] No such function erlang:timestamp/0
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
|
||||
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
|
||||
index 5947277..047594d 100644
|
||||
--- a/src/rebar_utils.erl
|
||||
+++ b/src/rebar_utils.erl
|
||||
@@ -816,9 +816,9 @@ windows_temp_dir() ->
|
||||
end.
|
||||
|
||||
rebar_now() ->
|
||||
- case erlang:function_exported(erlang, timestamp, 0) of
|
||||
+ case erlang:function_exported(os, timestamp, 0) of
|
||||
true ->
|
||||
- erlang:timestamp();
|
||||
+ os:timestamp();
|
||||
false ->
|
||||
%% erlang:now/0 was deprecated in 18.0. One solution to avoid the
|
||||
%% deprecation warning is to use
|
25
rebar-0010-Try-shell-variable-VSN-first.patch
Normal file
25
rebar-0010-Try-shell-variable-VSN-first.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Sun, 6 Mar 2016 01:25:36 +0300
|
||||
Subject: [PATCH] Try shell variable VSN first
|
||||
|
||||
Try shell variable VSN first before substituting version placeholder in
|
||||
app-file.
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
|
||||
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
|
||||
index b3566c8..187b1c3 100644
|
||||
--- a/src/rebar_otp_app.erl
|
||||
+++ b/src/rebar_otp_app.erl
|
||||
@@ -116,7 +116,10 @@ preprocess(Config, AppSrcFile) ->
|
||||
|
||||
|
||||
%% AppSrcFile may contain instructions for generating a vsn number
|
||||
- {Config2, Vsn} = rebar_app_utils:app_vsn(Config1, AppSrcFile),
|
||||
+ {Config2, Vsn} = case os:getenv("VSN") of
|
||||
+ false -> rebar_app_utils:app_vsn(Config1, AppSrcFile);
|
||||
+ V -> {Config1, V}
|
||||
+ end,
|
||||
A2 = lists:keystore(vsn, 1, A1, {vsn, Vsn}),
|
||||
|
||||
%% systools:make_relup/4 fails with {missing_param, registered}
|
30
rebar-0011-Allow-ignoring-missing-deps.patch
Normal file
30
rebar-0011-Allow-ignoring-missing-deps.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From: Peter Lemenkov <lemenkov@gmail.com>
|
||||
Date: Mon, 7 Mar 2016 16:55:33 +0300
|
||||
Subject: [PATCH] Allow ignoring missing deps
|
||||
|
||||
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
||||
|
||||
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl
|
||||
index 251bdee..577db64 100644
|
||||
--- a/src/rebar_deps.erl
|
||||
+++ b/src/rebar_deps.erl
|
||||
@@ -163,12 +163,17 @@ do_check_deps(Config) ->
|
||||
{Config1, {AvailDeps, []}} ->
|
||||
%% No missing deps
|
||||
{Config1, AvailDeps};
|
||||
- {_Config1, {_, MissingDeps}} ->
|
||||
+ {Config1, {AvailDeps, 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
|
||||
+ case os:getenv("IGNORE_MISSING_DEPS") of
|
||||
+ false -> ?FAIL;
|
||||
+ _ ->
|
||||
+ ?CONSOLE("Continue anyway because IGNORE_MISSING_DEPS was set\n", []),
|
||||
+ {Config1, lists:sort(AvailDeps ++ MissingDeps)}
|
||||
+ end
|
||||
end.
|
||||
|
||||
'check-deps'(Config, _) ->
|
Loading…
Reference in New Issue
Block a user