Top Level Namespace
- Includes:
- RroongaBuild
Defined Under Namespace
Modules: Groonga
Instance Method Summary collapse
- #build_groonga(major, minor, micro) ⇒ Object
- #build_groonga_from_git(major, minor, micro) ⇒ Object
- #build_groonga_from_tar_gz(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_for_gnu_build_system(install_dir) ⇒ Object
- #install_groonga_locally(major, minor, micro) ⇒ Object
- #run_command(start_message, command) ⇒ Object
- #win32? ⇒ Boolean
Instance Method Details
#build_groonga(major, minor, micro) ⇒ Object
221 222 223 224 225 226 227 |
# File 'ext/groonga/extconf.rb', line 221 def build_groonga(major, minor, micro) if RequiredGroongaVersion::RELEASED_DATE > Time.now build_groonga_from_git(major, minor, micro) else build_groonga_from_tar_gz(major, minor, micro) end end |
#build_groonga_from_git(major, minor, micro) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'ext/groonga/extconf.rb', line 174 def build_groonga_from_git(major, minor, micro) ("removing old cloned repository...") FileUtils.rm_rf("groonga") (" done\n") run_command("cloning...", "git clone --depth 1 https://github.com/groonga/groonga") Dir.chdir("groonga") do run_command("running autogen.sh...", "./autogen.sh") install_for_gnu_build_system(local_groonga_install_dir) end ("removing cloned repository...") FileUtils.rm_rf("groonga") (" done\n") end |
#build_groonga_from_tar_gz(major, minor, micro) ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'ext/groonga/extconf.rb', line 193 def build_groonga_from_tar_gz(major, minor, micro) tar_gz = "groonga-#{major}.#{minor}.#{micro}.tar.gz" url = "http://packages.groonga.org/source/groonga/#{tar_gz}" 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 install_for_gnu_build_system(local_groonga_install_dir) 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
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'ext/groonga/extconf.rb', line 149 def configure_command_line(prefix) command_line = ["./configure"] debug_build_p = ENV["RROONGA_DEBUG_BUILD"] == "yes" debug_flags = ["CFLAGS=-g3 -O0", "CXXFLAGS=-g3 -O0"] command_line.concat(debug_flags) if debug_build_p command_line << "--prefix=#{prefix}" command_line << "--disable-static" command_line << "--disable-document" command_line << "--disable-benchmark" command_line << "--without-cutter" escaped_command_line = command_line.collect do |command| Shellwords.escape(command) end escaped_command_line.join(" ") end |
#disable_optimization_build_flag(flags) ⇒ Object
271 272 273 274 275 276 277 |
# File 'ext/groonga/extconf.rb', line 271 def disable_optimization_build_flag(flags) if gcc? flags.gsub(/(^|\s)?-O\d(\s|$)?/, '\\1-O0\\2') else flags end end |
#download(url) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'ext/groonga/extconf.rb', line 80 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
279 280 281 282 283 284 285 |
# File 'ext/groonga/extconf.rb', line 279 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
108 109 110 111 112 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 |
# File 'ext/groonga/extconf.rb', line 108 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
97 98 99 100 101 102 103 104 105 106 |
# File 'ext/groonga/extconf.rb', line 97 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
267 268 269 |
# File 'ext/groonga/extconf.rb', line 267 def gcc? CONFIG["GCC"] == "yes" end |
#install_for_gnu_build_system(install_dir) ⇒ Object
165 166 167 168 169 170 171 172 |
# File 'ext/groonga/extconf.rb', line 165 def install_for_gnu_build_system(install_dir) run_command("configuring...", configure_command_line(install_dir)) run_command("building (maybe long time)...", "make") run_command("installing...", "make install") end |
#install_groonga_locally(major, minor, micro) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'ext/groonga/extconf.rb', line 66 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 |
#run_command(start_message, command) ⇒ Object
139 140 141 142 143 144 145 146 147 |
# File 'ext/groonga/extconf.rb', line 139 def run_command(, command) () if xsystem(command) (" done\n") else (" failed\n") exit(false) end end |
#win32? ⇒ Boolean
47 48 49 |
# File 'ext/groonga/extconf.rb', line 47 def win32? /cygwin|mingw|mswin/ =~ RUBY_PLATFORM end |