summaryrefslogtreecommitdiffhomepage
path: root/ext
diff options
context:
space:
mode:
authorTom Black <[email protected]>2016-01-01 17:02:41 -0600
committerTom Black <[email protected]>2016-01-01 17:02:41 -0600
commit425faa8986ae71438a538b40e996f551866bdf83 (patch)
treede5ace2f4b2e17e66ebc4ae6b717144725685c55 /ext
parent7f749675095383ca816b8469ae53d65c73d708d7 (diff)
downloadruby2d-425faa8986ae71438a538b40e996f551866bdf83.tar.gz
ruby2d-425faa8986ae71438a538b40e996f551866bdf83.zip
Add `--no-brew` option
Used to skip Homebrew on OS X, also some extconf cleanup
Diffstat (limited to 'ext')
-rw-r--r--ext/ruby2d/extconf.rb67
1 files changed, 35 insertions, 32 deletions
diff --git a/ext/ruby2d/extconf.rb b/ext/ruby2d/extconf.rb
index 9368d47..721c4fb 100644
--- a/ext/ruby2d/extconf.rb
+++ b/ext/ruby2d/extconf.rb
@@ -1,7 +1,5 @@
require 'mkmf'
-errors = []
-
class String
def colorize(c); "\e[#{c}m#{self}\e[0m" end
def error; colorize('1;31') end
@@ -19,40 +17,44 @@ def print_errors(errors)
#{"============================================================".bold}"
end
+errors = []
+
+# Install Simple 2D on supported platforms
# OS X
if RUBY_PLATFORM =~ /darwin/
-
- # Simple 2D not installed
- if `which simple2d`.empty?
- # 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
-
- # Simple 2D installed, update to latest version
- else
- # Homebrew not installed
- if `which brew`.empty?
- # TODO: Check for latest version manually and update
- # Homebrew installed, get latest version of Simple 2D
- else
- # An alternative, but slower and updates all formulas:
- # `brew update`
- # `brew upgrade simple2d`
+ unless ARGV.include? "--no-brew"
+ # Simple 2D not installed
+ if `which simple2d`.empty?
+ # 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
- `brew untap simple2d/tap`
- `brew tap simple2d/tap`
- `brew upgrade simple2d`
+ # Simple 2D installed, update to latest version
+ else
+ # Homebrew not installed
+ if `which brew`.empty?
+ # TODO: Check for latest version manually and update
+ # Homebrew installed, get latest version of Simple 2D
+ else
+ # An alternative, but slower and updates all formulas:
+ # `brew update`
+ # `brew upgrade simple2d`
+
+ `brew untap simple2d/tap`
+ `brew tap simple2d/tap`
+ `brew upgrade simple2d`
+ end
end
end
@@ -74,6 +76,7 @@ elsif RUBY_PLATFORM =~ /mingw/
exit
end
+# Configure Simple 2D and create Makefile
$LDFLAGS << ' ' << `simple2d --libs`
$LDFLAGS.gsub!(/\n/, ' ') # remove newlines in flags, they cause problems