#!/usr/bin/env ruby class String def shell_escape "\"#{self.gsub(/"/, '\"')}\"" end def url_escape escaped = '' self.each_byte do |byte| if byte > 32 && byte < 127 then escaped << byte else escaped << sprintf("%%%02x", byte) end end escaped end end def die(message) $stderr.puts(message) exit(1) end project_dir = ARGV[0] || die('usage: new_rgsc_project.rb ') project_name = File.basename(project_dir) bundle = "#{project_name}.app" archive = "#{project_name}.tar.bz2" executable = "#{project_name}.app/Contents/MacOS/#{project_name}" year = Time.now.year ruby_dir = "#{project_dir}/Resources/Ruby" system("mkdir -p #{ruby_dir.shell_escape}") || die("can't create project folder") File.open("#{project_dir}/build.rb", 'wb') do |build_rb| build_rb.write < '#{bundle}', :resources_directories => ['Resources', '../GameShell/Resources'], :info_plist_file => 'Info.plist') build(:targets => ['#{executable}'], :dependencies => ['../RubyGameShellCommon/RubyGameShellCommon'], :command => 'cp ../RubyGameShellCommon/RubyGameShellCommon #{executable.shell_escape}', :message => 'Copying RubyGameShellCommon Executable') build(:targets => ['#{bundle}/Contents/Frameworks/OpenAL.framework'], :dependencies => ['../Thirdparty/Root/universal/Frameworks/OpenAL.framework'], :command => 'tar --directory ../Thirdparty/Root/universal/Frameworks -c OpenAL.framework | tar -x --directory #{bundle.shell_escape}/Contents/Frameworks/', :message => 'Copying OpenAL Framework') END_OF_BUILD_RB end File.open("#{project_dir}/Info.plist", 'wb') do |info_plist| info_plist.write < CFBundleDevelopmentRegion English CFBundleExecutable #{project_name} CFBundleGetInfoString © #{year} Keith Bauer CFBundleIconFile #{project_name}.icns CFBundleIdentifier CFBundleInfoDictionaryVersion 6.0 CFBundleName #{project_name} CFBundlePackageType APPL CFBundleShortVersionString © #{year} Keith Bauer CFBundleSignature ???? CFBundleVersion 0.1 NSPrincipalClass GSApplication NSMainNibFile MainMenu END_OF_INFO_PLIST end File.open("#{ruby_dir}/main.rb", 'wb') do |main_rb| main_rb.write <