-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathRakefile
More file actions
92 lines (76 loc) · 2.79 KB
/
Rakefile
File metadata and controls
92 lines (76 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# -*- coding: utf-8 -*-
# -*- ruby -*-
require 'rubygems'
require 'hoe'
require 'rake/extensiontask'
require 'rbconfig'
PROTECT_SERVER_SDK_DIR = ENV['PROTECT_SERVER_SDK_DIR'] || '/opt/ETcpsdk'
RUBY_PKCS11_DIR = File.expand_path('..')
$: << File.join(RUBY_PKCS11_DIR, "lib")
SHARED_FILES = [
'ext/pk11_struct_macros.h',
'ext/pk11_const_macros.h',
'ext/pk11_version.h',
'ext/generate_structs.rb',
'ext/generate_constants.rb',
]
GENERATED_FILES = [
"ext/std_structs.rb"
]
CLEAN.include [
'ext/pk11s_struct_impl.inc',
'ext/pk11s_struct_def.inc',
'ext/pk11s_const_def.inc',
'ext/pk11s_struct.doc',
]
CLEAN.include SHARED_FILES
CLEAN.include GENERATED_FILES
CLEAN.include 'lib/pkcs11_protect_server_ext.so'
CLEAN.include 'tmp'
def pkcs11_version
file = File.join(RUBY_PKCS11_DIR, 'ext/pk11_version.h')
version_re = /VERSION += +([\"\'])([\d][\d\w\.]+)\1/
File.read_utf(file)[version_re, 2]
end
# Ensure pkg is rebuilt
task :remove_pkg do
rm_rf 'pkg'
end
task :gem => [:remove_pkg]
task :compile => GENERATED_FILES
hoe = Hoe.spec 'pkcs11_protect_server' do
developer('Lars Kanis', 'kanis@comcard.de')
extra_deps << ['pkcs11', "= #{pkcs11_version}"]
extra_dev_deps << ['yard', '~> 0.6']
extra_dev_deps << ['rake-compiler', '~> 0.7']
self.summary = 'Safenet-ProtectServer extensions for PKCS#11-Ruby'
self.description = 'This module allows Ruby programs to use vendor extensions for Safenet Protect Server.'
self.version = pkcs11_version
self.readme_file = 'README_PROTECT_SERVER.rdoc'
self.history_file = '../History.txt'
self.extra_rdoc_files << self.readme_file << 'ext/pk11s.c'
spec_extras[:extensions] = 'ext/extconf.rb'
spec_extras[:files] = File.read_utf("Manifest.txt").split(/\r?\n\r?/)
spec_extras[:files] += SHARED_FILES + GENERATED_FILES
spec_extras[:required_ruby_version] = '>= 2.2.0'
end
Rake::ExtensionTask.new('pkcs11_protect_server_ext', hoe.spec) do |ext|
ext.ext_dir = 'ext'
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
ext.cross_platform = ['i386-mingw32'] # forces the Windows platform instead of the default one
ext.config_options << "--with-protect-server-sdk-dir=#{PROTECT_SERVER_SDK_DIR.inspect}"
end
# Add shared file from base pkcs11 gem
SHARED_FILES.each do |filename|
file filename => File.join(RUBY_PKCS11_DIR, filename) do |t|
cp t.prerequisites.first, t.name, verbose: true
end
file 'ext/extconf.rb' => filename
end
file "ext/std_structs.rb" do |t|
require "pkcs11"
std_structs = PKCS11.constants.select{|c| PKCS11.const_get(c).respond_to?(:ancestors) && !(PKCS11.const_get(c).ancestors & [PKCS11::CStruct, PKCS11::CK_ATTRIBUTE]).empty? }
File.write t.name, "PKCS11_STD_STRUCTS = #{std_structs.inspect}"
end
task doc_files: 'ext/pk11s_struct.doc'
# vim: syntax=ruby