Skip to content

Commit

Permalink
for #438 and others
Browse files Browse the repository at this point in the history
* osx: './cshoes -g install rmagick' works. or 'bluecloth'
    Cobbler and Shoes.setup - not yet.
* create some targets for 64 bit Ruby Windows building. Experiment.
  • Loading branch information
Cecil committed Apr 24, 2019
1 parent 6a950f8 commit 304c525
Show file tree
Hide file tree
Showing 12 changed files with 527 additions and 22 deletions.
22 changes: 20 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ when :linux
require File.expand_path('make/linux/xmsys2/setup')
require File.expand_path('make/gems')
require File.expand_path('make/subsys')
when /mxe64/
require File.expand_path('make/linux/mxe64/env')
require File.expand_path('make/linux/mxe64/tasks')
require File.expand_path('make/linux/mxe64/stubs')
require File.expand_path('make/linux/mxe64/packdeps')
require File.expand_path('make/linux/mxe64/setup')
require File.expand_path('make/gems')
require File.expand_path('make/subsys')
when /mxe/
require File.expand_path('make/linux/mxe/env')
require File.expand_path('make/linux/mxe/tasks')
Expand Down Expand Up @@ -433,7 +441,7 @@ SubDirs = ["#{rtp}/zzbase.done", "#{rtp}/http/zzdownload.done",

# Windows doesn't use console - don't try to build it. Delete from dependcies
case TGT_DIR
when /win7/, /xwin7/, /msys2/, /xmsys2/, /mxe/, /mxe_osx/, /xmsw/
when /win7/, /xwin7/, /msys2/, /xmsys2/, /mxe/, /mxe_osx/, /xmsw/, /msw/, /mxe64/
SubDirs.delete("#{rtp}/console/zzconsole.done")
end

Expand Down Expand Up @@ -534,7 +542,12 @@ namespace :setup do
task :msys2 do
sh "echo TGT_ARCH=msys2 >build_target"
end
end

desc "Setup for Windows Native Widgets"
task :msw do
sh "echo TGT_ARCH=msw >build_target"
end
end

if build_os == :bsd
desc "Minimal Shoes for linux (default)"
Expand Down Expand Up @@ -608,6 +621,11 @@ namespace :setup do
task :mxe do
sh "echo 'TGT_ARCH=mxe' >build_target"
end

desc "Setup for Windows 64bit+ (MXE tools - recommended)"
task :mxe64 do
sh "echo 'TGT_ARCH=mxe64' >build_target"
end

desc "Setup for Win7+ using Linux (debian tools)"
task :xwin7 do
Expand Down
File renamed without changes.
7 changes: 5 additions & 2 deletions lib/shoes/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@
else
ruby_ins = "#{DIR}/shoes --ruby"
end
ccdlflags = RbConfig::CONFIG['CCDLFLAGS']+" "+arch_flag
config = {
'ruby_install_name' => ruby_ins,
'ruby_install_name' => ruby_ins, # unused ?
'RUBY_INSTALL_NAME' => ruby_ins,
'prefix' => "#{DIR}",
'bindir' => "#{DIR}",
Expand All @@ -85,7 +86,9 @@
'libdir' => "#{DIR}",
'LDFLAGS' => arch_flag + "-L. -L#{DIR}",
'rubylibprefix' => "#{DIR}/ruby",
'ARCH_FLAG' => arch_flag
'ARCH_FLAG' => arch_flag,
'CCDLFLAGS' => ccdlflags,
'ccdlflags' => ccdlflags
}
RbConfig::CONFIG.merge! config
RbConfig::MAKEFILE_CONFIG.merge! config
Expand Down
38 changes: 26 additions & 12 deletions lib/shoes/setup.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'rubygems'
require 'rubygems/dependency_installer'
# 2014-02-05 (CJC) There's lots of things in here that aren't needed
# or may not work as intended.
# 2019-04-23 (CJC) It works for some gems for some people in some situations.
module Gem
if Shoes::RELEASE_TYPE =~ /TIGHT/
if RUBY_PLATFORM =~ /darwin/
Expand All @@ -14,16 +13,31 @@ module Gem
end
end
class << Gem::Ext::ExtConfBuilder
alias_method :make__, :make
def make(dest_path, results)
raise unless File.exist?('Makefile')
mf = File.read('Makefile')
mf = mf.gsub(/^INSTALL\s*=\s*.*$/, "INSTALL = $(RUBY) -run -e install -- -vp")
mf = mf.gsub(/^INSTALL_PROG\s*=\s*.*$/, "INSTALL_PROG = $(INSTALL) -m 0755")
mf = mf.gsub(/^INSTALL_DATA\s*=\s*.*$/, "INSTALL_DATA = $(INSTALL) -m 0644")
File.open('Makefile', 'wb') {|f| f.print mf}
make__(dest_path, results)
end
if RUBY_PLATFORM =~ /darwin/
alias_method :make__, :make
def make(dest_path, results)
raise unless File.exist?('Makefile')
mf = File.read('Makefile')
mf = mf.gsub(/^V\ =\ 0/, "V = 1")
mf = mf.gsub(/^ARCH_FLAG =/, "ARCH_FLAG = #{RbConfig::CONFIG['ARCH_FLAG']}")
#mf = mf.gsub(/^INSTALL\s*=\s*.*$/, "INSTALL = $(RUBY) -run -e install -- -vp")
#mf = mf.gsub(/^INSTALL_PROG\s*=\s*.*$/, "INSTALL_PROG = $(INSTALL) -m 0755")
#mf = mf.gsub(/^INSTALL_DATA\s*=\s*.*$/, "INSTALL_DATA = $(INSTALL) -m 0644")
File.open('Makefile', 'wb') {|f| f.print mf}
make__(dest_path, results)
end
else
alias_method :make__, :make
def make(dest_path, results)
raise unless File.exist?('Makefile')
mf = File.read('Makefile')
mf = mf.gsub(/^INSTALL\s*=\s*.*$/, "INSTALL = $(RUBY) -run -e install -- -vp")
mf = mf.gsub(/^INSTALL_PROG\s*=\s*.*$/, "INSTALL_PROG = $(INSTALL) -m 0755")
mf = mf.gsub(/^INSTALL_DATA\s*=\s*.*$/, "INSTALL_DATA = $(INSTALL) -m 0644")
File.open('Makefile', 'wb') {|f| f.print mf}
make__(dest_path, results)
end
end
end

# STDIN.reopen("/dev/tty") if STDIN.eof?
Expand Down
174 changes: 174 additions & 0 deletions make/linux/mxe64/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# mxe64 cross build
# TODO: missing curl
# TODO: massage for mxe deps and locations. (basedll..)
cf =(ENV['ENV_CUSTOM'] || "#{APP['VAGRANT']}mxe64-custom.yaml")
gtk_version = '3'
if File.exists? cf
custmz = YAML.load_file(cf)
ShoesDeps = custmz['Deps']
EXT_RUBY = custmz['Ruby']
GtkDeps = custmz['GtkLoc'] ? custmz['GtkLoc'] : ShoesDeps
ENABLE_MS_THEME = custmz['MS-Theme'] == true
APP['GDB'] = 'basic' if custmz['Debug'] == true
APP['GEMLOC'] = custmz['Gemloc'] if custmz['Gemloc']
APP['EXTLOC'] = custmz['Extloc'] if custmz['Extloc']
APP['EXTLIST'] = custmz['Exts'] if custmz['Exts']
APP['GEMLIST'] = custmz['Gems'] if custmz['Gems']
APP['INCLGEMS'] = custmz['InclGems'] if custmz['InclGems']
APP['VIDEO'] = true
APP['GTK'] = 'gtk+-3.0'
APP['INSTALLER'] = custmz['Installer'] == 'qtifw'? 'qtifw' : 'nsis'
APP['INSTALLER_LOC'] = custmz['InstallerLoc']
else
abort "missing #{TGT_ARCH}-custom.yaml"
end

require_relative '../../switch_ruby'

# Ruby doesn't do triplets like everyone else.
arch_2_file = {'i386-mingw32.shared' => 'i386-mingw32'}
# Match what Gem:: does (not what you think it should do)
arch_2_gem = {'x64-mingw32.shared' => 'x64-mingw32'} # mxe compiled ruby


SHOES_TGT_ARCH = RbConfig::CONFIG['arch']
SHOES_GEM_ARCH = arch_2_gem[RbConfig::CONFIG['arch']]
APP['RUBY_V'] = RbConfig::CONFIG['ruby_version']
# dll locations for mxe
bindll = "#{ShoesDeps}/bin"
basedll = "#{ShoesDeps}/basedll"
gtkdll = "#{GtkDeps}/bin"
APP['LIBPATHS'] = [bindll, "#{EXT_RUBY}/bin"]

WINVERSION = "#{APP['VERSION']}-gtk3-32"
WINFNAME = "#{APPNAME}-#{WINVERSION}"

RUBY_HTTP = true

DLEXT = "dll"
# RbConfig doesn't have good values for these:
CC = RbConfig::CONFIG['CC'] #"i686-w64-mingw32-gcc"
STRIP = "#{RbConfig::CONFIG['STRIP']} -x" #"i686-w64-mingw32-strip -x"
WINDRES = RbConfig::CONFIG['WINDRES'] #"i686-w64-mingw32-windres"
PKG_CONFIG = "pkg-config"


ENV['PKG_CONFIG_PATH'] = "#{ShoesDeps}/lib/pkgconfig"
gtk_pkg_path = "#{GtkDeps}/lib/pkgconfig/gtk+-3.0.pc"
pkgruby ="#{EXT_RUBY}/lib/pkgconfig/#{RbConfig::CONFIG["ruby_pc"]}"

WIN32_CFLAGS = []
WIN32_LDFLAGS = []
WIN32_LIBS = []

if APP['GDB']
WIN32_CFLAGS << "-g3 -O0"
else
WIN32_CFLAGS << "-O -Wall"
end


GTK_CFLAGS = `#{PKG_CONFIG} --cflags gtk+-3.0 --define-variable=prefix=#{ShoesDeps}`.chomp
GTK_LDFLAGS = `#{PKG_CONFIG} --libs #{gtk_pkg_path} --define-variable=prefix=#{ShoesDeps}`.chomp
CAIRO_CFLAGS = `#{PKG_CONFIG} --cflags glib-2.0 --define-variable=prefix=#{ShoesDeps}`.chomp +
`#{PKG_CONFIG} --cflags cairo --define-variable=prefix=#{ShoesDeps}`.chomp
CAIRO_LDFLAGS = `#{PKG_CONFIG} --libs cairo --define-variable=prefix=#{ShoesDeps}`.chomp
PANGO_CFLAGS = `#{PKG_CONFIG} --cflags pango --define-variable=prefix=#{ShoesDeps}`.chomp
PANGO_LDFLAGS = `#{PKG_CONFIG} --libs pango --define-variable=prefix=#{ShoesDeps}`.chomp

#RUBY_LDFLAGS = " -Wl,-export-all-symbols -L#{EXT_RUBY}/lib -lmsvcrt-ruby230 "
RUBY_LDFLAGS = " -Wl,-export-all-symbols -L#{EXT_RUBY}/lib -l#{RbConfig::CONFIG["RUBY_SO_NAME"]} "

WIN32_CFLAGS << "-DSHOES_GTK -DSHOES_GTK_WIN32 -DRUBY_HTTP -DVIDEO"
WIN32_CFLAGS << "-DGTK3 "
WIN32_CFLAGS << "-Wno-unused-but-set-variable -Wno-attributes"
WIN32_CFLAGS << "-D__MINGW_USE_VC2005_COMPAT -DXMD_H -D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0501 -DWINVER=0x0501 -DCOBJMACROS"
WIN32_CFLAGS << GTK_CFLAGS
WIN32_CFLAGS << CAIRO_CFLAGS
WIN32_CFLAGS << PANGO_CFLAGS
WIN32_CFLAGS << "-I#{ShoesDeps}/include/librsvg-2.0/librsvg "
WIN32_CFLAGS << `pkg-config --cflags #{pkgruby} --define-variable=prefix=#{EXT_RUBY}`.chomp
WIN32_CFLAGS << "-Ishoes"

WIN32_LDFLAGS << "-lshell32 -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lcomctl32"
WIN32_LDFLAGS << "-lgif -ljpeg -lfontconfig"
WIN32_LDFLAGS << "-L#{ShoesDeps}/bin"
WIN32_LDFLAGS << "-fPIC -shared"
WIN32_LDFLAGS << GTK_LDFLAGS
WIN32_LDFLAGS << CAIRO_LDFLAGS
WIN32_LDFLAGS << PANGO_LDFLAGS
WIN32_LDFLAGS << RUBY_LDFLAGS

WIN32_LIBS << RUBY_LDFLAGS
WIN32_LIBS << CAIRO_LDFLAGS
WIN32_LIBS << PANGO_LDFLAGS
WIN32_LIBS << "-L#{ShoesDeps}/lib -lrsvg-2 -lyaml -lpthread"

# Cleaning up duplicates. Clunky? Hell yes!
wIN32_CFLAGS = WIN32_CFLAGS.join(' ').split(' ').uniq
wIN32_LDFLAGS = WIN32_LDFLAGS.join(' ').split(' ').uniq
wIN32_LIBS = WIN32_LIBS.join(' ').split(' ').uniq

LINUX_CFLAGS = wIN32_CFLAGS.join(' ')
LINUX_LDFLAGS = wIN32_LDFLAGS.join(' ')
LINUX_LIBS = wIN32_LIBS.join(' ')


# keys for SOLOCS are globed so libgio libgio-2 libgio-2.0 are the same
# see win_dep_find_and_copy() in Rakefile. Values in the hash are no longer used
SOLOCS = {
"#{RbConfig::CONFIG["RUBY_SO_NAME"]}" => "#{EXT_RUBY}/foobar-not-here/msvcrt-ruby230.dll",
'libgif-7' => "#{bindll}/libgif-7.dll",
'libjpeg-9' => "#{bindll}/libjpeg-9.dll",
'libyaml-0-2' => "#{bindll}/libyaml-0-2.dll",
'libiconv-2' => "#{bindll}/libiconv-2.dll",
#'libeay32' => "#{bindll}/libeay32.dll",
'libgdbm-6' => "#{bindll}/libgdbm-4.dll",
#'ssleay32' => "#{bindll}/ssleay32.dll",
'libepoxy-0' => "#{bindll}/libepoxy-0.dll",
#'libgmp-10' => "#{basedll}/libgmp-10.dll",
#'libgcc_s_dw2-1' => "#{basedll}/libgcc_s_dw2-1.dll",
#'libgcc_s_sjlj-1' => "{basedll}/libgcc_s_sjlj-1.dll",
'libgcc_s_seh-1' => '',
'libwebp-7' => '',
'libsqlite3' => "#{bindll}/libsqlite3-0.dll",
'libexpat-1' => "",
'libbz2' => "",
'libpcre-1' => "",
'libtiff-5' => '',
'liblzma-5' => '',
}


SOLOCS.merge!(
{
'libatk-1.0-0' => "#{bindll}/libatk-1.0-0.dll",
'libcairo-2' => "#{bindll}/libcairo-2.dll",
'libcairo-gobject-2' => "#{bindll}/libcairo-gobject-2.dll",
'libffi-6' => "#{bindll}/libffi-6.dll",
'libfontconfig-1' => "#{bindll}/libfontconfig-1.dll",
'libfreetype-6' => "#{bindll}/libfreetype-6.dll",
'libgdk_pixbuf-2.' => "#{bindll}/libgdk_pixbuf-2.0-0.dll",
'libgio-2.0-0' => "#{bindll}/libgio-2.0-0.dll",
'libglib-2.0-0' => "#{bindll}/libglib-2.0-0.dll",
'libgmodule-2' => "#{bindll}/libgmodule-2.0-0.dll",
'libgobject-2' => "#{bindll}/libgobject-2.0-0.dll",
'libgdk-3-0' => "#{gtkdll}/libgdk-3-0.dll",
'libgtk-3-0' => "#{gtkdll}/libgtk-3-0.dll",
'libpixman-1-0' => "#{bindll}/libpixman-1-0.dll",
'libintl-8' => "#{bindll}/libintl-8.dll",
'libpango-1.0-0' => "#{bindll}/libpango-1.0-0.dll",
'libpangocairo-1' => "#{bindll}/libpangocairo-1.0-0.dll",
'libpangoft2-1' => "#{bindll}/libpangoft2-1.0-0.dll",
'libpangowin32-1' => "#{bindll}/libpangowin32-1.0-0.dll",
'libharfbuzz-0' => "#{bindll}/libharfbuzz-0.dll",
'libpng16-16' => "#{bindll}/libpng16-16.dll",
'libcroco-0.6-3' => "#{bindll}/libcroco-0.6-3.dll",
'librsvg-2-2' => "#{bindll}/librsvg-2-2.dll",
'libxml2' => "#{bindll}/libxml2-2.dll",
'libgthread-2' => "#{bindll}/libgthread-2.0-0.dll",
'zlib1' => "#{bindll}/zlib1.dll",
'libwinpthread-1' => "#{basedll}/libwinpthread-1.dll",
}
)

33 changes: 33 additions & 0 deletions make/linux/mxe64/packdeps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# package ShoesDeps into just the minimum to upload
# expect symlink trouble with include/x --> lib/x/include/ ?
desc "package mingw dependencies"
task :packdeps do
# ugly - build a ShoesDeps.zip in dist
rm_rf 'mingwdeps'
mkdir_p 'mingwdeps'
cp "#{ShoesDeps}/README.txt", 'mingwdeps'
bin = 'mingwdeps/bin'
mkdir_p bin
Dir.glob("#{ShoesDeps}/bin/*.dll") { |f|
cp f, bin
}
Dir.glob("#{ShoesDeps}/bin/fc*.exe") {|f|
cp f, bin
}
cp "#{ShoesDeps}/bin//gtk-update-icon-cache.exe", bin
cp "#{ShoesDeps}/bin/pkg-config.exe", bin
sh "cp -a #{ShoesDeps}/include mingwdeps"
cp_r "#{ShoesDeps}/etc", 'mingwdeps'
cp_r "#{ShoesDeps}/lib", 'mingwdeps'
mkdir_p 'mingwdeps/share'
cp_r "#{ShoesDeps}/share/fontconfig", 'mingwdeps/share'
cp_r "#{ShoesDeps}/share/glib-2.0", 'mingwdeps/share'
cp_r "#{ShoesDeps}/share/themes", 'mingwdeps/share'
cp_r "#{ShoesDeps}/share/xml", 'mingwdeps/share'
cp_r "#{ShoesDeps}/share/fontconfig", 'mingwdeps/share'
cp_r "#{ShoesDeps}/share/icons", 'mingwdeps/share'
Dir.chdir('mingwdeps') do
sh "zip -r ShoesDeps.zip README.txt etc lib share include bin"
end
puts "Done"
end
Loading

0 comments on commit 304c525

Please sign in to comment.