unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] ruby: general improvements
@ 2013-05-20 12:24 Felipe Contreras
  2013-05-20 12:24 ` [PATCH 1/2] ruby: use in-tree notmuch library Felipe Contreras
  2013-05-20 12:24 ` [PATCH 2/2] ruby: fix missing symbol UINT2FIX() Felipe Contreras
  0 siblings, 2 replies; 9+ messages in thread
From: Felipe Contreras @ 2013-05-20 12:24 UTC (permalink / raw)
  To: notmuch; +Cc: Ali Polatel

Hi,

Not much to say here.

Felipe Contreras (2):
  ruby: use in-tree notmuch library
  ruby: fix missing symbol UINT2FIX()

 bindings/ruby/extconf.rb | 23 ++++++++++++++++++++---
 bindings/ruby/query.c    |  2 +-
 2 files changed, 21 insertions(+), 4 deletions(-)

-- 
1.8.3.rc3.286.g3d43083

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] ruby: use in-tree notmuch library
  2013-05-20 12:24 [PATCH 0/2] ruby: general improvements Felipe Contreras
@ 2013-05-20 12:24 ` Felipe Contreras
  2013-05-20 14:41   ` David Bremner
  2013-05-20 12:24 ` [PATCH 2/2] ruby: fix missing symbol UINT2FIX() Felipe Contreras
  1 sibling, 1 reply; 9+ messages in thread
From: Felipe Contreras @ 2013-05-20 12:24 UTC (permalink / raw)
  To: notmuch; +Cc: Ali Polatel

Currently it simply finds any library available, and if notmuch is
installed in the system, it would give priority to that library.

Let's implement our own helper functions to link directly to the local
library, and give priority to the local header file.

Also, add an option to properly check if there are missing symbols.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 bindings/ruby/extconf.rb | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb
index 7b9750f..ddd4e48 100644
--- a/bindings/ruby/extconf.rb
+++ b/bindings/ruby/extconf.rb
@@ -5,9 +5,26 @@
 
 require 'mkmf'
 
-# Notmuch Library
-find_header('notmuch.h', '../../lib')
-find_library('notmuch', 'notmuch_database_create', '../../lib')
+dir = File.join('..', '..', 'lib')
+
+# includes
+$INCFLAGS = "-I#{dir} #{$INCFLAGS}"
+
+# make sure there are no undefined symbols
+$LDFLAGS += ' -Wl,--no-undefined'
+
+def have_local_library(lib, path, func, headers = nil)
+  checking_for checking_message(func.funcall_style, lib) do
+    lib = File.join(path, lib)
+    if try_func(func, lib, headers)
+      $LOCAL_LIBS += lib
+    end
+  end
+end
+
+if not have_local_library('libnotmuch.so', dir, 'notmuch_database_create', 'notmuch.h')
+  exit 1
+end
 
 # Create Makefile
 dir_config('notmuch')
-- 
1.8.3.rc3.286.g3d43083

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] ruby: fix missing symbol UINT2FIX()
  2013-05-20 12:24 [PATCH 0/2] ruby: general improvements Felipe Contreras
  2013-05-20 12:24 ` [PATCH 1/2] ruby: use in-tree notmuch library Felipe Contreras
@ 2013-05-20 12:24 ` Felipe Contreras
  2013-05-21 14:17   ` Tomi Ollila
  1 sibling, 1 reply; 9+ messages in thread
From: Felipe Contreras @ 2013-05-20 12:24 UTC (permalink / raw)
  To: notmuch; +Cc: Ali Polatel

It has never existed in Ruby (maybe JRuby). Fortunately the symbols are
loaded lazily, so nobody would notice unless they try
'query::count_messages'.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 bindings/ruby/query.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
index e5ba1b7..1658ede 100644
--- a/bindings/ruby/query.c
+++ b/bindings/ruby/query.c
@@ -180,5 +180,5 @@ notmuch_rb_query_count_messages (VALUE self)
      * (function may return 0 after printing a message)
      * Thus there is nothing we can do here...
      */
-    return UINT2FIX(notmuch_query_count_messages(query));
+    return UINT2NUM(notmuch_query_count_messages(query));
 }
-- 
1.8.3.rc3.286.g3d43083

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ruby: use in-tree notmuch library
  2013-05-20 12:24 ` [PATCH 1/2] ruby: use in-tree notmuch library Felipe Contreras
@ 2013-05-20 14:41   ` David Bremner
  2013-05-20 22:24     ` Felipe Contreras
  0 siblings, 1 reply; 9+ messages in thread
From: David Bremner @ 2013-05-20 14:41 UTC (permalink / raw)
  To: Felipe Contreras, notmuch; +Cc: Ali Polatel

Felipe Contreras <felipe.contreras@gmail.com> writes:

> Currently it simply finds any library available, and if notmuch is
> installed in the system, it would give priority to that library.
>

I like the concept, but I get the following: 

,----
| ╭─ zancas:upstream/notmuch/bindings/ruby 
| ╰─ (git)-[rubytest]-% ruby extconf.rb 
| *** extconf.rb failed ***
| Could not create Makefile due to some reason, probably lack of
| necessary libraries and/or headers.  Check the mkmf.log file for more
| details.  You may need configuration options.
| 
| Provided configuration options:
| 	--with-opt-dir
| 	--without-opt-dir
| 	--with-opt-include
| 	--without-opt-include=${opt-dir}/include
| 	--with-opt-lib
| 	--without-opt-lib=${opt-dir}/lib
| 	--with-make-prog
| 	--without-make-prog
| 	--srcdir=.
| 	--curdir
| 	--ruby=/usr/bin/ruby1.9.1
| extconf.rb:17:in `have_local_library': undefined method `funcall_style' for "notmuch_database_create":String (NoMethodError)
| 	from extconf.rb:25:in `<main>'
`----

I have the ruby 1.9.3 development headers (at least "ruby extconf.rb"
works on master).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ruby: use in-tree notmuch library
  2013-05-20 14:41   ` David Bremner
@ 2013-05-20 22:24     ` Felipe Contreras
  2013-05-23 11:44       ` David Bremner
  0 siblings, 1 reply; 9+ messages in thread
From: Felipe Contreras @ 2013-05-20 22:24 UTC (permalink / raw)
  To: David Bremner; +Cc: Ali Polatel, notmuch

On Mon, May 20, 2013 at 9:41 AM, David Bremner <david@tethera.net> wrote:

> | extconf.rb:17:in `have_local_library': undefined method `funcall_style' for "notmuch_database_create":String (NoMethodError)
> |       from extconf.rb:25:in `<main>'
> `----
>
> I have the ruby 1.9.3 development headers (at least "ruby extconf.rb"
> works on master).

checking_for checking_message(func, lib) do

Then

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] ruby: fix missing symbol UINT2FIX()
  2013-05-20 12:24 ` [PATCH 2/2] ruby: fix missing symbol UINT2FIX() Felipe Contreras
@ 2013-05-21 14:17   ` Tomi Ollila
  2013-05-21 14:46     ` Ali Polatel
  0 siblings, 1 reply; 9+ messages in thread
From: Tomi Ollila @ 2013-05-21 14:17 UTC (permalink / raw)
  To: Felipe Contreras, notmuch; +Cc: Ali Polatel

On Mon, May 20 2013, Felipe Contreras <felipe.contreras@gmail.com> wrote:

> It has never existed in Ruby (maybe JRuby). Fortunately the symbols are
> loaded lazily, so nobody would notice unless they try
> 'query::count_messages'.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>

This patch could be pushed on it's own, but someone (like Ali) could
comment on the change as searches on both UINT2FIX() & UINT2NUM()
provides (IMH) insatisfactory results...

Tomi

> ---
>  bindings/ruby/query.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
> index e5ba1b7..1658ede 100644
> --- a/bindings/ruby/query.c
> +++ b/bindings/ruby/query.c
> @@ -180,5 +180,5 @@ notmuch_rb_query_count_messages (VALUE self)
>       * (function may return 0 after printing a message)
>       * Thus there is nothing we can do here...
>       */
> -    return UINT2FIX(notmuch_query_count_messages(query));
> +    return UINT2NUM(notmuch_query_count_messages(query));
>  }
> -- 
> 1.8.3.rc3.286.g3d43083
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] ruby: fix missing symbol UINT2FIX()
  2013-05-21 14:17   ` Tomi Ollila
@ 2013-05-21 14:46     ` Ali Polatel
  2013-05-21 14:59       ` Tomi Ollila
  0 siblings, 1 reply; 9+ messages in thread
From: Ali Polatel @ 2013-05-21 14:46 UTC (permalink / raw)
  To: Tomi Ollila; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 1717 bytes --]

2013/05/21 Tomi Ollila <tomi.ollila@iki.fi>:
>On Mon, May 20 2013, Felipe Contreras <felipe.contreras@gmail.com> wrote:
>
>> It has never existed in Ruby (maybe JRuby). Fortunately the symbols are
>> loaded lazily, so nobody would notice unless they try
>> 'query::count_messages'.
>>
>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>
>This patch could be pushed on it's own, but someone (like Ali) could
>comment on the change as searches on both UINT2FIX() & UINT2NUM()
>provides (IMH) insatisfactory results...

LGTM.

My bad, there's no such thing as UINT2FIX().
Yet, what's wrong with UINT2NUM()?

The description looks like:
"...take an unsigned int and convert it to a FIXNUM object if it will fit;
otherwise, convert to a Bignum object..."

Besides ruby-1.8 has it and that's the oldest version I was willing to
support. (If you have some free time, please confirm this because I may
not be remembering correctly.)

>Tomi

		-alip

>
>> ---
>>  bindings/ruby/query.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
>> index e5ba1b7..1658ede 100644
>> --- a/bindings/ruby/query.c
>> +++ b/bindings/ruby/query.c
>> @@ -180,5 +180,5 @@ notmuch_rb_query_count_messages (VALUE self)
>>       * (function may return 0 after printing a message)
>>       * Thus there is nothing we can do here...
>>       */
>> -    return UINT2FIX(notmuch_query_count_messages(query));
>> +    return UINT2NUM(notmuch_query_count_messages(query));
>>  }
>> --
>> 1.8.3.rc3.286.g3d43083
>>
>> _______________________________________________
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> http://notmuchmail.org/mailman/listinfo/notmuch

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] ruby: fix missing symbol UINT2FIX()
  2013-05-21 14:46     ` Ali Polatel
@ 2013-05-21 14:59       ` Tomi Ollila
  0 siblings, 0 replies; 9+ messages in thread
From: Tomi Ollila @ 2013-05-21 14:59 UTC (permalink / raw)
  To: Ali Polatel; +Cc: notmuch

On Tue, May 21 2013, Ali Polatel <polatel@gmail.com> wrote:

> 2013/05/21 Tomi Ollila <tomi.ollila@iki.fi>:
>>On Mon, May 20 2013, Felipe Contreras <felipe.contreras@gmail.com> wrote:
>>
>>> It has never existed in Ruby (maybe JRuby). Fortunately the symbols are
>>> loaded lazily, so nobody would notice unless they try
>>> 'query::count_messages'.
>>>
>>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>>
>>This patch could be pushed on it's own, but someone (like Ali) could
>>comment on the change as searches on both UINT2FIX() & UINT2NUM()
>>provides (IMH) insatisfactory results...
>
> LGTM.
>
> My bad, there's no such thing as UINT2FIX().
> Yet, what's wrong with UINT2NUM()?

Nothing wrong -- although it seems obvious UINT2NUM() is the right thing
to do I was not qualified to say so...

>
> The description looks like:
> "...take an unsigned int and convert it to a FIXNUM object if it will fit;
> otherwise, convert to a Bignum object..."

... as I did not find this description when browsing the search results
(now this was in the first search result -- sometimes one just doesn't
get the right search terms in place)...

>
> Besides ruby-1.8 has it and that's the oldest version I was willing to
> support. (If you have some free time, please confirm this because I may
> not be remembering correctly.)

Cannot confirm for sure -- I found references to UINT2NUM() and ruby
1.8.6...

.. anyway UINT2FIX() doesn't work and UINT2NUM() works with very high
probablility I'd say lets get this pushed.

"Hey, it compiles! Ship It !"

>
>>Tomi
>
> 		-alip

Tomi

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] ruby: use in-tree notmuch library
  2013-05-20 22:24     ` Felipe Contreras
@ 2013-05-23 11:44       ` David Bremner
  0 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2013-05-23 11:44 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Ali Polatel, notmuch

Felipe Contreras <felipe.contreras@gmail.com> writes:

> On Mon, May 20, 2013 at 9:41 AM, David Bremner <david@tethera.net> wrote:
>
>> | extconf.rb:17:in `have_local_library': undefined method `funcall_style' for "notmuch_database_create":String (NoMethodError)
>> |       from extconf.rb:25:in `<main>'
>> `----
>>
>> I have the ruby 1.9.3 development headers (at least "ruby extconf.rb"
>> works on master).
>
> checking_for checking_message(func, lib) do
>
> Then

OK, eventually I figured out this cryptic message ;).

pushed both.

d

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-05-23 11:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-20 12:24 [PATCH 0/2] ruby: general improvements Felipe Contreras
2013-05-20 12:24 ` [PATCH 1/2] ruby: use in-tree notmuch library Felipe Contreras
2013-05-20 14:41   ` David Bremner
2013-05-20 22:24     ` Felipe Contreras
2013-05-23 11:44       ` David Bremner
2013-05-20 12:24 ` [PATCH 2/2] ruby: fix missing symbol UINT2FIX() Felipe Contreras
2013-05-21 14:17   ` Tomi Ollila
2013-05-21 14:46     ` Ali Polatel
2013-05-21 14:59       ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).