Skip to content
Browse files

Improved test and compilations task.

  • Loading branch information...
1 parent da7e3d5 commit a4dac367a14904232933b8f3032dd63548707434 @benburkert benburkert committed with mrsimo Aug 23, 2011
View
1 .gitignore
@@ -3,3 +3,4 @@ gpgme_n.*
mkmf.log
Makefile
coverage
+Gemfile.lock
View
2 Gemfile
@@ -2,3 +2,5 @@ source "http://rubygems.org"
# Specify your gem's dependencies in gpgme.gemspec
gemspec
+
+gem 'rake'
View
37 Gemfile.lock
@@ -1,37 +0,0 @@
-PATH
- remote: .
- specs:
- gpgme (1.0.8)
-
-GEM
- remote: http://rubygems.org/
- specs:
- archive-tar-minitar (0.5.2)
- columnize (0.3.2)
- linecache19 (0.5.12)
- ruby_core_source (>= 0.1.4)
- minitest (2.1.0)
- mocha (0.9.12)
- rcov (0.9.9)
- ruby-debug-base19 (0.11.25)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby_core_source (>= 0.1.4)
- ruby-debug19 (0.11.6)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby-debug-base19 (>= 0.11.19)
- ruby_core_source (0.1.4)
- archive-tar-minitar (>= 0.5.2)
- yard (0.6.7)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- gpgme!
- minitest (~> 2.1.0)
- mocha (~> 0.9.12)
- rcov (~> 0.9.9)
- ruby-debug19 (~> 0.11.6)
- yard (~> 0.6.7)
View
13 Rakefile
@@ -8,17 +8,18 @@ require 'yard'
desc "Re-compile the extensions"
task :compile do
- FileUtils.rm_f('gpgme_n.bundle')
- FileUtils.rm_f('gpgme_n.o')
- FileUtils.rm_f('Makefile')
+ FileUtils.rm_rf('tmp') if File.directory?('tmp')
+ mkdir 'tmp'
- system "ruby extconf.rb"
- system "make"
+ Dir.chdir('tmp') do
+ system "ruby #{File.dirname(__FILE__)}/ext/gpgme/extconf.rb"
+ system "make"
+ end
end
task :default => [:test]
-Rake::TestTask.new(:test) do |t|
+Rake::TestTask.new(:test => :compile) do |t|
t.libs << 'test'
t.pattern = "test/**/*_test.rb"
t.verbose = true
View
69 ext/gpgme/extconf.rb
@@ -1,26 +1,57 @@
require 'mkmf'
-unless find_executable('gpgme-config')
- $stderr.puts("gpgme-config not found")
- exit(1)
+CWD = File.expand_path(File.dirname(__FILE__))
+PREFIX = "#{CWD}/dst/"
+
+def sys(*cmd)
+ puts " -- #{cmd.join(' ')}"
+
+ unless ret = xsystem(cmd.join(' '))
+ raise "#{cmd.join(' ')} failed!"
+ end
+
+ ret
end
-$CFLAGS += ' ' << `gpgme-config --cflags`.chomp
-$libs += ' ' << `gpgme-config --libs`.chomp
-
-checking_for('gpgme >= 1.1.3') do
- if try_run(<<'End')
-#include <gpgme.h>
-#include <stdlib.h>
-int main (void) {
- return gpgme_check_version ("1.1.3") == NULL;
-}
-End
- true
- else
- $CFLAGS += ' -DRUBY_GPGME_NEED_WORKAROUND_KEYLIST_NEXT'
- false
+def build(tgz, *flags)
+ sys("tar xjvf #{tgz}")
+
+ Dir.chdir(File.basename(tgz, '.tar.bz2')) do
+ sys("./configure --prefix=#{PREFIX} --disable-shared --enable-static --with-pic", *flags)
+ sys("make")
+ sys("make install")
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')
View
BIN ext/gpgme/gpgme-1.3.1.tar.bz2
Binary file not shown.
View
BIN ext/gpgme/libassuan-2.0.2.tar.bz2
Binary file not shown.
View
BIN ext/gpgme/libgpg-error-1.10.tar.bz2
Binary file not shown.
View
2 gpgme.gemspec
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
s.date = '2011-05-09'
s.email = 'ueno@unixuser.org'
s.extensions = ['ext/gpgme/extconf.rb']
- s.files = `git ls-files`.split("\n")
+ s.files = Dir['{lib,ext}/**/*']
s.has_rdoc = true
s.rubyforge_project = 'ruby-gpgme'
s.homepage = 'http://rubyforge.org/projects/ruby-gpgme/'
View
5 test/test_helper.rb
@@ -1,4 +1,9 @@
# -*- 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 'bundler/setup'
require 'minitest/autorun'

0 comments on commit a4dac36

Please sign in to comment.
Something went wrong with that request. Please try again.