Permalink
Browse files

updated build scripts local and cross-compiler platform builds

  • Loading branch information...
1 parent 14a6568 commit 81bb8ab772a44fe4e54c0a8b56a4c0e9cd304b44 @savageautomate savageautomate committed Dec 5, 2016
Showing with 167 additions and 81 deletions.
  1. +3 −3 BUILD.INSTRUCTIONS
  2. +0 −3 pi4j-native/build-local-cross-compile.sh
  3. +0 −46 pi4j-native/build-local.sh
  4. +160 −26 pi4j-native/build.xml
  5. +1 −1 pi4j-native/pom.xml
  6. +3 −2 pom.xml
View
@@ -39,9 +39,9 @@ these prerequisites automatically:
Use the following command to deploy a snapshot build to the OSS Maven staging repository.
(Note, you must have a "sonatype-oss-snapshot-repo" site credentials defined in your private Maven settings.xml file.)
-> mvn clean deploy (Java libraries only)
-> mvn clean deploy --projects pi4j-native -P native (JNI native libraries for all supported platforms)
-> mvn clean deploy -P native (Java libraries and JNI native library for all supported platforms)
+> mvn clean deploy (Java libraries only)
+> mvn clean deploy --projects pi4j-native -P all-platforms (JNI native libraries for all supported platforms)
+> mvn clean deploy -P all-platforms (Java libraries and JNI native library for all supported platforms)
If changes or additions are made to the Java JNI classes, then you may need to regenerate the native JNI .H header files.
Use the following Maven command to regenerate the .H header source file.
@@ -1,3 +0,0 @@
-#!/bin/bash
-# INVOKE LOCAL BUILD SCRIPT WITH CROSS-COMPILER OPTIONS
-./build-local.sh ARCH=arm CC=arm-linux-gnueabihf-gcc
@@ -1,46 +0,0 @@
-#!/bin/bash -e
-###
-# #%L
-# **********************************************************************
-# ORGANIZATION : Pi4J
-# PROJECT : Pi4J :: JNI Native Library
-# FILENAME : build-local.sh
-#
-# 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%
-###
-
-echo "-------------------------------------------"
-echo "BUILDING Pi4J NATIVE LIBRARY"
-echo "-------------------------------------------"
-
-# ----------------------------------
-# COPY SOURCES TO TARGET FOLDER
-# ----------------------------------
-mkdir -p target/native
-cp -R src/main/native target
-cd target/native
-
-# ----------------------------------
-# LAUNCH BUILD FROM TARGET FOLDER
-# ----------------------------------
-chmod +x build.sh
-./build.sh $@
View
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="pi4j-native" default="build-libpi4j.so-remote" basedir="." >
+ <!-- ********************************************************************************** -->
+ <!-- MACRO BUILD STEPS FOR REMOTE PLATFORM BUILDS -->
+ <!-- ********************************************************************************** -->
+
<macrodef name="pi4j-build-remote">
<attribute name="name" default="UNKNOWN"/>
<attribute name="platform" default="UNKNOWN"/>
@@ -54,8 +58,42 @@
</sequential>
</macrodef>
- <!-- build target for RaspberryPi platform -->
- <target name="raspberrypi" if="${raspberrypi.build}">
+ <!-- ********************************************************************************** -->
+ <!-- MACRO BUILD STEPS FOR LOCAL & CROSS-COMPILED PLATFORM BUILDS -->
+ <!-- ********************************************************************************** -->
+
+ <macrodef name="pi4j-build-local">
+ <attribute name="name" default="UNKNOWN"/>
+ <attribute name="platform" default="UNKNOWN"/>
+ <attribute name="args" default=""/>
+ <sequential>
+ <echo message="----------------------------------------------------" />
+ <echo message="Pi4J NATIVE LIBRARY BUILD FOR: @{name}" />
+ <echo message="----------------------------------------------------" />
+ <echo message=" ARGS: @{args}" />
+ <echo message="----------------------------------------------------" />
+
+ <!-- copy all the necessary source files -->
+ <copy todir="${project.build.directory}/native">
+ <fileset dir="src/main/native"/>
+ </copy>
+
+ <!-- compile the 'lib4j.so' JNI native shared library on each of the supported platforms -->
+ <exec dir="${project.build.directory}/native" executable="chmod">
+ <arg line="+x build-@{platform}.sh"/>
+ </exec>
+ <exec dir="${project.build.directory}/native" executable="/bin/bash">
+ <arg line="build-@{platform}.sh @{args}"/>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!-- ********************************************************************************** -->
+ <!-- REMOTE PLATFORM BUILD TARGETS -->
+ <!-- ********************************************************************************** -->
+
+ <!-- remote build target for RaspberryPi platform -->
+ <target name="raspberrypi-remote" if="${raspberrypi.build}">
<pi4j-build-remote platform="${raspberrypi.platform}"
name="${raspberrypi.name}"
host="${raspberrypi.host}"
@@ -65,8 +103,8 @@
directory="${raspberrypi.directory}"/>
</target>
- <!-- build target for Odroid platform -->
- <target name="odroid" if="${odroid.build}">
+ <!-- remote build target for Odroid platform -->
+ <target name="odroid-remote" if="${odroid.build}">
<pi4j-build-remote platform="${odroid.platform}"
name="${odroid.name}"
host="${odroid.host}"
@@ -76,8 +114,8 @@
directory="${odroid.directory}"/>
</target>
- <!-- build target for BananaPi platform -->
- <target name="bananapi" if="${bananapi.build}">
+ <!-- remote build target for BananaPi platform -->
+ <target name="bananapi-remote" if="${bananapi.build}">
<pi4j-build-remote platform="${bananapi.platform}"
name="${bananapi.name}"
host="${bananapi.host}"
@@ -87,8 +125,8 @@
directory="${bananapi.directory}"/>
</target>
- <!-- build target for BananaPro platform -->
- <target name="bananapro" if="${bananapro.build}">
+ <!-- remote build target for BananaPro platform -->
+ <target name="bananapro-remote" if="${bananapro.build}">
<pi4j-build-remote platform="${bananapro.platform}"
name="${bananapro.name}"
host="${bananapro.host}"
@@ -98,8 +136,8 @@
directory="${bananapro.directory}"/>
</target>
- <!-- build target for OrangePi platform -->
- <target name="orangepi" if="${orangepi.build}">
+ <!-- remote build target for OrangePi platform -->
+ <target name="orangepi-remote" if="${orangepi.build}">
<pi4j-build-remote platform="${orangepi.platform}"
name="${orangepi.name}"
host="${orangepi.host}"
@@ -109,32 +147,128 @@
directory="${orangepi.directory}"/>
</target>
+ <!-- ********************************************************************************** -->
+ <!-- LOCAL PLATFORM BUILD TARGETS -->
+ <!-- ********************************************************************************** -->
+
+ <!-- local build target for RaspberryPi platform -->
+ <target name="raspberrypi-local" if="${raspberrypi.build}">
+ <pi4j-build-local platform="${raspberrypi.platform}"
+ name="${raspberrypi.name}"/>
+ </target>
+
+ <!-- local build target for Odroid platform -->
+ <target name="odroid-local" if="${odroid.build}">
+ <pi4j-build-local platform="${odroid.platform}"
+ name="${odroid.name}"/>
+ </target>
+
+ <!-- local build target for BananaPi platform -->
+ <target name="bananapi-local" if="${bananapi.build}">
+ <pi4j-build-local platform="${bananapi.platform}"
+ name="${bananapi.name}"/>
+ </target>
+
+ <!-- local build target for BananaPro platform -->
+ <target name="bananapro-local" if="${bananapro.build}">
+ <pi4j-build-local platform="${bananapro.platform}"
+ name="${bananapro.name}"/>
+ </target>
+
+ <!-- local build target for OrangePi platform -->
+ <target name="orangepi-local" if="${orangepi.build}">
+ <pi4j-build-local platform="${orangepi.platform}"
+ name="${orangepi.name}"/>
+ </target>
+
+ <!-- ********************************************************************************** -->
+ <!-- CROSS COMPILER PLATFORM BUILD TARGETS -->
+ <!-- ********************************************************************************** -->
+
+ <!-- local build target for RaspberryPi platform using cross-compiler -->
+ <target name="raspberrypi-cross-compile" if="${raspberrypi.build}">
+ <pi4j-build-local platform="${raspberrypi.platform}"
+ name="${raspberrypi.name}"
+ args="ARCH=arm CC=arm-linux-gnueabihf-gcc"/>
+ </target>
+
+ <!-- local build target for Odroid platform using cross-compiler -->
+ <target name="odroid-cross-compile" if="${odroid.build}">
+ <pi4j-build-local platform="${odroid.platform}"
+ name="${odroid.name}"
+ args="ARCH=arm CC=arm-linux-gnueabihf-gcc"/>
+ </target>
+
+ <!-- local build target for BananaPi platform using cross-compiler -->
+ <target name="bananapi-cross-compile" if="${bananapi.build}">
+ <pi4j-build-local platform="${bananapi.platform}"
+ name="${bananapi.name}"
+ args="ARCH=arm CC=arm-linux-gnueabihf-gcc"/>
+ </target>
+
+ <!-- local build target for BananaPro platform using cross-compiler -->
+ <target name="bananapro-cross-compile" if="${bananapro.build}">
+ <pi4j-build-local platform="${bananapro.platform}"
+ name="${bananapro.name}"
+ args="ARCH=arm CC=arm-linux-gnueabihf-gcc"/>
+ </target>
+
+ <!-- local build target for OrangePi platform using cross-compiler -->
+ <target name="orangepi-cross-compile" if="${orangepi.build}">
+ <pi4j-build-local platform="${orangepi.platform}"
+ name="${orangepi.name}"
+ args="ARCH=arm CC=arm-linux-gnueabihf-gcc"/>
+ </target>
+
+ <!-- ********************************************************************************** -->
+ <!-- MAVEN INITIATED BUILD TARGETS -->
+ <!-- ********************************************************************************** -->
+
<!-- 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"/>
- <antcall target="orangepi"/>
+ <antcall target="raspberrypi-remote"/>
+ <antcall target="odroid-remote"/>
+ <antcall target="bananapi-remote"/>
+ <antcall target="bananapro-remote"/>
+ <antcall target="orangepi-remote"/>
</target>
- <!-- this target is used when building maven project directly on the Raspberry Pi -->
+ <!-- this target is used when building maven project directly on a local platform/system -->
<target name="build-libpi4j.so-local">
- <echo message="Building native libpi4j shared library"/>
- <exec command="chmod +x build-local.sh" />
- <exec executable="/bin/sh">
- <arg line="build-local.sh"/>
- </exec>
+
+ <!-- ensure the target directory is empty -->
+ <delete dir="${project.build.directory}/native" includeemptydirs="true" />
+
+ <!-- ensure the target directory exists -->
+ <mkdir dir="${project.build.directory}/native"/>
+ <mkdir dir="${project.build.directory}/native/lib"/>
+
+ <!-- include a local build target for each supported platform -->
+ <antcall target="raspberrypi-local"/>
+ <antcall target="odroid-local"/>
+ <antcall target="bananapi-local"/>
+ <antcall target="bananapro-local"/>
+ <antcall target="orangepi-local"/>
</target>
- <!-- this target is used when building maven project using the RPi cross-compiler -->
+ <!-- this target is used when building maven project using the ARM cross-compiler -->
<target name="build-libpi4j.so-cross-compile">
<echo message="Building native libpi4j shared library using CROSS-COMPILER"/>
- <exec command="chmod +x build-local.sh" />
- <exec executable="/bin/sh">
- <arg line="build-local-cross-compile.sh"/>
- </exec>
+
+ <!-- ensure the target directory is empty -->
+ <delete dir="${project.build.directory}/native" includeemptydirs="true" />
+
+ <!-- ensure the target directory exists -->
+ <mkdir dir="${project.build.directory}/native"/>
+ <mkdir dir="${project.build.directory}/native/lib"/>
+
+ <!-- include a local build target for each supported platform -->
+ <antcall target="raspberrypi-cross-compile"/>
+ <antcall target="odroid-cross-compile"/>
+ <antcall target="bananapi-cross-compile"/>
+ <antcall target="bananapro-cross-compile"/>
+ <antcall target="orangepi-cross-compile"/>
</target>
</project>
View
@@ -23,7 +23,7 @@
<!-- SPECIAL PROFILE TO DETERMINE IF RUNNING ON THE PI HARDWARE -->
<profile>
- <id>rpi-local</id>
+ <id>local-compile</id>
<activation>
<os>
<name>linux</name>
View
@@ -283,9 +283,9 @@
<!-- BUILD PROFILES -->
<profiles>
- <!-- SPECIAL PROFILE TO INCLUDE JNI NATIVE LIBRARY -->
+ <!-- SPECIAL PROFILE TO INCLUDE JNI NATIVE LIBRARY FOR ALL PLATFORMS -->
<profile>
- <id>native</id>
+ <id>all-platforms</id>
<activation>
<property>
<name>release-build</name>
@@ -299,6 +299,7 @@
<bananapi.build>true</bananapi.build>
<bananapro.build>true</bananapro.build>
<odroid.build>true</odroid.build>
+ <orangepi.build>true</orangepi.build>
</properties>
</profile>

0 comments on commit 81bb8ab

Please sign in to comment.