summaryrefslogtreecommitdiffhomepage
path: root/ext
diff options
context:
space:
mode:
authorTom Black <[email protected]>2017-04-02 13:37:30 -0400
committerTom Black <[email protected]>2017-04-02 13:37:30 -0400
commit5247c3caa0091a77cce772de30cd44aaff484e16 (patch)
treeee3b9d29b2d21306d00d0855e31bebeb7a9c3995 /ext
parent5cb0c0581b2ba9b9c436edb7b6699c2b44243e2f (diff)
downloadruby2d-5247c3caa0091a77cce772de30cd44aaff484e16.tar.gz
ruby2d-5247c3caa0091a77cce772de30cd44aaff484e16.zip
Fixes for Windows / MinGW
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.
Diffstat (limited to 'ext')
-rw-r--r--ext/ruby2d/extconf.rb34
1 files changed, 12 insertions, 22 deletions
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')