Top Level Namespace
- Includes:
- RroongaBuild
Defined Under Namespace
Modules: Groonga
Instance Method Summary collapse
- #build_groonga(major, minor, micro) ⇒ Object
- #configure_command_line(prefix) ⇒ Object
- #disable_optimization_build_flag(flags) ⇒ Object
- #download(url) ⇒ Object
- #enable_debug_build_flag(flags) ⇒ Object
- #extract_groonga_win32_binary(major, minor, micro) ⇒ Object
- #extract_zip(filename, destrination_dir) ⇒ Object
- #gcc? ⇒ Boolean
- #install_groonga_locally(major, minor, micro) ⇒ Object
- #win32? ⇒ Boolean
Instance Method Details
#build_groonga(major, minor, micro) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'ext/groonga/extconf.rb', line 158 def build_groonga(major, minor, micro) tar_gz = "groonga-#{major}.#{minor}.#{micro}.tar.gz" url = "http://packages.groonga.org/source/groonga/#{tar_gz}" install_dir = local_groonga_install_dir download(url) ("extracting...") if xsystem("tar xfz #{tar_gz}") (" done\n") else (" failed\n") exit(false) end groonga_source_dir = "groonga-#{major}.#{minor}.#{micro}" Dir.chdir(groonga_source_dir) do ("configuring...") if xsystem(configure_command_line(install_dir)) (" done\n") else (" failed\n") exit(false) end ("building (maybe long time)...") if xsystem("make") (" done\n") else (" failed\n") exit(false) end ("installing...") if xsystem("make install") (" done\n") else (" failed\n") exit(false) end end ("removing source...") FileUtils.rm_rf(groonga_source_dir) (" done\n") ("removing source archive...") FileUtils.rm_rf(tar_gz) (" done\n") end |
#configure_command_line(prefix) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'ext/groonga/extconf.rb', line 144 def configure_command_line(prefix) command_line = ["./configure"] debug_build_p = ENV["RROONGA_DEBUG_BUILD"] == "yes" debug_flags = ["CFLAGS=-ggdb3 -O0", "CXXFLAGS=-ggdb3 -O0"] command_line.concat(debug_flags) if debug_build_p command_line << "--prefix=#{prefix}" command_line << "--disable-static" command_line << "--disable-document" escaped_command_line = command_line.collect do |command| Shellwords.escape(command) end escaped_command_line.join(" ") end |
#disable_optimization_build_flag(flags) ⇒ Object
245 246 247 248 249 250 251 |
# File 'ext/groonga/extconf.rb', line 245 def disable_optimization_build_flag(flags) if gcc? flags.gsub(/(^|\s)?-O\d(\s|$)?/, '\\1-O0\\2') else flags end end |
#download(url) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/groonga/extconf.rb', line 85 def download(url) ("downloading %s...", url) base_name = File.basename(url) if File.exist?(base_name) (" skip (use downloaded file)\n") else open(url, "rb") do |input| File.open(base_name, "wb") do |output| while (buffer = input.read(1024)) output.print(buffer) end end end (" done\n") end end |
#enable_debug_build_flag(flags) ⇒ Object
253 254 255 256 257 258 259 |
# File 'ext/groonga/extconf.rb', line 253 def enable_debug_build_flag(flags) if gcc? flags.gsub(/(^|\s)?-g\d?(\s|$)?/, '\\1-ggdb3\\2') else flags end end |
#extract_groonga_win32_binary(major, minor, micro) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'ext/groonga/extconf.rb', line 113 def extract_groonga_win32_binary(major, minor, micro) if ENV["RROONGA_USE_GROONGA_X64"] architecture = "x64" else architecture = "x86" end zip = "groonga-#{major}.#{minor}.#{micro}-#{architecture}.zip" url = "http://packages.groonga.org/windows/groonga/#{zip}" install_dir = local_groonga_install_dir download(url) ("extracting...") extract_zip(zip, ".") (" done\n") if File.exist?(install_dir) ("removing old install... #{install_dir}") FileUtils.rm_rf(install_dir) (" done\n") end ("installing...") FileUtils.mv(File.basename(zip, ".zip"), install_dir) (" done\n") ("removing binary archive...") FileUtils.rm_rf(zip) (" done\n") end |
#extract_zip(filename, destrination_dir) ⇒ Object
102 103 104 105 106 107 108 109 110 111 |
# File 'ext/groonga/extconf.rb', line 102 def extract_zip(filename, destrination_dir) begin require "archive/zip" rescue LoadError require "rubygems" require "archive/zip" end Archive::Zip.extract(filename, destrination_dir) end |
#gcc? ⇒ Boolean
241 242 243 |
# File 'ext/groonga/extconf.rb', line 241 def gcc? CONFIG["GCC"] == "yes" end |
#install_groonga_locally(major, minor, micro) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'ext/groonga/extconf.rb', line 71 def install_groonga_locally(major, minor, micro) FileUtils.mkdir_p(local_groonga_base_dir) Dir.chdir(local_groonga_base_dir) do if win32? extract_groonga_win32_binary(major, minor, micro) else build_groonga(major, minor, micro) end end prepend_pkg_config_path_for_local_groonga end |
#win32? ⇒ Boolean
52 53 54 |
# File 'ext/groonga/extconf.rb', line 52 def win32? /cygwin|mingw|mswin/ =~ RUBY_PLATFORM end |