To support Windows, you need to modify your Rakefile to handle .zip creation instead of .tar.gz and to download the correct Windows binaries.
Follow these steps to update your Rakefile:
Add a task to download Windows binaries:
Add a file task that uses download_runtime("win32").
Add the package:win32 task:
Define a task within the package namespace that depends on :bundle_install and the downloaded runtime.
Update create_package signature:
Modify the create_package method to accept an os_type parameter (defaulting to :unix).
Update wrapper copying logic:
Use a conditional to copy wrapper.bat and rename it to hello.bat when os_type is not :unix.
Update archive creation logic:
Use a conditional to use the zip command instead of tar when targeting Windows.
Update the main package task:
Add 'package:win32' to the dependencies of the package task.
# 1. Download task
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-win32.tar.gz" do
download_runtime("win32")
end
# 2. Package task
namespace :package do
desc "Package your app for Windows x86"
task :win32 => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-win32.tar.gz"] do
create_package("win32", :windows)
end
end
# 3. Updated method signature
def create_package(target, os_type = :unix)
# ... logic ...
end
# 4. Conditional wrapper copying
if os_type == :unix
sh "cp packaging/wrapper.sh #{package_dir}/hello"
else
sh "cp packaging/wrapper.bat #{package_dir}/hello.bat"
end
# 5. Conditional archiving
if os_type == :unix
sh "tar -czf #{package_dir}.tar.gz #{package_dir}"
else
sh "zip -9r #{package_dir}.zip #{package_dir}"
end
# 6. Update main task
task :package => ['package:linux:x86', 'package:linux:x86_64', 'package:osx', 'package:win32']