This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
/
compile.rake
63 lines (53 loc) · 2.24 KB
/
compile.rake
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
tasks_dir = ROOT.parent + 'tasks'
begin
gem('rake-compiler')
require 'rake/extensiontask'
require 'rake/javaextensiontask'
Rake::ExtensionTask.new('do_mysql_ext', $gemspec) do |ext|
mysql_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-#{BINARY_VERSION}-win32"))
# automatically add build options to avoid need of manual input
if RUBY_PLATFORM =~ /mswin|mingw/ then
ext.config_options << "--with-mysql-include=#{mysql_lib}/include"
ext.config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
else
ext.cross_compile = true
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
ext.cross_config_options << "--with-mysql-include=#{mysql_lib}/include"
ext.cross_config_options << "--with-mysql-lib=#{mysql_lib}/lib/opt"
end
end
Rake::JavaExtensionTask.new('do_mysql_ext', $gemspec) do |ext|
ext.ext_dir = 'ext-java/src/main/java'
ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar'
ext.java_compiling do |gem|
gem.add_dependency 'jdbc-mysql', '>=5.0.4'
gem.add_dependency 'do_jdbc', '0.10.1'
gem.post_install_message = <<EOF
==========================================================================
DataObjects MySQL Driver:
You've installed the binary extension for JRuby (Java platform)
==========================================================================
EOF
# components, files and paths
# gem.files = Dir['lib/**/*.rb', 'spec/**/*.rb', 'tasks/**/*.rake',
# 'LICENSE', 'Rakefile', '*.{markdown,rdoc,txt,yml}', 'lib/*.jar']
end
end
rescue LoadError
warn "To compile, install rake-compiler (gem install rake-compiler)"
end
# Stolen from http://github.com/karottenreibe/joker/blob/master/tasks/c_extensions.rake:
#
# Workaround for rake-compiler, which YAML-dump-loads the gemspec, which leads
# to errors since Procs can't be loaded.
Rake::Task.tasks.each do |task_name|
case task_name.to_s
when /^native|java/
task_name.prerequisites.unshift("fix_rake_compiler_gemspec_dump")
end
end
task :fix_rake_compiler_gemspec_dump do
%w{files extra_rdoc_files test_files}.each do |accessor|
$gemspec.send(accessor).instance_eval { @exclude_procs = Array.new }
end
end