summaryrefslogtreecommitdiffhomepage
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
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.
-rw-r--r--Rakefile11
-rw-r--r--ext/ruby2d/extconf.rb34
2 files changed, 20 insertions, 25 deletions
diff --git a/Rakefile b/Rakefile
index 58e48c8..e7fbd2a 100644
--- a/Rakefile
+++ b/Rakefile
@@ -32,20 +32,25 @@ end
def run_mri_test(file)
print_task "Running MRI test: #{file}.rb"
- system "( cd test/ ; ruby #{file}.rb )"
+ system "( cd test/ && ruby #{file}.rb )"
end
def run_native_test(file)
print_task "Running native test: #{file}.rb"
run_cmd "ruby2d build --native test/#{file}.rb --debug"
- system "( cd test/ ; ../build/app )"
+ system "( cd test/ && ../build/app )"
end
def run_web_test(file)
print_task "Running web test: #{file}.rb"
run_cmd "ruby2d build --web test/#{file}.rb --debug"
open_cmd = 'open'
- if RUBY_PLATFORM =~ /linux/ then open_cmd = "xdg-#{open_cmd}" end
+ case RUBY_PLATFORM
+ when /linux/
+ open_cmd = "xdg-#{open_cmd}"
+ when /mingw/
+ open_cmd = "start"
+ end
system "#{open_cmd} build/app.html"
end
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')