ironruby 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/env bash
  2. ironruby_install()
  3. {
  4. rvm_error "WARNING! IronRuby is not anywhere around usable (with or without RVM),
  5. there are multiple issues with it, here is an effort to improve/fix it:
  6. https://github.com/rvm/rvm/pull/1543"
  7. builtin command -v mono > /dev/null ||
  8. {
  9. printf "%b" "mono must be installed and in your path in order to install IronRuby."
  10. return 1
  11. }
  12. if
  13. (( ${rvm_head_flag:=0} == 1 ))
  14. then
  15. mono_version="$(mono -V | \command \head -n 1 | __rvm_grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | \command \head -n 1 )"
  16. if
  17. [[ -n "${mono_version:-}" ]]
  18. then
  19. mono_major_ver="$(echo "$mono_version" | cut -d '.' -f1)"
  20. mono_minor_ver="$(echo "$mono_version" | cut -d '.' -f2)"
  21. if
  22. [[ $mono_major_ver -lt 2 ]] ||
  23. [[ $mono_major_ver -eq 2 && $mono_minor_ver -lt 6 ]]
  24. then
  25. printf "%b" "Mono 2.6 (or greater) must be installed and in your path in order to build IronRuby from the repository."
  26. printf "%b" "Version detected: ${mono_version}"
  27. return 1
  28. fi
  29. else
  30. printf "%b" "Cannot recognize mono version."
  31. return 1
  32. fi
  33. __rvm_ensure_has_mri_ruby
  34. __rvm_fetch_ruby || return $?
  35. __rvm_cd "${rvm_src_path}/$rvm_ruby_string"
  36. compatible_ruby="$(__rvm_mri_ruby)"
  37. "$rvm_wrappers_path/$compatible_ruby/gem" install pathname2 --no-rdoc --no-ri
  38. # MONO_LIB=/Library/Frameworks/Mono.framework/Versions/current/lib/
  39. rvm_ruby_make=( $rvm_wrappers_path/$compatible_ruby/rake MERLIN_ROOT="${rvm_src_path}/$rvm_ruby_string/Merlin/Main" compile mono=1 configuration=release --trace )
  40. __rvm_log_command rake "Building IronRuby..." "${rvm_ruby_make[@]}" || return $?
  41. __rvm_rm_rf "$rvm_ruby_home"/*
  42. mkdir -p "$rvm_ruby_home/bin" "$rvm_ruby_home/lib" "$rvm_ruby_home/Lib/ruby" "$rvm_ruby_home/Lib/IronRuby"
  43. __rvm_cp -r "${rvm_src_path}/$rvm_ruby_string/Merlin/Main/Bin/mono_release"/* "$rvm_ruby_home/bin/"
  44. __rvm_cp -r "${rvm_src_path}/$rvm_ruby_string/Merlin/Main/Languages/Ruby/Scripts/bin"/* "$rvm_ruby_home/bin/"
  45. __rvm_cp -r "${rvm_src_path}/$rvm_ruby_string/Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby"/* "$rvm_ruby_home/lib/ruby"
  46. __rvm_cp -r "${rvm_src_path}/$rvm_ruby_string/Merlin/Main/Languages/Ruby/Libs"/* "$rvm_ruby_home/lib/IronRuby"
  47. else
  48. rvm_log "Retrieving IronRuby"
  49. "$rvm_scripts_path/fetch" "$rvm_ruby_url" "$rvm_ruby_package_file" ||
  50. {
  51. result=$?
  52. rvm_error "There has been an error while trying to fetch the source. \nHalting the installation."
  53. exit $result
  54. }
  55. mkdir -p "${rvm_src_path}/$rvm_ruby_string" "$rvm_ruby_home"
  56. __rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
  57. __rvm_package_extract "${rvm_archives_path}/${rvm_ruby_package_file}" "${rvm_src_path}/$rvm_ruby_string" ||
  58. case $? in
  59. 199)
  60. rvm_error "\nUnrecognized archive format '$archive_format'"
  61. return 199
  62. ;;
  63. *)
  64. rvm_error "There has been an error while trying to extract the source. Halting the installation."
  65. return 1
  66. ;;
  67. esac
  68. for dir in bin Lib Silverlight
  69. do
  70. __rvm_cp -Rf "${rvm_src_path}/$rvm_ruby_string/$dir" "$rvm_ruby_home/$dir"
  71. done
  72. fi
  73. binaries=(gem irb rdoc rake ri ruby)
  74. for binary_name in "${binaries[@]}"
  75. do
  76. if
  77. [[ -s "$rvm_ruby_home/bin/$binary_name" ]]
  78. then
  79. \command \tr -d '\r' < "$rvm_ruby_home/bin/$binary_name" > "$rvm_ruby_home/bin/$binary_name.new" &&
  80. \command \mv -f "$rvm_ruby_home/bin/$binary_name.new" "$rvm_ruby_home/bin/$binary_name"
  81. chmod +x "$rvm_ruby_home/bin/$binary_name"
  82. fi
  83. done
  84. unset binaries
  85. if
  86. [[ -f "$rvm_ruby_home/bin/ir" ]]
  87. then
  88. __rvm_sed -e '1,1s=.*=#!'"/usr/bin/env bash=" "$rvm_ruby_home/bin/ir" | \command \tr -d '\r' > "$rvm_ruby_home/bin/ir.new" &&
  89. \command \mv -f "$rvm_ruby_home/bin/ir.new" "$rvm_ruby_home/bin/ir"
  90. else
  91. echo "mono \"$rvm_ruby_home/bin/ir\" \"\$@\"" > "$rvm_ruby_home/bin/ir"
  92. fi
  93. chmod +x "$rvm_ruby_home/bin/ir"
  94. ln -fs "$rvm_ruby_home/bin/ir" "$rvm_ruby_home/bin/ruby"
  95. __rvm_initial_gemsets_create "$rvm_ruby_home/bin/ruby"
  96. __rvm_fetch_ruby_cleanup
  97. }