rubinius 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #!/usr/bin/env bash
  2. source "$rvm_scripts_path/functions/osx-ssl-certs"
  3. make_sure_its_enough_ram_for_rbx()
  4. {
  5. \typeset rvm_rbx_required_ram
  6. rvm_rbx_required_ram_mb=500
  7. __rvm_compiler_is_llvm ||
  8. __rvm_is_enough_ram ${rvm_rbx_required_ram_mb} ||
  9. rvm_error "For rbx (Rubinius) more than ${rvm_rbx_required_ram_mb}MB of free RAM might be required."
  10. }
  11. rubinius_install_detect_required_ruby()
  12. {
  13. export ruby
  14. case "${rvm_ruby_version}" in
  15. (2.0.0)
  16. case "${rvm_ruby_patch_level}" in
  17. (rc1) ruby="ruby-1.9" ;;
  18. (*) ruby="ruby-2.2" ;;
  19. esac
  20. ;;
  21. (2*)
  22. case "$rvm_ruby_repo_branch" in
  23. (1.8.7|1.9.3) ruby="ruby-1.9|ruby-2.2" ;;
  24. (*) ruby="ruby-2.2" ;;
  25. esac
  26. ;;
  27. (*)
  28. ruby="ruby-2.3.1"
  29. ;;
  30. esac
  31. __rvm_ensure_has_mri_ruby "$ruby" || {
  32. rvm_log "No $ruby found, cannot build rbx."
  33. return 1
  34. }
  35. ruby="$(__rvm_mri_ruby "$ruby")"
  36. }
  37. rubinius_install_ensure_gem()
  38. {
  39. __rvm_which "$1" >/dev/null &&
  40. [[ -x "$rvm_wrappers_path/$ruby/$1" ]] ||
  41. __rvm_log_command "install.${2:-$1}" \
  42. "$ruby - #install gem ${2:-$1}" \
  43. gem_install ${2:-$1} &&
  44. __rvm_which "$1" >/dev/null &&
  45. [[ -x "$rvm_wrappers_path/$ruby/$1" ]] ||
  46. return $?
  47. }
  48. rubinius_install_regenerate_binstubs()
  49. {
  50. gem_install executable-hooks &&
  51. gem regenerate_binstubs ||
  52. return $?
  53. }
  54. rubinius_install_ensure_wrappers()
  55. {
  56. [[ -x "$rvm_wrappers_path/$ruby/ruby" && -x "$rvm_wrappers_path/$ruby/gem" ]] ||
  57. __rvm_log_command "gemset.wrappers.rubinius" "$ruby - #generating wrappers" \
  58. run_gem_wrappers regenerate ||
  59. return $?
  60. rubinius_install_ensure_gem rake || return $?
  61. rubinius_install_ensure_gem bundle bundler || return $?
  62. __rvm_log_command "regenerate_binstubs" \
  63. "$ruby - #regenerating binstubs" \
  64. rubinius_install_regenerate_binstubs ||
  65. return $?
  66. }
  67. rubinius_install_setup_ruby()
  68. {
  69. if [[ ${rvm_ignore_gemsets_flag:-0} -eq 0 ]]
  70. then ruby="${ruby}@rubinius"
  71. fi
  72. __rvm_with "$ruby" rubinius_install_ensure_wrappers
  73. __rvm_osx_ssl_certs_ensure_for_ruby "$rvm_wrappers_path/$ruby/ruby"
  74. }
  75. rubinius_install()
  76. {
  77. rubinius_install_detect_required_ruby || return $?
  78. make_sure_its_enough_ram_for_rbx
  79. \typeset rvm_configure_args
  80. \typeset -a rvm_ruby_configure
  81. unset CFLAGS LDFLAGS ARCHFLAGS # Important.
  82. unset GEM_HOME GEM_PATH MY_RUBY_HOME IRBRC RBXOPT
  83. export PATH
  84. rvm_ruby_make=""
  85. __rvm_setup_compile_environment "${rvm_ruby_string}" || return $?
  86. __rvm_remove_rvm_from_path
  87. __rvm_conditionally_add_bin_path
  88. rubinius_install_setup_ruby || return $?
  89. __rvm_fetch_ruby || return $?
  90. __rvm_cd "${rvm_src_path}/$rvm_ruby_string"
  91. chmod +x ./configure
  92. __rvm_apply_patches ||
  93. {
  94. result=$?
  95. rvm_error "There has been an error while trying to apply patches to rubinius. \nHalting the installation."
  96. return $result
  97. }
  98. rvm_configure_flags=( --prefix="$rvm_ruby_home" "${rvm_configure_flags[@]}" )
  99. __rvm_db "${rvm_ruby_interpreter}_configure_flags" "db_configure_flags"
  100. if [[ -n "${ZSH_VERSION:-}" ]]
  101. then rvm_configure_flags=( ${=db_configure_flags} "${rvm_configure_flags[@]}" )
  102. else rvm_configure_flags=( ${db_configure_flags} "${rvm_configure_flags[@]}" )
  103. fi
  104. # Explicitly disabled
  105. (( ${rvm_llvm_flag:=1} )) || rvm_configure_flags+=( --disable-llvm )
  106. if
  107. [[ -f "Gemfile" ]]
  108. then
  109. __rvm_log_command "bundle" "$ruby - #bundle install" "$rvm_wrappers_path/$ruby/bundle" install ||
  110. return $?
  111. fi
  112. if
  113. [[ -f "$HOME/.gem/credentials" && -w "$HOME/.gem/credentials" ]]
  114. then
  115. chmod 600 "$HOME/.gem/credentials"
  116. fi
  117. __rvm_log_command "configure" "$rvm_ruby_string - #configuring" \
  118. env "${rvm_configure_env[@]}" $rvm_wrappers_path/$ruby/ruby ./configure "${rvm_configure_flags[@]}" ||
  119. return $?
  120. if [[ -n "${rvm_configure_args:-}" ]]
  121. then rvm_ruby_make="CONFIGURE_ARGS=${rvm_configure_args## } "
  122. fi
  123. __setup_lang_fallback
  124. __rvm_log_command rake "$rvm_ruby_string - #compiling" \
  125. "${rvm_ruby_make:-}$rvm_wrappers_path/$ruby/rake" install --trace ||
  126. return $?
  127. [[ -d "$rvm_ruby_home" && -f "$rvm_ruby_home/bin/rbx" ]] ||
  128. {
  129. result=$?
  130. rvm_error "Rubinius reported it was installed successfully, but RVM could not find proper installation,
  131. please check why '$rvm_ruby_home/bin/rbx' was not created,
  132. maybe here '$rvm_log_path/$rvm_ruby_string/rake.log',
  133. also make sure to report an error here 'https://github.com/rubinius/rubinius/issues'
  134. about not returning non zero status in case of errors."
  135. return $result
  136. }
  137. unset ruby
  138. # Symlink rubinius wrapper if not available
  139. [[ -f "$rvm_ruby_home/bin/ruby" ]] ||
  140. ln -fs "$rvm_ruby_home/bin/rbx" "$rvm_ruby_home/bin/ruby"
  141. # remove the rdoc link, the gem is not builtin
  142. if [[ -f "$rvm_ruby_home/bin/rdoc" ]]
  143. then rm -f "$rvm_ruby_home/bin/rdoc"
  144. fi
  145. case ${rvm_ruby_string} in
  146. rbx-head*|rubinius-head*|rbx-2.*|rubinius-2.*)
  147. binaries=()
  148. ;;
  149. *) # older rbx had issues
  150. # Install IRB Wrapper on Rubinius.
  151. file_name="$rvm_ruby_home/bin/irb"
  152. \command \rm -f "$file_name"
  153. printf "%b" '#!/usr/bin/env bash\n' > "$file_name"
  154. printf "%b" "exec '$rvm_ruby_home/bin/rbx' 'irb' \"\$@\"\n" >> "$file_name"
  155. [[ -x "$file_name" ]] || chmod +x "$file_name"
  156. # Install Gem Wrapper on Rubinius.
  157. file_name="$rvm_ruby_home/bin/gem"
  158. __rvm_cp -f "$rvm_ruby_home/lib/bin/gem.rb" "$file_name"
  159. __rvm_inject_ruby_shebang "$file_name"
  160. [[ -x "$file_name" ]] || chmod +x "$file_name"
  161. unset file_name
  162. binaries=(erb ri)
  163. ;;
  164. esac
  165. __rvm_initial_gemsets_create "$rvm_ruby_home/bin/ruby" &&
  166. __rvm_post_install &&
  167. __rvm_fetch_ruby_cleanup
  168. }