Permalink
Browse files

added missing build script for Odroid examples

  • Loading branch information...
1 parent b178884 commit b8792d68b828d59b4fe773be6269c4d0b901004f @savageautomate savageautomate committed Dec 8, 2016
Showing with 180 additions and 1 deletion.
  1. +0 −1 .gitignore
  2. +90 −0 pi4j-example/src/main/java/odroid/c1/build
  3. +90 −0 pi4j-example/src/main/java/odroid/xu4/build
View
@@ -2,7 +2,6 @@
out
target
gen
-build
bin
# IntelliJ files
@@ -0,0 +1,90 @@
+#!/bin/sh
+set -e # exit on error
+
+###
+# #%L
+# **********************************************************************
+# ORGANIZATION : Pi4J
+# PROJECT : Pi4J :: Java Examples (for Odroid C1/C1+)
+# FILENAME : build
+#
+# This file is part of the Pi4J project. More information about
+# this project can be found here: http://www.pi4j.com/
+# **********************************************************************
+# %%
+# Copyright (C) 2012 - 2016 Pi4J
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+
+cd $(dirname $(readlink -f $0))
+
+# platform constants used in this script
+PLATFORM_NAME="Odroid C1/C1+"
+PLATFORM_ID="odroid"
+
+# first optional argument can be a single Java source file or "clean"
+filename=$1
+
+# if the first argument is "clean", then only clean the *.class files from the directory
+if [ "$filename" = "clean" ]; then
+ echo "-------------------------------------------------------------------------"
+ echo " CLEANING Pi4J EXAMPLES (for $PLATFORM_NAME)"
+ echo "-------------------------------------------------------------------------"
+ rm -f *.class
+ echo ".. done .."
+ exit 0
+fi
+
+# otherwise, continue with building the samples
+echo "-------------------------------------------------------------------------"
+echo " BUILDING Pi4J EXAMPLES (for $PLATFORM_NAME)"
+echo "-------------------------------------------------------------------------"
+
+# check for user provided filename argument
+if [ -z $filename ]; then
+ # COMPILE ALL THE EXAMPLE JAVA SOURCE FILES
+
+ # get total number of .java example source files
+ total=`ls -l *.java | grep -v ^l | wc -l`
+ index=1
+
+ # iterate over all *.java files
+ for filename in *.java; do
+ printf "[%02d of %02d] ... compiling : $filename\n" $index $total
+
+ # compile each *.java file with Pi4J in the classpath
+ javac -classpath .:classes:/opt/pi4j/lib/'*' -d . $filename
+
+ # increment index counter
+ index=$((index+1))
+ done
+
+else
+ # COMPILE SINGLE JAVA SOURCE FILE
+ echo "[1 of 1] ... compiling : $filename"
+ javac -classpath .:classes:/opt/pi4j/lib/'*' -d . $filename
+fi
+
+# THE FOLLOWING INSTRUCTIONS WILL EXECUTE ONE OF THE EXAMPLES
+echo "-------------------------------------------------------------------------"
+echo "The following command syntax can be used to execute the sample projects:"
+echo " sudo pi4j --run $PLATFORM_ID.c1.${filename%.*} "
+echo " - or - "
+echo " sudo java -classpath .:classes:/opt/pi4j/lib/'*' $PLATFORM_ID.c1.${filename%.*}"
+echo " - or - "
+echo " ./run ${filename%.*}"
+echo "-------------------------------------------------------------------------"
@@ -0,0 +1,90 @@
+#!/bin/sh
+set -e # exit on error
+
+###
+# #%L
+# **********************************************************************
+# ORGANIZATION : Pi4J
+# PROJECT : Pi4J :: Java Examples (for Odroid XU4)
+# FILENAME : build
+#
+# This file is part of the Pi4J project. More information about
+# this project can be found here: http://www.pi4j.com/
+# **********************************************************************
+# %%
+# Copyright (C) 2012 - 2016 Pi4J
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+
+cd $(dirname $(readlink -f $0))
+
+# platform constants used in this script
+PLATFORM_NAME="Odroid XU4"
+PLATFORM_ID="odroid"
+
+# first optional argument can be a single Java source file or "clean"
+filename=$1
+
+# if the first argument is "clean", then only clean the *.class files from the directory
+if [ "$filename" = "clean" ]; then
+ echo "-------------------------------------------------------------------------"
+ echo " CLEANING Pi4J EXAMPLES (for $PLATFORM_NAME)"
+ echo "-------------------------------------------------------------------------"
+ rm -f *.class
+ echo ".. done .."
+ exit 0
+fi
+
+# otherwise, continue with building the samples
+echo "-------------------------------------------------------------------------"
+echo " BUILDING Pi4J EXAMPLES (for $PLATFORM_NAME)"
+echo "-------------------------------------------------------------------------"
+
+# check for user provided filename argument
+if [ -z $filename ]; then
+ # COMPILE ALL THE EXAMPLE JAVA SOURCE FILES
+
+ # get total number of .java example source files
+ total=`ls -l *.java | grep -v ^l | wc -l`
+ index=1
+
+ # iterate over all *.java files
+ for filename in *.java; do
+ printf "[%02d of %02d] ... compiling : $filename\n" $index $total
+
+ # compile each *.java file with Pi4J in the classpath
+ javac -classpath .:classes:/opt/pi4j/lib/'*' -d . $filename
+
+ # increment index counter
+ index=$((index+1))
+ done
+
+else
+ # COMPILE SINGLE JAVA SOURCE FILE
+ echo "[1 of 1] ... compiling : $filename"
+ javac -classpath .:classes:/opt/pi4j/lib/'*' -d . $filename
+fi
+
+# THE FOLLOWING INSTRUCTIONS WILL EXECUTE ONE OF THE EXAMPLES
+echo "-------------------------------------------------------------------------"
+echo "The following command syntax can be used to execute the sample projects:"
+echo " sudo pi4j --run $PLATFORM_ID.xu4.${filename%.*} "
+echo " - or - "
+echo " sudo java -classpath .:classes:/opt/pi4j/lib/'*' $PLATFORM_ID.xu4.${filename%.*}"
+echo " - or - "
+echo " ./run ${filename%.*}"
+echo "-------------------------------------------------------------------------"

0 comments on commit b8792d6

Please sign in to comment.