Skip to content

Commit

Permalink
for #438 - osx build native gems like rmagick. Works but
Browse files Browse the repository at this point in the history
it's easy for the gem (rmagick in partular) to not work. It's an
OSX and ruby thing. Shoes only looks like ruby.
  • Loading branch information
Cecil committed May 1, 2019
1 parent 57014d0 commit 8788853
Show file tree
Hide file tree
Showing 8 changed files with 291 additions and 86 deletions.
12 changes: 6 additions & 6 deletions make/darwin/minosx/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
elsif EXT_RUBY.include? '/usr/local/Cellar/'
# brew install [email protected]
APP['RVMGEM'] = ENV['GEM_HOME']
APP['ABSBUNDLE'] = true # ie. bundles use ABS patchs
APP['ABSBUNDLE'] = true # ie. bundles use ABS paths
else
$stderr.puts "Your ruby is Suspicious. Create a minosx-custom.yaml"
abort
Expand Down Expand Up @@ -114,13 +114,14 @@
CAIRO_LDFLAGS = "-L#{ShoesDeps}/lib -lcairo"
PANGO_CFLAGS = "-I#{ShoesDeps}/include/pango-1.0"
PANGO_LDFLAGS = "-L#{ShoesDeps}/lib -lpango-1.0"
#RUBY_CFLAGS = "-I#{EXT_RUBY}/include/ruby-2.3.0/x86_64-darwin14 -I#{EXT_RUBY}/include/ruby-2.3.0 "
RUBY_CFLAGS =`pkg-config --cflags "#{pkgruby}"`.strip+" "
RUBY_LDFLAGS = "-L#{EXT_RUBY}lib/ -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -lruby.2.3.0 -lpthread -ldl -lobjc "
RUBY_CFLAGS = `pkg-config --cflags "#{pkgruby}"`.strip+" "
#RUBY_LDFLAGS = `pkg-config --libs "#{pkgruby}"`.strip+" "
#RUBY_LDFLAGS = "-L#{EXT_RUBY}lib/ -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -lruby.2.4.5 -lpthread -ldl -lobjc "

LINUX_CFLAGS << " -I#{ShoesDeps}/include #{GLIB_CFLAGS} #{RUBY_CFLAGS} #{CAIRO_CFLAGS} #{PANGO_CFLAGS}"

LINUX_LIB_NAMES = %W[#{RUBY_SO} cairo pangocairo-1.0 gif]
#LINUX_LIB_NAMES = %W[#{RUBY_LDFLAGS} cairo pangocairo-1.0 gif]

LINUX_CFLAGS << " -DRUBY_1_9 "

Expand All @@ -130,7 +131,6 @@
LINUX_LDFLAGS = "-framework Cocoa -framework QuartzCore -framework Carbon -dynamiclib -Wl,-single_module INSTALL_NAME"
LINUX_LIB_NAMES << 'pixman-1' << 'jpeg.8'

#OSX_SDK = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk'
OSX_SDK = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/#{osxsdk}"
ENV['MACOSX_DEPLOYMENT_TARGET'] = osxminv
LINUX_CFLAGS << " -mmacosx-version-min=#{osxminv}"
Expand All @@ -151,7 +151,7 @@
LINUX_CFLAGS << " -isysroot #{OSX_SDK} #{OSX_ARCH}"
LINUX_LDFLAGS << " -isysroot #{OSX_SDK} #{OSX_ARCH} -L#{ShoesDeps}/lib/ #{GLIB_LDFLAGS}"

LINUX_LIBS = " -l#{RUBY_SO} -L#{ShoesDeps}/lib -l cairo -L#{ShoesDeps}/lib -lpangocairo-1.0 -L#{ShoesDeps}/lib -lgif -ljpeg"
LINUX_LIBS = " -L #{EXT_RUBY}/lib -l#{RUBY_SO} -L#{ShoesDeps}/lib -l cairo -L#{ShoesDeps}/lib -lpangocairo-1.0 -L#{ShoesDeps}/lib -lgif -ljpeg"
LINUX_LIBS << " -L#{TGT_DIR} #{CAIRO_LDFLAGS} #{PANGO_LDFLAGS} #{GLIB_LDFLAGS}"

# Sigh - shoesdeps and homebrew versions can be out of sync.
Expand Down
78 changes: 45 additions & 33 deletions make/darwin/minosx/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,50 @@ module Make

def static_setup (so_list)
$stderr.puts "setup: dir=#{`pwd`} for #{TGT_DIR}"
#rm_rf "#{TGT_DIR} "
mkdir_p "#{TGT_DIR}"
# copy Ruby, dylib, includes - have them in place before
# we build things
puts "Ruby at #{EXT_RUBY} : #{SHOES_GEM_ARCH}"
rbvt = RUBY_V
rbvm = RUBY_V[/^\d+\.\d+/]
rm_rf "#{TGT_DIR}/lib"
mkdir_p "#{TGT_DIR}/lib"
# clean out leftovers from last build
#rm_f "#{TGT_DIR}/libruby.dylib" if File.exist? "#{TGT_DIR}/libruby.dylib"
#rm_f "#{TGT_DIR}/libruby.#{rbvm}.dylib" if File.exist? "#{TGT_DIR}/libruby.#{rbvm}.dylib"
#rm_f "#{TGT_DIR}/libruby.#{rbvt}.dylib" if File.exist? "#{TGT_DIR}/libruby.#{rbvt}.dylib"
#mkdir_p "#{TGT_DIR}/lib/ruby/#{rbvm}.0/#{RUBY_PLATFORM}"
cp_r "#{EXT_RUBY}/lib/ruby", "#{TGT_DIR}/lib"
# copy and link libruby.dylib
cp "#{EXT_RUBY}/lib/libruby.#{rbvt}.dylib", "#{TGT_DIR}"
# copy include files - it might help build gems
mkdir_p "#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}"
cp_r "#{EXT_RUBY}/include/ruby-#{rbvt}/", "#{TGT_DIR}/lib/ruby/include"

if APP['LIBPATHS']
dep_find_and_copy( APP['LIBPATHS'], SOLOCS)
else
SOLOCS.each do |k, v|
cp v, TGT_DIR
end
end
# copy ssl engines
if File.exist?("#{ShoesDeps}/lib/engines")
cp_r "#{ShoesDeps}/lib/engines", "#{TGT_DIR}"
end

=begin
#rm_rf "#{TGT_DIR} "
mkdir_p "#{TGT_DIR}"
# copy Ruby, dylib, includes - have them in place before
# we build things
puts "Ruby at #{EXT_RUBY} : #{SHOES_GEM_ARCH}"
rbvt = RUBY_V
rbvm = RUBY_V[/^\d+\.\d+/]
rm_rf "#{TGT_DIR}/lib"
mkdir_p "#{TGT_DIR}/lib"
# clean out leftovers from last build
#rm_f "#{TGT_DIR}/libruby.dylib" if File.exist? "#{TGT_DIR}/libruby.dylib"
#rm_f "#{TGT_DIR}/libruby.#{rbvm}.dylib" if File.exist? "#{TGT_DIR}/libruby.#{rbvm}.dylib"
#rm_f "#{TGT_DIR}/libruby.#{rbvt}.dylib" if File.exist? "#{TGT_DIR}/libruby.#{rbvt}.dylib"
#mkdir_p "#{TGT_DIR}/lib/ruby/#{rbvm}.0/#{RUBY_PLATFORM}"
cp_r "#{EXT_RUBY}/lib/ruby", "#{TGT_DIR}/lib"
# copy and link libruby.dylib
cp "#{EXT_RUBY}/lib/libruby.#{rbvt}.dylib", "#{TGT_DIR}"
# copy include files - it might help build gems
mkdir_p "#{TGT_DIR}/lib/ruby/include/ruby-#{rbvt}"
cp_r "#{EXT_RUBY}/include/ruby-#{rbvt}/", "#{TGT_DIR}/lib/ruby/include"
if APP['LIBPATHS']
dep_find_and_copy( APP['LIBPATHS'], SOLOCS)
else
SOLOCS.each do |k, v|
cp v, TGT_DIR
end
end
# copy ssl engines
if File.exist?("#{ShoesDeps}/lib/engines")
cp_r "#{ShoesDeps}/lib/engines", "#{TGT_DIR}"
end
=end
srcloc= `pwd`.strip
ln_s "#{srcloc}/lib", TGT_DIR
ln_s "#{srcloc}/samples", TGT_DIR
ln_s "#{srcloc}/static", TGT_DIR
ln_s "#{srcloc}/fonts", TGT_DIR
ln_s "#{srcloc}/themes", TGT_DIR
cp "README.md", TGT_DIR
cp "CHANGELOG", TGT_DIR
cp "COPYING", TGT_DIR
=begin
# copy some static stuff
cp_r "fonts", "#{TGT_DIR}/fonts"
cp_r "lib", "#{TGT_DIR}"
Expand All @@ -46,6 +57,7 @@ def static_setup (so_list)
cp "README.md", "#{TGT_DIR}/README.txt"
cp "CHANGELOG", "#{TGT_DIR}/CHANGELOG.txt"
cp "COPYING", "#{TGT_DIR}/COPYING.txt"
=end
end
end

21 changes: 18 additions & 3 deletions make/darwin/minosx/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def rewrite_ary before, after, reg = /\#\{(\w+\[\'\w+\'\])\}/, reg2 = '\1'
end
end
end

# a stub, loose osx doesn't copy gems but the Builder will call it
def copy_gems
end

end

class MakeDarwin
Expand Down Expand Up @@ -93,7 +98,9 @@ def dylibs_to_change lib
end

def copy_deps_to_dist
puts "Entering copy_deps_to_dist #{TGT_DIR}"
$stderr.puts "Entering copy_deps_to_dist #{TGT_DIR}"
# for loose shoes (minosx) , see postbuild_fix
return
# Generate a list of dependencies straight from the generated files.
# Start with dependencies of shoes-bin, and then add the dependencies
# of those dependencies. Finally, add any oddballs that must be
Expand Down Expand Up @@ -164,6 +171,7 @@ def copy_deps_to_dist
end

def setup_system_resources
return
# called after the gems are copied into the above setup.
# build a hash of x.dylib > ShoesDeps/**/*.dylib
@brew_hsh = {}
Expand Down Expand Up @@ -219,8 +227,15 @@ def setup_system_resources

def postbuild_fix
# if this is called, the only thing that has changed is libshoes.dylib
# and shoes-bin. This hasn't needed but might involve
#$stderr.puts "called postbuild_fix"
# and shoes-bin. minosx needs this.
$stderr.puts "called postbuild_fix"
Dir.chdir TGT_DIR do
#sh "#{INTOOL} -id @executable_path/shoes-bin shoes-bin"
sh "#{INTOOL} -change @executable_path/librsvg-2.2.dylib /usr/local/lib/librsvg-2.2.dylib shoes-bin"
sh "#{INTOOL} -change @executable_path/librsvg-2.2.dylib /usr/local/lib/librsvg-2.2.dylib libshoes.dylib"
#sh "#{INTOOL} -change @executable_path/../lib/libruby.2.4.5.dylib #{EXT_RUBY}/lib/libruby.2.4.5.dylib shoes-bin"
#sh "#{INTOOL} -change @executable_path/../lib/libruby.2.4.5.dylib #{EXT_RUBY}/lib/libruby.2.4.5.dylib libshoes.dylibq"
end
=begin
install_name_tool -id @executable_path/shoes-bin shoes-bin
install_name_tool -change /usr/local/lib/libcairo.2.dylib @executable_path/libcairo.2.dylib shoes-bin
Expand Down
2 changes: 1 addition & 1 deletion make/darwin/yosemite/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
LINUX_CFLAGS << " -isysroot #{OSX_SDK} #{OSX_ARCH}"
LINUX_LDFLAGS << " -isysroot #{OSX_SDK} #{OSX_ARCH} -L#{ShoesDeps}/lib/ #{GLIB_LDFLAGS}"

RUBY_SO = RbConfig::CONFIG['RUBY_SO_NAME']
#RUBY_SO = RbConfig::CONFIG['RUBY_SO_NAME']
LINUX_LIBS = " -l#{RUBY_SO} -L#{ShoesDeps}/lib -l cairo -L#{ShoesDeps}/lib -lpangocairo-1.0 -L#{ShoesDeps}/lib -lgif -ljpeg"
LINUX_LIBS << " -L#{TGT_DIR} #{CAIRO_LDFLAGS} #{PANGO_LDFLAGS} #{GLIB_LDFLAGS}"

Expand Down
84 changes: 43 additions & 41 deletions make/darwin/yosemite/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,49 @@ module Make

def static_setup (so_list)
$stderr.puts "setup: dir=#{`pwd`} for #{TGT_DIR}"
#rm_rf "#{TGT_DIR} "
mkdir_p "#{TGT_DIR}"
# copy Ruby, dylib, includes - have them in place before
# we build things
puts "Ruby at #{EXT_RUBY} : #{SHOES_GEM_ARCH} RUBY_V : #{RUBY_V}"
rbvt = rbinc = RUBY_V
rbvm = RUBY_V[/^\d+\.\d+/]
rm_rf "#{TGT_DIR}/lib"
mkdir_p "#{TGT_DIR}/lib"
if rbvm != '2.3'
# because ruby changes from version to version, os to os. Curses!
rbvt = RUBY_VERSION[/(\d+\.\d+\.\d+)/]
rbinc = rbvt[/\d+\.\d+/] + '.0'
end
# clean out leftovers from last build
#rm_f "#{TGT_DIR}/libruby.dylib" if File.exist? "#{TGT_DIR}/libruby.dylib"
#rm_f "#{TGT_DIR}/libruby.#{rbvm}.dylib" if File.exist? "#{TGT_DIR}/libruby.#{rbvm}.dylib"
#rm_f "#{TGT_DIR}/libruby.#{rbvt}.dylib" if File.exist? "#{TGT_DIR}/libruby.#{rbvt}.dylib"
#mkdir_p "#{TGT_DIR}/lib/ruby/#{rbvm}.0/#{RUBY_PLATFORM}"
cp_r "#{EXT_RUBY}/lib/ruby", "#{TGT_DIR}/lib"
# copy and link libruby.dylib
cp "#{EXT_RUBY}/lib/libruby.#{rbvt}.dylib", "#{TGT_DIR}"
Dir.chdir(TGT_DIR) do
ln_s "libruby.#{rbvt}.dylib", "libruby.#{rbvm}.dylib"
ln_s "libruby.#{rbvt}.dylib", "libruby.dylib"
end
# copy include files - it might help build gems
mkdir_p "#{TGT_DIR}/lib/ruby/include/ruby-#{rbinc}"
cp_r "#{EXT_RUBY}/include/ruby-#{rbinc}/", "#{TGT_DIR}/lib/ruby/include"

if APP['LIBPATHS']
dep_find_and_copy( APP['LIBPATHS'], SOLOCS)
else
SOLOCS.each do |k, v|
cp v, TGT_DIR
end
end
# copy ssl engines
if File.exist?("#{ShoesDeps}/lib/engines")
cp_r "#{ShoesDeps}/lib/engines", "#{TGT_DIR}"
end
#rm_rf "#{TGT_DIR} "
mkdir_p "#{TGT_DIR}"
# copy Ruby, dylib, includes - have them in place before
# we build things
puts "Ruby at #{EXT_RUBY} : #{SHOES_GEM_ARCH} RUBY_V : #{RUBY_V}"
rbvt = rbinc = APP['RUBY_V']
rbvm = APP['RUBY_V'][/^\d+\.\d+/]
rm_rf "#{TGT_DIR}/lib"
mkdir_p "#{TGT_DIR}/lib"
if rbvm == '2.3'
cp_r "#{EXT_RUBY}/lib/ruby", "#{TGT_DIR}/lib"
# copy and link libruby.dylib
cp "#{EXT_RUBY}/lib/libruby.#{rbvm}.0.dylib", "#{TGT_DIR}"
Dir.chdir(TGT_DIR) do
ln_s "libruby.#{rbvm}.0.dylib", "libruby.dylib"
end
else
# because ruby changes from version to version, os to os. Curses!
rbvt = RUBY_VERSION[/(\d+\.\d+\.\d+)/]
rbinc = rbvt[/\d+\.\d+/] + '.0'
cp_r "#{EXT_RUBY}/lib/ruby", "#{TGT_DIR}/lib"
# copy and link libruby.dylib
cp "#{EXT_RUBY}/lib/libruby.#{rbvt}.dylib", "#{TGT_DIR}"
Dir.chdir(TGT_DIR) do
ln_s "libruby.#{rbvt}.dylib", "libruby.#{rbvm}.dylib"
ln_s "libruby.#{rbvt}.dylib", "libruby.dylib"
end
end
# copy include files - it might help build gems
mkdir_p "#{TGT_DIR}/lib/ruby/include/ruby-#{rbinc}"
cp_r "#{EXT_RUBY}/include/ruby-#{rbinc}/", "#{TGT_DIR}/lib/ruby/include"

if APP['LIBPATHS']
dep_find_and_copy( APP['LIBPATHS'], SOLOCS)
else
SOLOCS.each do |k, v|
cp v, TGT_DIR
end
end
# copy ssl engines
if File.exist?("#{ShoesDeps}/lib/engines")
cp_r "#{ShoesDeps}/lib/engines", "#{TGT_DIR}"
end

# copy some static stuff
cp_r "fonts", "#{TGT_DIR}/fonts"
Expand Down
4 changes: 2 additions & 2 deletions make/darwin/yosemite/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def copy_deps_to_dist
# included.
dylibs = get_dylibs("#{TGT_DIR}/#{NAME}-bin")
# add the gem's bundles.
rbvm = RUBY_V[/^\d+\.\d+/]
rbvm = APP['RUBY_V'][/^\d+\.\d+/]
Dir["#{TGT_DIR}/lib/ruby/gems/#{rbvm}.0/gems/**/*.bundle"].each do |gb|
puts "Bundle: #{gb}"
dylibs.concat get_dylibs(gb)
Expand Down Expand Up @@ -178,7 +178,7 @@ def setup_system_resources
@brew_hsh[key] = path
end
end
rbvm = RUBY_V[/^\d+\.\d+/]
rbvm = APP['RUBY_V'][/^\d+\.\d+/]
#tgtd = File.join(Dir.getwd, TGT_DIR)
tgtd = File.absolute_path(TGT_DIR)
puts "tgtd: #{tgtd}"
Expand Down
Loading

0 comments on commit 8788853

Please sign in to comment.