Skip to content

Commit

Permalink
Fix openwsman.gem creation to include raw SWIG files
Browse files Browse the repository at this point in the history
SWIG includes its own C preprocessor, thus handling all the
  #if RUBY_VERSION
directives.

This commit drops the swig-generated files in favor of raw swig files.
This makes the resulting gem independant from the host creating the gem.
  • Loading branch information
kkaempf committed Oct 28, 2014
1 parent a307a12 commit 5e6892e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions bindings/ruby/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ ADD_CUSTOM_COMMAND (
COMMAND "cp" "${CMAKE_CURRENT_SOURCE_DIR}/../openwsman.c" "ext/openwsman"
COMMAND "cp" "${CMAKE_CURRENT_SOURCE_DIR}/../openwsman.h" "ext/openwsman"
COMMAND "cp" "${CMAKE_CURRENT_SOURCE_DIR}/extconf.rb" "ext/openwsman"
COMMAND "cp" "*.c" "ext/openwsman"
COMMAND "cp" "${CMAKE_CURRENT_BINARY_DIR}/../version.i" "ext/openwsman"
COMMAND "cp" "${CMAKE_CURRENT_SOURCE_DIR}/../*.i" "ext/openwsman"
COMMAND "mkdir" "-p" "ext/ruby"
COMMAND "cp" "${CMAKE_CURRENT_SOURCE_DIR}/helpers.h" "ext/ruby"

Expand All @@ -132,7 +133,8 @@ ADD_CUSTOM_COMMAND (
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/openwsman/*.rb
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/openwsman/*.rb.in
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.h
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/*.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../*.i
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/../*.i
)

ENDIF( BUILD_RUBY_GEM )
Expand Down
6 changes: 6 additions & 0 deletions bindings/ruby/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
end
find_header 'libxml/parser.h', '/usr/include/libxml2'

swig = find_executable("swig")
raise "SWIG not found" unless swig

major, minor, path = RUBY_VERSION.split(".")
raise "SWIG failed to run" unless system("#{swig} -ruby -autorename -DRUBY_VERSION=#{major}#{minor} -I. -I/usr/include/openwsman -o openwsman_wrap.c openwsman.i")

$CPPFLAGS = "-I/usr/include/openwsman -I.."

create_makefile('_openwsman')
12 changes: 6 additions & 6 deletions bindings/ruby/openwsman.gemspec.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.authors = ["Klaus Kämpf"]
s.email = ["kkaempf@suse.de"]
s.license = "BSD 3-clause"
s.homepage = "http://openwsman.github.io"
s.summary = "Ruby client bindings for Openwsman"
s.description = "The openwsman gem provides a Ruby API to manage
systems using the WS-Management protocol."

s.required_rubygems_version = ">= 1.3.6"
s.add_development_dependency("rake-compiler", [">= 0"])
s.add_development_dependency("mocha", [">= 0.9"])
s.add_development_dependency("yard", [">= 0.5"])
s.add_development_dependency("rake-compiler", ["~> 0"])
s.add_development_dependency("mocha", ["~> 0.9"])
s.add_development_dependency("yard", ["~> 0.5"])
if RUBY_VERSION >= "2.1"
# stdlib test/unit deprecated(broken) with Ruby 2.1 and Minitest 5
# adding test-unit gem fixes this
s.add_development_dependency("test-unit")
s.add_development_dependency("test-unit", ["~> 0"])
end
s.extensions << "ext/openwsman/extconf.rb"

s.files = Dir.glob("lib/*.rb") +
Dir.glob("lib/**/*.rb") +
Dir.glob("ext/*.{h,c}") +
Dir.glob("ext/**/*.{h,c}")
Dir.glob("ext/**/*.{i,h,c}")

# s.require_path = ''

Expand Down

0 comments on commit 5e6892e

Please sign in to comment.