Add more windows compatibility. run does not actually put the app on the simulator though

This commit is contained in:
Dave Johnson 2010-08-31 13:21:23 -07:00
parent 86a7a0d9e3
commit cf7a4f0fb6
3 changed files with 14 additions and 6 deletions

View File

@ -36,7 +36,7 @@ class Package
@pkg = "com.phonegap.tmp#{ Time.now.usec }" # ensure a unique pkg @pkg = "com.phonegap.tmp#{ Time.now.usec }" # ensure a unique pkg
# android sdk discovery ... could be better # android sdk discovery ... could be better
@android_sdk_path = `which android`.gsub('/tools/android','') @android_sdk_path = Dir.getwd[0,1] != "/" ? `android-sdk-path.bat android.bat`.gsub('\\tools','').gsub('\\', '\\\\\\\\') : `which android`.gsub('/tools/android','')
@android_dir = File.expand_path(File.dirname(__FILE__).gsub('lib','')) @android_dir = File.expand_path(File.dirname(__FILE__).gsub('lib',''))
@framework_dir = File.join(@android_dir, "framework") @framework_dir = File.join(@android_dir, "framework")

View File

@ -15,6 +15,7 @@ class Run
# if no path is supplied uses current directory for project # if no path is supplied uses current directory for project
def initialize(path) def initialize(path)
puts 'packaging www as phonegap/android project in ./tmp/android...' puts 'packaging www as phonegap/android project in ./tmp/android...'
path = FileUtils.pwd if path.nil? || path == ""
@pkg = Package.new(path) @pkg = Package.new(path)
@apk = File.join(@pkg.path, "bin", "#{ @pkg.name.gsub(' ','') }-debug.apk") @apk = File.join(@pkg.path, "bin", "#{ @pkg.name.gsub(' ','') }-debug.apk")
build_apk build_apk
@ -23,18 +24,25 @@ class Run
def build_apk def build_apk
puts 'building apk...' puts 'building apk...'
`cd #{ @pkg.path }; ant debug;` Dir.chdir(@pkg.path)
`ant debug;`
end end
def install_to_device def install_to_device
puts 'installing to device...' puts 'installing to device...'
`cd #{ @pkg.path }; ant install;` Dir.chdir(@pkg.path)
`ant install;`
end end
def start_emulator def start_emulator
puts "No devices attached. Starting emulator w/ first avd...\n" puts "No devices attached. Starting emulator w/ first avd...\n"
$stdout.sync = true $stdout.sync = true
IO.popen("emulator -avd #{ first_avd } -logcat all") do |f| avd = first_avd
if (avd.nil? || avd == "")
puts "No Android Virtual Device (AVD) could be found. Please create one with the Android SDK."
return
end
IO.popen("emulator -avd #{ avd } -logcat all") do |f|
until f.eof? until f.eof?
puts f.gets puts f.gets
if f.gets.include? 'Boot is finished' if f.gets.include? 'Boot is finished'

View File

@ -6,7 +6,7 @@ class Update
def initialize def initialize
@path = FileUtils.pwd @path = FileUtils.pwd
@android_sdk_path = `which android`.gsub('/tools/android','') @android_sdk_path = Dir.getwd[0,1] != "/" ? `android-sdk-path.bat android.bat`.gsub('\\tools','').gsub('\\', '\\\\\\\\') : `which android`.gsub('/tools/android','')
@android_dir = File.expand_path(File.dirname(__FILE__)) @android_dir = File.expand_path(File.dirname(__FILE__))
@framework_dir = File.join(@android_dir, "..", "framework") @framework_dir = File.join(@android_dir, "..", "framework")
# puts "updating #{ @path } with phonegap from #{ @android_dir }" # puts "updating #{ @path } with phonegap from #{ @android_dir }"