Module: Ruby_core_source
- Defined in:
- lib/ruby_core_source.rb
Class Method Summary collapse
-
.create_makefile_with_core(hdrs, name) ⇒ Object
params hdrs: proc ex: proc { have_header(“vm_core.h”) and have_header(“iseq.h”) } name: string (config name for makefile).
-
.download_headers(hdrs, dest_dir = nil, just_headers = true, existing_pre_unpacked_dir = nil) ⇒ Object
returns the location of headers downloaded and extracted from source you can pass it a specific dest_dir if you don’t want it at the default location and can specify just_headers = false if you want all the source files to be downloaded there, not just *.inc.
Class Method Details
.create_makefile_with_core(hdrs, name) ⇒ Object
params hdrs: proc ex: proc { have_header(“vm_core.h”) and have_header(“iseq.h”) } name: string (config name for makefile)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_core_source.rb', line 18 def create_makefile_with_core(hdrs, name) # # First, see if the needed headers already exist somewhere # if hdrs.call create_makefile(name) return true end dest_dir = download_headers hdrs with_cppflags("-I" + dest_dir) { if hdrs.call create_makefile(name) return true end } return false end |
.download_headers(hdrs, dest_dir = nil, just_headers = true, existing_pre_unpacked_dir = nil) ⇒ Object
returns the location of headers downloaded and extracted from source you can pass it a specific dest_dir if you don’t want it at the default location and can specify just_headers = false if you want all the source files to be downloaded there, not just *.inc
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ruby_core_source.rb', line 45 def download_headers hdrs, dest_dir = nil, just_headers = true, existing_pre_unpacked_dir = nil ruby_dir = "" ruby_version = RUBY_VERSION[0..-2] if RUBY_VERSION >= '1.9' ruby_version = '1.8' # for the latest 1.8.7 patch, for now [see below] end if RUBY_PATCHLEVEL < 0 # some type of svn checkout # try to use mark's lookup Tempfile.open("preview-revision") { |temp| uri = URI.parse("http://cloud.github.com/downloads/mark-moseley/ruby_core_source/preview_revision.yml") uri.download(temp) revision_map = YAML::load(File.open(temp.path)) ruby_dir = revision_map[RUBY_REVISION] return false if ruby_dir.nil? } else version = RUBY_VERSION.to_s patch_level = RUBY_PATCHLEVEL.to_s if RUBY_VERSION >= '1.9' $stderr.puts 'installing 1.8.7 source, since rdoc doesn\'t work on 1.9 core source yet' version = '1.8.7' patch_level = '160' end ruby_dir = "ruby-" + version + "-p" + patch_level end # # Download the source headers # uri_path = "http://ftp.ruby-lang.org/pub/ruby/" + ruby_version + "/" + ruby_dir + ".tar.gz" Tempfile.open("ruby-src") { |temp| temp.binmode uri = URI.parse(uri_path) unless existing_pre_unpacked_dir uri.download(temp) tgz = Zlib::GzipReader.new(File.open(temp.path, 'rb')) end FileUtils.mkdir_p(dest_dir) require File.dirname(__FILE__) + "/dir_mktmpdir" unless Dir.respond_to? :mktmpdir Dir.mktmpdir { |dir| dir = existing_pre_unpacked_dir if existing_pre_unpacked_dir Archive::Tar::Minitar.unpack(tgz, dir) unless existing_pre_unpacked_dir if just_headers inc_dir = dir + "/" + ruby_dir + "/*.inc" hdr_dir = dir + "/" + ruby_dir + "/*.h" glob = [inc_dir, hdr_dir] FileUtils.cp(Dir.glob(glob), dest_dir) else FileUtils.cp_r(Dir.glob(dir + "/" + ruby_dir + "/*"), dest_dir) end } } dest_dir end |