Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swig csharp fixes #3959

Merged
merged 13 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# * Use only full 40-character hashes
# * Here's an example of a way to grep the commit history to find commits to exclude:
# ```
# git log --all --reverse --grep='copyright' --pretty='format:# %C(auto)%s [%an, %as]%n%H%n' >> .git-blame-ignore-revs
# git log --all --reverse --grep='copyright' --grep='\[chore\]' --pretty='format:# %C(auto)%s [%an, %as]%n%H%n' >> .git-blame-ignore-revs
#
# ```
# Note: On older git (like 2.17 which is default in 18.04, without `sudo add-apt-repository ppa:git-core/ppa`),
Expand Down Expand Up @@ -127,3 +127,6 @@ b2d77f6923934f6cabe86560d46ef37002f1732b

# Updated copyrights for 2020 [Alex Swindler, 2020-02-28]
1a0500de74b83093e22892a1f3ff3b67b799e648

# whitespace changes in bundle tests [chore] [Julien Marrec, 2020-04-21]
fa7a5b99830bcab336eba7ebf6bf799948ba0cc4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ developer/msvc/Visualizers/all_concat.natvis
*.sublime-workspace
*.sublime-projet
*.cache
.clangd/

4 changes: 2 additions & 2 deletions csharp/developer/OpenStudio/OpenStudio.csproj.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>${CSHARP_LIBRARY_OUTPUT_DIRECTORY}\Debug\OpenStudio.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<NoWarn>1591,0108</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|${CSHARP_PLATFORM}' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -34,7 +34,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>${CSHARP_LIBRARY_OUTPUT_DIRECTORY}\Release\OpenStudio.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<NoWarn>1591,0108</NoWarn> <!-- CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member', CS0108: iddObjectType() hides inherited member ModelObject.iddObjectType() -->
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
22 changes: 13 additions & 9 deletions ruby/openstudio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@
# add binary dir to system path
original_path = ENV['PATH']
if /mswin/.match(RUBY_PLATFORM) or /mingw/.match(RUBY_PLATFORM)
cur_location = File.dirname(__FILE__)

if defined?(RubyInstaller::Runtime)

cur_location = File.dirname(__FILE__)

build_type = File.basename(cur_location)
build_type = File.basename(cur_location)

if build_type == "Debug" or build_type == "Release" or build_type == "RelWithDebugInfo" or build_type == "RelMinSize"
# in build dir execution
relative_dll_path = File.join(File.dirname(File.dirname(cur_location)), build_type)
RubyInstaller::Runtime.add_dll_directory(relative_dll_path)
else
# install dir execution
RubyInstaller::Runtime.add_dll_directory(File.join(File.dirname(cur_location), "lib"))
if build_type == "Debug" or build_type == "Release" or build_type == "RelWithDebugInfo" or build_type == "RelMinSize"
# in build dir execution
relative_dll_path = File.join(File.dirname(File.dirname(cur_location)), build_type)
RubyInstaller::Runtime.add_dll_directory(relative_dll_path)
else
# install dir execution
RubyInstaller::Runtime.add_dll_directory(File.join(File.dirname(cur_location), "lib"))
end
end
else
# Do something here for Mac OSX environments
Expand Down
5 changes: 1 addition & 4 deletions src/cli/test/bundle/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
source 'http://rubygems.org'

gem 'openstudio-standards', '0.2.0'
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 'tilt', '2.0.8'

# CLI requires json_pure gem if JSON will be used
gem 'json_pure', '= 2.1.0'
12 changes: 7 additions & 5 deletions src/cli/test/bundle/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def local_gems
end

# list installed gems
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
}

# test a simple gem
Expand All @@ -15,7 +15,9 @@ def local_gems
raise "Tilt version does not match" unless Tilt::VERSION == '2.0.8'

# test a more complex / larger gem, that should override the existing version installed
# openstudio-workflow 2.0.0.pre1 is compatible with bundler 2.1 (OS 3.x),
# and already older than currently used at this time (2.0.0)
require 'openstudio'
require 'openstudio-standards'
puts OpenstudioStandards::VERSION
raise "OpenStudio Standards version does not match" unless OpenstudioStandards::VERSION == '0.2.0'
require 'openstudio-workflow'
puts OpenStudio::Workflow::VERSION
raise "OpenStudio Workflow gem version does not match" unless OpenStudio::Workflow::VERSION == '2.0.0.pre1'
4 changes: 2 additions & 2 deletions src/cli/test/bundle_default/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def local_gems
end

# list installed gems
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
}

# test a more complex / larger gem, that should override the existing version installed
Expand Down
4 changes: 2 additions & 2 deletions src/cli/test/bundle_native/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def local_gems
end

# list installed gems
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
}
# test a gem that required native extensions
require 'ffi'
Expand Down
4 changes: 2 additions & 2 deletions src/cli/test/bundle_no_install/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def local_gems
end

# list installed gems
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
}

# test a simple gem
Expand Down
5 changes: 2 additions & 3 deletions src/cli/test/no_bundle/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ def local_gems
end

# list installed gems
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
puts local_gems.map{ |name, specs|
[name, specs.map{ |spec| spec.version.to_s }.join(',')].join(' ')
}

# test a more complex / larger gem, that should override the existing version installed
require 'openstudio'
require 'openstudio-standards'
puts OpenstudioStandards::VERSION
96 changes: 48 additions & 48 deletions src/cli/test/test_bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,143 +16,143 @@ def rm_if_exist(p)
def test_bundle
original_dir = Dir.pwd
Dir.chdir(File.join(File.dirname(__FILE__), 'bundle'))

rm_if_exist('Gemfile.lock')
rm_if_exist('./test_gems')
rm_if_exist('./bundle')

assert(system('bundle install --path ./test_gems'))
assert(system('bundle lock --add_platform ruby'))
assert(system("'#{OpenStudio::getOpenStudioCLI}' --bundle Gemfile --bundle_path './test_gems' --verbose test.rb"))

ensure
Dir.chdir(original_dir)
Dir.chdir(original_dir)
end

def test_bundle_git
original_dir = Dir.pwd
Dir.chdir(File.join(File.dirname(__FILE__), 'bundle_git'))

rm_if_exist('Gemfile.lock')
rm_if_exist('./test_gems')
rm_if_exist('./bundle')

assert(system('bundle install --path ./test_gems'))
assert(system('bundle lock --add_platform ruby'))
assert(system("'#{OpenStudio::getOpenStudioCLI}' --bundle Gemfile --bundle_path './test_gems' --verbose test.rb"))

ensure
Dir.chdir(original_dir)
end
Dir.chdir(original_dir)
end

def test_bundle_native
original_dir = Dir.pwd
Dir.chdir(File.join(File.dirname(__FILE__), 'bundle_native'))

if /mingw/.match(RUBY_PLATFORM) || /mswin/.match(RUBY_PLATFORM)
skip("Native gems not supported on Windows")
skip("Native gems not supported on Windows")
else
skip("Native gems not supported on Unix or Mac")
skip("Native gems not supported on Unix or Mac")
end

rm_if_exist('Gemfile.lock')
rm_if_exist('./test_gems')
rm_if_exist('./bundle')

assert(system('bundle install --path ./test_gems'))
#assert(system('bundle lock --add_platform ruby'))
if /mingw/.match(RUBY_PLATFORM) || /mswin/.match(RUBY_PLATFORM)
assert(system('bundle lock --add_platform mswin64'))
end
end
assert(system("'#{OpenStudio::getOpenStudioCLI}' --bundle Gemfile --bundle_path './test_gems' --verbose test.rb"))

ensure
Dir.chdir(original_dir)
end
Dir.chdir(original_dir)
end

def test_bundle_no_install
original_dir = Dir.pwd
Dir.chdir(File.join(File.dirname(__FILE__), 'bundle_no_install'))

rm_if_exist('Gemfile.lock')
rm_if_exist('./test_gems')
rm_if_exist('./bundle')

#assert(system('bundle install --path ./test_gems'))
#assert(system('bundle lock --add_platform ruby'))

# intentionally called with dependencies not found in the CLI, expected to fail
assert_equal(system("'#{OpenStudio::getOpenStudioCLI}' --bundle Gemfile --verbose test.rb"), false)

ensure
Dir.chdir(original_dir)
end
Dir.chdir(original_dir)
end

def test_no_bundle
original_dir = Dir.pwd
Dir.chdir(File.join(File.dirname(__FILE__), 'no_bundle'))

puts "'#{OpenStudio::getOpenStudioCLI}' --verbose test.rb"
assert(system("'#{OpenStudio::getOpenStudioCLI}' --verbose test.rb"))

ensure
Dir.chdir(original_dir)
end
Dir.chdir(original_dir)
end

def test_bundle_default

original_dir = Dir.pwd

if !defined?(OpenStudio::CLI) || !OpenStudio::CLI
skip("Embedded gems not available unless CLI")
skip("Embedded gems not available unless CLI")
end

Dir.chdir(File.join(File.dirname(__FILE__), 'bundle_default'))

rm_if_exist('openstudio-gems.gemspec')
rm_if_exist('Gemfile')
rm_if_exist('Gemfile.lock')
rm_if_exist('./test_gems')
rm_if_exist('./bundle')

assert(EmbeddedScripting::hasFile(':/openstudio-gems.gemspec'))
assert(EmbeddedScripting::hasFile(':/Gemfile'))
assert(EmbeddedScripting::hasFile(':/Gemfile.lock'))

File.open(File.join(File.dirname(__FILE__), 'bundle_default', 'openstudio-gems.gemspec'), 'w') do |f|
f.puts EmbeddedScripting::getFileAsString(':/openstudio-gems.gemspec')
begin
f.fsync
rescue
f.flush
end
end
end
File.open(File.join(File.dirname(__FILE__), 'bundle_default', 'Gemfile'), 'w') do |f|
f.puts EmbeddedScripting::getFileAsString(':/Gemfile')
begin
f.fsync
rescue
f.flush
end
end
end
File.open(File.join(File.dirname(__FILE__), 'bundle_default', 'Gemfile.lock'), 'w') do |f|
f.puts EmbeddedScripting::getFileAsString(':/Gemfile.lock')
begin
f.fsync
rescue
f.flush
end
end
end

# just use embedded gems
assert(system("'#{OpenStudio::getOpenStudioCLI}' --verbose test.rb"))

# DLM: do we need to be able to pass a Gemfile without a bundle?
# don't pass bundle_path since we want to use embedded gems
#assert(system("'#{OpenStudio::getOpenStudioCLI}' --bundle './Gemfile' --verbose test.rb"))

ensure
Dir.chdir(original_dir)
end
Dir.chdir(original_dir)
end

end
Loading