Permalink
Browse files

First `export_ghostdriver.sh` script!

This script is to export into PhantomJS the source of GhostDriver.
It also takes care of generating the `ghostdriver.qrc` (Qt Resource File) to include GhostDriver as Resource Files into PhantomJS.
  • Loading branch information...
1 parent a5f2f3f commit 96f446b9d4b22ab1279f48ea6248f7efe4abdf08 @detro committed Nov 12, 2012
Showing with 80 additions and 0 deletions.
  1. +15 −0 tools/export_ghostdriver.README.md
  2. +65 −0 tools/export_ghostdriver.sh
View
15 tools/export_ghostdriver.README.md
@@ -0,0 +1,15 @@
+The script `export_ghostdriver.sh` is a Bash script designed to export GhostDriver sources
+into your local PhantomJS source.
+
+It's a manual update that should be done "regularly" by project maintainers.
+
+## How does it work?
+
+It first deletes `PHANTOMJS_SOURCE/src/ghostdriver` directory, than creates it again
+and copies GhostDriver's source over.
+
+After that, it generates the `PHANTOMJS_SOURCE/src/ghostdriver/ghostdriver.qrc` XML
+file, so that GhostDriver source code can be included in PhantomJS as Qt Resource Files.
+
+Ivan De Marino
+@detronizator / github.com/detro
View
65 tools/export_ghostdriver.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+usage() {
+ echo ""
+ echo "Usage:"
+ echo " export_ghostdriver.sh <PATH_TO_PHANTOMJS_REPO>"
+ echo ""
+}
+
+info() {
+ echo -e "\033[1;32m*** ${1}\033[0m"
+}
+
+if [[ $# < 1 ]]
+then
+ usage
+ exit
+fi
+
+################################################################################
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+PHANTOMJS_REPO_PATH=$1
+DESTINATION_PATH="${1}/src/ghostdriver"
+DESTINATION_QRC_FILE="ghostdriver.qrc"
+GHOSTDRIVER_SOURCE_PATH="${SCRIPT_DIR}/../src"
+
+#1. Delete the Destination Directory, if any
+if [ -d $DESTINATION_PATH ]; then
+ info "Deleting current GhostDriver exported in local PhantomJS source (path: '${DESTINATION_PATH}')"
+ rm -rf $DESTINATION_PATH
+fi
+
+#2. Create the Destination Directory again
+info "Creating directory to export GhostDriver into local PhantomJS source (path: '${DESTINATION_PATH}')"
+mkdir -p $DESTINATION_PATH
+
+#3. Copy all the content of the SOURCE_DIR in there
+info "Copying GhostDriver over ('${GHOSTDRIVER_SOURCE_PATH}/*' => '${DESTINATION_PATH}')"
+cp -r $GHOSTDRIVER_SOURCE_PATH/* $DESTINATION_PATH
+
+#4. Generate the .qrc file
+info "Generating Qt Resource File to import GhostDriver into local PhantomJS (path: '${DESTINATION_PATH}/${DESTINATION_QRC_FILE}')"
+
+pushd $DESTINATION_PATH
+
+# Initiate the .qrc destination file
+echo "<RCC>" > $DESTINATION_QRC_FILE
+echo " <qresource prefix=\"ghostdriver/\">" >> $DESTINATION_QRC_FILE
+
+for FILE in `find . | sed "s/.\///"`
+do
+ if [ $FILE != "." ]; then
+ echo " <file>${FILE}</file>" >> $DESTINATION_QRC_FILE
+ fi
+done
+
+# Finish the .qrc destination file
+echo " </qresource>" >> $DESTINATION_QRC_FILE
+echo "</RCC>" >> $DESTINATION_QRC_FILE
+
+popd
+
+info "DONE!"
+

0 comments on commit 96f446b

Please sign in to comment.