Top Level Namespace
Defined Under Namespace
Modules: Audio, NativeAudio
Instance Method Summary collapse
-
#add_flags(type, flags) ⇒ Object
Add compiler and linker flags.
-
#check_sdl ⇒ Object
Check for SDL libraries.
-
#print_errors ⇒ Object
Print installation errors.
-
#set_linux_bsd_flags ⇒ Object
Set flags for Linux and BSD.
-
#set_rpi_flags ⇒ Object
Set Raspberry Pi flags.
-
#use_usr_libs ⇒ Object
Use SDL and other libraries installed by the user (not those bundled with the gem).
Instance Method Details
#add_flags(type, flags) ⇒ Object
Add compiler and linker flags
32 33 34 35 36 37 38 39 |
# File 'ext/extconf.rb', line 32 def add_flags(type, flags) case type when :c $CFLAGS << " #{flags} " when :ld $LDFLAGS << " #{flags} " end end |
#check_sdl ⇒ Object
Check for SDL libraries
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'ext/extconf.rb', line 42 def check_sdl unless have_library('SDL2') && have_library('SDL2_mixer') $errors << "Couldn't find packages needed." case $platform when :linux, :linux_rpi # Fedora and CentOS if system('which yum') $errors << "Install the following packages using `yum` (or `dnf`) and try again:\n" << " SDL2-devel SDL2_mixer-devel".bold # Arch elsif system('which pacman') $errors << "Install the following packages using `pacman` and try again:\n" << " sdl2 sdl2_mixer".bold # openSUSE elsif system('which zypper') $errors << "Install the following packages using `zypper` and try again:\n" << " libSDL2-devel libSDL2_mixer-devel".bold # Ubuntu, Debian, and Mint # `apt` must be last because openSUSE has it aliased to `zypper` elsif system('which apt') $errors << "Install the following packages using `apt` and try again:\n" << " libsdl2-dev libsdl2-mixer-dev".bold end when :bsd $errors << "Install the following packages using `pkg` and try again:\n" << " sdl2 sdl2_mixer".bold end $errors << "" << "See #{"ruby2d.com".bold} for additional help." print_errors; exit end end |
#print_errors ⇒ Object
Print installation errors
24 25 26 27 28 29 |
# File 'ext/extconf.rb', line 24 def print_errors puts " #{"== #{"Ruby 2D Installation Errors".error} =======================================\n"} #{$errors.join("\n ")}\n #{"======================================================================"}" end |
#set_linux_bsd_flags ⇒ Object
Set flags for Linux and BSD
89 90 91 92 93 94 |
# File 'ext/extconf.rb', line 89 def set_linux_bsd_flags check_sdl set_rpi_flags add_flags(:ld, "-lSDL2 -lSDL2_mixer -lm") if $PLATFORM == :linux then add_flags(:ld, '-lGL') end end |
#set_rpi_flags ⇒ Object
Set Raspberry Pi flags
81 82 83 84 85 86 |
# File 'ext/extconf.rb', line 81 def set_rpi_flags if $platform == :linux_rpi add_flags(:c, '-I/opt/vc/include') add_flags(:ld, '-L/opt/vc/lib -lbrcmGLESv2') end end |
#use_usr_libs ⇒ Object
Use SDL and other libraries installed by the user (not those bundled with the gem)
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'ext/extconf.rb', line 98 def use_usr_libs case $PLATFORM when :macos add_flags(:c, `sdl2-config --cflags`) add_flags(:c, '-I/opt/homebrew/include') add_flags(:ld, `sdl2-config --libs`) add_flags(:ld, '-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf') add_flags(:ld, '-Wl,-framework,OpenGL') when :windows add_flags(:ld, '-lSDL2 -lSDL2_mixer') add_flags(:ld, '-lopengl32 -lglew32') when :linux_rpi set_linux_bsd_flags end end |