From d67c5198b23c375502fe1c540b3d075326729413 Mon Sep 17 00:00:00 2001
From: Lars Kanis <lars@greiz-reinsdorf.de>
Date: Sun, 31 Mar 2013 15:32:36 +0200
Subject: [PATCH] Add support for x64-mingw32 target.
Update cross compilation tasks to build x64 and x86 targets.
---
Rakefile | 34 +-
Rakefile.cross | 718 ++++++++++++++++++----------------
ext/fox16_c/FXRuby.cpp | 10 +-
ext/fox16_c/extconf.rb | 2 +-
ext/fox16_c/include/FXRuby.h | 11 +-
swig-interfaces/FXApp.i | 4 +-
swig-interfaces/FXGLCanvas.i | 8 +-
swig-interfaces/FXScintilla.i | 10 +-
8 files changed, 423 insertions(+), 374 deletions(-)
diff --git a/Rakefile b/Rakefile
index e4f47f6..9348b70 100755
--- a/Rakefile
+++ b/Rakefile
@@ -19,7 +19,8 @@ end
# Some constants we'll need
PKG_VERSION = Fox.fxrubyversion
-FXSCINTILLA_INSTALL_DIR = Pathname( "build/builds/fxscintilla-#{LIBFXSCINTILLA_VERSION}" ).expand_path
+# TODO: Don't depend on cross compilation task
+FXSCINTILLA_INSTALL_DIR = Pathname( CrossLibraries.first.static_libfxscintilla_builddir ).expand_path
SWIG = (RUBY_PLATFORM =~ /mingw/) ? "swig-1.3.22.exe" : "swig-1.3.22"
SWIGFLAGS = "-fcompact -noruntime -c++ -ruby -no_default -I../fox-includes"
@@ -91,14 +92,29 @@ task :test => [:compile]
Rake::ExtensionTask.new("fox16_c", hoe.spec) do |ext|
ext.cross_compile = true
- ext.cross_platform = ['i386-mingw32']
- ext.cross_config_options += [
- "--with-fox-include=#{STATIC_INSTALLDIR}/include/fox-1.6",
- "--with-fxscintilla-include=#{STATIC_INSTALLDIR}/include/fxscintilla",
- "--with-installed-dir=#{STATIC_INSTALLDIR}",
- "--enable-win32-static-build",
- "--with-fxscintilla",
- ]
+ ext.cross_platform = CrossLibraries.map &:ruby_platform
+
+ ext.cross_config_options += CrossLibraries.map do |lib|
+ {
+ lib.ruby_platform => [
+ "--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",
+ "--with-installed-lib=#{lib.static_installdir}/lib",
+ "--enable-win32-static-build",
+ "--with-fxscintilla",
+ ]
+ }
+ end
+
+end
+
+CrossLibraries.each do |lib|
+ ENV['RUBY_CC_VERSION'].split(":").each do |ruby_version|
+ task "copy:fox16_c:#{lib.ruby_platform}:#{ruby_version}" do |t|
+ sh "#{lib.host_platform}-strip -S tmp/#{lib.ruby_platform}/stage/lib/#{ruby_version[0,3]}/fox16_c.so"
+ end
+ end
end
# Set environment variable SWIG_LIB to
diff --git a/Rakefile.cross b/Rakefile.cross
index 922b104..0c057b8 100755
--- a/Rakefile.cross
+++ b/Rakefile.cross
@@ -9,20 +9,7 @@ require 'uri'
require 'rbconfig'
require 'pathname'
-ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3'
-
-# Cross-compilation constants
-COMPILE_HOME = Pathname( "build" ).expand_path
-STATIC_SOURCESDIR = COMPILE_HOME + 'sources'
-STATIC_BUILDDIR = COMPILE_HOME + 'builds'
-STATIC_INSTALLDIR = COMPILE_HOME + 'install'
-RUBY_BUILD = RbConfig::CONFIG["host"]
-CROSS_PREFIX = begin
- Rake::ExtensionCompiler.mingw_host
-rescue => err
- $stderr.puts "Cross-compilation disabled -- %s" % [ err.message ]
- 'unknown'
-end
+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
@@ -32,354 +19,392 @@ else
1
end
-
-# Fetch zlib tarball
-LIBZ_VERSION = ENV['LIBZ_VERSION'] || '1.2.7'
-LIBZ_SOURCE_URI = URI( "http://downloads.sourceforge.net/project/libpng/zlib/#{LIBZ_VERSION}/zlib-#{LIBZ_VERSION}.tar.bz2" )
-LIBZ_TARBALL = STATIC_SOURCESDIR + File.basename( LIBZ_SOURCE_URI.path )
-STATIC_LIBZ_BUILDDIR = STATIC_BUILDDIR + LIBZ_TARBALL.basename(".tar.bz2")
-LIBZ_MAKEFILE = STATIC_LIBZ_BUILDDIR + 'Makefile'
-LIBZ_A = STATIC_INSTALLDIR + 'lib' + 'libz.a'
-
-# Fetch libpng tarball
-LIBPNG_VERSION = ENV['LIBPNG_VERSION'] || '1.5.13'
-LIBPNG_SOURCE_URI = URI( "http://prdownloads.sourceforge.net/libpng/libpng-#{LIBPNG_VERSION}.tar.gz?download" )
-LIBPNG_TARBALL = STATIC_SOURCESDIR + File.basename( LIBPNG_SOURCE_URI.path )
-STATIC_LIBPNG_BUILDDIR = STATIC_BUILDDIR + LIBPNG_TARBALL.basename(".tar.gz")
-LIBPNG_MAKEFILE = STATIC_LIBPNG_BUILDDIR + 'Makefile'
-LIBPNG_A = STATIC_INSTALLDIR + 'lib' + 'libpng.a'
-
-
-# Fetch libjpeg tarball
-LIBJPEG_VERSION = ENV['LIBJPEG_VERSION'] || '8d'
-LIBJPEG_SOURCE_URI = URI( "http://www.ijg.org/files/jpegsrc.v#{LIBJPEG_VERSION}.tar.gz" )
-LIBJPEG_TARBALL = STATIC_SOURCESDIR + File.basename( LIBJPEG_SOURCE_URI.path )
-STATIC_LIBJPEG_BUILDDIR = STATIC_BUILDDIR + "jpeg-#{LIBJPEG_VERSION}"
-LIBJPEG_MAKEFILE = STATIC_LIBJPEG_BUILDDIR + 'Makefile'
-LIBJPEG_A = STATIC_INSTALLDIR + 'lib' + 'libjpeg.a'
-
-
-# Fetch libtiff tarball
-LIBTIFF_VERSION = ENV['LIBTIFF_VERSION'] || '4.0.3'
-LIBTIFF_SOURCE_URI = URI( "http://download.osgeo.org/libtiff/tiff-#{LIBTIFF_VERSION}.tar.gz" )
-LIBTIFF_TARBALL = STATIC_SOURCESDIR + File.basename( LIBTIFF_SOURCE_URI.path )
-STATIC_LIBTIFF_BUILDDIR = STATIC_BUILDDIR + LIBTIFF_TARBALL.basename(".tar.gz")
-LIBTIFF_MAKEFILE = STATIC_LIBTIFF_BUILDDIR + 'Makefile'
-LIBTIFF_A = STATIC_INSTALLDIR + 'lib' + 'libtiff.a'
-
-
-# Fetch libfox tarball
-LIBFOX_VERSION = ENV['LIBFOX_VERSION'] || '1.6.47'
-LIBFOX_SOURCE_URI = URI( "http://ftp.fox-toolkit.org/pub/fox-#{LIBFOX_VERSION}.tar.gz" )
-LIBFOX_TARBALL = STATIC_SOURCESDIR + File.basename( LIBFOX_SOURCE_URI.path )
-STATIC_LIBFOX_BUILDDIR = STATIC_BUILDDIR + LIBFOX_TARBALL.basename(".tar.gz")
-LIBFOX_MAKEFILE = STATIC_LIBFOX_BUILDDIR + 'Makefile'
-LIBFOX_A = STATIC_INSTALLDIR + 'lib' + 'libfox.a'
-
-# Fetch fxscintilla tarball
-LIBFXSCINTILLA_VERSION = ENV['LIBFXSCINTILLA_VERSION'] || '2.28.0'
-LIBFXSCINTILLA_SOURCE_URI = URI( "http://download.savannah.gnu.org/releases/fxscintilla/fxscintilla-#{LIBFXSCINTILLA_VERSION}.tar.gz" )
-LIBFXSCINTILLA_TARBALL = STATIC_SOURCESDIR + File.basename( LIBFXSCINTILLA_SOURCE_URI.path )
-STATIC_LIBFXSCINTILLA_BUILDDIR = STATIC_BUILDDIR + LIBFXSCINTILLA_TARBALL.basename(".tar.gz")
-LIBFXSCINTILLA_MAKEFILE = STATIC_LIBFXSCINTILLA_BUILDDIR + 'Makefile'
-LIBFXSCINTILLA_A = STATIC_INSTALLDIR + 'lib' + '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
-
-LIBZ_ENV = [
- "CC=#{CROSS_PREFIX}-gcc",
- "AR=#{CROSS_PREFIX}-ar",
- "RANLIB=#{CROSS_PREFIX}-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}",
+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.47'
+ 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",
]
- 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
-
-LIBPNG_ENV = [
- "'CPPFLAGS=-I#{STATIC_INSTALLDIR}/include'",
- "'LDFLAGS=-L#{STATIC_INSTALLDIR}/lib'",
-]
-# 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=#{CROSS_PREFIX}",
- "--host=#{CROSS_PREFIX}",
- "--build=#{RUBY_BUILD}",
- "--prefix=#{STATIC_INSTALLDIR}",
- "--disable-shared",
+ # 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}'",
]
-
- 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=#{CROSS_PREFIX}",
- "--host=#{CROSS_PREFIX}",
- "--build=#{RUBY_BUILD}",
- "--prefix=#{STATIC_INSTALLDIR}",
- "--disable-shared",
+ # 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'",
]
- 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
-
-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=#{CROSS_PREFIX}",
- "--host=#{CROSS_PREFIX}",
- "--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)}",
+ # 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'",
]
- 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
-
-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=#{CROSS_PREFIX}",
- "--host=#{CROSS_PREFIX}",
- "--build=#{RUBY_BUILD}",
- "--prefix=#{STATIC_INSTALLDIR}",
- "--disable-shared",
- "--without-xft",
- "--without-x",
+ # 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'",
]
- configure_path = STATIC_LIBFOX_BUILDDIR + 'configure'
- sh "env #{[LIBFOX_ENV, configure_path.to_s, *options].join(" ")}"
+ # 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
-# 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
-
-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=#{CROSS_PREFIX}",
- "--host=#{CROSS_PREFIX}",
- "--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"
+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 "compile static libz libraries"
-task :static_libs => [ LIBZ_A, LIBPNG_A, LIBJPEG_A, LIBTIFF_A, LIBFOX_A, LIBFXSCINTILLA_A ]
-
desc 'cross compile required libs for win32'
task :cross => [ :mingw32, :static_libs ]
@@ -390,7 +415,6 @@ task :mingw32 do
warn "Please refer to your distribution/package manager documentation about installation."
fail
end
- ENV['CROSS_PREFIX'] = Rake::ExtensionCompiler.mingw_host
end
diff --git a/ext/fox16_c/FXRuby.cpp b/ext/fox16_c/FXRuby.cpp
index 4f2cb14..7ef9f06 100644
--- a/ext/fox16_c/FXRuby.cpp
+++ b/ext/fox16_c/FXRuby.cpp
@@ -552,7 +552,7 @@ static VALUE FXRbConvertMessageData(FXObject* sender,FXObject* recv,FXSelector s
return to_ruby(reinterpret_cast<FXEvent*>(ptr));
}
else if(type==SEL_SIGNAL){
- return to_ruby(static_cast<int>(reinterpret_cast<long>(ptr)));
+ return to_ruby(static_cast<int>(reinterpret_cast<FXuval>(ptr)));
}
else if(type==SEL_IO_READ ||
type==SEL_IO_WRITE ||
@@ -600,7 +600,7 @@ static VALUE FXRbConvertMessageData(FXObject* sender,FXObject* recv,FXSelector s
}
}
else if(sender->isMemberOf(FXMETACLASS(FXColorDialog))){
- if(type==SEL_CHANGED || type==SEL_COMMAND) return to_ruby(static_cast<FXColor>(reinterpret_cast<unsigned long>(ptr)));
+ if(type==SEL_CHANGED || type==SEL_COMMAND) return to_ruby(static_cast<FXColor>(reinterpret_cast<FXuval>(ptr)));
}
else if(sender->isMemberOf(FXMETACLASS(FXColorRing))){
if(type==SEL_CHANGED || type==SEL_COMMAND){
@@ -609,7 +609,7 @@ static VALUE FXRbConvertMessageData(FXObject* sender,FXObject* recv,FXSelector s
}
}
else if(sender->isMemberOf(FXMETACLASS(FXColorSelector))){
- if(type==SEL_CHANGED || type==SEL_COMMAND) return to_ruby(static_cast<FXColor>(reinterpret_cast<unsigned long>(ptr)));
+ if(type==SEL_CHANGED || type==SEL_COMMAND) return to_ruby(static_cast<FXColor>(reinterpret_cast<FXuval>(ptr)));
}
else if(sender->isMemberOf(FXMETACLASS(FXColorWell))){
if(type==SEL_CHANGED ||
@@ -617,7 +617,7 @@ static VALUE FXRbConvertMessageData(FXObject* sender,FXObject* recv,FXSelector s
type==SEL_CLICKED ||
type==SEL_DOUBLECLICKED ||
type==SEL_TRIPLECLICKED) {
- VALUE v=to_ruby(static_cast<FXColor>(reinterpret_cast<unsigned long>(ptr)));
+ VALUE v=to_ruby(static_cast<FXColor>(reinterpret_cast<FXuval>(ptr)));
return v;
}
}
@@ -819,7 +819,7 @@ static VALUE FXRbConvertMessageData(FXObject* sender,FXObject* recv,FXSelector s
}
else if(sender->isMemberOf(FXMETACLASS(FXSpinner))){
if(type==SEL_CHANGED || type==SEL_COMMAND)
- return to_ruby(static_cast<FXint>(reinterpret_cast<long>(ptr)));
+ return to_ruby(static_cast<FXint>(reinterpret_cast<FXuval>(ptr)));
}
else if(sender->isMemberOf(FXMETACLASS(FXSplitter))){
if(type==SEL_CHANGED || type==SEL_COMMAND)
diff --git a/ext/fox16_c/extconf.rb b/ext/fox16_c/extconf.rb
index 9e9b75a..89e9b17 100755
--- a/ext/fox16_c/extconf.rb
+++ b/ext/fox16_c/extconf.rb
@@ -79,7 +79,7 @@ def do_rake_compiler_setup
have_library( 'opengl32' ) && append_library( $libs, 'opengl32' )
have_library( 'winspool', 'EnumPrintersA') && append_library( $libs, 'winspool' )
- CONFIG['CC'] += "\nCXX=#{ENV['CROSS_PREFIX']}-g++" # Hack CXX into Makefile for cross compilation
+ CONFIG['CC'] += "\nCXX=#{RbConfig::CONFIG["host"]}-g++" # Hack CXX into Makefile for cross compilation
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
elsif RUBY_PLATFORM =~ /mingw/
diff --git a/ext/fox16_c/include/FXRuby.h b/ext/fox16_c/include/FXRuby.h
index 21f527d..111c11e 100644
--- a/ext/fox16_c/include/FXRuby.h
+++ b/ext/fox16_c/include/FXRuby.h
@@ -41,6 +41,13 @@
#define RSTRING_PTR(s) RSTRING((s))->ptr
#endif
+#ifndef NUM2SIZET
+#define NUM2SIZET(s) NUM2ULONG(s)
+#endif
+#ifndef SIZET2NUM
+#define SIZET2NUM(s) ULONG2NUM(s)
+#endif
+
// Opaque type declaration for SWIG runtime support
struct swig_type_info;
@@ -322,7 +329,7 @@ inline VALUE fxid_to_int(FXID id){
#ifndef WIN32
return UINT2NUM(static_cast<unsigned int>(id));
#else
- return ULONG2NUM(reinterpret_cast<unsigned long>(id));
+ return SIZET2NUM(reinterpret_cast<size_t>(id));
#endif
}
@@ -334,7 +341,7 @@ inline FXID int_to_fxid(VALUE value){
#ifndef WIN32
return static_cast<FXID>(NUM2UINT(value));
#else
- return reinterpret_cast<FXID>(NUM2ULONG(value));
+ return reinterpret_cast<FXID>(NUM2SIZET(value));
#endif
}
diff --git a/swig-interfaces/FXApp.i b/swig-interfaces/FXApp.i
index e215142..f192169 100644
--- a/swig-interfaces/FXApp.i
+++ b/swig-interfaces/FXApp.i
@@ -197,8 +197,8 @@ public:
%extend {
/// Return pointer to display
- unsigned long getDisplay() const {
- return reinterpret_cast<unsigned long>(self->getDisplay());
+ FXuval getDisplay() const {
+ return reinterpret_cast<FXuval>(self->getDisplay());
}
}
diff --git a/swig-interfaces/FXGLCanvas.i b/swig-interfaces/FXGLCanvas.i
index 59bbcef..4c9162d 100644
--- a/swig-interfaces/FXGLCanvas.i
+++ b/swig-interfaces/FXGLCanvas.i
@@ -53,13 +53,13 @@ public:
%extend {
/// Return current context, if any
- static unsigned long getCurrentContext(){
- return reinterpret_cast<unsigned long>(FXGLCanvas::getCurrentContext());
+ static FXuval getCurrentContext(){
+ return reinterpret_cast<FXuval>(FXGLCanvas::getCurrentContext());
}
/// Get GL context handle
- unsigned long getContext() const {
- return reinterpret_cast<unsigned long>(self->getContext());
+ FXuval getContext() const {
+ return reinterpret_cast<FXuval>(self->getContext());
}
}
diff --git a/swig-interfaces/FXScintilla.i b/swig-interfaces/FXScintilla.i
index cb31972..8d06eb8 100644
--- a/swig-interfaces/FXScintilla.i
+++ b/swig-interfaces/FXScintilla.i
@@ -139,11 +139,12 @@ public:
// Convert wParam argument
uptr_t wp;
switch(TYPE(wParam)){
+ case T_BIGNUM:
case T_FIXNUM:
- wp=static_cast<uptr_t>(NUM2UINT(wParam));
+ wp=static_cast<uptr_t>(NUM2SIZET(wParam));
break;
case T_STRING:
- wp=static_cast<uptr_t>(reinterpret_cast<long>(RSTRING_PTR(wParam)));
+ wp=static_cast<uptr_t>(reinterpret_cast<FXuval>(RSTRING_PTR(wParam)));
break;
case T_TRUE:
case T_FALSE:
@@ -157,11 +158,12 @@ public:
// Convert lParam argument
sptr_t lp;
switch(TYPE(lParam)){
+ case T_BIGNUM:
case T_FIXNUM:
- lp=static_cast<sptr_t>(NUM2UINT(lParam));
+ lp=static_cast<sptr_t>(NUM2SIZET(lParam));
break;
case T_STRING:
- lp=static_cast<sptr_t>(reinterpret_cast<long>(RSTRING_PTR(lParam)));
+ lp=static_cast<sptr_t>(reinterpret_cast<FXival>(RSTRING_PTR(lParam)));
break;
case T_TRUE:
case T_FALSE:
--
GitLab