Compare commits

...

26 Commits
f22 ... master

Author SHA1 Message Date
Fedora Release Engineering 804db89e99 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-07-13 00:06:24 +00:00
Fedora Release Engineering 97c0e95ba1 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-02-07 08:51:50 +00:00
Fedora Release Engineering c3d77ebda6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild 2017-08-02 20:15:22 +00:00
Fedora Release Engineering f52a72f05f - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild 2017-07-26 07:43:45 +00:00
Fedora Release Engineering d95db754dd - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild 2017-02-10 09:22:29 +00:00
Peter Lemenkov 2b3f6c608c Rebar ver. 2.6.4
- Ver. 2.6.4 (rhbz#1350988)
- Re-enable upstream behaviour for get-deps (rhbz#999054)
- Added erlang-eflame dependency

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-09-02 17:38:59 +03:00
Peter Lemenkov 915ee4c8e4 Bootstrap it first (lots of internal ABI differences)
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-09-01 18:27:25 +03:00
Peter Lemenkov 8a2757da9c Rebar ver. 2.6.4
- Ver. 2.6.4 (rhbz#1350988)
- Re-enable upstream behaviour for get-deps (rhbz#999054)
- Added erlang-eflame dependency

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-09-01 17:53:53 +03:00
Peter Lemenkov 4d6c5fc2f0 Fix tests
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-15 22:44:49 +03:00
Peter Lemenkov 4d9f3c57db Allow skipping check for apps
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-07 17:05:03 +03:00
Peter Lemenkov a537e470a7 forgotten patch
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-06 01:44:25 +03:00
Peter Lemenkov 2a260a7b1f Allow VSN override
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-06 01:36:32 +03:00
Peter Lemenkov 5814a86de3 Re-add erlang-diameter as a BuildRequires again
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-03 00:06:25 +03:00
Peter Lemenkov 65089ff906 typo
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-02 18:09:03 +03:00
Peter Lemenkov 0c0b0d4175 Disable gbp properly
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-02 18:02:54 +03:00
Peter Lemenkov ec50daad4d Disable gbp properly (have to bootstrap) (#3)
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-02 17:27:48 +03:00
Peter Lemenkov 42babe1cbe Disable gbp properly (have to bootstrap) (#2)
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-02 17:01:30 +03:00
Peter Lemenkov 17155b605c Disable gbp properly (have to bootstrap)
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-02 16:54:32 +03:00
Peter Lemenkov 9339c89dc5 Fix dependency issues mentioned by automatic dependency checker
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-02 15:40:32 +03:00
Peter Lemenkov a19a584c26 Add (Build)Requires which weren't picked up automatically
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-01 20:17:39 +03:00
Peter Lemenkov 6e33339f57 Use autogenetated dependency list
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
2016-03-01 18:59:48 +03:00
Dennis Gilmore a25d24109d - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild 2016-02-03 20:00:53 +00:00
Filip Andres 038e536333 Update the sources file 2015-12-31 11:03:17 +01:00
Filip Andres 776b74cd43 Update to 2.6.1 2015-12-31 11:02:17 +01:00
Filip Andres 48af4311e1 Ver. 2.6.0 2015-07-07 08:58:01 +02:00
Dennis Gilmore b29a014600 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild 2015-06-17 05:42:16 +00:00
19 changed files with 1049 additions and 530 deletions

4
.gitignore vendored
View File

@ -2,3 +2,7 @@
/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

View File

@ -1,8 +1,6 @@
%global realname rebar
%global upstream basho
%global upstream rebar
%global debug_package %{nil}
%global git_tag ebb474b
%global patchnumber 0
# 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
@ -13,77 +11,85 @@
Name: erlang-%{realname}
Version: 2.1.0
Release: 0.9%{?dist}
Version: 2.6.4
Release: 7%{?dist}
Summary: Erlang Build Tools
Group: Development/Tools
License: MIT
URL: https://github.com/rebar/rebar
# wget --content-disposition https://github.com/basho/rebar/tarball/ebb474b
Source0: %{upstream}-%{realname}-%{version}-pre-%{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
# Fedora/EPEL-specific
Patch1: rebar-0001-Don-t-load-templates-from-the-bundle.patch
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.
%if 0%{?need_bootstrap} < 1
# Fedora/EPEL-specific
Patch3: rebar-0003-Remove-bundled-getopt.patch
%endif
# Backported from upstream
Patch4: rebar-0004-Be-sure-to-filter-empty-sources-h-t-to-Tuncer-and-Jo.patch
# Will be proposed for inclusion
Patch5: rebar-0005-Allow-discarding-building-ports.patch
# Fedora/EPEL-specific
Patch6: rebar-0006-Check-system-wide-libdir-in-case-of-source-based-dep.patch
# Fedora/EPEL-specific
Patch7: rebar-0007-Remove-any-traces-of-long-time-obsolete-escript-fold.patch
# Fedora/EPEL-specific - unfortunately we don't have abnfc compiler available yet
Patch8: rebar-0008-Remove-abnfc-compiler-support-n-a-in-Fedora-EPEL.patch
# Fedora/EPEL-specific - cosmetic
Patch9: rebar-0009-Adjust-app-version.patch
# Backported from upstream
Patch10: rebar-0010-Fix-default-DTL-compilation-when-no-erlydtl_opts-are.patch
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
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
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-asn1%{?_isa}
#Requires: erlang-gpb%{?_isa}
# This one cannot be picked up automatically
# See https://bugzilla.redhat.com/960079
Requires: erlang-common_test%{?_isa}
Requires: erlang-compiler%{?_isa}
Requires: erlang-crypto%{?_isa}
# FIXME does it still needed?
Requires: erlang-dialyzer%{?_isa}
Requires: erlang-edoc%{?_isa}
Requires: erlang-erlydtl%{?_isa}
Requires: erlang-erts%{?_isa}
# Requires for port compiling - no direct references in Rebar's src/*.erl files
Requires: erlang-erl_interface%{?_isa}
# Autochecker picks up a missing dependency in R16 -
# eunit_test:function_wrapper/2. This function was removed in R16, and rebar
# contains a workaround for that. So no need to worry about that.
Requires: erlang-eunit%{?_isa}
Requires: erlang-getopt%{?_isa}
Requires: erlang-kernel%{?_isa}
Requires: erlang-lfe%{?_isa}
Requires: erlang-mustache%{?_isa}
Requires: erlang-neotoma%{?_isa}
# This one cannot be picked up automatically
# See https://bugzilla.redhat.com/960079
Requires: erlang-parsetools%{?_isa}
Requires: erlang-protobuffs%{?_isa}
Requires: erlang-reltool%{?_isa}
Requires: erlang-sasl%{?_isa}
Requires: erlang-snmp%{?_isa}
Requires: erlang-stdlib%{?_isa}
Requires: erlang-syntax_tools%{?_isa}
Requires: erlang-tools%{?_isa}
Requires: erlang-rpm-macros >= 0.2.4
Provides: %{realname} = %{version}-%{release}
@ -92,24 +98,25 @@ Erlang Build Tools.
%prep
%setup -q -n %{upstream}-%{realname}-%{git_tag}
%patch1 -p1 -b .dont_load_templates
%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 .dont_try_building_so
%patch5 -p1 -b .allow_discarding_ports
%patch6 -p1 -b .use_locally_installed
%patch7 -p1 -b .remove_escript_foldl_3
%patch8 -p1 -b .no_abnfc
%patch9 -p1 -b .adjust_ver
%patch10 -p1 -b .fix_dtl
%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
rebar compile -v
%{erlang_compile}
%else
./bootstrap
./rebar compile -v
@ -117,26 +124,94 @@ rebar compile -v
%install
%{erlang_install}
# Install rebar script itself
install -D -p -m 0755 %{SOURCE1} %{buildroot}%{_bindir}/rebar
mkdir -p %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/ebin
mkdir -p %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/include
install -m 644 ebin/%{realname}.app %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/ebin
install -m 644 ebin/*.beam %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/ebin
install -m 644 include/*.hrl %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/include
cp -a priv %{buildroot}%{_libdir}/erlang/lib/%{realname}-%{version}/
# Copy the contents of priv folder
cp -a priv %{buildroot}%{_erllibdir}/%{realname}-%{version}/
%check
#rebar eunit -v
%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
%doc LICENSE NOTES.org README.md 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

View File

@ -1,72 +0,0 @@
From b658042106136a5b471f0d248ec988c6eed77006 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Mon, 4 Mar 2013 19:03:03 +0400
Subject: [PATCH 01/10] Don't load templates from the bundle
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_templater.erl | 31 +++++--------------------------
1 file changed, 5 insertions(+), 26 deletions(-)
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index 0e1eef1..7cc36f7 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -167,27 +167,11 @@ create1(Config, TemplateId) ->
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}.
+ ++ find_escript_templates(),
-%%
-%% 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.
+ {AvailTemplates, []}.
template_id(Config) ->
case rebar_config:get_global(Config, template, undefined) of
@@ -197,10 +181,8 @@ template_id(Config) ->
TemplateId
end.
-find_escript_templates(Files) ->
- [{escript, Name}
- || {Name, _Bin} <- Files,
- re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match].
+find_escript_templates() ->
+ [{file, Name} || Name <- rebar_utils:find_files(code:priv_dir(rebar) ++ "/templates", ?TEMPLATE_RE)].
find_disk_templates(Config) ->
OtherTemplates = find_other_templates(Config),
@@ -231,10 +213,7 @@ select_template([{Type, Avail} | Rest], Template) ->
%%
%% 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) ->
+load_file(_Files, _, Name) ->
{ok, Bin} = file:read_file(Name),
Bin.
--
1.8.1.4

View 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

View File

@ -1,35 +1,26 @@
From fce5d859e5a24dcbff1796293a4835078b758080 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sat, 20 Nov 2010 16:36:45 +0300
Subject: [PATCH 02/10] 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 | 228 -------------------------------------------------------
2 files changed, 1 insertion(+), 230 deletions(-)
delete mode 100644 src/mustache.erl
diff --git a/ebin/rebar.app b/ebin/rebar.app
index 8df929f..9e000fa 100644
index 9449e1e..d3f8e42 100644
--- a/ebin/rebar.app
+++ b/ebin/rebar.app
@@ -37,8 +37,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 f6963cd..0000000
--- a/src/mustache.erl
index 9016c0f..0000000
--- a/src/rebar_mustache.erl
+++ /dev/null
@@ -1,228 +0,0 @@
@@ -1,230 +0,0 @@
-%% The MIT License
-%%
-%% Copyright (c) 2009 Tom Preston-Werner <tom@mojombo.com>
@ -55,7 +46,7 @@ index f6963cd..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,6 +54,8 @@ index f6963cd..0000000
- section_re = undefined,
- tag_re = undefined}).
-
--define(MUSTACHE_STR, "rebar_mustache").
-
-compile(Body) when is_list(Body) ->
- State = #mstate{},
- CompiledTemplate = pre_compile(Body, State),
@ -140,7 +133,7 @@ index f6963cd..0000000
- Mod = State#mstate.mod,
- Result = compiler(Content, State),
- "fun() -> " ++
- "case mustache:get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
- "case " ++ ?MUSTACHE_STR ++ ":get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
- "\"true\" -> " ++
- Result ++ "; " ++
- "\"false\" -> " ++
@ -175,10 +168,10 @@ index f6963cd..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) ->
- "[]".
-
@ -258,6 +251,17 @@ index f6963cd..0000000
-start([T]) ->
- Out = render(list_to_atom(T)),
- io:format(Out ++ "~n", []).
--
1.8.1.4
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

View File

@ -1,35 +1,48 @@
From e200556bfca9db7e496a50b62fa09a5f46f22b25 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sat, 20 Nov 2010 16:40:15 +0300
Subject: [PATCH 03/10] 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 9e000fa..cba8bf8 100644
index d3f8e42..986f12f 100644
--- a/ebin/rebar.app
+++ b/ebin/rebar.app
@@ -36,8 +36,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,42 +71,89 @@ 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'.
--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().
--type arg_value() :: atom() | binary() | boolean() | float() | integer() | string().
-%% Argument specification.
--type arg_spec() :: arg_type() | {arg_type(), arg_value()} | undefined.
--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().
--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
- Name :: atom(),
- Short :: char() | undefined,
- Long :: string() | undefined,
- ArgSpec :: arg_spec(),
- Help :: string() | undefined
- }.
-%% Output streams
--type output_stream() :: 'standard_io' | 'standard_error'.
--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()}.
-
-
-%% @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.
--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
@ -110,7 +163,7 @@ index 175b7a5..0000000
-
-
--spec parse([option_spec()], [option()], [string()], integer(), [string()]) ->
- {ok, {[option()], [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.
@ -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:
@ -142,7 +213,7 @@ index 175b7a5..0000000
-%% --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()]}}.
- {ok, {[option()], [string()]}}.
-parse_long_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptArg) ->
- case split_assigned_arg(OptArg) of
- {Long, Arg} ->
@ -229,7 +300,7 @@ index 175b7a5..0000000
-%% -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()]}}.
- {ok, {[option()], [string()]}}.
-parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptArg) ->
- parse_short_option(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, first, OptArg).
-
@ -290,7 +361,7 @@ index 175b7a5..0000000
-%% 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};
- {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) ->
@ -304,12 +375,12 @@ index 175b7a5..0000000
--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);
- 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);
@ -502,155 +573,387 @@ index 175b7a5..0000000
-%% arguments that are supported by the program.
--spec usage([option_spec()], string()) -> ok.
-usage(OptSpecList, ProgramName) ->
- usage(OptSpecList, ProgramName, standard_error).
- 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, "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.
-usage(OptSpecList, ProgramName, CmdLineTail) ->
- usage(OptSpecList, ProgramName, CmdLineTail, standard_error).
- 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()], 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
-%% 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).
- 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()], 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 ->
- 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, $]];
- true ->
- []
- end;
- _ ->
- if
- %% For options with short form and argument.
- Short =/= undefined ->
- [$\s, $[, $-, Short, $\s, $<, atom_to_list(Name), $>, $]];
- %% For options with only long form and argument.
- Long =/= undefined ->
- [$\s, $[, $-, $-, 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)).
-
-
-%% @doc Return a string with the help message 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_reverse([{Name, Short, Long, _ArgSpec, Help} | Tail], Acc) ->
- Prefix =
- case Long of
- undefined ->
- case Short of
- %% Neither short nor long form (non-option argument).
- undefined ->
- [$<, atom_to_list(Name), $>];
- %% Only short form.
- _ ->
- [$-, Short]
- end;
- _ ->
- case Short of
- %% Only long form.
- undefined ->
- [$-, $- | Long];
- %% Both short and long form.
- _ ->
- [$-, Short, $,, $\s, $-, $- | Long]
- end
- end,
- usage_options_reverse(Tail, add_option_help(Prefix, Help, Acc));
-usage_options_reverse([], Acc) ->
- 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.
-
-
-
-%% @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 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.
--
1.8.1.4
-
-
-%% @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 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);
- _ ->
- {[], 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) ->
- 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, [], []).
-
--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() -> 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]).

View File

@ -1,21 +1,17 @@
From a101ee059baff585da6d1086097e8ceb20bda5d1 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 5 Jun 2012 15:10:12 +0400
Subject: [PATCH 05/10] Allow discarding building ports
Subject: [PATCH] Allow discarding building ports
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
Conflicts:
src/rebar_port_compiler.erl
---
src/rebar_port_compiler.erl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 70ee308..3deeb7c 100644
index 9679c80..0ba9e84 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -253,6 +253,12 @@ get_specs(Config, AppFile) ->
@@ -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)];
@ -28,6 +24,3 @@ index 70ee308..3deeb7c 100644
PortSpecs ->
Filtered = filter_port_specs(PortSpecs),
OsType = os:type(),
--
1.8.1.4

View File

@ -1,45 +0,0 @@
From 53508faa9cba923751653901ba21d6025da46e5b Mon Sep 17 00:00:00 2001
From: Dave Smith <dizzyd@dizzyd.com>
Date: Mon, 12 Nov 2012 20:18:00 -0700
Subject: [PATCH 04/10] Be sure to filter empty sources (h/t to Tuncer and Joe
Norton)
---
src/rebar_port_compiler.erl | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 71b27a5..70ee308 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -248,16 +248,17 @@ needs_link(SoName, NewBins) ->
%%
get_specs(Config, AppFile) ->
- 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.
+ 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
--
1.8.1.4

View File

@ -1,18 +1,14 @@
From 1900df4838d7623009b09fffaa6f23daa5da46c8 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sat, 2 Mar 2013 13:35:36 +0400
Subject: [PATCH 07/10] Remove any traces of long-time obsolete escript:foldl/3
Subject: [PATCH] Remove any traces of long-time obsolete escript:foldl/3
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_utils.erl | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index bb58460..c86c210 100644
index a5cc0ff..5947277 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -155,12 +155,7 @@ abort(String, Args) ->
@@ -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),
@ -26,6 +22,3 @@ index bb58460..c86c210 100644
find_executable(Name) ->
case os:find_executable(Name) of
--
1.8.1.4

View File

@ -1,32 +0,0 @@
From 13fd63738960c567d32df3061a2a4e5452dac0e1 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sat, 2 Mar 2013 10:39:15 +0400
Subject: [PATCH 06/10] Check system-wide libdir in case of source-based
dependency
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
src/rebar_deps.erl | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl
index 074e929..9cc82f7 100644
--- a/src/rebar_deps.erl
+++ b/src/rebar_deps.erl
@@ -305,7 +305,12 @@ 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)).
+ 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_in_dir(Config, _Dep, {false, Dir}) ->
{Config, {missing, Dir}};
--
1.8.1.4

View File

@ -1,41 +1,46 @@
From ec4f8e74c6058e6ba61e9687cccf30ed9378dca2 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sat, 2 Mar 2013 13:52:04 +0400
Subject: [PATCH 08/10] Remove abnfc compiler support (n/a in Fedora/EPEL)
From: Filip Andres <filip@andresovi.net>
Date: Mon, 29 Jun 2015 14:05:01 +0200
Subject: [PATCH] remove abnfc
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
ebin/rebar.app | 2 -
src/rebar_abnfc_compiler.erl | 108 -------------------------------------------
2 files changed, 110 deletions(-)
delete mode 100644 src/rebar_abnfc_compiler.erl
diff --git a/ebin/rebar.app b/ebin/rebar.app
index cba8bf8..e84e905 100644
index 986f12f..167dad8 100644
--- a/ebin/rebar.app
+++ b/ebin/rebar.app
@@ -5,7 +5,6 @@
[{description, "Rebar: Erlang Build Tool"},
{vsn, "2.1.0-pre"},
{vsn, "2.6.4"},
{modules, [ rebar,
- rebar_abnfc_compiler,
rebar_app_utils,
rebar_appups,
rebar_asn1_compiler,
@@ -61,7 +60,6 @@
@@ -82,7 +81,6 @@
%% Dir specific processing modules
{modules, [
{app_dir, [
- rebar_abnfc_compiler,
rebar_proto_compiler,
rebar_protobuffs_compiler,
rebar_neotoma_compiler,
rebar_asn1_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 0e6749a..0000000
index 37731b5..0000000
--- a/src/rebar_abnfc_compiler.erl
+++ /dev/null
@@ -1,108 +0,0 @@
@@ -1,123 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
-%% -------------------------------------------------------------------
@ -85,6 +90,9 @@ index 0e6749a..0000000
-
--export([compile/2]).
-
-%% for internal use only
--export([info/2]).
-
--include("rebar.hrl").
-
-%% ===================================================================
@ -100,11 +108,23 @@ index 0e6749a..0000000
- 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, []).
-
@ -144,6 +164,3 @@ index 0e6749a..0000000
- ?FAIL
- end
- end.
--
1.8.1.4

View 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, ".").

View 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) ->

View File

@ -1,26 +0,0 @@
From 15f315f3b3ec0d4e11186b9eabb9789b4c38b1b0 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sat, 2 Mar 2013 13:52:35 +0400
Subject: [PATCH 09/10] Adjust app version
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
ebin/rebar.app | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ebin/rebar.app b/ebin/rebar.app
index e84e905..3f0aabe 100644
--- a/ebin/rebar.app
+++ b/ebin/rebar.app
@@ -3,7 +3,7 @@
{application, rebar,
[{description, "Rebar: Erlang Build Tool"},
- {vsn, "2.1.0-pre"},
+ {vsn, "2.1.0"},
{modules, [ rebar,
rebar_app_utils,
rebar_appups,
--
1.8.1.4

View 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

View File

@ -1,26 +0,0 @@
From 4139a739f3cfafdb46e511f09b58644cd8c9addb Mon Sep 17 00:00:00 2001
From: serge <saleyn@gmail.com>
Date: Thu, 15 Nov 2012 16:34:06 -0500
Subject: [PATCH 10/10] Fix default DTL compilation when no erlydtl_opts are
provided
---
src/rebar_erlydtl_compiler.erl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl
index b5fe899..aef41c5 100644
--- a/src/rebar_erlydtl_compiler.erl
+++ b/src/rebar_erlydtl_compiler.erl
@@ -133,7 +133,7 @@ erlydtl_opts(Config) ->
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:keysort(1, Tuples)];
Lists ->
lists:map(fun(L) ->
lists:keysort(1, lists:foldl(fun({K,T}, Acc) ->
--
1.8.1.4

View 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}

View 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, _) ->

View File

@ -1 +1 @@
43a094165eb54b474e6b6aa95f1b3f8b basho-rebar-2.1.0-pre-0-gebb474b.tar.gz
5704a54547096b9b910e840db4c61caf rebar-2.6.4.tar.gz