[PATCH 1/2] fix out of tree build for ruby bindings
Tomi Ollila
tomi.ollila at iki.fi
Wed Nov 30 13:40:06 PST 2016
On Tue, Nov 29 2016, David Bremner <david at tethera.net> wrote:
> Tomi Ollila <too at guru.guru-group.fi> writes:
>
>> From: Tomi Ollila <tomi.ollila at iki.fi>
>>
>> Ruby bindings source files had to be copied to the out-of-tree
>> target directory -- final obstacle avoiding that was that if
>> there were built object files in source directory, new target object
>> files were not built (caused link failure, fortunately).
>> ---
>>
>> The ruby-part fix of id:1479146030-17083-1-git-send-email-tomi.ollila at iki.fi
>>
>> bindings/Makefile.local | 2 +-
>> bindings/ruby/extconf.rb | 12 +++++++++++-
>> configure | 6 ++++++
>> 3 files changed, 18 insertions(+), 2 deletions(-)
>>
>> diff --git a/bindings/Makefile.local b/bindings/Makefile.local
>> index 11d11d4..61fe412 100644
>> --- a/bindings/Makefile.local
>> +++ b/bindings/Makefile.local
>> @@ -8,7 +8,7 @@ ifeq ($(HAVE_RUBY_DEV),1)
>> cd $(dir)/ruby && \
>> EXTRA_LDFLAGS="$(NO_UNDEFINED_LDFLAGS)" \
>> LIBNOTMUCH="../../lib/$(LINKER_NAME)" \
>> - ruby extconf.rb --vendor
>> + SRCDIR=$(srcdir) ruby extconf.rb --vendor
>> $(MAKE) -C $(dir)/ruby
>> endif
>>
>> diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb
>> index ddaa684..ed57d33 100644
>> --- a/bindings/ruby/extconf.rb
>> +++ b/bindings/ruby/extconf.rb
>> @@ -1,11 +1,21 @@
>> #!/usr/bin/env ruby
>> # coding: utf-8
>> # Copyright 2010, 2011, 2012 Ali Polatel <alip at exherbo.org>
>> +# Out of tree build update: 2016 Tomi Ollila
>> # Distributed under the terms of the GNU General Public License v3
>>
>> require 'mkmf'
>>
>> -dir = File.join('..', '..', 'lib')
>> +# ENV['SRCDIR'] is build system's vision of source dir...
>> +srcroot = ENV['SRCDIR']
>> +# ...so fix it; expect hardcoded ../.. to work
>> +if srcroot == '.'
>> + srcroot = File.join('..', '..')
>> +elsif srcroot[0] != '/'
>> + srcroot = File.join('..', '..', srcroot)
>> +end
>
> I guess I have the same question about the non-absolute path case
> here. Are we assuming some convention?
The case here is that $srcdir can be either relative or absolute.
In normat in-tree build it (usually is '.') (./configure is executed,
but in case of in-tree build also $PWD/configure could also be executed).
In out-of-tree build $srcdir can be e.g. ../notmuch (../notmuch/configure
was executed) or absolute /path/to/notmuch.
In case of $TEST_DIRECTORY. When $srcdir is relative, the real it is to be
referenced from $TEST_DIRECTORY/.. (as current dir when tests are executed
is (path/to/)notmuch/test ) is $srcdir is absolute, then that is the source
directory (and prefixing that with ../* is just plain wrong ;) (in 1st patch
I used cd and then pwd -P to resolve real physical path, to be in
consistency with TEST_DIRECTORY=$(pwd -P) (*))
In case of ruby bindings (notmuch/ruby/bindings), same story, just ../..
(and no physical path resolvation).
There are now 2 alternatives
1) write srcdir as absolute path (only or additionally) to the *.config
files. this would make these things simpler. Here the hard problem is off^H^H^H
name the variable...
2) I write some more comments to the code -- it took a second or two for me
to re-orient this change so I could write this reply.
Tomi
(*) here it does not matter, but in generic case this pwd -P would not be
such a good idea, if TEST_DIRECTORY were a symlink in notmuch directory,
the parent dir of $TEST_DIRECTORY could point elsewhere. But also note that
if x=$(pwd) and y=$(pwd -P) of any directory differs, then also "$x/.." may
point to different location than "${x%/*}" -- I got hit by this couple of
weeks ago...
More information about the notmuch
mailing list