Skip to content

Commit

Permalink
Improved test and compilations task.
Browse files Browse the repository at this point in the history
  • Loading branch information
benburkert authored and mrsimo committed Sep 29, 2011
1 parent da7e3d5 commit a4dac36
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ gpgme_n.*
mkmf.log mkmf.log
Makefile Makefile
coverage coverage
Gemfile.lock
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -2,3 +2,5 @@ source "http://rubygems.org"


# Specify your gem's dependencies in gpgme.gemspec # Specify your gem's dependencies in gpgme.gemspec
gemspec gemspec

gem 'rake'
37 changes: 0 additions & 37 deletions Gemfile.lock

This file was deleted.

13 changes: 7 additions & 6 deletions Rakefile
Expand Up @@ -8,17 +8,18 @@ require 'yard'


desc "Re-compile the extensions" desc "Re-compile the extensions"
task :compile do task :compile do
FileUtils.rm_f('gpgme_n.bundle') FileUtils.rm_rf('tmp') if File.directory?('tmp')
FileUtils.rm_f('gpgme_n.o') mkdir 'tmp'
FileUtils.rm_f('Makefile')


system "ruby extconf.rb" Dir.chdir('tmp') do
system "make" system "ruby #{File.dirname(__FILE__)}/ext/gpgme/extconf.rb"
system "make"
end
end end


task :default => [:test] task :default => [:test]


Rake::TestTask.new(:test) do |t| Rake::TestTask.new(:test => :compile) do |t|
t.libs << 'test' t.libs << 'test'
t.pattern = "test/**/*_test.rb" t.pattern = "test/**/*_test.rb"
t.verbose = true t.verbose = true
Expand Down
69 changes: 50 additions & 19 deletions ext/gpgme/extconf.rb
@@ -1,26 +1,57 @@
require 'mkmf' require 'mkmf'


unless find_executable('gpgme-config') CWD = File.expand_path(File.dirname(__FILE__))
$stderr.puts("gpgme-config not found") PREFIX = "#{CWD}/dst/"
exit(1)
def sys(*cmd)
puts " -- #{cmd.join(' ')}"

unless ret = xsystem(cmd.join(' '))
raise "#{cmd.join(' ')} failed!"
end

ret
end end


$CFLAGS += ' ' << `gpgme-config --cflags`.chomp def build(tgz, *flags)
$libs += ' ' << `gpgme-config --libs`.chomp sys("tar xjvf #{tgz}")


checking_for('gpgme >= 1.1.3') do Dir.chdir(File.basename(tgz, '.tar.bz2')) do
if try_run(<<'End') sys("./configure --prefix=#{PREFIX} --disable-shared --enable-static --with-pic", *flags)
#include <gpgme.h> sys("make")
#include <stdlib.h> sys("make install")
int main (void) {
return gpgme_check_version ("1.1.3") == NULL;
}
End
true
else
$CFLAGS += ' -DRUBY_GPGME_NEED_WORKAROUND_KEYLIST_NEXT'
false
end end
end end
have_func('gpgme_op_export_keys')
libgpg_error_tgz = File.join(CWD, 'libgpg-error-1.10.tar.bz2')
libassuan_tgz = File.join(CWD, 'libassuan-2.0.2.tar.bz2')
gpgme_tgz = File.join(CWD, 'gpgme-1.3.1.tar.bz2')

# build deps

build(libgpg_error_tgz, "--disable-nls")
build(libassuan_tgz, "--with-gpg-error-prefix=#{PREFIX}")
build(gpgme_tgz, "--with-gpg-error-prefix=#{PREFIX}", "--with-libassuan-prefix=#{PREFIX}")

# copy gpgme


%w[ libassuan libgpg-error libgpgme ].each do |lib|
FileUtils.cp "#{CWD}/dst/lib/#{lib}.a", "#{CWD}/#{lib}_ext.a"
end

$INCFLAGS[0,0] = " -I#{CWD}/dst/include "
#$LDFLAGS << " -L#{CWD} "
$CFLAGS << " -fPIC "

# build gpgme extension

unless have_library 'gpg-error_ext' and have_library 'gpgme_ext' and have_library 'assuan_ext' and have_library 'gpg-error_ext' and have_header 'gpgme.h'
STDERR.puts "\n\n"
STDERR.puts "*********************************************************"
STDERR.puts "********* error compiling and linking libgpgme. *********"
STDERR.puts "*********************************************************"
exit(1)
end

create_makefile ('gpgme_n') create_makefile ('gpgme_n')
Binary file added ext/gpgme/gpgme-1.3.1.tar.bz2
Binary file not shown.
Binary file added ext/gpgme/libassuan-2.0.2.tar.bz2
Binary file not shown.
Binary file added ext/gpgme/libgpg-error-1.10.tar.bz2
Binary file not shown.
2 changes: 1 addition & 1 deletion gpgme.gemspec
Expand Up @@ -5,7 +5,7 @@ Gem::Specification.new do |s|
s.date = '2011-05-09' s.date = '2011-05-09'
s.email = 'ueno@unixuser.org' s.email = 'ueno@unixuser.org'
s.extensions = ['ext/gpgme/extconf.rb'] s.extensions = ['ext/gpgme/extconf.rb']
s.files = `git ls-files`.split("\n") s.files = Dir['{lib,ext}/**/*']
s.has_rdoc = true s.has_rdoc = true
s.rubyforge_project = 'ruby-gpgme' s.rubyforge_project = 'ruby-gpgme'
s.homepage = 'http://rubyforge.org/projects/ruby-gpgme/' s.homepage = 'http://rubyforge.org/projects/ruby-gpgme/'
Expand Down
5 changes: 5 additions & 0 deletions test/test_helper.rb
@@ -1,4 +1,9 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-

# include compiled gpgme_n.bundle
tmp_dir = File.join(File.dirname(__FILE__), '..', 'tmp')
$:.unshift(tmp_dir) if File.directory?(tmp_dir)

require 'rubygems' require 'rubygems'
require 'bundler/setup' require 'bundler/setup'
require 'minitest/autorun' require 'minitest/autorun'
Expand Down

0 comments on commit a4dac36

Please sign in to comment.