From 75233711e33761681021559f8f295e989a5428d7 Mon Sep 17 00:00:00 2001 From: Dave Johnson Date: Fri, 26 Aug 2011 10:54:37 -0700 Subject: [PATCH] Moved around the scripts so that you can create a self contained project that you can run debug, emulate and log from --- bin/create | 35 +++++++----------- bin/debug | 4 --- bin/emulate | 3 -- bin/templates/project/bin/create | 36 +++++++++++++++++++ bin/templates/project/bin/debug | 9 +++++ bin/templates/project/bin/emulate | 12 +++++++ bin/{ => templates/project/bin}/log | 0 .../{ => project/bin/templates}/Activity.java | 0 .../templates/project}/AndroidManifest.xml | 0 .../templates/project}/assets/www/index.html | 0 .../templates/project}/assets/www/main.js | 0 .../templates/project}/assets/www/master.css | 0 .../templates/project}/res/xml/plugins.xml | 0 bin/test | 3 +- framework/build.xml | 2 +- 15 files changed, 72 insertions(+), 32 deletions(-) delete mode 100755 bin/debug delete mode 100755 bin/emulate create mode 100755 bin/templates/project/bin/create create mode 100755 bin/templates/project/bin/debug create mode 100755 bin/templates/project/bin/emulate rename bin/{ => templates/project/bin}/log (100%) rename bin/templates/{ => project/bin/templates}/Activity.java (100%) rename bin/templates/project/{ => bin/templates/project}/AndroidManifest.xml (100%) rename bin/templates/project/{ => bin/templates/project}/assets/www/index.html (100%) rename bin/templates/project/{ => bin/templates/project}/assets/www/main.js (100%) rename bin/templates/project/{ => bin/templates/project}/assets/www/master.css (100%) rename bin/templates/project/{ => bin/templates/project}/res/xml/plugins.xml (100%) diff --git a/bin/create b/bin/create index a97486e0..d0bed3f9 100755 --- a/bin/create +++ b/bin/create @@ -8,9 +8,6 @@ PROJECT_PATH=${1:-"./example"} PACKAGE=${2:-"com.phonegap.example"} ACTIVITY=${3:-"PhoneGapExample"} -PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g') -ACTIVITY_PATH=$PROJECT_PATH/src/$PACKAGE_AS_PATH/$ACTIVITY.java -MANIFEST_PATH=$PROJECT_PATH/AndroidManifest.xml TARGET=$(android list targets | grep 'id: ' | sed 's/id: \([0-9]\).*/\1/g' | tail -1) VERSION=$(cat ./VERSION) @@ -26,28 +23,22 @@ android update project --target $TARGET --path ./framework # compile phonegap.js and phonegap.jar cd ./framework && ant jar && cd ../ -# create the project -android create project --target $TARGET --path $PROJECT_PATH --package $PACKAGE --activity $ACTIVITY - -# copy in all default project files (plugins.xml, manifest, www etc) -cp -r ./bin/templates/project $PROJECT_PATH +# copy all the bin scripts etc in there +cp -R ./bin/templates/project/ $PROJECT_PATH # copy in phonegap.js -cp ./framework/assets/www/phonegap-$VERSION.js $PROJECT_PATH/assets/www/phonegap-$VERSION.js +cp ./framework/assets/www/phonegap-$VERSION.js $PROJECT_PATH/.phonegap/android/phonegap-$VERSION.js # copy in phonegap.jar -mkdir -p $PROJECT_PATH/libs && cp ./framework/phonegap-$VERSION.jar $PROJECT_PATH/libs/phonegap-$VERSION.jar +cp ./framework/phonegap-$VERSION.jar $PROJECT_PATH/.phonegap/android/phonegap-$VERSION.jar -# copy in default activity -cat ./bin/templates/Activity.java > $ACTIVITY_PATH +# app properties +cat > $PROJECT_PATH/.phonegap/config < $PROJECT_PATH/package-activity \ No newline at end of file +(cd $PROJECT_PATH && ./bin/create) \ No newline at end of file diff --git a/bin/debug b/bin/debug deleted file mode 100755 index 962816f1..00000000 --- a/bin/debug +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh - -ant debug install -adb shell am start -n $(cat ./package-activity) diff --git a/bin/emulate b/bin/emulate deleted file mode 100755 index 5fac4eed..00000000 --- a/bin/emulate +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh - -emulator -cpu-delay 0 -no-boot-anim -cache ./tmp/cache -avd default > /dev/null 2>&1 & # put the avd's chatty ass in the background \ No newline at end of file diff --git a/bin/templates/project/bin/create b/bin/templates/project/bin/create new file mode 100755 index 00000000..7f398bfa --- /dev/null +++ b/bin/templates/project/bin/create @@ -0,0 +1,36 @@ +#! /bin/sh +# +# create a phonegap/android project +# +# USAGE +# ./create [path package activity] +# + +# load up the config +. ./.phonegap/config + +PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g') +ACTIVITY_PATH=./src/$PACKAGE_AS_PATH/$ACTIVITY.java +MANIFEST_PATH=./AndroidManifest.xml + +# create the project +android create project --target $TARGET --path . --package $PACKAGE --activity $ACTIVITY + +# copy all the bin scripts etc in there +cp -R ./bin/templates/project/ . + +# copy in phonegap.js +cp ./.phonegap/android/phonegap-$VERSION.js ./assets/www + +# copy in phonegap.jar +cp ./.phonegap/android/phonegap-$VERSION.jar ./libs + +# copy in default activity +cat ./bin/templates/Activity.java > $ACTIVITY_PATH + +# interpolate the acivity name and package +find "$ACTIVITY_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i "" "s/__ACTIVITY__/${ACTIVITY}/g" +find "$ACTIVITY_PATH" | xargs grep '__ID__' -sl | xargs -L1 sed -i "" "s/__ID__/${PACKAGE}/g" + +find "$MANIFEST_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i "" "s/__ACTIVITY__/${ACTIVITY}/g" +find "$MANIFEST_PATH" | xargs grep '__PACKAGE__' -sl | xargs -L1 sed -i "" "s/__PACKAGE__/${PACKAGE}/g" \ No newline at end of file diff --git a/bin/templates/project/bin/debug b/bin/templates/project/bin/debug new file mode 100755 index 00000000..bfa3df1c --- /dev/null +++ b/bin/templates/project/bin/debug @@ -0,0 +1,9 @@ +#! /bin/sh + +. ./.phonegap/config + +# if there are no devices listed then emulate + + +ant debug install +adb shell am start -n $PACKAGE/$PACKAGE.$ACTIVITY diff --git a/bin/templates/project/bin/emulate b/bin/templates/project/bin/emulate new file mode 100755 index 00000000..21d7b9c4 --- /dev/null +++ b/bin/templates/project/bin/emulate @@ -0,0 +1,12 @@ +#! /bin/sh + +#Available Android Virtual Devices: +# Name: default +# Path: /Users/davejohnson/.android/avd/default.avd +# Target: Android 2.2 (API level 8) +# Skin: WVGA800 +# Sdcard: 100M + +# get the name of the first virtual device or use command line arg or use "default" + +emulator -cpu-delay 0 -no-boot-anim -cache ./tmp/cache -avd default > /dev/null 2>&1 & # put the avd's chatty ass in the background \ No newline at end of file diff --git a/bin/log b/bin/templates/project/bin/log similarity index 100% rename from bin/log rename to bin/templates/project/bin/log diff --git a/bin/templates/Activity.java b/bin/templates/project/bin/templates/Activity.java similarity index 100% rename from bin/templates/Activity.java rename to bin/templates/project/bin/templates/Activity.java diff --git a/bin/templates/project/AndroidManifest.xml b/bin/templates/project/bin/templates/project/AndroidManifest.xml similarity index 100% rename from bin/templates/project/AndroidManifest.xml rename to bin/templates/project/bin/templates/project/AndroidManifest.xml diff --git a/bin/templates/project/assets/www/index.html b/bin/templates/project/bin/templates/project/assets/www/index.html similarity index 100% rename from bin/templates/project/assets/www/index.html rename to bin/templates/project/bin/templates/project/assets/www/index.html diff --git a/bin/templates/project/assets/www/main.js b/bin/templates/project/bin/templates/project/assets/www/main.js similarity index 100% rename from bin/templates/project/assets/www/main.js rename to bin/templates/project/bin/templates/project/assets/www/main.js diff --git a/bin/templates/project/assets/www/master.css b/bin/templates/project/bin/templates/project/assets/www/master.css similarity index 100% rename from bin/templates/project/assets/www/master.css rename to bin/templates/project/bin/templates/project/assets/www/master.css diff --git a/bin/templates/project/res/xml/plugins.xml b/bin/templates/project/bin/templates/project/res/xml/plugins.xml similarity index 100% rename from bin/templates/project/res/xml/plugins.xml rename to bin/templates/project/bin/templates/project/res/xml/plugins.xml diff --git a/bin/test b/bin/test index 1edbed90..257b4fce 100755 --- a/bin/test +++ b/bin/test @@ -16,7 +16,6 @@ fi # kill the default app and replace it w/ mobile-spec rm -rf ./test/assets/www mv ./mobile-spec ./test/assets/www -cp ./framework/assets/www/phonegap-$VERSION.js ./test/assets/www/phoengap-$VERSION.js # build it, launch it and start logging on stdout -cd ./test && ./../bin/debug && ./../bin/log +cd ./test && ./bin/debug && ./bin/log \ No newline at end of file diff --git a/framework/build.xml b/framework/build.xml index a253d2b1..9c9a52b8 100755 --- a/framework/build.xml +++ b/framework/build.xml @@ -120,7 +120,7 @@ - +