Skip to content

Commit

Permalink
Move recipe definitions in dependencies.yml
Browse files Browse the repository at this point in the history
A similar approach is used in native gems such as re2 and nokogiri.
It makes it easier to auto-update the dependencies if they are
in a YAML file.
  • Loading branch information
stanhu committed Aug 28, 2024
1 parent c55a80e commit 51020b8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 44 deletions.
7 changes: 7 additions & 0 deletions dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
libgpg-error:
version: '1.47'
sha256: 9e3c670966b96ecc746c28c2c419541e3bcb787d1a73930f5e5f5e1bcbbb9bdb
libassuan:
version: '2.5.6'
sha256: e9fd27218d5394904e4e39788f9b1742711c3e6b41689a31aa3380bd5aa4f426
95 changes: 52 additions & 43 deletions ext/gpgme/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'mkmf'
require 'yaml'

# Available options:
#
Expand All @@ -9,6 +10,56 @@

ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))

def load_recipes
require 'rubygems'
require 'mini_portile2'

dependencies = YAML.load_file(File.join(ROOT, 'dependencies.yml'))

libgpg_error_recipe = MiniPortile.new('libgpg-error', dependencies['libgpg-error']['version']).tap do |recipe|
recipe.target = File.join(ROOT, "ports")
recipe.files = [{
:url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
:sha256 => dependencies['libgpg-error']['sha256']
}]
recipe.configure_options = [
'--enable-install-gpg-error-config',
'--disable-shared',
'--enable-static',
'--disable-nls',
"CFLAGS=-fPIC #{ENV["CFLAGS"]}",
]
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
unless File.exist?(checkpoint)
recipe.cook
FileUtils.touch checkpoint
end
recipe.activate
end

libassuan_recipe = MiniPortile.new('libassuan', dependencies['libassuan']['version']).tap do |recipe|
recipe.target = File.join(ROOT, "ports")
recipe.files = [{
:url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
:sha256 => dependencies['libassuan']['sha256']
}]
recipe.configure_options = [
'--disable-shared',
'--enable-static',
"--with-gpg-error-prefix=#{libgpg_error_recipe.path}",
"CFLAGS=-fPIC #{ENV["CFLAGS"]}",
]
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
unless File.exist?(checkpoint)
recipe.cook
FileUtils.touch checkpoint
end
recipe.activate
end

[libgpg_error_recipe, libassuan_recipe]
end

if arg_config('--clean')
require 'pathname'
require 'fileutils'
Expand Down Expand Up @@ -62,49 +113,7 @@
************************************************************************
EOS

require 'rubygems'
require 'mini_portile2'

libgpg_error_recipe = MiniPortile.new('libgpg-error', '1.47').tap do |recipe|
recipe.target = File.join(ROOT, "ports")
recipe.files = [{
:url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
:sha256 => '9e3c670966b96ecc746c28c2c419541e3bcb787d1a73930f5e5f5e1bcbbb9bdb'
}]
recipe.configure_options = [
'--enable-install-gpg-error-config',
'--disable-shared',
'--enable-static',
'--disable-nls',
"CFLAGS=-fPIC #{ENV["CFLAGS"]}",
]
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
unless File.exist?(checkpoint)
recipe.cook
FileUtils.touch checkpoint
end
recipe.activate
end

libassuan_recipe = MiniPortile.new('libassuan', '2.5.6').tap do |recipe|
recipe.target = File.join(ROOT, "ports")
recipe.files = [{
:url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
:sha256 => 'e9fd27218d5394904e4e39788f9b1742711c3e6b41689a31aa3380bd5aa4f426'
}]
recipe.configure_options = [
'--disable-shared',
'--enable-static',
"--with-gpg-error-prefix=#{libgpg_error_recipe.path}",
"CFLAGS=-fPIC #{ENV["CFLAGS"]}",
]
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
unless File.exist?(checkpoint)
recipe.cook
FileUtils.touch checkpoint
end
recipe.activate
end
libgpg_error_recipe, libassuan_recipe = load_recipes

pkg_config_paths = [
File.join(libgpg_error_recipe.lib_path, 'pkgconfig'),
Expand Down
3 changes: 2 additions & 1 deletion gpgme.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Gem::Specification.new do |s|
s.date = '2024-01-31'
s.email = '[email protected]'
s.extensions = ['ext/gpgme/extconf.rb']
s.files = Dir['{lib,ext,test,examples}/**/*'] +
s.files = ['dependencies.yml'] +
Dir['{lib,ext,test,examples}/**/*'] +
Dir['ports/archives/*']
s.rubyforge_project = 'ruby-gpgme'
s.homepage = 'http://github.com/ueno/ruby-gpgme'
Expand Down

0 comments on commit 51020b8

Please sign in to comment.