[erlang-protobuffs] Added three patches from Basho's fork (required for riak_client)

Peter Lemenkov peter at fedoraproject.org
Fri Mar 11 13:15:32 UTC 2011


commit a91f48f6ae09ac31db4167f00833b3df8c5ee4c8
Author: Peter Lemenkov <lemenkov at gmail.com>
Date:   Fri Mar 11 16:15:18 2011 +0300

    Added three patches from Basho's fork (required for riak_client)
    
    Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>

 ...s-to-see-if-leaving-the-encoded-protocol-.patch |   79 ++++++++++++++++++++
 ...-0002-Added-debug-info-to-generated-beams.patch |   25 ++++++
 ...buffs-how-to-skip-directives-it-doesn-t-u.patch |   26 +++++++
 erlang-protobuffs.spec                             |   16 +++-
 4 files changed, 143 insertions(+), 3 deletions(-)
---
diff --git a/erlang-protobuffs-0001-Test-changes-to-see-if-leaving-the-encoded-protocol-.patch b/erlang-protobuffs-0001-Test-changes-to-see-if-leaving-the-encoded-protocol-.patch
new file mode 100644
index 0000000..363e098
--- /dev/null
+++ b/erlang-protobuffs-0001-Test-changes-to-see-if-leaving-the-encoded-protocol-.patch
@@ -0,0 +1,79 @@
+From eb7fca892599c6e79e2ea2f9d7905d0354472b6c Mon Sep 17 00:00:00 2001
+From: Jon Meredith <jmeredith at thehive.com>
+Date: Fri, 21 Aug 2009 15:53:08 -0600
+Subject: [PATCH 1/3] Test changes to see if leaving the encoded protocol buffer as an iolist is faster if sending to a TCP socket.
+
+---
+ src/pokemon_pb.erl         |    8 +++++---
+ src/protobuffs_compile.erl |   15 +++++++++++++--
+ 2 files changed, 18 insertions(+), 5 deletions(-)
+
+diff --git a/src/pokemon_pb.erl b/src/pokemon_pb.erl
+index b400d53..fce8ed2 100644
+--- a/src/pokemon_pb.erl
++++ b/src/pokemon_pb.erl
+@@ -24,6 +24,7 @@
+ %% OTHER DEALINGS IN THE SOFTWARE.
+ -module(pokemon_pb).
+ -export([encode_pikachu/1, decode_pikachu/1]).
++-compile([export_all]).
+ -record(pikachu, {abc, def}).
+ 
+ %% ENCODE
+@@ -31,9 +32,10 @@ encode_pikachu(Record) when is_record(Record, pikachu) ->
+     encode(pikachu, Record).
+ 
+ encode(pikachu, Record) ->
+-    iolist_to_binary([
+-        pack(1, required, with_default(Record#pikachu.abc, none), string, [])
+-    ]).
++    iolist_to_binary(iolist(pikachu, Record)).
++
++iolist(pikachu, Record) ->
++    [pack(1, required, with_default(Record#pikachu.abc, none), string, [])].
+ 
+ with_default(undefined, none) -> undefined;
+ with_default(undefined, Default) -> Default;
+diff --git a/src/protobuffs_compile.erl b/src/protobuffs_compile.erl
+index 1fdecbf..2806ebf 100644
+--- a/src/protobuffs_compile.erl
++++ b/src/protobuffs_compile.erl
+@@ -71,6 +71,9 @@ filter_forms(Msgs, [{function,L,encode_pikachu,1,[Clause]}|Tail], Basename, Acc)
+ filter_forms(Msgs, [{function,L,encode,2,[Clause]}|Tail], Basename, Acc) ->
+     filter_forms(Msgs, Tail, Basename, [expand_encode_function(Msgs, L, Clause)|Acc]);
+ 
++filter_forms(Msgs, [{function,L,iolist,2,[Clause]}|Tail], Basename, Acc) ->
++	filter_forms(Msgs, Tail, Basename, [expand_iolist_function(Msgs, L, Clause)|Acc]);
++
+ filter_forms(Msgs, [{function,L,decode_pikachu,1,[Clause]}|Tail], Basename, Acc) ->
+     Functions = [begin
+         {function,L,list_to_atom("decode_" ++ string:to_lower(Name)),1,[replace_atom(Clause, pikachu, atomize(Name))]} 
+@@ -92,6 +95,15 @@ expand_encode_function(Msgs, Line, Clause) ->
+     {function,Line,encode,2,[filter_encode_clause(Msg, Clause) || Msg <- Msgs]}.
+ 
+ filter_encode_clause({MsgName, Fields}, {clause,L,_Args,Guards,_Content}) ->
++    ToBin = {call,L,{atom,L,iolist_to_binary},[{call,L,
++                                                {atom,L,iolist},
++                                                [{atom,L,atomize(MsgName)},{var,L,'Record'}]}]},
++    {clause,L,[{atom,L,atomize(MsgName)},{var,L,'Record'}],Guards,[ToBin]}.
++
++expand_iolist_function(Msgs, Line, Clause) ->
++    {function,Line,iolist,2,[filter_iolist_clause(Msg, Clause) || Msg <- Msgs]}.
++
++filter_iolist_clause({MsgName, Fields}, {clause,L,_Args,Guards,_Content}) ->
+     Cons = lists:foldl(
+         fun({FNum,Tag,SType,SName,_,Default}, Acc) ->
+             {cons,L,
+@@ -103,8 +115,7 @@ filter_encode_clause({MsgName, Fields}, {clause,L,_Args,Guards,_Content}) ->
+                     {nil,L}]},
+                 Acc}
+         end, {nil,L}, Fields),
+-    ToBin = {call,L,{atom,L,iolist_to_binary},[Cons]},
+-    {clause,L,[{atom,L,atomize(MsgName)},{var,L,'Record'}],Guards,[ToBin]}.
++    {clause,L,[{atom,L,atomize(MsgName)},{var,L,'Record'}],Guards,[Cons]}.
+ 
+ expand_decode_function(Msgs, Line, Clause) ->
+     {function,Line,decode,2,[filter_decode_clause(Msgs, Msg, Clause) || Msg <- Msgs]}.
+-- 
+1.7.4.1
+
diff --git a/erlang-protobuffs-0002-Added-debug-info-to-generated-beams.patch b/erlang-protobuffs-0002-Added-debug-info-to-generated-beams.patch
new file mode 100644
index 0000000..6036db7
--- /dev/null
+++ b/erlang-protobuffs-0002-Added-debug-info-to-generated-beams.patch
@@ -0,0 +1,25 @@
+From 77c5c74f35addcd0e2876593675e009e921ff349 Mon Sep 17 00:00:00 2001
+From: Jon Meredith <jmeredith at basho.com>
+Date: Thu, 22 Apr 2010 08:10:44 -0600
+Subject: [PATCH 2/3] Added debug info to generated beams.
+
+---
+ src/protobuffs_compile.erl |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/protobuffs_compile.erl b/src/protobuffs_compile.erl
+index 2806ebf..6968629 100644
+--- a/src/protobuffs_compile.erl
++++ b/src/protobuffs_compile.erl
+@@ -37,7 +37,7 @@ output(Basename, Messages) ->
+     BeamFile = filename:dirname(code:which(?MODULE)) ++ "/pokemon_pb.beam",
+     {ok,{_,[{abstract_code,{_,Forms}}]}} = beam_lib:chunks(BeamFile, [abstract_code]),
+     Forms1 = filter_forms(Messages, Forms, Basename, []),
+-    {ok, _, Bytes, _Warnings} = compile:forms(Forms1, [return]),
++    {ok, _, Bytes, _Warnings} = compile:forms(Forms1, [return, debug_info]),
+     file:write_file(Basename ++ ".beam", Bytes).
+ 
+ filter_forms(Msgs, [{attribute,L,file,{_,_}}|Tail], Basename, Acc) ->
+-- 
+1.7.4.1
+
diff --git a/erlang-protobuffs-0003-Teach-protobuffs-how-to-skip-directives-it-doesn-t-u.patch b/erlang-protobuffs-0003-Teach-protobuffs-how-to-skip-directives-it-doesn-t-u.patch
new file mode 100644
index 0000000..d6e17a4
--- /dev/null
+++ b/erlang-protobuffs-0003-Teach-protobuffs-how-to-skip-directives-it-doesn-t-u.patch
@@ -0,0 +1,26 @@
+From bbd5f2e749ded803b4bb96673aa7f1b3edb01b61 Mon Sep 17 00:00:00 2001
+From: Kevin Smith <ksmith at basho.com>
+Date: Wed, 16 Jun 2010 15:42:40 -0400
+Subject: [PATCH 3/3] Teach protobuffs how to skip directives it doesn't understand
+
+---
+ src/protobuffs_compile.erl |    3 +++
+ 1 files changed, 3 insertions(+), 0 deletions(-)
+
+diff --git a/src/protobuffs_compile.erl b/src/protobuffs_compile.erl
+index 6968629..45bba70 100644
+--- a/src/protobuffs_compile.erl
++++ b/src/protobuffs_compile.erl
+@@ -180,6 +180,9 @@ collect_full_messages([{package, _Line1},
+                        {bareword, _Line2, _PackageName},
+                        {';', _Line3} | Tail], Acc) ->
+     collect_full_messages(Tail, Acc);
++%% Skip anything we don't understand
++collect_full_messages([_|Tail], Acc) ->
++	collect_full_messages(Tail, Acc);
+ collect_full_messages([], Acc) -> 
+     Acc.
+ 
+-- 
+1.7.4.1
+
diff --git a/erlang-protobuffs.spec b/erlang-protobuffs.spec
index 6e4a41e..94b008c 100644
--- a/erlang-protobuffs.spec
+++ b/erlang-protobuffs.spec
@@ -5,21 +5,25 @@
 
 Name:		erlang-%{realname}
 Version:	0
-Release:	0.3.20100930git%{git_tag}%{?dist}
+Release:	0.4.20100930git%{git_tag}%{?dist}
 Summary:	A set of Protocol Buffers tools and modules for Erlang applications
 Group:		Development/Libraries
 License:	MIT
 URL:		http://github.com/ngerakines/erlang_protobuffs
 # wget http://github.com/ngerakines/erlang_protobuffs/tarball/58ff962
 Source0:	ngerakines-erlang_%{realname}-%{git_tag}.tar.gz
+# All patches below were taken from Basho's fork
+Patch1:		erlang-protobuffs-0001-Test-changes-to-see-if-leaving-the-encoded-protocol-.patch
+Patch2:		erlang-protobuffs-0002-Added-debug-info-to-generated-beams.patch
+Patch3:		erlang-protobuffs-0003-Teach-protobuffs-how-to-skip-directives-it-doesn-t-u.patch
 BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 BuildRequires:	erlang-erts
 BuildRequires:	erlang-etap
 # For /usr/bin/prove
 BuildRequires:	perl(Test::Harness)
-Requires:	erlang-compiler >= R12B-5
+Requires:	erlang-compiler
 Requires:	erlang-erts >= R12B-5
-Requires:	erlang-kernel >= R12B-5
+Requires:	erlang-kernel
 Requires:	erlang-stdlib >= R12B-5
 
 
@@ -29,6 +33,9 @@ A set of Protocol Buffers tools and modules for Erlang applications.
 
 %prep
 %setup -q -n ngerakines-erlang_%{realname}-%{git_tag}
+%patch1 -p1 -b .p1
+%patch2 -p1 -b .p2
+%patch3 -p1 -b .p3
 mkdir ebin
 sed -i -e "s,\.\.\/src,\.\.\/ebin,g" tests/*.t
 
@@ -66,6 +73,9 @@ cd ./tests && ./runtests.sh
 
 
 %changelog
+* Fri Mar 11 2011 Peter Lemenkov <lemenkov at gmail.com> -  0-0.4.20100930git58ff962
+- Added three patches from Basho's fork (required for riak_client)
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0-0.3.20100930git58ff962
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list