From be1daebb052a163c77d70cc8c504ba61ce46c949 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Wed, 7 Oct 2015 00:35:17 -0400 Subject: Add Simple 2D to gem installation --- ext/ruby2d/extconf.rb | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'ext') diff --git a/ext/ruby2d/extconf.rb b/ext/ruby2d/extconf.rb index 96c9eb4..04d9cd6 100644 --- a/ext/ruby2d/extconf.rb +++ b/ext/ruby2d/extconf.rb @@ -12,9 +12,9 @@ def print_errors(errors) puts " #{"== Ruby 2D Installation Errors =============================".bold} - Ruby 2D found some problems and was not installed: + #{"Ruby 2D found some problems and was not installed:".error} - #{errors.join("\n ").error} + #{errors.join("\n ")} #{"============================================================".bold} @@ -28,15 +28,23 @@ $LDFLAGS << ' ' # Mac OS if RUBY_PLATFORM =~ /darwin/ - # if `which simple2d`.empty? && has brew - # brew tap simple2d/tap - # brew install simple2d - # end - + # If Simple 2D not installed if `which simple2d`.empty? - errors << "Simple 2D not found!" - print_errors(errors) - exit + + # If Homebrew not installed, print and quit + if `which brew`.empty? + errors << "Ruby 2D uses a library called Simple 2D." << + "On OS X,this can be installed using Homebrew." << + "Install Homebrew, then try installing this gem again.\n" << + "Learn more at http://brew.sh" + print_errors(errors) + exit + + # Install Simple 2D using Homebrew + else + `brew tap simple2d/tap` + `brew install simple2d` + end end $LDFLAGS << `simple2d --libs` @@ -44,18 +52,27 @@ if RUBY_PLATFORM =~ /darwin/ # Windows elsif RUBY_PLATFORM =~ /mingw/ + puts "Ruby 2D doesn't support windows yet :(" + exit + # Linux else - # if `which simple2d`.empty? - # install simple2d using script - # end + # If Simple 2D not installed + if `which simple2d`.empty? + + errors << "Ruby 2D uses a library called Simple 2D." << + "On Linux, there's a script to make installaton easy.\n" << + "Follow the instructions in the README to get started:" << + " https://github.com/simple2d/simple2d" + print_errors(errors) + exit + end $LDFLAGS << `simple2d --libs` - end -# Remove any newlines in flags +# Remove newlines in flags, they cause problems $LDFLAGS.gsub!(/\n/, ' ') create_makefile('ruby2d/ruby2d') -- cgit v1.2.3