Permalink
Browse files

Refactored remote platform builds to allow building on separate remot…

…e systems and allow discrete build profiles for targeted platforms.
  • Loading branch information...
1 parent c915000 commit 6fa56e9e5f713b8fd2e2a6e6787e34178bec53e9 @savageautomate savageautomate committed Dec 5, 2016
View
@@ -305,19 +305,19 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<if>
- <equals arg1="${pi.transfer.dev}" arg2="true" />
+ <equals arg1="${pi4j.dev.transfer}" arg2="true" />
<then>
<!-- ensure the target directory exists on the Raspberry Pi -->
- <sshexec host="${pi.host.dev}" port="${pi.port.dev}" username="${pi.user.dev}"
- password="${pi.password.dev}" trust="true" failonerror="false"
- verbose="true" command="mkdir --parents ${pi.dirCopyTo.dev}" />
+ <sshexec host="${pi4j.dev.host}" port="${pi4j.dev.port}" username="${pi4j.dev.user}"
+ password="${pi4j.dev.password}" trust="true" failonerror="false"
+ verbose="true" command="mkdir --parents ${pi4j.dev.directory}" />
<!-- copy the JAR file to the Raspberry Pi -->
<scp
file="${project.build.directory}/${project.build.finalName}.jar"
- todir="${pi.user.dev}:${pi.password.dev}@${pi.host.dev}:${pi.dirCopyTo.dev}"
- port="${pi.port.dev}" trust="true" verbose="true" failonerror="true">
+ todir="${pi4j.dev.user}:${pi4j.dev.password}@${pi4j.dev.host}:${pi4j.dev.directory}"
+ port="${pi4j.dev.port}" trust="true" verbose="true" failonerror="true">
</scp>
</then>
</if>
View
@@ -103,19 +103,19 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<if>
- <equals arg1="${pi.transfer.dev}" arg2="true" />
+ <equals arg1="${pi4j.dev.transfer}" arg2="true" />
<then>
<!-- ensure the target directory exists on the Raspberry Pi -->
- <sshexec host="${pi.host.dev}" port="${pi.port.dev}" username="${pi.user.dev}"
- password="${pi.password.dev}" trust="true" failonerror="false"
- verbose="true" command="mkdir --parents ${pi.dirCopyTo.dev}" />
+ <sshexec host="${pi4j.dev.host}" port="${pi4j.dev.port}" username="${pi4j.dev.user}"
+ password="${pi4j.dev.password}" trust="true" failonerror="false"
+ verbose="true" command="mkdir --parents ${pi4j.dev.directory}" />
<!-- copy the JAR file to the Raspberry Pi -->
<scp
file="${project.build.directory}/${project.build.finalName}.jar"
- todir="${pi.user.dev}:${pi.password.dev}@${pi.host.dev}:${pi.dirCopyTo.dev}"
- port="${pi.port.dev}" trust="true" verbose="true" failonerror="true">
+ todir="${pi4j.dev.user}:${pi4j.dev.password}@${pi4j.dev.host}:${pi4j.dev.directory}"
+ port="${pi4j.dev.port}" trust="true" verbose="true" failonerror="true">
</scp>
</then>
</if>
@@ -445,18 +445,18 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<if>
- <equals arg1="${pi.transfer.dev}" arg2="true" />
+ <equals arg1="${pi4j.dev.transfer}" arg2="true" />
<then>
<!-- ensure the target directory exists on the Raspberry Pi -->
- <sshexec host="${pi.host.dev}" port="${pi.port.dev}" username="${pi.user.dev}"
- password="${pi.password.dev}" trust="true" failonerror="false"
- verbose="true" command="mkdir --parents ${pi.dirCopyTo.dev}" />
+ <sshexec host="${pi4j.dev.host}" port="${pi4j.dev.port}" username="${pi4j.dev.user}"
+ password="${pi4j.dev.password}" trust="true" failonerror="false"
+ verbose="true" command="mkdir --parents ${pi4j.dev.directory}" />
<!-- copy the DEB file to the Raspberry Pi -->
<scp
file="${project.build.directory}/pi4j-${project.version}.deb"
- remoteTofile="${pi.user.dev}:${pi.password.dev}@${pi.host.dev}:${pi.dirCopyTo.dev}/pi4j.deb"
- port="${pi.port.dev}" trust="true" verbose="true" failonerror="true">
+ remoteTofile="${pi4j.dev.user}:${pi4j.dev.password}@${pi4j.dev.host}:${pi4j.dev.directory}/pi4j.deb"
+ port="${pi4j.dev.port}" trust="true" verbose="true" failonerror="true">
</scp>
</then>
</if>
View
@@ -97,24 +97,24 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<if>
- <equals arg1="${pi.transfer.dev}" arg2="true" />
+ <equals arg1="${pi4j.dev.transfer}" arg2="true" />
<then>
<!-- ensure the target directory exists on the Raspberry Pi -->
- <sshexec host="${pi.host.dev}" port="${pi.port.dev}" username="${pi.user.dev}"
- password="${pi.password.dev}" trust="true" failonerror="false"
- verbose="true" command="mkdir --parents ${pi.dirCopyTo.dev}" />
+ <sshexec host="${pi4j.dev.host}" port="${pi4j.dev.port}" username="${pi4j.dev.user}"
+ password="${pi4j.dev.password}" trust="true" failonerror="false"
+ verbose="true" command="mkdir --parents ${pi4j.dev.directory}" />
<!-- copy the JAR file to the Raspberry Pi -->
<scp
file="${project.build.directory}/${project.build.finalName}.jar"
- todir="${pi.user.dev}:${pi.password.dev}@${pi.host.dev}:${pi.dirCopyTo.dev}"
- port="${pi.port.dev}" trust="true" verbose="true" failonerror="true">
+ todir="${pi4j.dev.user}:${pi4j.dev.password}@${pi4j.dev.host}:${pi4j.dev.directory}"
+ port="${pi4j.dev.port}" trust="true" verbose="true" failonerror="true">
</scp>
<!-- copy the example source files to the Raspberry Pi -->
- <scp todir="${pi.user.dev}:${pi.password.dev}@${pi.host.dev}:${pi.dirCopyTo.dev}"
- port="${pi.port.dev}" trust="true" verbose="true" failonerror="true">
+ <scp todir="${pi4j.dev.user}:${pi4j.dev.password}@${pi4j.dev.host}:${pi4j.dev.directory}"
+ port="${pi4j.dev.port}" trust="true" verbose="true" failonerror="true">
<fileset dir="src/main/java" />
</scp>
</then>
@@ -98,20 +98,20 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<if>
- <equals arg1="${pi.transfer.dev}" arg2="true" />
+ <equals arg1="${pi4j.dev.transfer}" arg2="true" />
<then>
<!-- ensure the target directory exists on the Raspberry Pi -->
- <sshexec host="${pi.host.dev}" port="${pi.port.dev}"
- username="${pi.user.dev}" password="${pi.password.dev}"
+ <sshexec host="${pi4j.dev.host}" port="${pi4j.dev.port}"
+ username="${pi4j.dev.user}" password="${pi4j.dev.password}"
trust="true" failonerror="false" verbose="true"
- command="mkdir --parents ${pi.dirCopyTo.dev}" />
+ command="mkdir --parents ${pi4j.dev.directory}" />
<!-- copy the JAR file to the Raspberry Pi -->
<scp
file="${project.build.directory}/${project.build.finalName}.jar"
- todir="${pi.user.dev}:${pi.password.dev}@${pi.host.dev}:${pi.dirCopyTo.dev}"
- port="${pi.port.dev}" trust="true" verbose="true"
+ todir="${pi4j.dev.user}:${pi4j.dev.password}@${pi4j.dev.host}:${pi4j.dev.directory}"
+ port="${pi4j.dev.port}" trust="true" verbose="true"
failonerror="true">
</scp>
</then>
View
@@ -1,43 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="pi4j-native" default="build-libpi4j.so-remote" basedir=".">
+<project name="pi4j-native" default="build-libpi4j.so-remote" basedir="." >
- <!-- this target is used when building maven project remotely from your workstation -->
- <target name="build-libpi4j.so-remote">
+ <macrodef name="pi4j-build-remote">
+ <attribute name="name" default="UNKNOWN"/>
+ <attribute name="platform" default="UNKNOWN"/>
+ <attribute name="host" default="${pi4j.default.host}"/>
+ <attribute name="port" default="${pi4j.default.port}"/>
+ <attribute name="user" default="${pi4j.default.user}"/>
+ <attribute name="password" default="${pi4j.default.password}"/>
+ <attribute name="directory" default="${pi4j.default.directory}"/>
+ <sequential>
+ <echo message="----------------------------------------------------" />
+ <echo message="Pi4J NATIVE LIBRARY BUILD FOR: @{name}" />
+ <echo message="----------------------------------------------------" />
+ <echo message=" HOST: @{host}" />
+ <echo message=" PORT: @{port}" />
+ <echo message=" USER: @{user}" />
+ <echo message=" DIR : @{directory}" />
+ <echo message="----------------------------------------------------" />
- <echo message="Building native libpi4j shared library"/>
+ <!-- ensure the target directory is empty on the Raspberry Pi -->
+ <sshexec host="@{host}" port="@{port}" username="@{user}"
+ password="@{password}" trust="true" failonerror="true"
+ verbose="false" command="rm --recursive --force @{directory}" />
+
+ <!-- ensure the target directory exists on the Raspberry Pi -->
+ <sshexec host="@{host}" port="@{port}" username="@{user}"
+ password="@{password}" trust="true" failonerror="false"
+ verbose="false" command="mkdir --parents @{directory}" />
+
+ <!-- copy all the necessary source files to the Raspberry Pi -->
+ <scp todir="@{user}:@{password}@@@{host}:@{directory}"
+ port="@{port}" trust="true" verbose="false" failonerror="true">
+ <fileset dir="src/main/native" />
+ </scp>
+
+ <!-- compile the 'lib4j.so' JNI native shared library on each of the supported platforms -->
+ <sshexec host="@{host}" port="@{port}" username="@{user}"
+ password="@{password}" trust="true" failonerror="true"
+ verbose="false" command="cd @{directory}; sudo chmod +x build-@{platform}.sh; ./build-@{platform}.sh" />
+
+ <!-- copy the compiled 'lib4j.so' JNI native shared library files back for each supported platform -->
+ <scp
+ file="@{user}:@{password}@@@{host}:@{directory}/lib/**"
+ todir="target/native/lib" port="@{port}" trust="true"
+ verbose="false" failonerror="true">
+ </scp>
+
+ <!-- remove the temporary target directory from the Raspberry Pi -->
+ <sshexec host="@{host}" port="@{port}" username="@{user}"
+ password="@{password}" trust="true" failonerror="true"
+ verbose="false" command="rm --recursive --force @{directory}" />
+ </sequential>
+ </macrodef>
+
+ <!-- build target for RaspberryPi platform -->
+ <target name="raspberrypi" if="${raspberrypi.build}">
+ <pi4j-build-remote platform="${raspberrypi.platform}"
+ name="${raspberrypi.name}"
+ host="${raspberrypi.host}"
+ port="${raspberrypi.port}"
+ user="${raspberrypi.user}"
+ password="${raspberrypi.password}"
+ directory="${raspberrypi.directory}"/>
+ </target>
- <!-- ensure the target directory is empty on the Raspberry Pi -->
- <sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
- password="${pi-password}" trust="true" failonerror="true"
- verbose="true" command="rm --recursive --force ${pi-dirBuildTemp}" />
-
- <!-- ensure the target directory exists on the Raspberry Pi -->
- <sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
- password="${pi-password}" trust="true" failonerror="false"
- verbose="true" command="mkdir --parents ${pi-dirBuildTemp}" />
-
- <!-- copy all the necessary source files to the Raspberry Pi -->
- <scp todir="${pi-user}:${pi-password}@${pi-host}:${pi-dirBuildTemp}"
- port="${pi-port}" trust="true" verbose="true" failonerror="true">
- <fileset dir="src/main/native" />
- </scp>
-
- <!-- compile the 'lib4j.so' JNI native shared library on each of the supported platforms -->
- <sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
- password="${pi-password}" trust="true" failonerror="true"
- verbose="true" command="cd ${pi-dirBuildTemp}; sudo chmod +x build.sh; ./build.sh" />
-
- <!-- copy the compiled 'lib4j.so' JNI native shared library files back for each supported platform -->
- <scp
- file="${pi-user}:${pi-password}@${pi-host}:${pi-dirBuildTemp}/lib/**"
- todir="${project-build-directory}/native/lib" port="${pi-port}" trust="true"
- verbose="true" failonerror="true">
- </scp>
-
- <!-- remove the temporary target directory from the Raspberry Pi -->
- <sshexec host="${pi-host}" port="${pi-port}" username="${pi-user}"
- password="${pi-password}" trust="true" failonerror="true"
- verbose="true" command="rm --recursive --force ${pi-dirBuildTemp}" />
+ <!-- build target for Odroid platform -->
+ <target name="odroid" if="${odroid.build}">
+ <pi4j-build-remote platform="${odroid.platform}"
+ name="${odroid.name}"
+ host="${odroid.host}"
+ port="${odroid.port}"
+ user="${odroid.user}"
+ password="${odroid.password}"
+ directory="${odroid.directory}"/>
+ </target>
+
+ <!-- build target for BananaPi platform -->
+ <target name="bananapi" if="${bananapi.build}">
+ <pi4j-build-remote platform="${bananapi.platform}"
+ name="${bananapi.name}"
+ host="${bananapi.host}"
+ port="${bananapi.port}"
+ user="${bananapi.user}"
+ password="${bananapi.password}"
+ directory="${bananapi.directory}"/>
+ </target>
+
+ <!-- build target for BananaPro platform -->
+ <target name="bananapro" if="${bananapro.build}">
+ <pi4j-build-remote platform="${bananapro.platform}"
+ name="${bananapro.name}"
+ host="${bananapro.host}"
+ port="${bananapro.port}"
+ user="${bananapro.user}"
+ password="${bananapro.password}"
+ directory="${bananapro.directory}"/>
+ </target>
+
+
+ <!-- this target is used when building maven project remotely from your workstation -->
+ <target name="build-libpi4j.so-remote">
+ <!-- include a remote build target for each supported platform -->
+ <antcall target="raspberrypi"/>
+ <antcall target="odroid"/>
+ <antcall target="bananapi"/>
+ <antcall target="bananapro"/>
</target>
<!-- this target is used when building maven project directly on the Raspberry Pi -->
Oops, something went wrong.

0 comments on commit 6fa56e9

Please sign in to comment.