Skip to content

Commit

Permalink
Merge pull request #4207 from NREL/ruby_272
Browse files Browse the repository at this point in the history
Update to Ruby 2.7.2
  • Loading branch information
kbenne authored Feb 19, 2021
2 parents f3d94a6 + 7eb2395 commit 988dd3f
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 71 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -742,16 +742,16 @@ if(BUILD_CLI)
# need to update the MD5sum for each platform and url below
if(UNIX)
if(APPLE)
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20201214-darwin.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "6b2cd8a4c53d7c53c8693e8b78398458")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20210216-darwin.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "9f5c1d508324088a88c62f4daf5ae336")
else()
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20201214-linux.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "a651bf46e6e5f848742eefddaadfcfd6")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20210216-linux.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "02273eb2a14679919de836f0c3fa77c8")
endif()
elseif(WIN32)
# OpenStudio gems are only supported on 64 bit windows
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20201223-windows.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "71f200d7fa7f895c3884dafd0d539ddd")
set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20210217-windows.tar.gz")
set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "62fb83a5371361e623ef5761cf679575")
endif()

set(OPENSTUDIO_GEMS_ZIP_LOCAL_PATH "${PROJECT_BINARY_DIR}/${OPENSTUDIO_GEMS_ZIP_FILENAME}")
Expand Down
8 changes: 4 additions & 4 deletions ConanInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ if(NOT CONAN_OPENSTUDIO_ALREADY_RUN)
set(CONAN_GTEST "")
endif()

if(BUILD_RUBY_BINDINGS)
set(CONAN_RUBY "openstudio_ruby/2.5.5@nrel/testing")
if(BUILD_RUBY_BINDINGS OR BUILD_CLI)
# Track NREL/stable in general, on a feature branch this could be temporarily switched to NREL/testing
set(CONAN_RUBY "openstudio_ruby/2.7.2@nrel/testing#5cc83469365344df986cd820cca4884d")
endif()

# This will create the conanbuildinfo.cmake in the current binary dir, not the cmake_binary_dir
conan_cmake_run(REQUIRES
${CONAN_READLINE}
${CONAN_QT}
${CONAN_RUBY}
"openssl/1.1.0l#7f3fa5cfcfba31fffa344c71a9795176" # ruby 2.5.5 won't work with 1.1.1x, so use 1.1.0l here to try to force every package to align on the same as ruby
# Track NREL/stable in general, on a feature branch this could be temporarily switched to NREL/testing
"openstudio_ruby/2.5.5@nrel/stable#29449dcdcc813fb3f4730365902afc3c" # TODO: Temp #@nrel/stable
"boost/1.73.0#4129a76c9b83c300fc103e36d1908792"
"pugixml/1.10#64b3ebc897bb9d9854c8a2443bf112a8"
"jsoncpp/1.9.3#073a6d3cb40911d7c8027bddb6ae7dbf"
Expand Down
6 changes: 3 additions & 3 deletions FetchRubyMinGW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ macro(FetchRubyMinGW)
# Only need this on Windows systems
if(WIN32)
if(NOT EXISTS ${RUBY_MINGW_LIB_DIR})
set(RUBY_MINGW_LIB_ZIP_FILENAME "Ruby250-mingw-install.tar.gz")
set(RUBY_MINGW_LIB_ZIP_EXPECTED_MD5 "ce454cfe886b32f7fe829385bc06af1c")
set(RUBY_MINGW_LIB_ZIP_FILENAME "Ruby270-mingw-install.tar.gz")
set(RUBY_MINGW_LIB_ZIP_EXPECTED_MD5 "c9fd6232f49ae6031b914ac1e59229ec")

set(RUBY_MINGW_LIB_ZIP_LOCAL_PATH "${PROJECT_BINARY_DIR}/${RUBY_MINGW_LIB_ZIP_FILENAME}")
if(EXISTS "${RUBY_MINGW_LIB_ZIP_LOCAL_PATH}")
Expand All @@ -25,7 +25,7 @@ macro(FetchRubyMinGW)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${RUBY_MINGW_LIB_ZIP_LOCAL_PATH} WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
endif()

set(RUBY_MINGW_STUB_LIB "${PROJECT_BINARY_DIR}/Ruby-mingw-install/libx64-msvcrt-ruby250.dll.a")
set(RUBY_MINGW_STUB_LIB "${PROJECT_BINARY_DIR}/Ruby-mingw-install/libx64-msvcrt-ruby270.dll.a")
endif()
endif()
endmacro()
44 changes: 16 additions & 28 deletions ruby/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,38 +134,26 @@ file(GLOB RUBY_TEST_SRC "test/*.rb")

set(_RUBY_POSSIBLE_EXECUTABLE_NAMES
ruby
ruby2.5
ruby2.5.5
ruby2.5.1
ruby25
ruby255
ruby251)
ruby2.7
ruby2.7.2
ruby27
ruby272)

# TODO: this isn't great but I haven't found a better way to locate the system ruby (and avoid the one in build/Ruby-install/)
find_program(SYSTEM_RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}
HINTS
"/usr/share/rvm/rubies/ruby-2.5.5/bin/"
"$ENV{HOME}/.rvm/rubies/ruby-2.5.5/bin/"
"/usr/local/rvm/rubies/ruby-2.5.5/bin/ruby"
"C:/Ruby25-x64/bin/"

"/usr/share/rvm/rubies/ruby-2.5.4/bin/"
"/usr/share/rvm/rubies/ruby-2.5.3/bin/"
"/usr/share/rvm/rubies/ruby-2.5.2/bin/"
"/usr/share/rvm/rubies/ruby-2.5.1/bin/"

"$ENV{HOME}/.rvm/rubies/ruby-2.5.4/bin/"
"$ENV{HOME}/.rvm/rubies/ruby-2.5.3/bin/"
"$ENV{HOME}/.rvm/rubies/ruby-2.5.2/bin/"
"$ENV{HOME}/.rvm/rubies/ruby-2.5.1/bin/"

"/usr/local/rvm/rubies/ruby-2.5.4/bin/ruby"
"/usr/local/rvm/rubies/ruby-2.5.3/bin/ruby"
"/usr/local/rvm/rubies/ruby-2.5.2/bin/ruby"
"/usr/local/rvm/rubies/ruby-2.5.1/bin/ruby"

"/usr/local/bin/"
"/usr/bin/"
"/usr/local/rvm/rubies/ruby-2.7.2/bin/"
"/usr/local/rvm/rubies/ruby-2.7.2/bin/ruby"
"/usr/share/rvm/rubies/ruby-2.7.2/bin/"
"$ENV{HOME}/.rvm/rubies/ruby-2.7.2/bin/"

"C:/Ruby27-x64/bin/"

"/usr/local/ruby272/bin/"
"/usr/local/ruby27/bin/"
"/usr/bin/"
"/usr/local/bin/"


NO_DEFAULT_PATH)

Expand Down
2 changes: 1 addition & 1 deletion src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ target_link_libraries(openstudio
)

if (UNIX AND NOT APPLE)
target_link_libraries(additional_ruby_libs dl crypt)
target_link_libraries(additional_ruby_libs dl crypt anl)
target_link_libraries(openstudio PRIVATE "icui18n" "icuuc" "gmp")
elseif(WIN32)
target_link_libraries(openstudio PRIVATE wsock32 ws2_32 Dbghelp Shlwapi Iphlpapi)
Expand Down
15 changes: 11 additions & 4 deletions src/cli/embedded_help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ module Kernel
ENV['RUBYLIB'].split(File::PATH_SEPARATOR).each {|lib| $LOAD_PATH.unshift(lib)}
end
$LOAD_PATH << ':'
$LOAD_PATH << ':/ruby/2.5.0'
$LOAD_PATH << ':/ruby/2.5.0/x86_64-darwin16'
$LOAD_PATH << ':/ruby/2.5.0/x64-mswin64_140'
$LOAD_PATH << ':/ruby/2.7.0'
$LOAD_PATH << ':/ruby/2.7.0/x86_64-darwin16'
$LOAD_PATH << ':/ruby/2.7.0/x86_64-darwin17'
$LOAD_PATH << ':/ruby/2.7.0/x86_64-darwin18'
$LOAD_PATH << ':/ruby/2.7.0/x64-mswin64_140'
# DLM: now done in embedded gem initialization section in openstudio_cli.rb
#$LOAD_PATH << EmbeddedScripting::findFirstFileByName('openstudio-standards.rb').gsub('/openstudio-standards.rb', '')
#$LOAD_PATH << EmbeddedScripting::findFirstFileByName('openstudio-workflow.rb').gsub('/openstudio-workflow.rb', '')
Expand Down Expand Up @@ -379,7 +381,12 @@ def self.read(name, *args)

#puts "self.original_read, name = #{name}, args = #{args}, block_given? = #{block_given?}"
#STDOUT.flush
return original_read(name, *args)

# ruby2.7+ now issues warning: "Using the last argument as keyword parameters is deprecated"
# The optional args for IO.read should be a hash. This does simple conversion before sending to IO.read
args = Hash[*args]

return original_read(name, **args)
end

def self.open(name, *args)
Expand Down
10 changes: 6 additions & 4 deletions src/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ extern "C"
void Init_etc(void);
void Init_fcntl(void);
void Init_fiber(void);
void Init_monitor(void);
void Init_fiddle(void);
void Init_generator(void);
void Init_md5(void);
Expand All @@ -135,7 +136,6 @@ extern "C"
void Init_objspace(void);
void Init_parser(void);
void Init_pathname(void);
void Init_prelude(void);
void Init_psych(void);
void Init_ripper(void);
void Init_rmd160(void);
Expand Down Expand Up @@ -371,8 +371,6 @@ int main(int argc, char* argv[]) {
Init_trans_utf_16_32();
rb_provide("enc/trans/utf_16_32.o");

Init_prelude();

Init_bigdecimal();
rb_provide("bigdecimal");
rb_provide("bigdecimal.so");
Expand Down Expand Up @@ -423,6 +421,10 @@ int main(int argc, char* argv[]) {
rb_provide("md5.so");
rb_provide("digest/md5.so");

Init_monitor();
rb_provide("monitor");
rb_provide("monitor.so");

Init_nkf();
rb_provide("nkf");
rb_provide("nkf.so");
Expand Down Expand Up @@ -583,7 +585,7 @@ extern "C"
{
int rb_hasFile(const char* t_filename) {
// TODO Consider expanding this to use the path which we have artificially defined in embedded_help.rb
std::string expandedName = std::string(":/ruby/2.5.0/") + std::string(t_filename) + ".rb";
std::string expandedName = std::string(":/ruby/2.7.0/") + std::string(t_filename) + ".rb";
return embedded_files::hasFile(expandedName);
}

Expand Down
51 changes: 46 additions & 5 deletions src/cli/openstudio_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,31 @@

module Gem
class Specification < BasicSpecification

# This isn't ideal but there really is no available method to add specs for our use case.
# Using self.dirs=() works for ruby official gems but since it appends the dir paths with 'specifications' it breaks for bundled gem specs
def self.add_spec spec
warn "Gem::Specification.add_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
# TODO: find all extraneous adds
# puts
# p :add_spec => [spec.full_name, caller.reject { |s| s =~ /minitest/ }]

# TODO: flush the rest of the crap from the tests
# raise "no dupes #{spec.full_name} in #{all_names.inspect}" if
# _all.include? spec

raise "nil spec!" unless spec # TODO: remove once we're happy with tests

return if _all.include? spec

_all << spec
stubs << spec
(@@stubs_by_name[spec.name] ||= []) << spec
sort_by!(@@stubs_by_name[spec.name]) { |s| s.version }
_resort!(_all)
_resort!(stubs)
end

def gem_dir
embedded = false
tmp_loaded_from = loaded_from.clone
Expand Down Expand Up @@ -417,8 +442,8 @@ def parse_main_args(main_args)
# bundle was requested but bundle_path was not provided
$logger.warn "Bundle activated but ENV['BUNDLE_PATH'] is not set"

$logger.info "Setting BUNDLE_PATH to ':/ruby/2.5.0/'"
ENV['BUNDLE_PATH'] = ':/ruby/2.5.0/'
$logger.info "Setting BUNDLE_PATH to ':/ruby/2.7.0/'"
ENV['BUNDLE_PATH'] = ':/ruby/2.7.0/'

end

Expand Down Expand Up @@ -447,8 +472,8 @@ def parse_main_args(main_args)

end

Gem.paths.path << ':/ruby/2.5.0/gems/'
Gem.paths.path << ':/ruby/2.5.0/bundler/gems/'
Gem.paths.path << ':/ruby/2.7.0/gems/'
Gem.paths.path << ':/ruby/2.7.0/bundler/gems/'
Gem::Deprecate.skip = true

# find all the embedded gems
Expand All @@ -473,7 +498,7 @@ class << s
Gem::Specification.each {|x| init_count += 1}

# if already have an equivalent spec this will be a no-op
Gem::Specification.add_spec(s)
Gem::Specification.add_spec(s)

post_count = 0
Gem::Specification.each {|x| post_count += 1}
Expand Down Expand Up @@ -541,6 +566,22 @@ class << s

# Load the bundle before activating any embedded gems
if use_bundler

embedded_gems_to_activate.each do |spec|
if spec.name == "bundler"
$logger.debug "Activating gem #{spec.spec_file}"
begin
# Activate will manipulate the $LOAD_PATH to include the gem
spec.activate
rescue Gem::LoadError
# There may be conflicts between the bundle and the embedded gems,
# those will be logged here
$logger.error "Error activating gem #{spec.spec_file}"
activation_errors = true
end
end
end

current_dir = Dir.pwd

original_arch = nil
Expand Down
2 changes: 1 addition & 1 deletion src/cli/test/bundle/Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'http://rubygems.org'

gem 'openstudio-workflow', '2.0.0.pre1' # This is compatible with bundler 2.1 (OS 3.x), and already older than currently used at this time
gem 'openstudio-workflow', '2.2.0' # This is compatible with bundler 2.1 (OS 3.x), and already older than currently used at this time
gem 'tilt', '2.0.8'
2 changes: 1 addition & 1 deletion src/cli/test/bundle/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def local_gems
require 'openstudio'
require 'openstudio-workflow'
puts OpenStudio::Workflow::VERSION
raise "OpenStudio Workflow gem version does not match" unless OpenStudio::Workflow::VERSION == '2.0.0.pre1'
raise "OpenStudio Workflow gem version does not match" unless OpenStudio::Workflow::VERSION == '2.2.0'
3 changes: 1 addition & 2 deletions src/cli/test/bundle_git/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
source 'http://rubygems.org'

gem 'xml-simple'
gem 'json_pure'
gem 'openstudio-extension', github: 'nrel/openstudio-extension-gem', tag: 'v0.2.0'
gem 'openstudio-extension', github: 'nrel/openstudio-extension-gem', ref: 'v0.4.0'
gem 'tilt', github: 'rtomayko/tilt', ref: 'abe77eaf1b5f8da0a7e46135f'
2 changes: 1 addition & 1 deletion src/cli/test/bundle_git/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def local_gems
require 'openstudio'
require 'openstudio/extension'
puts OpenStudio::Extension::VERSION
raise "OpenStudio Extension version does not match" unless OpenStudio::Extension::VERSION.to_s == '0.2.0'
raise "OpenStudio Extension version does not match" unless OpenStudio::Extension::VERSION.to_s == '0.4.0'

require 'tilt'
puts Tilt::VERSION
Expand Down
23 changes: 12 additions & 11 deletions src/cli/test/test_embedded_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
# these tests should all pass when run by ruby or openstudio CLI
class EmbeddedRuby_Test < Minitest::Test

def test_io_open_null_device
io = nil
begin
io = File.open(Gem::Util::NULL_DEVICE, 'w')
io.puts "Hi"
assert(true)
ensure
io.close
end
end
#Gem::Util::NULL_DEVICE not supported in ruby 2.7.0
# def test_io_open_null_device
# io = nil
# begin
# io = File.open(Gem::Util::NULL_DEVICE, 'w')
# io.puts "Hi"
# assert(true)
# ensure
# io.close
# end
# end

def test_encodings
s = "some string"
Expand All @@ -24,7 +25,7 @@ def test_encodings

def test_bigdecimal
require 'bigdecimal'
d = BigDecimal.new("0")
d = BigDecimal("0")
assert(true)
end

Expand Down

0 comments on commit 988dd3f

Please # to comment.