Top Level Namespace
Defined Under Namespace
Modules: GLib, GNOME2 Classes: GNOME2WindowsBinaryBuildTask, GNOME2WindowsBinaryDownloadTask
Constant Summary collapse
- GNOME2Package =
GNOME2::Rake::PackageTask
Instance Method Summary collapse
-
#add_depend_package(target_name, target_srcdir, top_srcdir, options = {}) ⇒ Object
add_depend_package(“glib2”, “ext/glib2”, “/.…./ruby-gnome2”).
- #add_depend_package_path(target_name, target_source_dir, target_build_dir) ⇒ Object
- #add_distcleanfile(file) ⇒ Object
- #add_obj(name) ⇒ Object
- #check_cairo(options = {}) ⇒ Object
- #check_ruby_func ⇒ Object
- #create_makefile_at_srcdir(pkg_name, srcdir, defs = nil) ⇒ Object
- #create_pkg_config_file(package_name, c_package, version = nil, pc_file_name = nil) ⇒ Object
- #create_top_makefile(sub_dirs = ["src"]) ⇒ Object
- #disable_optimization_build_flag(flags) ⇒ Object
- #enable_debug_build_flag(flags) ⇒ Object
- #ensure_objs ⇒ Object
- #find_gem_spec(package) ⇒ Object
- #gcc? ⇒ Boolean
- #glib_mkenums(prefix, files, g_type_prefix, include_files, options = {}) ⇒ Object
- #install_missing_native_package(native_package_info) ⇒ Object
-
#make_version_header(app_name, pkgname, dir = "src") ⇒ Object
This is used for the library which doesn’t support version info.
- #normalize_native_package_info(native_package_info) ⇒ Object
- #package_platform ⇒ Object
- #required_pkg_config_package(package_info, native_package_info = nil) ⇒ Object
- #ruby_gnome2_version(glib_source_directory = nil) ⇒ Object
- #run_make_in_sub_dirs_command(command, sub_dirs) ⇒ Object
-
#setup_win32(*args, &block) ⇒ Object
For backward compatibility.
- #setup_windows(target_name, base_dir = nil) ⇒ Object
- #super_user? ⇒ Boolean
- #try_compiler_option(opt, &block) ⇒ Object
- #windows_platform? ⇒ Boolean
Instance Method Details
#add_depend_package(target_name, target_srcdir, top_srcdir, options = {}) ⇒ Object
add_depend_package(“glib2”, “ext/glib2”, “/.…./ruby-gnome2”)
155 156 157 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 |
# File 'lib/mkmf-gnome2.rb', line 155 def add_depend_package(target_name, target_srcdir, top_srcdir, ={}) gem_spec = find_gem_spec(target_name) if gem_spec target_source_dir = File.join(gem_spec.full_gem_path, "ext/#{target_name}") target_build_dir = target_source_dir add_depend_package_path(target_name, target_source_dir, target_build_dir) end [top_srcdir, File.join(top_srcdir, target_name), $configure_args['--topdir'], File.join($configure_args['--topdir'], target_name)].each do |topdir| topdir = File.(topdir) target_source_dir_full_path = File.join(topdir, target_srcdir) top_build_dir = [:top_build_dir] || topdir target_build_dir = [:target_build_dir] || target_srcdir target_build_dir_full_path = File.join(top_build_dir, target_build_dir) unless File.exist?(target_build_dir_full_path) target_build_dir_full_path = File.join(top_build_dir, target_srcdir) end unless File.exist?(target_build_dir_full_path) target_build_dir_full_path = File.join(topdir, target_build_dir) end unless File.exist?(target_build_dir_full_path) target_build_dir_full_path = File.join(topdir, target_srcdir) end add_depend_package_path(target_name, target_source_dir_full_path, target_build_dir_full_path) end end |
#add_depend_package_path(target_name, target_source_dir, target_build_dir) ⇒ Object
190 191 192 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 220 221 |
# File 'lib/mkmf-gnome2.rb', line 190 def add_depend_package_path(target_name, target_source_dir, target_build_dir) if File.exist?(target_source_dir) $INCFLAGS = "-I#{target_source_dir} #{$INCFLAGS}" end if windows_platform? target_base_dir = Pathname.new(target_source_dir).parent.parent target_binary_base_dir = target_base_dir + "vendor" + "local" if target_binary_base_dir.exist? $INCFLAGS = "-I#{target_binary_base_dir}/include #{$INCFLAGS}" target_pkg_config_dir = target_binary_base_dir + "lib" + "pkgconfig" PKGConfig.add_path(target_pkg_config_dir.to_s) end end return unless File.exist?(target_build_dir) if target_source_dir != target_build_dir $INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}" end if windows_platform? library_base_name = "ruby-#{target_name.gsub(/-/, '_')}" case RUBY_PLATFORM when /cygwin|mingw/ $LDFLAGS << " -L#{target_build_dir}" $libs << " -l#{library_base_name}" when /mswin/ $DLDFLAGS << " /libpath:#{target_build_dir}" $libs << " lib#{library_base_name}.lib" end end end |
#add_distcleanfile(file) ⇒ Object
223 224 225 226 |
# File 'lib/mkmf-gnome2.rb', line 223 def add_distcleanfile(file) $distcleanfiles ||= [] $distcleanfiles << file end |
#add_obj(name) ⇒ Object
441 442 443 444 |
# File 'lib/mkmf-gnome2.rb', line 441 def add_obj(name) ensure_objs $objs << name unless $objs.index(name) end |
#check_cairo(options = {}) ⇒ Object
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/mkmf-gnome2.rb', line 453 def check_cairo(={}) rcairo_source_dir = [:rcairo_source_dir] if rcairo_source_dir.nil? suffix = nil if windows_platform? case RUBY_PLATFORM when /\Ax86-mingw/ suffix = "win32" when /\Ax64-mingw/ suffix = "win64" end end rcairo_source_base_dir = "rcairo" rcairo_source_base_dir << ".#{suffix}" if suffix top_dir = [:top_dir] if top_dir rcairo_source_dir = File.join(top_dir, "..", rcairo_source_base_dir) end end if rcairo_source_dir and !File.exist?(rcairo_source_dir) rcairo_source_dir = nil end if rcairo_source_dir.nil? cairo_gem_spec = find_gem_spec("cairo") rcairo_source_dir = cairo_gem_spec.full_gem_path if cairo_gem_spec end unless rcairo_source_dir.nil? if windows_platform? = {} build_dir = "tmp/#{RUBY_PLATFORM}/cairo/#{RUBY_VERSION}" if File.exist?(File.join(rcairo_source_dir, build_dir)) [:target_build_dir] = build_dir end add_depend_package("cairo", "ext/cairo", rcairo_source_dir, ) $defs << "-DRUBY_CAIRO_PLATFORM_WIN32" end $CFLAGS += " -I#{rcairo_source_dir}/ext/cairo" end PKGConfig.have_package('cairo') and have_header('rb_cairo.h') end |
#check_ruby_func ⇒ Object
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/mkmf-gnome2.rb', line 413 def check_ruby_func #Other options ruby_header = "ruby.h" have_func("rb_define_alloc_func", ruby_header) # for ruby-1.8 have_func("rb_block_proc", ruby_header) # for ruby-1.8 STDOUT.print("checking for new allocation framework... ") # for ruby-1.7 if Object.respond_to? :allocate STDOUT.print "yes\n" $defs << "-DHAVE_OBJECT_ALLOCATE" else STDOUT.print "no\n" end STDOUT.print("checking for attribute assignment... ") # for ruby-1.7 STDOUT.flush if defined? try_compile and try_compile <<SRC #include "ruby.h" #include "node.h" int node_attrasgn = (int)NODE_ATTRASGN; SRC STDOUT.print "yes\n" $defs << "-DHAVE_NODE_ATTRASGN" else STDOUT.print "no\n" end end |
#create_makefile_at_srcdir(pkg_name, srcdir, defs = nil) ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/mkmf-gnome2.rb', line 288 def create_makefile_at_srcdir(pkg_name, srcdir, defs = nil) base_dir = File.basename(Dir.pwd) last_common_index = srcdir.rindex(base_dir) if last_common_index builddir = srcdir[(last_common_index + base_dir.size + 1)..-1] end builddir ||= "." FileUtils.mkdir_p(builddir) Dir.chdir(builddir) do yield if block_given? $defs << defs if defs ensure_objs create_makefile(pkg_name, srcdir) end end |
#create_pkg_config_file(package_name, c_package, version = nil, pc_file_name = nil) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/mkmf-gnome2.rb', line 228 def create_pkg_config_file(package_name, c_package, version=nil, pc_file_name=nil) pc_file_name ||= "#{package_name.downcase.sub(/\//, '-')}.pc" version ||= ruby_gnome2_version || PKGConfig.modversion(c_package) puts "creating #{pc_file_name}" File.open(pc_file_name, 'w') do |pc_file| if package_name.nil? c_module_name = PKGConfig.name(c_package) package_name = "Ruby/#{c_module_name}" if c_module_name end pc_file.puts("Name: #{package_name}") if package_name description = PKGConfig.description(c_package) pc_file.puts("Description: Ruby bindings for #{description}") if description pc_file.printf("Version: #{version}") end add_distcleanfile(pc_file_name) end |
#create_top_makefile(sub_dirs = ["src"]) ⇒ Object
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/mkmf-gnome2.rb', line 322 def create_top_makefile(sub_dirs=["src"]) File.open("Makefile", "w") do |makefile| makefile.print(<<-EOM) all: #{run_make_in_sub_dirs_command("all", sub_dirs)} install: #{run_make_in_sub_dirs_command("install", sub_dirs)} site-install: #{run_make_in_sub_dirs_command("site-install", sub_dirs)} clean: #{run_make_in_sub_dirs_command("clean", sub_dirs)} EOM if /mswin/ =~ RUBY_PLATFORM makefile.print(<<-EOM) @if exist extconf.h del extconf.h @if exist conftest.* del conftest.* @if exist *.lib del *.lib @if exist *~ del *~ @if exist mkmf.log del mkmf.log EOM else makefile.print(<<-EOM) distclean: clean #{run_make_in_sub_dirs_command("distclean", sub_dirs)} @rm -f Makefile extconf.h conftest.* @rm -f core *~ mkmf.log EOM end end end |
#disable_optimization_build_flag(flags) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/mkmf-gnome2.rb', line 23 def disable_optimization_build_flag(flags) if gcc? flags.gsub(/(^|\s)?-O\d(\s|$)?/, '\\1-O0\\2') else flags end end |
#enable_debug_build_flag(flags) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mkmf-gnome2.rb', line 31 def enable_debug_build_flag(flags) if gcc? debug_option_pattern = /(^|\s)-g\d?(\s|$)/ if debug_option_pattern =~ flags flags.gsub(debug_option_pattern, '\\1-g3\\2') else flags + " -g3" end else flags end end |
#ensure_objs ⇒ Object
274 275 276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/mkmf-gnome2.rb', line 274 def ensure_objs return unless $objs.nil? source_dir = '$(srcdir)' RbConfig.(source_dir) pattern = "*.{#{SRC_EXT.join(',')}}" srcs = Dir[File.join(source_dir, pattern)] srcs |= Dir[File.join(".", pattern)] $objs = srcs.collect do |f| File.basename(f, ".*") + ".o" end.uniq end |
#find_gem_spec(package) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/mkmf-gnome2.rb', line 141 def find_gem_spec(package) begin require 'rubygems' if Gem::Specification.respond_to?(:find_by_name) Gem::Specification.find_by_name(package) else Gem.source_index.find_name(package).last end rescue LoadError nil end end |
#gcc? ⇒ Boolean
19 20 21 |
# File 'lib/mkmf-gnome2.rb', line 19 def gcc? CONFIG["GCC"] == "yes" end |
#glib_mkenums(prefix, files, g_type_prefix, include_files, options = {}) ⇒ Object
446 447 448 449 450 451 |
# File 'lib/mkmf-gnome2.rb', line 446 def glib_mkenums(prefix, files, g_type_prefix, include_files, ={}) add_distcleanfile(prefix + ".h") add_distcleanfile(prefix + ".c") GLib::MkEnums.create(prefix, files, g_type_prefix, include_files, ) add_obj("#{prefix}.o") end |
#install_missing_native_package(native_package_info) ⇒ Object
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
# File 'lib/mkmf-gnome2.rb', line 527 def install_missing_native_package(native_package_info) platform = package_platform native_package_info = normalize_native_package_info(native_package_info) package = native_package_info[platform] return false if package.nil? package_name, * = package package_command_line = [package_name, *].join(" ") need_super_user_priviledge = true case platform when :debian install_command = "apt-get install -V -y #{package_command_line}" when :fedora, :redhat install_command = "yum install -y #{package_command_line}" when :suse install_command = "zypper --non-interactive install #{package_command_line}" when :homebrew need_super_user_priviledge = false install_command = "brew install #{package_command_line}" when :macports install_command = "port install -y #{package_command_line}" else return false end have_priviledge = (not need_super_user_priviledge or super_user?) unless have_priviledge sudo = find_executable("sudo") end = "installing '#{package_name}' native package... " ("%s", ) failed_to_get_super_user_priviledge = false if have_priviledge succeeded = xsystem(install_command) else if sudo prompt = "[sudo] password for %u to install <#{package_name}>: " = "-p #{Shellwords.escape(prompt)}" install_command = "#{sudo} #{} #{install_command}" succeeded = xsystem(install_command) else succeeded = false failed_to_get_super_user_priviledge = true end end if failed_to_get_super_user_priviledge = "require super user privilege" else = succeeded ? "succeeded" : "failed" end Logging.postpone do "#{}#{}\n" end ("#{}\n") = nil unless succeeded if failed_to_get_super_user_priviledge = <<-EOM '#{package_name}' native package is required. run the following command as super user to install required native package: \# #{install_command} EOM else = <<-EOM failed to run '#{install_command}'. EOM end end if ("%s", ) Logging.("%s", ) end Logging.("--------------------\n\n") succeeded end |
#make_version_header(app_name, pkgname, dir = "src") ⇒ Object
This is used for the library which doesn’t support version info.
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/mkmf-gnome2.rb', line 359 def make_version_header(app_name, pkgname, dir = "src") version = PKGConfig.modversion(pkgname).split(/\./) (0..2).each do |v| version[v] = "0" unless version[v] if /\A(\d+)/ =~ version[v] number = $1 tag = $POSTMATCH unless tag.empty? version[v] = number version[3] = tag end end end filename = "rb#{app_name.downcase}version.h" puts "creating #{filename}" add_distcleanfile(filename) FileUtils.mkdir_p(dir) out = File.open(File.join(dir, filename), "w") version_definitions = [] ["MAJOR", "MINOR", "MICRO", "TAG"].each_with_index do |type, i| _version = version[i] next if _version.nil? version_definitions << "#define #{app_name}_#{type}_VERSION (#{_version})" end out.print %Q[/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ /************************************************ #{filename} - This file was generated by mkmf-gnome2.rb. ************************************************/ #ifndef __RB#{app_name}_VERSION_H__ #define __RB#{app_name}_VERSION_H__ #{version_definitions.join("\n")} #define #{app_name}_CHECK_VERSION(major,minor,micro) \\ (#{app_name}_MAJOR_VERSION > (major) || \\ (#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION > (minor)) || \\ (#{app_name}_MAJOR_VERSION == (major) && #{app_name}_MINOR_VERSION == (minor) && \\ #{app_name}_MICRO_VERSION >= (micro))) #endif /* __RB#{app_name}_VERSION_H__ */ ] out.close end |
#normalize_native_package_info(native_package_info) ⇒ Object
519 520 521 522 523 524 525 |
# File 'lib/mkmf-gnome2.rb', line 519 def normalize_native_package_info(native_package_info) native_package_info ||= {} native_package_info = native_package_info.dup native_package_info[:fedora] ||= native_package_info[:redhat] native_package_info[:suse] ||= native_package_info[:fedora] native_package_info end |
#package_platform ⇒ Object
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
# File 'lib/mkmf-gnome2.rb', line 497 def package_platform if File.exist?("/etc/debian_version") :debian elsif File.exist?("/etc/fedora-release") :fedora elsif File.exist?("/etc/redhat-release") :redhat elsif File.exist?("/etc/SuSE-release") :suse elsif find_executable("brew") :homebrew elsif find_executable("port") :macports else :unknown end end |
#required_pkg_config_package(package_info, native_package_info = nil) ⇒ Object
608 609 610 611 612 613 614 615 616 617 618 619 620 |
# File 'lib/mkmf-gnome2.rb', line 608 def required_pkg_config_package(package_info, native_package_info=nil) if package_info.is_a?(Array) required_package_info = package_info else required_package_info = [package_info] end return true if PKGConfig.have_package(*required_package_info) native_package_info ||= {} return false unless install_missing_native_package(native_package_info) PKGConfig.have_package(*required_package_info) end |
#ruby_gnome2_version(glib_source_directory = nil) ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/mkmf-gnome2.rb', line 250 def ruby_gnome2_version(glib_source_directory=nil) glib_source_directory ||= File.join(File.dirname(__FILE__), "..", "ext", "glib2") rbglib_h = File.join(glib_source_directory, "rbglib.h") return nil unless File.exist?(rbglib_h) version = nil File.open(rbglib_h) do |h_file| version_info = {} h_file.each_line do |line| case line when /\A#define RBGLIB_(MAJOR|MINOR|MICRO)_VERSION\s+(\d+)/ version_info[$1] = $2 end end version_info = [version_info["MAJOR"], version_info["MINOR"], version_info["MICRO"]].compact version = version_info.join(".") if version_info.size == 3 end version end |
#run_make_in_sub_dirs_command(command, sub_dirs) ⇒ Object
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/mkmf-gnome2.rb', line 306 def run_make_in_sub_dirs_command(command, sub_dirs) if /mswin/ =~ RUBY_PLATFORM sub_dirs.collect do |dir| <<-EOM.chmop @cd #{dir} @nmake -nologo DESTDIR=$(DESTDIR) #{command} @cd .. EOM end.join("\n") else sub_dirs.collect do |dir| "\t@cd #{dir}; $(MAKE) #{command}" end.join("\n") end end |
#setup_win32(*args, &block) ⇒ Object
For backward compatibility
137 138 139 |
# File 'lib/mkmf-gnome2.rb', line 137 def setup_win32(*args, &block) setup_windows(*args, &block) end |
#setup_windows(target_name, base_dir = nil) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/mkmf-gnome2.rb', line 116 def setup_windows(target_name, base_dir=nil) checking_for(("Windows")) do if windows_platform? import_library_name = "libruby-#{target_name}.a" $DLDFLAGS << " -Wl,--out-implib=#{import_library_name}" $cleanfiles << import_library_name base_dir ||= Pathname($0).dirname.parent.parent. base_dir = Pathname(base_dir) if base_dir.is_a?(String) binary_base_dir = base_dir + "vendor" + "local" if binary_base_dir.exist? $CFLAGS += " -I#{binary_base_dir}/include" pkg_config_dir = binary_base_dir + "lib" + "pkgconfig" PKGConfig.add_path(pkg_config_dir.to_s) end true else false end end end |
#super_user? ⇒ Boolean
515 516 517 |
# File 'lib/mkmf-gnome2.rb', line 515 def super_user? Process.uid.zero? end |
#try_compiler_option(opt, &block) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/mkmf-gnome2.rb', line 56 def try_compiler_option(opt, &block) checking_for "#{opt} option to compiler" do if try_compile '', opt + " -Werror", &block $CFLAGS += " #{opt}" true else false end end end |
#windows_platform? ⇒ Boolean
112 113 114 |
# File 'lib/mkmf-gnome2.rb', line 112 def windows_platform? /cygwin|mingw|mswin/ === RUBY_PLATFORM end |