From 5247c3caa0091a77cce772de30cd44aaff484e16 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Sun, 2 Apr 2017 13:37:30 -0400 Subject: Fixes for Windows / MinGW MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Rakefile, can’t use semicolons to separate commands, using “&&” instead; for the web, use `start` command to open browser. In `extconf.rb`, use `bash` explicitly when calling `simple2d` with flags; make experience consistent with Linux. --- ext/ruby2d/extconf.rb | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'ext') diff --git a/ext/ruby2d/extconf.rb b/ext/ruby2d/extconf.rb index 4989961..1256333 100644 --- a/ext/ruby2d/extconf.rb +++ b/ext/ruby2d/extconf.rb @@ -17,7 +17,7 @@ def print_errors end def check_s2d_version - unless Gem::Version.new(`simple2d --version`) >= Gem::Version.new(S2D_VERSION) + unless Gem::Version.new(`bash simple2d --version`) >= Gem::Version.new(S2D_VERSION) $errors << "Simple 2D needs to be updated for this version of Ruby 2D." << "Run the following, then try reinstalling this gem:\n" << " simple2d update".bold @@ -28,9 +28,10 @@ end # Install Simple 2D on supported platforms +case RUBY_PLATFORM -# OS X -if RUBY_PLATFORM =~ /darwin/ +# macOS +when /darwin/ # Simple 2D not installed if `which simple2d`.empty? @@ -57,36 +58,25 @@ if RUBY_PLATFORM =~ /darwin/ end end -# Linux -elsif RUBY_PLATFORM =~ /linux/ +# Linux and Windows / MinGW +when /linux|mingw/ # Simple 2D not installed if `which simple2d`.empty? $errors << "Ruby 2D uses a native library called Simple 2D.\n" << - "To install Simple 2D on Linux, follow the instructions" << - "in the README: #{"https://github.com/simple2d/simple2d".bold}" + "To install Simple 2D, follow the instructions in the README:" << + " #{"https://github.com/simple2d/simple2d".bold}" print_errors exit end - - $CFLAGS << ' -std=c11' - -# Windows / MinGW -elsif RUBY_PLATFORM =~ /mingw/ - # Add flags - $CFLAGS << ' -std=c11 -I/usr/local/include' - $LDFLAGS << ' -Dmain=SDL_main -L/usr/local/lib -lmingw32 -lsimple2d -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lopengl32 -lglew32 -mwindows' end -unless RUBY_PLATFORM =~ /mingw/ - # Simple 2D installed, check version - check_s2d_version - - # Add flags - $LDFLAGS << ' ' << `simple2d --libs` -end +check_s2d_version +# Add flags +$CFLAGS << ' -std=c11 -I/usr/local/include' +$LDFLAGS << ' ' << `bash simple2d --libs` $LDFLAGS.gsub!(/\n/, ' ') # Remove newlines in flags, they cause problems create_makefile('ruby2d/ruby2d') -- cgit v1.2.3