Helper for link window's library
MODIFY
lib/mruby/gem.rb
lib/mruby/gem.rb
@@ -106,6 +106,15 @@ module MRuby
define_gem_init_builder if @generate_functions
end
+ def for_windows?
+ if build.kind_of?(MRuby::CrossBuild)
+ return %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
+ elsif build.kind_of?(MRuby::Build)
+ return ('A'..'Z').to_a.any? { |vol| Dir.exist?("#{vol}:") }
+ end
+ return false
+ end
+
def add_dependency(name, *requirements)
default_gem = requirements.last.kind_of?(Hash) ? requirements.pop : nil
requirements = ['>= 0.0.0'] if requirements.empty?

MODIFY
mrbgems/mruby-io/mrbgem.rake
mrbgems/mruby-io/mrbgem.rake
@@ -5,26 +5,10 @@ MRuby::Gem::Specification.new('mruby-io') do |spec|
spec.cc.include_paths << "#{build.root}/src"
- case RUBY_PLATFORM
- when /mingw|mswin|msys/
- really_for_window = true
-
- if build.kind_of?(MRuby::CrossBuild)
- if %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
- really_for_window = true
- else
- really_for_window = false
- end
- end
-
- if really_for_window
+ if for_windows?
spec.linker.libraries += ['Ws2_32']
#spec.cc.include_paths += ["C:/Windows/system/include"]
spec.linker.library_paths += ["C:/Windows/system"]
end
- end
- if build.kind_of?(MRuby::CrossBuild) && %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
- spec.linker.libraries += ['ws2_32']
- end
spec.add_test_dependency 'mruby-time', core: 'mruby-time'
end

MODIFY
mrbgems/mruby-socket/mrbgem.rake
mrbgems/mruby-socket/mrbgem.rake
@@ -7,22 +7,10 @@ MRuby::Gem::Specification.new('mruby-socket') do |spec|
#spec.cc.defines << "HAVE_SA_LEN=0"
# If Windows, use winsock
- if ( /mswin|mingw|win32/ =~ RUBY_PLATFORM ) then
- really_for_window = true
-
- if build.kind_of?(MRuby::CrossBuild)
- if %w(x86_64-w64-mingw32 i686-w64-mingw32).include?(build.host_target)
- really_for_window = true
- else
- really_for_window = false
- end
- end
-
- if really_for_window
+ if for_windows?
spec.linker.libraries << "wsock32"
spec.linker.libraries << "ws2_32"
end
- end
spec.add_dependency('mruby-io', :core => 'mruby-io')
spec.add_dependency('mruby-pack', :core => 'mruby-pack')

Helper for link window's library