Skip to content
Snippets Groups Projects
Commit d85ba86c authored by Lars Kanis's avatar Lars Kanis
Browse files

Use mini_portile and shared libraries to build Windows binaries.

Static linking all dependent libraries into each ruby version (from
1.8 to 2.2) would blow up the gem to >20MB.
parent 2fd7eff1
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,6 @@ History.txt ...@@ -5,7 +5,6 @@ History.txt
Manifest.txt Manifest.txt
README.rdoc README.rdoc
Rakefile Rakefile
Rakefile.cross
TODO TODO
doap.rdf.erb doap.rdf.erb
examples/RAA.rb examples/RAA.rb
......
...@@ -3,7 +3,6 @@ require 'hoe' ...@@ -3,7 +3,6 @@ require 'hoe'
require 'erb' require 'erb'
require 'rake/extensiontask' require 'rake/extensiontask'
require './lib/fox16/version.rb' require './lib/fox16/version.rb'
load 'Rakefile.cross'
# Use forked process for chdir'ed environment, to allow parallel execution with drake # Use forked process for chdir'ed environment, to allow parallel execution with drake
module FileUtils module FileUtils
...@@ -19,8 +18,6 @@ end ...@@ -19,8 +18,6 @@ end
# Some constants we'll need # Some constants we'll need
PKG_VERSION = Fox.fxrubyversion PKG_VERSION = Fox.fxrubyversion
# TODO: Don't depend on cross compilation task
FXSCINTILLA_INSTALL_DIR = Pathname( CrossLibraries.first.static_libfxscintilla_builddir ).expand_path
SWIG = (RUBY_PLATFORM =~ /mingw/) ? "swig.exe" : "swig" SWIG = (RUBY_PLATFORM =~ /mingw/) ? "swig.exe" : "swig"
SWIGFLAGS = "-c++ -ruby -nodefaultdtor -nodefaultctor -w302 -features compactdefaultargs -I../fox-includes" SWIGFLAGS = "-c++ -ruby -nodefaultdtor -nodefaultctor -w302 -features compactdefaultargs -I../fox-includes"
...@@ -92,28 +89,40 @@ task :test => [:compile] ...@@ -92,28 +89,40 @@ task :test => [:compile]
Rake::ExtensionTask.new("fox16_c", hoe.spec) do |ext| Rake::ExtensionTask.new("fox16_c", hoe.spec) do |ext|
ext.cross_compile = true ext.cross_compile = true
ext.cross_platform = CrossLibraries.map &:ruby_platform ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
ext.cross_config_options += CrossLibraries.map do |lib| ext.cross_config_options += [
{ "--enable-win32-cross",
lib.ruby_platform => [ "--with-fxscintilla",
"--with-fox-include=#{lib.static_installdir}/include/fox-1.6", ]
"--with-fxscintilla-include=#{lib.static_installdir}/include/fxscintilla",
"--with-installed-include=#{lib.static_installdir}/include", # Add dependent DLLs to the cross gems
"--with-installed-lib=#{lib.static_installdir}/lib", ext.cross_compiling do |spec|
"--enable-win32-static-build", plat = spec.platform
"--with-fxscintilla", dlls = Dir["tmp/#{plat}/#{ext.name}/*/*.dll"].map{|dll| File.basename(dll) }.uniq
] spec.files += dlls.map{|dll| "lib/#{plat}/#{dll}" }
}
directory "tmp/#{plat}/stage/lib/#{plat}/"
dlls.each do |dll|
ENV['RUBY_CC_VERSION'].to_s.split(':').last.tap do |ruby_version|
file "tmp/#{plat}/stage/lib/#{plat}/#{dll}" => ["tmp/#{plat}/stage/lib/#{plat}/", "tmp/#{plat}/#{ext.name}/#{ruby_version}/#{dll}"] do
cp "tmp/#{plat}/#{ext.name}/#{ruby_version}/#{dll}", "tmp/#{plat}/stage/lib/#{plat}"
sh "x86_64-w64-mingw32-strip", "tmp/#{plat}/stage/lib/#{plat}/#{dll}"
end
end
file "lib/#{plat}/#{dll}" => "tmp/#{plat}/stage/lib/#{plat}/#{dll}"
end
end end
end end
CrossLibraries.each do |lib| # To reduce the gem file size strip mingw32 dlls before packaging
ENV['RUBY_CC_VERSION'].split(":").each do |ruby_version| ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
task "copy:fox16_c:#{lib.ruby_platform}:#{ruby_version}" do |t| task "tmp/x86-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/fox16_c.so" do |t|
sh "#{lib.host_platform}-strip -S tmp/#{lib.ruby_platform}/stage/lib/#{ruby_version[0,3]}/fox16_c.so" sh "i686-w64-mingw32-strip -S tmp/x86-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/fox16_c.so"
end end
task "tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/fox16_c.so" do |t|
sh "x86_64-w64-mingw32-strip -S tmp/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/fox16_c.so"
end end
end end
...@@ -215,9 +224,16 @@ namespace :fxruby do ...@@ -215,9 +224,16 @@ namespace :fxruby do
file "ext/fox16_c/extconf.rb" => ['ext/fox16_c/swigruby.h', 'ext/fox16_c/impl.cpp', 'ext/fox16_c/include/inlinestubs.h'] + file "ext/fox16_c/extconf.rb" => ['ext/fox16_c/swigruby.h', 'ext/fox16_c/impl.cpp', 'ext/fox16_c/include/inlinestubs.h'] +
SWIG_MODULES.map{|ifile, cppfile| File.join("ext/fox16_c", cppfile) } SWIG_MODULES.map{|ifile, cppfile| File.join("ext/fox16_c", cppfile) }
directory "tmp/fxscintilla"
task "tmp/fxscintilla/fxscintilla-2.28.0/include/Scintilla.iface" => ["tmp/fxscintilla", "ports/archives/fxscintilla-2.28.0.tar.gz"] do
chdir "tmp/fxscintilla" do
sh "tar xzf ../../ports/archives/fxscintilla-2.28.0.tar.gz"
end
end
task :scintilla => 'lib/fox16/scintilla.rb' task :scintilla => 'lib/fox16/scintilla.rb'
file 'lib/fox16/scintilla.rb' => [FXSCINTILLA_INSTALL_DIR, 'scripts/iface.rb'] do file 'lib/fox16/scintilla.rb' => ["tmp/fxscintilla/fxscintilla-2.28.0/include/Scintilla.iface", 'scripts/iface.rb'] do
ruby "scripts/iface.rb -i #{FXSCINTILLA_INSTALL_DIR}/include/Scintilla.iface -o lib/fox16/scintilla.rb" ruby "scripts/iface.rb -i tmp/fxscintilla/fxscintilla-2.28.0/include/Scintilla.iface -o lib/fox16/scintilla.rb"
end end
task :generate_kwargs_lib => 'lib/fox16/kwargs.rb' task :generate_kwargs_lib => 'lib/fox16/kwargs.rb'
......
# -*- coding: utf-8 -*-
# -*- ruby -*-
require 'rubygems'
require 'hoe'
require 'rake/extensiontask'
require 'rake/extensioncompiler'
require 'uri'
require 'rbconfig'
require 'pathname'
ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3:2.0.0'
NUM_CPUS = if File.exist?('/proc/cpuinfo')
File.read('/proc/cpuinfo').scan('processor').length
elsif RUBY_PLATFORM.include?( 'darwin' )
`system_profiler SPHardwareDataType | grep 'Cores' | awk '{print $5}'`.chomp
else
1
end
class CrossLibrary < OpenStruct
include Rake::DSL
def initialize(ruby_platform)
super()
self.ruby_platform = ruby_platform
# Cross-compilation constants
self.compile_home = Pathname( "build" ).expand_path
self.static_sourcesdir = compile_home + 'sources'
self.static_builddir = compile_home + 'builds' + ruby_platform
self.static_installdir = compile_home + 'install' + ruby_platform
self.ruby_build = RbConfig::CONFIG["host"]
# Use rake-compilers config.yml to determine the toolchain that was used
# to build Ruby for this platform.
self.host_platform = begin
config_file = YAML.load_file(File.expand_path("~/.rake-compiler/config.yml"))
_, rbfile = config_file.find{|key, fname| key.start_with?("rbconfig-#{ruby_platform}-") }
IO.read(rbfile).match(/CONFIG\["host"\] = "(.*)"/)[1]
rescue
nil
end
# Fetch zlib tarball
self.libz_version = ENV['libz_version'] || '1.2.7'
self.libz_source_uri = URI( "http://downloads.sourceforge.net/project/libpng/zlib/#{libz_version}/zlib-#{libz_version}.tar.bz2" )
self.libz_tarball = static_sourcesdir + File.basename( libz_source_uri.path )
self.static_libz_builddir = static_builddir + libz_tarball.basename(".tar.bz2")
self.libz_makefile = static_libz_builddir + 'Makefile'
self.libz_a = static_libz_builddir + 'libz.a'
# Fetch libpng tarball
self.libpng_version = ENV['libpng_version'] || '1.5.13'
self.libpng_source_uri = URI( "http://prdownloads.sourceforge.net/libpng/libpng-#{libpng_version}.tar.gz?download" )
self.libpng_tarball = static_sourcesdir + File.basename( libpng_source_uri.path )
self.static_libpng_builddir = static_builddir + libpng_tarball.basename(".tar.gz")
self.libpng_makefile = static_libpng_builddir + 'Makefile'
self.libpng_a = static_libpng_builddir + '.libs' + 'libpng15.a'
# Fetch libjpeg tarball
self.libjpeg_version = ENV['libjpeg_version'] || '8d'
self.libjpeg_source_uri = URI( "http://www.ijg.org/files/jpegsrc.v#{libjpeg_version}.tar.gz" )
self.libjpeg_tarball = static_sourcesdir + File.basename( libjpeg_source_uri.path )
self.static_libjpeg_builddir = static_builddir + "jpeg-#{libjpeg_version}"
self.libjpeg_makefile = static_libjpeg_builddir + 'Makefile'
self.libjpeg_a = static_libjpeg_builddir + '.libs' + 'libjpeg.a'
# Fetch libtiff tarball
self.libtiff_version = ENV['libtiff_version'] || '4.0.3'
self.libtiff_source_uri = URI( "http://download.osgeo.org/libtiff/tiff-#{libtiff_version}.tar.gz" )
self.libtiff_tarball = static_sourcesdir + File.basename( libtiff_source_uri.path )
self.static_libtiff_builddir = static_builddir + libtiff_tarball.basename(".tar.gz")
self.libtiff_makefile = static_libtiff_builddir + 'Makefile'
self.libtiff_a = static_libtiff_builddir + 'libtiff' + '.libs' + 'libtiff.a'
# Fetch libfox tarball
self.libfox_version = ENV['libfox_version'] || '1.6.49'
self.libfox_source_uri = URI( "http://ftp.fox-toolkit.org/pub/fox-#{libfox_version}.tar.gz" )
self.libfox_tarball = static_sourcesdir + File.basename( libfox_source_uri.path )
self.static_libfox_builddir = static_builddir + libfox_tarball.basename(".tar.gz")
self.libfox_makefile = static_libfox_builddir + 'Makefile'
self.libfox_a = static_libfox_builddir + 'src' + '.libs' + 'libFOX-1.6.a'
# Fetch fxscintilla tarball
self.libfxscintilla_version = ENV['libfxscintilla_version'] || '2.28.0'
self.libfxscintilla_source_uri = URI( "http://download.savannah.gnu.org/releases/fxscintilla/fxscintilla-#{libfxscintilla_version}.tar.gz" )
self.libfxscintilla_tarball = static_sourcesdir + File.basename( libfxscintilla_source_uri.path )
self.static_libfxscintilla_builddir = static_builddir + libfxscintilla_tarball.basename(".tar.gz")
self.libfxscintilla_makefile = static_libfxscintilla_builddir + 'Makefile'
self.libfxscintilla_a = static_libfxscintilla_builddir + 'fox' + '.libs' + 'libfxscintilla.a'
# clean intermediate files and folders
CLEAN.include( static_builddir.to_s )
#####################################################################
### C R O S S - C O M P I L A T I O N - T A S K S
#####################################################################
directory static_sourcesdir.to_s
#
# Static libz build tasks
#
directory static_libz_builddir.to_s
# libz source file should be stored there
file libz_tarball => static_sourcesdir do |t|
# download the source file using wget or curl
chdir File.dirname(t.name) do
sh "wget '#{libz_source_uri}' -O #{libz_tarball}"
end
end
# Extract the libz builds
file static_libz_builddir => libz_tarball do |t|
sh 'tar', '-xjf', libz_tarball.to_s, '-C', static_libz_builddir.parent.to_s
rm libz_makefile
end
self.libz_env = [
"CC=#{host_platform}-gcc",
"AR=#{host_platform}-ar",
"RANLIB=#{host_platform}-ranlib",
]
# generate the makefile in a clean build location
file libz_makefile => [static_libz_builddir] do |t|
chdir( static_libz_builddir ) do
options = [
"--prefix=#{static_installdir}",
]
configure_path = static_libz_builddir + 'configure'
sh "env #{[libz_env, configure_path.to_s, *options].join(" ")}"
end
end
# generate the makefile in a clean build location
task libz_a => libz_makefile do |t|
chdir( static_libz_builddir ) do
sh "make -j#{NUM_CPUS} install 'LDSHAREDLIBC=-lmsvcrt'"
end
end
#
# Static libpng build tasks
#
directory static_libpng_builddir.to_s
# libpng source file should be stored there
file libpng_tarball => static_sourcesdir do |t|
# download the source file using wget or curl
chdir File.dirname(t.name) do
sh "wget '#{libpng_source_uri}' -O #{libpng_tarball}"
end
end
# Extract the libpng builds
file static_libpng_builddir => libpng_tarball do |t|
sh 'tar', '-xzf', libpng_tarball.to_s, '-C', static_libpng_builddir.parent.to_s
end
self.libpng_env = [
# Use build directory instead of install, to avoid unnecessary rebuilds of libpng
"'CPPFLAGS=-I#{static_libz_builddir}'",
"'LDFLAGS=-L#{static_libz_builddir}'",
]
# generate the makefile in a clean build location
file libpng_makefile => [static_libpng_builddir, libz_a] do |t|
chdir( static_libpng_builddir ) do
options = [
"--target=#{host_platform}",
"--host=#{host_platform}",
"--build=#{ruby_build}",
"--prefix=#{static_installdir}",
"--disable-shared",
]
configure_path = static_libpng_builddir + 'configure'
sh "env #{[libpng_env, configure_path.to_s, *options].join(" ")}"
end
end
# generate the makefile in a clean build location
task libpng_a => [libpng_makefile, libz_a] do |t|
chdir( static_libpng_builddir ) do
sh "make -j#{NUM_CPUS} install"
end
end
#
# Static libjpeg build tasks
#
directory static_libjpeg_builddir.to_s
# libjpeg source file should be stored there
file libjpeg_tarball => static_sourcesdir do |t|
# download the source file using wget or curl
chdir File.dirname(t.name) do
sh "wget '#{libjpeg_source_uri}' -O #{libjpeg_tarball}"
end
end
# Extract the libjpeg builds
file static_libjpeg_builddir => libjpeg_tarball do |t|
sh 'tar', '-xzf', libjpeg_tarball.to_s, '-C', static_libjpeg_builddir.parent.to_s
end
# generate the makefile in a clean build location
file libjpeg_makefile => static_libjpeg_builddir do |t|
chdir( static_libjpeg_builddir ) do
options = [
"--target=#{host_platform}",
"--host=#{host_platform}",
"--build=#{ruby_build}",
"--prefix=#{static_installdir}",
"--disable-shared",
]
configure_path = static_libjpeg_builddir + 'configure'
cmd = [ configure_path.to_s, *options ]
sh *cmd
end
end
# build libjpeg.a
task libjpeg_a => [libjpeg_makefile] do |t|
chdir( static_libjpeg_builddir ) do
sh "make -j#{NUM_CPUS} install"
end
end
#
# Static libtiff build tasks
#
directory static_libtiff_builddir.to_s
# libtiff source file should be stored there
file libtiff_tarball => static_sourcesdir do |t|
# download the source file using wget or curl
chdir File.dirname(t.name) do
sh "wget '#{libtiff_source_uri}' -O #{libtiff_tarball}"
end
end
# Extract the libtiff builds
file static_libtiff_builddir => libtiff_tarball do |t|
sh 'tar', '-xzf', libtiff_tarball.to_s, '-C', static_libtiff_builddir.parent.to_s
end
self.libtiff_env = [
"'CPPFLAGS=-I#{static_installdir}/include'",
"'LDFLAGS=-L#{static_installdir}/lib'",
]
# generate the makefile in a clean build location
file libtiff_makefile => [static_libtiff_builddir, libjpeg_a, libz_a] do |t|
chdir( static_libtiff_builddir ) do
options = [
"--target=#{host_platform}",
"--host=#{host_platform}",
"--build=#{ruby_build}",
"--prefix=#{static_installdir}",
"--disable-shared",
"--with-zlib-include-dir=#{static_libz_builddir}",
"--with-zlib-lib-dir=#{File.dirname(libz_a)}",
"--with-jpeg-include-dir=#{static_libjpeg_builddir}",
"--with-jpeg-lib-dir=#{File.dirname(libjpeg_a)}",
]
configure_path = static_libtiff_builddir + 'configure'
sh "env #{[libtiff_env, configure_path.to_s, *options].join(" ")}"
end
end
# build libtiff.a
task libtiff_a => [libtiff_makefile] do |t|
chdir( static_libtiff_builddir ) do
sh "make -j#{NUM_CPUS} install"
end
end
#
# Static libfox build tasks
#
directory static_libfox_builddir.to_s
# libfox source file should be stored there
file libfox_tarball => static_sourcesdir do |t|
# download the source file using wget or curl
chdir File.dirname(t.name) do
sh "wget '#{libfox_source_uri}' -O #{libfox_tarball}"
end
end
# Extract the libfox builds
file static_libfox_builddir => libfox_tarball do |t|
sh 'tar', '-xzf', libfox_tarball.to_s, '-C', static_libfox_builddir.parent.to_s
end
self.libfox_env = [
"'CPPFLAGS=-I#{static_installdir}/include'",
"'LDFLAGS=-L#{static_installdir}/lib'",
]
# generate the makefile in a clean build location
file libfox_makefile => [static_libfox_builddir, libjpeg_a, libz_a] do |t|
chdir( static_libfox_builddir ) do
options = [
"--target=#{host_platform}",
"--host=#{host_platform}",
"--build=#{ruby_build}",
"--prefix=#{static_installdir}",
"--disable-shared",
"--without-xft",
"--without-x",
]
configure_path = static_libfox_builddir + 'configure'
sh "env #{[libfox_env, configure_path.to_s, *options].join(" ")}"
end
end
# build libfox.a
task libfox_a => [libfox_makefile] do |t|
chdir( static_libfox_builddir ) do
sh "make -j#{NUM_CPUS} #{fox_env.join(" ")} install"
end
end
#
# Static libfxscintilla build tasks
#
directory static_libfxscintilla_builddir.to_s
# libfxscintilla source file should be stored there
file libfxscintilla_tarball => static_sourcesdir do |t|
# download the source file using wget or curl
chdir File.dirname(t.name) do
sh "wget '#{libfxscintilla_source_uri}' -O #{libfxscintilla_tarball}"
end
end
# Extract the libfxscintilla builds
file static_libfxscintilla_builddir => libfxscintilla_tarball do |t|
sh 'tar', '-xzf', libfxscintilla_tarball.to_s, '-C', static_libfxscintilla_builddir.parent.to_s
end
self.fox_env = [
"'CFLAGS=-I#{static_installdir}/include'",
"'CPPFLAGS=-I#{static_installdir}/include'",
"'LDFLAGS=-L#{static_installdir}/lib'",
"'FOX_CFLAGS=-I#{static_installdir}/include/fox-1.6 -DFOX_1_6'",
"'FOX_LIBS=-L#{static_installdir}/lib -lFOX-1.6'",
]
# generate the makefile in a clean build location
file libfxscintilla_makefile => [static_libfxscintilla_builddir, libfox_a] do |t|
chdir( static_libfxscintilla_builddir ) do
options = [
"--target=#{host_platform}",
"--host=#{host_platform}",
"--build=#{ruby_build}",
"--prefix=#{static_installdir}",
"--disable-shared",
]
configure_path = static_libfxscintilla_builddir + 'configure'
sh "env #{[fox_env, configure_path.to_s, *options].join(" ")}"
end
end
# build libfxscintilla.a
task libfxscintilla_a => [libfxscintilla_makefile] do |t|
chdir( static_libfxscintilla_builddir ) do
sh "make -j#{NUM_CPUS} #{fox_env.join(" ")} install"
end
end
desc "compile static libz libraries"
task :static_libs => [ libz_a, libpng_a, libjpeg_a, libtiff_a, libfox_a, libfxscintilla_a ]
end
end
if File.exist?(File.expand_path("~/.rake-compiler/config.yml"))
CrossLibraries = [
'i386-mingw32',
'x64-mingw32',
].map do |platform|
CrossLibrary.new platform
end
else
$stderr.puts "Cross-compilation disabled -- rake-compiler not properly installed"
CrossLibraries = []
end
desc 'cross compile required libs for win32'
task :cross => [ :mingw32, :static_libs ]
task :mingw32 do
# Use Rake::ExtensionCompiler helpers to find the proper host
unless Rake::ExtensionCompiler.mingw_host then
warn "You need to install mingw32 cross compile functionality to be able to continue."
warn "Please refer to your distribution/package manager documentation about installation."
fail
end
end
# vim: syntax=ruby
...@@ -72,16 +72,259 @@ def fxscintilla_support_suppressed? ...@@ -72,16 +72,259 @@ def fxscintilla_support_suppressed?
ARGV.include? "--without-fxscintilla" ARGV.include? "--without-fxscintilla"
end end
def with_env(hash)
hash.each do |k, v|
ENV[k] = v
end
begin
yield
ensure
hash.each do |k, v|
ENV.delete(k)
end
end
end
LIBZ_VERSION = ENV['LIBZ_VERSION'] || '1.2.7'
LIBZ_SOURCE_URI = "http://downloads.sourceforge.net/project/libpng/zlib/#{LIBZ_VERSION}/zlib-#{LIBZ_VERSION}.tar.bz2"
LIBPNG_VERSION = ENV['LIBPNG_VERSION'] || '1.5.13'
LIBPNG_SOURCE_URI = "http://prdownloads.sourceforge.net/libpng/libpng-#{LIBPNG_VERSION}.tar.gz"
LIBJPEG_VERSION = ENV['LIBJPEG_VERSION'] || '8d'
LIBJPEG_SOURCE_URI = "http://www.ijg.org/files/jpegsrc.v#{LIBJPEG_VERSION}.tar.gz"
LIBTIFF_VERSION = ENV['LIBTIFF_VERSION'] || '4.0.3'
LIBTIFF_SOURCE_URI = "http://download.osgeo.org/libtiff/tiff-#{LIBTIFF_VERSION}.tar.gz"
LIBFOX_VERSION = ENV['LIBFOX_VERSION'] || '1.6.49'
LIBFOX_SOURCE_URI = "http://ftp.fox-toolkit.org/pub/fox-#{LIBFOX_VERSION}.tar.gz"
LIBFXSCINTILLA_VERSION = ENV['LIBFXSCINTILLA_VERSION'] || '2.28.0'
LIBFXSCINTILLA_SOURCE_URI = "http://download.savannah.gnu.org/releases/fxscintilla/fxscintilla-#{LIBFXSCINTILLA_VERSION}.tar.gz"
def do_rake_compiler_setup def do_rake_compiler_setup
if enable_config("win32-static-build") if enable_config("win32-cross")
require 'mini_portile'
dir_config("installed") dir_config("installed")
have_library( 'gdi32', 'CreateDC' ) && append_library( $libs, 'gdi32' )
have_library( 'opengl32' ) && append_library( $libs, 'opengl32' )
have_library( 'winspool', 'EnumPrintersA') && append_library( $libs, 'winspool' )
CONFIG['CC'] += "\nCXX=#{RbConfig::CONFIG["host"]}-g++" # Hack CXX into Makefile for cross compilation libz_recipe = MiniPortile.new("libz", LIBZ_VERSION).tap do |recipe|
recipe.files = [LIBZ_SOURCE_URI]
recipe.target = portsdir = File.expand_path('../../../ports', __FILE__)
# Prefer host_alias over host in order to use i586-mingw32msvc as
# correct compiler prefix for cross build, but use host if not set.
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
class << recipe
def configure
Dir.chdir work_path do
mk = File.read 'win32/Makefile.gcc'
File.open 'win32/Makefile.gcc', 'wb' do |f|
f.puts "BINARY_PATH = #{path}/bin"
f.puts "LIBRARY_PATH = #{path}/lib"
f.puts "INCLUDE_PATH = #{path}/include"
mk.sub!(/^PREFIX\s*=\s*$/, "PREFIX = #{host}-")
f.puts mk
end
end
end
def configured?
Dir.chdir work_path do
!! (File.read('win32/Makefile.gcc') =~ /^BINARY_PATH/)
end
end
def compile
execute "compile", "make -f win32/Makefile.gcc SHARED_MODE=1"
end
def install
execute "install", "make -f win32/Makefile.gcc install SHARED_MODE=1"
end
end
checkpoint = File.join(portsdir, "#{recipe.name}-#{recipe.version}-#{recipe.host}.installed")
unless File.exist?(checkpoint)
recipe.cook
FileUtils.touch checkpoint
end
recipe.activate
end
libpng_recipe = MiniPortile.new("libpng", LIBPNG_VERSION).tap do |recipe|
recipe.files = [LIBPNG_SOURCE_URI]
recipe.target = portsdir = File.expand_path('../../../ports', __FILE__)
# Prefer host_alias over host in order to use i586-mingw32msvc as
# correct compiler prefix for cross build, but use host if not set.
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
recipe.configure_options = [
"--host=#{recipe.host}",
"--enable-shared",
"--disable-static",
]
checkpoint = File.join(portsdir, "#{recipe.name}-#{recipe.version}-#{recipe.host}.installed")
unless File.exist?(checkpoint)
with_env(
'CPPFLAGS' => "-I#{libz_recipe.path}/include",
'LDFLAGS' => "-L#{libz_recipe.path}/lib"
) do
recipe.cook
FileUtils.touch checkpoint
end
end
recipe.activate
end
libjpeg_recipe = MiniPortile.new("libjpeg", LIBJPEG_VERSION).tap do |recipe|
recipe.files = [LIBJPEG_SOURCE_URI]
recipe.target = portsdir = File.expand_path('../../../ports', __FILE__)
# Prefer host_alias over host in order to use i586-mingw32msvc as
# correct compiler prefix for cross build, but use host if not set.
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
recipe.configure_options = [
"--host=#{recipe.host}",
"--enable-shared",
"--disable-static",
]
checkpoint = File.join(portsdir, "#{recipe.name}-#{recipe.version}-#{recipe.host}.installed")
unless File.exist?(checkpoint)
recipe.cook
FileUtils.touch checkpoint
end
recipe.activate
end
libtiff_recipe = MiniPortile.new("libtiff", LIBTIFF_VERSION).tap do |recipe|
recipe.files = [LIBTIFF_SOURCE_URI]
recipe.target = portsdir = File.expand_path('../../../ports', __FILE__)
# Prefer host_alias over host in order to use i586-mingw32msvc as
# correct compiler prefix for cross build, but use host if not set.
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
recipe.configure_options = [
"--host=#{recipe.host}",
"--enable-shared",
"--disable-static",
]
checkpoint = File.join(portsdir, "#{recipe.name}-#{recipe.version}-#{recipe.host}.installed")
unless File.exist?(checkpoint)
recipe.cook
FileUtils.touch checkpoint
end
recipe.activate
end
libfox_recipe = MiniPortile.new("libfox", LIBFOX_VERSION).tap do |recipe|
recipe.files = [LIBFOX_SOURCE_URI]
recipe.target = portsdir = File.expand_path('../../../ports', __FILE__)
# Prefer host_alias over host in order to use i586-mingw32msvc as
# correct compiler prefix for cross build, but use host if not set.
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
recipe.configure_options = [
"--host=#{recipe.host}",
"--without-xft",
"--without-x",
"--enable-shared",
"--disable-static",
]
class << recipe
def compile
# Add param -no-undefined to libtool to build a win32 shared lib
execute "compile", "#{ENV['MAKE'] || "make"} libFOX_1_6_la_LDFLAGS='-version-info 0:49:0 -export-dynamic -no-undefined'"
end
end
checkpoint = File.join(portsdir, "#{recipe.name}-#{recipe.version}-#{recipe.host}.installed")
unless File.exist?(checkpoint)
with_env(
"CPPFLAGS" => "-I#{libjpeg_recipe.path}/include -I#{libpng_recipe.path}/include -I#{libtiff_recipe.path}/include -I#{libz_recipe.path}/include",
"LDFLAGS" => "-L#{libjpeg_recipe.path}/lib -L#{libpng_recipe.path}/lib -L#{libtiff_recipe.path}/lib -L#{libz_recipe.path}/lib"
) do
recipe.cook
FileUtils.touch checkpoint
end
end
recipe.activate
end
libfxscintills_recipe = MiniPortile.new("libfxscintilla", LIBFXSCINTILLA_VERSION).tap do |recipe|
recipe.files = [LIBFXSCINTILLA_SOURCE_URI]
recipe.target = portsdir = File.expand_path('../../../ports', __FILE__)
# Prefer host_alias over host in order to use i586-mingw32msvc as
# correct compiler prefix for cross build, but use host if not set.
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
recipe.configure_options = [
"--host=#{recipe.host}",
"--enable-shared",
"--disable-static",
]
class << recipe
attr_accessor :libfox_path
def mk
"#{ENV['MAKE'] || "make"}"
end
def compile
execute "compile_lexers", "cd lexers && #{mk}"
execute "compile_lexlib", "cd lexlib && #{mk}"
execute "compile_src", "cd src && #{mk}"
execute "compile_fox", "cd fox && #{mk} libfxscintilla_la_LDFLAGS='-version-info 23:0:3 -export-dynamic -no-undefined -L#{libfox_path}/lib -lFOX-1.6'"
end
def install
execute "install", "cd fox && #{mk} install && cd ../include && #{mk} install"
end
end
recipe.libfox_path = libfox_recipe.path
checkpoint = File.join(portsdir, "#{recipe.name}-#{recipe.version}-#{recipe.host}.installed")
unless File.exist?(checkpoint)
recipe.cook
FileUtils.touch checkpoint
end
recipe.activate
end
# have_library( 'gdi32', 'CreateDC' ) && append_library( $libs, 'gdi32' )
# have_library( 'opengl32' ) && append_library( $libs, 'opengl32' )
# have_library( 'winspool', 'EnumPrintersA') && append_library( $libs, 'winspool' )
# dir_config('libz', "#{libz_recipe.path}/include", "#{libz_recipe.path}/lib")
# dir_config('libpng', "#{libpng_recipe.path}/include", "#{libpng_recipe.path}/lib")
# dir_config('libtiff', "#{libtiff_recipe.path}/include", "#{libtiff_recipe.path}/lib")
# dir_config('libjpeg', "#{libjpeg_recipe.path}/include", "#{libjpeg_recipe.path}/lib")
dir_config('libfox', "#{libfox_recipe.path}/include", "#{libfox_recipe.path}/lib")
dir_config('libfxscintilla', "#{libfxscintills_recipe.path}/include", "#{libfxscintills_recipe.path}/lib")
shared_dlls = [
"#{libfxscintills_recipe.path}/bin/libfxscintilla-20.dll",
"#{libfox_recipe.path}/bin/libFOX-1.6-0.dll",
"#{libjpeg_recipe.path}/bin/libjpeg-8.dll",
"#{libpng_recipe.path}/bin/libpng15-15.dll",
"#{libtiff_recipe.path}/bin/libtiff-5.dll",
"#{libz_recipe.path}/bin/zlib1.dll",
]
shared_dlls.each do |dll|
FileUtils.cp dll, '.', verbose: true
end
gcc_shared_dlls = %w[libwinpthread-1.dll libgcc_s_dw2-1.dll libgcc_s_sjlj-1.dll libgcc_s_seh-1.dll libstdc++-6.dll]
gcc_shared_dlls.each do |dll|
cmd = "#{CONFIG['CC']} -print-file-name=#{dll}"
res = `#{cmd}`.chomp
next if dll == res
puts "#{cmd} => #{res}"
FileUtils.cp `#{cmd}`.chomp, '.', verbose: true
end
CONFIG['CXX'] = "#{RbConfig::CONFIG["host"]}-g++" # CXX setting must be prefixed for cross build
CONFIG['CC'] += "\nCXX=#{CONFIG['CXX']}" # Hack CXX into Makefile for cross compilation
CONFIG['LDSHARED'].gsub!('gcc', 'g++') # ensure C++ linker is used, so that libstdc++ is linked static CONFIG['LDSHARED'].gsub!('gcc', 'g++') # ensure C++ linker is used, so that libstdc++ is linked static
$LDFLAGS += " -s -static-libgcc -static-libstdc++" # mingw-w64 v4.7 defaults to dynamic linking $LDFLAGS += " -s" # remove symbol table informations from shared lib
elsif RUBY_PLATFORM =~ /mingw/ elsif RUBY_PLATFORM =~ /mingw/
$CFLAGS = $CFLAGS + " -I/usr/local/include" $CFLAGS = $CFLAGS + " -I/usr/local/include"
$LDFLAGS = $LDFLAGS + " -I/usr/local/lib" $LDFLAGS = $LDFLAGS + " -I/usr/local/lib"
...@@ -96,9 +339,8 @@ def do_rake_compiler_setup ...@@ -96,9 +339,8 @@ def do_rake_compiler_setup
$libs = append_library($libs, "stdc++") unless RUBY_PLATFORM =~ /mingw/ || enable_config("win32-static-build") $libs = append_library($libs, "stdc++") unless RUBY_PLATFORM =~ /mingw/ || enable_config("win32-static-build")
have_header("sys/time.h") unless RUBY_PLATFORM =~ /mingw/ || enable_config("win32-static-build") have_header("sys/time.h") unless RUBY_PLATFORM =~ /mingw/ || enable_config("win32-static-build")
have_header("signal.h") have_header("signal.h")
if have_library("z", "deflate") have_library("z", "deflate")
have_library("png", "png_create_read_struct") have_library("png", "png_create_read_struct")
end
have_library("jpeg", "jpeg_mem_init") have_library("jpeg", "jpeg_mem_init")
have_library("tiff", "TIFFSetErrorHandler") have_library("tiff", "TIFFSetErrorHandler")
have_library("Xft", "XftInit") have_library("Xft", "XftInit")
...@@ -106,11 +348,10 @@ def do_rake_compiler_setup ...@@ -106,11 +348,10 @@ def do_rake_compiler_setup
find_library("X11", "XFindContext", "/usr/X11R6/lib") find_library("X11", "XFindContext", "/usr/X11R6/lib")
find_library("GL", "glXCreateContext", "/usr/X11R6/lib") find_library("GL", "glXCreateContext", "/usr/X11R6/lib")
find_library("GLU", "gluNewQuadric", "/usr/X11R6/lib") find_library("GLU", "gluNewQuadric", "/usr/X11R6/lib")
$libs = append_library($libs, "FOX-1.6")
$libs = append_library($libs, "Xrandr") unless RUBY_PLATFORM =~ /mingw/ || enable_config("win32-static-build") $libs = append_library($libs, "Xrandr") unless RUBY_PLATFORM =~ /mingw/ || enable_config("win32-static-build")
$libs = append_library($libs, "Xcursor") unless RUBY_PLATFORM =~ /mingw/ || enable_config("win32-static-build") $libs = append_library($libs, "Xcursor") unless RUBY_PLATFORM =~ /mingw/ || enable_config("win32-static-build")
$libs = append_library($libs, "png")
find_header('FXRbCommon.h', File.join(File.dirname(__FILE__), 'include')) find_header('FXRbCommon.h', File.join(File.dirname(__FILE__), 'include'))
$libs = append_library($libs, "FOX-1.6")
if is_fxscintilla_build? if is_fxscintilla_build?
FileUtils.move('scintilla_wrap.cpp.bak', 'scintilla_wrap.cpp') if FileTest.exist?('scintilla_wrap.cpp.bak') FileUtils.move('scintilla_wrap.cpp.bak', 'scintilla_wrap.cpp') if FileTest.exist?('scintilla_wrap.cpp.bak')
$CPPFLAGS = $CPPFLAGS + " -DWITH_FXSCINTILLA -DHAVE_FOX_1_6" $CPPFLAGS = $CPPFLAGS + " -DWITH_FXSCINTILLA -DHAVE_FOX_1_6"
......
...@@ -454,7 +454,6 @@ IMPLEMENT_FXID_STUBS(FXRbImage) ...@@ -454,7 +454,6 @@ IMPLEMENT_FXID_STUBS(FXRbImage)
IMPLEMENT_FXDRAWABLE_STUBS(FXRbImage) IMPLEMENT_FXDRAWABLE_STUBS(FXRbImage)
IMPLEMENT_FXIMAGE_STUBS(FXRbImage) IMPLEMENT_FXIMAGE_STUBS(FXRbImage)
/* Start stub implementations for class FXRbImageData */
/* Start stub implementations for class FXRbImageFrame */ /* Start stub implementations for class FXRbImageFrame */
IMPLEMENT_FXOBJECT_STUBS(FXRbImageFrame) IMPLEMENT_FXOBJECT_STUBS(FXRbImageFrame)
IMPLEMENT_FXID_STUBS(FXRbImageFrame) IMPLEMENT_FXID_STUBS(FXRbImageFrame)
......
if RUBY_PLATFORM =~ /(mswin|mingw)/i begin
require "#{RUBY_VERSION.sub(/\.\d+$/, '')}/fox16_c.so" require 'fox16_c'
elsif RUBY_PLATFORM =~ /darwin/ rescue LoadError
require "fox16_c.bundle" # If it's a Windows binary gem, try the <major>.<minor> subdirectory
else if RUBY_PLATFORM =~/(mswin|mingw)/i
require "fox16_c.so" major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
# Set the PATH environment variable, so that libpq.dll can be found.
old_path = ENV['PATH']
ENV['PATH'] = "#{File.expand_path("../#{RUBY_PLATFORM.gsub("i386", "x86")}", __FILE__)};#{old_path}"
require "#{major_minor}/fox16_c"
ENV['PATH'] = old_path
else
raise
end
end end
require "fox16/core" require "fox16/core"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment