forked from github/cordova-android
Add more windows compatibility. run does not actually put the app on the simulator though
This commit is contained in:
parent
86a7a0d9e3
commit
cf7a4f0fb6
@ -36,7 +36,7 @@ class Package
|
||||
@pkg = "com.phonegap.tmp#{ Time.now.usec }" # ensure a unique pkg
|
||||
|
||||
# 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',''))
|
||||
@framework_dir = File.join(@android_dir, "framework")
|
||||
|
||||
|
16
lib/run.rb
16
lib/run.rb
@ -15,7 +15,8 @@ class Run
|
||||
# if no path is supplied uses current directory for project
|
||||
def initialize(path)
|
||||
puts 'packaging www as phonegap/android project in ./tmp/android...'
|
||||
@pkg = Package.new(path)
|
||||
path = FileUtils.pwd if path.nil? || path == ""
|
||||
@pkg = Package.new(path)
|
||||
@apk = File.join(@pkg.path, "bin", "#{ @pkg.name.gsub(' ','') }-debug.apk")
|
||||
build_apk
|
||||
first_device.nil? ? start_emulator : install_to_device
|
||||
@ -23,18 +24,25 @@ class Run
|
||||
|
||||
def build_apk
|
||||
puts 'building apk...'
|
||||
`cd #{ @pkg.path }; ant debug;`
|
||||
Dir.chdir(@pkg.path)
|
||||
`ant debug;`
|
||||
end
|
||||
|
||||
def install_to_device
|
||||
puts 'installing to device...'
|
||||
`cd #{ @pkg.path }; ant install;`
|
||||
Dir.chdir(@pkg.path)
|
||||
`ant install;`
|
||||
end
|
||||
|
||||
def start_emulator
|
||||
puts "No devices attached. Starting emulator w/ first avd...\n"
|
||||
$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?
|
||||
puts f.gets
|
||||
if f.gets.include? 'Boot is finished'
|
||||
|
@ -6,7 +6,7 @@ class Update
|
||||
|
||||
def initialize
|
||||
@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__))
|
||||
@framework_dir = File.join(@android_dir, "..", "framework")
|
||||
# puts "updating #{ @path } with phonegap from #{ @android_dir }"
|
||||
|
Loading…
Reference in New Issue
Block a user