require "rbconfig" def linux? not windows? and not cygwin? end def windows? not (target_os.downcase =~ /32/).nil? end def cygwin? not (target_os.downcase =~ /cyg/).nil? end def target_os Config::CONFIG["target_os"] or "" end namespace :build do desc "Build a single executable Lite version" task :lite do puts "Creating distribution directory ../dist..." if windows? FileUtils.rm_rf "../dist" Dir.mkdir "../dist" Dir.mkdir "../dist/slimarray_lite" puts "Packaging all ruby into one file with tar2rubyscript..." cmd = "cmd /c tar2rubyscript ../slimarray_lite" system cmd puts "Organizing files..." FileUtils.move "../slimarray_lite.rb", "../dist/slimarray_lite" FileUtils.copy "db/default.sqlite", "../dist/slimarray_lite/slimarray_production.sqlite" FileUtils.copy "db/default.sqlite", "../dist/slimarray_lite/slimarray_development.sqlite" FileUtils.copy "db/default.sqlite", "../dist/slimarray_lite/slimarray_test.sqlite" puts "Creating executable with rubyscript2exe (press Ctrl-C when WEBrick is finished booting..." cmd = "cmd /c rubyscript2exe ../dist/slimarray_lite/slimarray_lite.rb" system cmd FileUtils.move "slimarray_lite.exe", "../dist/slimarray_lite" FileUtils.rm "../dist/slimarray_lite/slimarray_lite.rb" puts "Now just create a zip file from ../dist/slimarray_lite" else FileUtils.rm_rf "../dist", :secure => true Dir.mkdir "../dist" Dir.mkdir "../dist/slimarray_lite" puts "Packaging all ruby into one file with tar2rubyscript..." cmd = "tar2rubyscript ../slimarray_lite" system cmd puts "Organizing files..." FileUtils.move "../slimarray_lite.rb", "../dist/slimarray_lite" FileUtils.copy "db/default.sqlite", "../dist/slimarray_lite/slimarray_production.sqlite" FileUtils.copy "db/default.sqlite", "../dist/slimarray_lite/slimarray_development.sqlite" FileUtils.copy "db/default.sqlite", "../dist/slimarray_lite/slimarray_test.sqlite" puts "Creating executable with rubyscript2exe (press Ctrl-C when WEBrick is finished booting..." cmd = "rubyscript2exe ../dist/slimarray_lite/slimarray_lite.rb" system cmd FileUtils.move "slimarray_lite_linux", "../dist/slimarray_lite" FileUtils.rm "../dist/slimarray_lite/slimarray_lite.rb" puts "Packaging everything into a .tar.gz file..." cmd = "cd ../dist; tar zcf slimarray_lite.tar.gz slimarray_lite" system cmd end end end