lib/bowline/tasks/app.rake in maccman-bowline-0.1.7 vs lib/bowline/tasks/app.rake in maccman-bowline-0.1.8

- old
+ new

@@ -1,90 +1,139 @@ require 'fileutils' -namespace :app do - desc "Bundles up app into executables" - task :bundle => ["bundle:windows", "bundle:linux", "bundle:osx"] - - namespace :bundle do - task :windows => :environment do +namespace :app do + task :configure => :environment do + build_path = File.join(APP_ROOT, 'build') + + conf = Bowline.configuration + + # Titanium complains about whitespace + manifest = <<-EOF +#appname:#{conf.name} +#appid:#{conf.id} +#publisher:#{conf.publisher} +#image:public/logo.png +#url:#{conf.url} +#guid:0e70684a-dd4b-4d97-9396-6bc01ba10a4e +#desc:#{conf.description} +#type:desktop +runtime:0.4.4 +api:0.4.4 +tiapp:0.4.4 +tifilesystem:0.4.4 +tiplatform:0.4.4 +tiui:0.4.4 +javascript:0.4.4 +tianalytics:0.4.4 +ruby:0.4.4 +tidatabase:0.4.4 +tidesktop:0.4.4 +tigrowl:0.4.4 +timedia:0.4.4 +timonkey:0.4.4 +tinetwork:0.4.4 +tinotification:0.4.4 +tiprocess:0.4.4 + EOF + + conf.publisher ||= 'Bowline' + conf.copyright ||= "Copyright © #{Time.now.year}" + + tiapp = <<-EOF +<?xml version='1.0' encoding='UTF-8'?> +<ti:app xmlns:ti='http://ti.appcelerator.org'> + <id>#{conf.id}</id> + <name>#{conf.name}</name> + <version>#{conf.version}</version> + <publisher>#{conf.publisher}</publisher> + <url>#{conf.url}</url> + <icon>public/icon.png</icon> + <copyright>#{conf.copyright}</copyright> + <window> + <id>initial</id> + <title>#{conf.name}</title> + <url>app://public/index.html</url> + <width>700</width> + <max-width>3000</max-width> + <min-width>0</min-width> + <height>800</height> + <max-height>3000</max-height> + <min-height>0</min-height> + <fullscreen>false</fullscreen> + <resizable>true</resizable> + <chrome scrollbars="true">true</chrome> + <maximizable>true</maximizable> + <minimizable>true</minimizable> + <closeable>true</closeable> + </window> +</ti:app> + EOF + + FileUtils.makedirs(build_path) + FileUtils.cd(build_path) do + File.open('manifest', 'w+') {|f| f.write manifest } + File.open('tiapp.xml', 'w+') {|f| f.write tiapp } end + end - task :linux => :environment do - end - - task :osx => :environment do - build_path = File.join(APP_ROOT, 'build') - titanium_path = ENV['TIPATH'] - raise 'You need to provide TIPATH' unless titanium_path - titanium_path = File.expand_path(titanium_path) + desc "Bundles up app into executables" + task :bundle do + build_path = File.join(APP_ROOT, 'build') + app_path = File.join(build_path, 'app') - titanium_path = File.join(titanium_path, 'build', 'osx') - build_path = File.join(build_path, 'osx') - FileUtils.rm_rf(build_path) + tiapp = File.join(build_path, 'tiapp.xml') + manifest = File.join(build_path, 'manifest') - build_path = File.join(build_path, "#{APP_NAME}.app", 'Contents') - FileUtils.mkdir_p(build_path) + if !File.exists?(tiapp) || !File.exists?(manifest) + Rake::Task['app:configure'].invoke + end - exec_path = File.join(build_path, 'MacOS') - FileUtils.mkdir_p(exec_path) + # Todo - check gem dependencies + FileUtils.rm_rf(app_path) + FileUtils.makedirs(app_path) - FileUtils.cd(titanium_path) do - FileUtils.cp_r('runtime/template/kboot', File.join(exec_path, APP_NAME)) - FileUtils.cp_r('runtime/installer', build_path) - FileUtils.cp_r('modules', build_path) - FileUtils.cp_r('runtime', build_path) - # FileUtils.cp_r('Frameworks', build_path) # todo - end - - # Todo - put this in config? - File.open(File.join(build_path, 'Info.plist'), 'w+') do |f| - f.write <<-EOF - <?xml version="1.0" encoding="UTF-8"?> - <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> - <plist version="1.0"> - <dict> - <key>CFBundleDevelopmentRegion</key> - <string>English</string> - <key>CFBundleExecutable</key> - <string>#{APP_NAME}</string> - <key>CFBundleIconFile</key> - <string>titanium.icns</string> - <key>CFBundleIdentifier</key> - <string>com.titaniumapp.testapp</string> - <key>CFBundleInfoDictionaryVersion</key> - <string>6.0</string> - <key>CFBundleName</key> - <string>#{APP_NAME}</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleSignature</key> - <string>WRUN</string> - <key>CFBundleVersion</key> - <string>0.4</string> - <key>NSMainNibFile</key> - <string>MainMenu</string> - <key>NSPrincipalClass</key> - <string>NSApplication</string> - </dict> - </plist> - EOF - end + FileUtils.cp(tiapp, app_path) + FileUtils.cp(manifest, app_path) - resources_path = File.join(build_path, 'Resources') - FileUtils.mkdir_p(resources_path) + dirs = Dir[File.join(APP_ROOT, '**')] + dirs.delete(build_path) + dirs.delete(File.join(APP_ROOT, 'log')) + dirs.delete(File.join(APP_ROOT, 'tmp')) + dirs.delete(File.join(APP_ROOT, 'db')) + dirs.delete_if {|i| i =~ /\.svn|\.DS_Store/ } - english_path = File.join(resources_path, 'English.lproj') - FileUtils.mkdir_p(english_path) - FileUtils.cd(build_path) do - FileUtils.cp_r('runtime/template/MainMenu.nib', english_path) - FileUtils.cp_r('runtime/template/titanium.icns', english_path) + FileUtils.cd(app_path) do + FileUtils.makedirs('Resources') + FileUtils.cp_r(dirs, 'Resources') + schema_path = File.join(APP_ROOT, 'db', 'schema.rb') + if File.exists?(schema_path) + FileUtils.cp( + schema_path, + File.join('Resources', 'db') + ) end + end + end + + desc "Use the Titanium SDK to build the app" + task :build do + build_path = File.join(APP_ROOT, 'build') + app_path = File.join(build_path, 'app') + + # Todo - cross OS + ti_path = ENV['TIPATH'] || '/Library/Application Support/Titanium' + ti_lib_path = Dir[File.join(ti_path, "sdk", "*", "*")][0] - dirs = Dir[File.join(APP_ROOT, '*')] - [File.join(APP_ROOT, 'build')] - FileUtils.cp_r(dirs, resources_path) + # Space in path + ti_path.gsub!(' ', '\ ') + ti_lib_path.gsub!(' ', '\ ') - FileUtils.cd(resources_path) do - FileUtils.mv(File.join('config', 'manifest'), build_path) - FileUtils.mv(File.join('config', 'tiapp.xml'), build_path) - end - end + command = [] + command << File.join(ti_lib_path, "tibuild.py") + command << "-d #{build_path}" + command << "-s #{ti_path}" + command << "-r" + command << "-a #{ti_lib_path}" + command << app_path + + exec(command.join(' ')) end end \ No newline at end of file