Skip to content

Commit

Permalink
droidgap run now works
Browse files Browse the repository at this point in the history
  • Loading branch information
brianleroux committed Apr 4, 2010
1 parent a51f053 commit a9911bb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 40 deletions.
25 changes: 7 additions & 18 deletions bin/droidgap
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,12 @@ Generate.new(ARGV[1]) if ARGV.first == 'gen'
Package.new(ARGV[1]) if ARGV.first == 'pkg'

# droidgap run [optional directory]
Run.new if ARGV.first == 'run'

puts "droidgap ship not implemented" if ARGV.first == 'ship'


Run.new(ARGV[1]) if ARGV.first == 'run'

# droidgap log
`adb logcat` if ARGV.first == 'log'

=begin
if ARGV.first == 'pkg'
ARGV.slice! 0 # remove the cmd
Package.new(*ARGV).run
end
if ARGV.first == 'run'
puts "Running PhoneGap/Android..."
Build.new(android_sdk_path, name, pkg, www, path).run
end
=end
puts "droidgap ship not implemented" if ARGV.first == 'ship'


if ARGV.first.nil? || ARGV.first == 'help'
Expand All @@ -55,7 +43,8 @@ if ARGV.first.nil? || ARGV.first == 'help'
help ... See this message. Type help <command name> to see specific help topics.
gen .... Generate an example PhoneGap application to current directory.
pkg .... Creates an Android compatible project from a www folder. Careful, this clobbers previous packaging.
run .... Launch widget or www folder to first device found and attach a logger that listens for console.log statements.
run .... Launch widget or www folder to first device found.
log .... Attach a logger that listens for console.log statements.
ship ... Build and sign an APK suitable for submission to an Android Marketplace.
Quickstart:
Expand Down Expand Up @@ -116,7 +105,7 @@ if ARGV.first.nil? || ARGV.first == 'help'
droidgap pkg <path>
Params:
DEPRECATED and to be moved into config.xml:
android_sdk_path ... The path to your Android SDK install.
name ............... The name of your application.
Expand Down
4 changes: 2 additions & 2 deletions lib/generate.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ProjectName
# |
# |-tmp ......... Temporary directory for generated projects to launch into emulators or devices. Ignored by the end developer.
# |-tmp ......... Temporary directory for generated projects to launch into emulators or devices. Ignore.
# | '-android ... A generated Android project.
# |
# |-opt ......... Platform specific code. Plugins install native code here.
# |-opt ......... Optional platform specific code. Plugins install native code here.
# | |-android ... Java files
# | '-iphone .... Objective C
# |
Expand Down
9 changes: 3 additions & 6 deletions lib/package.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Package
#
# Generates an Android project from a PhoneGap project. Assumes a valid PhoneGap project structure.
# Generates an Android project from a valid PhoneGap project directory and puts it in [PROJECT ROOT]/tmp/android
#
# TODO validtes a valid package
# TODO validate project directory
# TODO add ability to config.xml (for pkg, android version target)

#
# creates an android project in project/tmp/projectname
#
#
class Package
attr_reader :name, :pkg, :www, :path
Expand All @@ -26,6 +22,7 @@ def initialize(path)
end

# creates tmp/android directory in project to create working android project
@name = path.split("/").last
@path = File.join(path, "tmp", "android")
@www = File.join(path, 'www')
@name = path.split('/').last
Expand Down
40 changes: 26 additions & 14 deletions lib/run.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
#
# Run
# ---
#
# A handy machine that does the following:
#
# - packages www to a valid android project in tmp/android
# - builds tmp/android project into an apk
# - installs apk onto first device found
# - attaches a logger to catch output from console.log statements
#
class Run

def apk
Package.new(args).run
# if no path is supplied uses current directory for project
def initialize(path)
@pkg = Package.new(path)
@apk = File.join(@pkg.path, "bin", "#{ @pkg.name }-debug.apk")

build
install
end

def jar
`ant jar`
end

def list
`adb devices`
# creates tmp/android/bin/project.apk
def build
`cd #{ @pkg.path }; ant debug`
end

# installs apk to first device found
def install
`apk -s 0123456789012 install phonegap.apk`
end

def log

@device = `adb devices`.split("\n")[1]
raise "Unable to run! No devices found." if @device.nil?
@device.gsub!("\tdevice",'')
puts `adb -s #{ @device } install -r #{ @apk }`
end
end
Binary file removed src/phonegap.jar
Binary file not shown.

0 comments on commit a9911bb

Please sign in to comment.