travis: improve docker images generation for building
Make a build heriarchy to reduce images size. Add Android Thing Build. Signed-off-by: Nicolas Oliver <dario.n.oliver@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
3d77c86634
commit
4bedd68c4e
139
scripts/build-android.sh
Executable file
139
scripts/build-android.sh
Executable file
@@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PKG_CONFIG_LIBDIR=$NDK_HOME/platforms/android-24/arch-x86/usr/lib
|
||||
PKG_CONFIG_SYSROOT_DIR=""
|
||||
|
||||
# Run cmake
|
||||
cmake \
|
||||
-DANDROID_COMPILER_FLAGS_CXX='-std=c++11' \
|
||||
-DANDROID_PIE=1 \
|
||||
-DANDROID_PLATFORM=android-24 \
|
||||
-DANDROID_STL_FORCE_FEATURES=on \
|
||||
-DANDROID_STL=c++_shared \
|
||||
-DANDROID_TOOLCHAIN_NAME=x86-i686 \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=BOTH \
|
||||
-DCMAKE_FIND_ROOT_PATH=$NDK_HOME/platforms/android-24/arch-x86/ \
|
||||
-DCMAKE_MODULE_PATH=$ANDROIDTHINGS_NATIVE_LIB \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$NDK_HOME/build/cmake/android.toolchain.cmake \
|
||||
-DJAVA_AWT_INCLUDE_PATH=$JAVA_HOME/include \
|
||||
-DJAVA_AWT_LIBRARY=$JAVA_HOME/jre/lib/amd64/libjawt.so \
|
||||
-DJAVA_INCLUDE_PATH=$JAVA_HOME/include \
|
||||
-DJAVA_INCLUDE_PATH2=$JAVA_HOME/include/linux \
|
||||
-DJAVA_JVM_LIBRARY=$JAVA_HOME/jre/lib/amd64/server/libjvm.so \
|
||||
-DBUILDARCH=$BUILDARCH \
|
||||
-DBUILDDOC=$BUILDDOC \
|
||||
-DBUILDSWIG=$BUILDSWIG \
|
||||
-DBUILDSWIGPYTHON=$BUILDSWIGPYTHON \
|
||||
-DBUILDSWIGNODE=$BUILDSWIGNODE \
|
||||
-DBUILDSWIGJAVA=$BUILDSWIGJAVA \
|
||||
-DUSBPLAT=$USBPLAT \
|
||||
-DFIRMATA=$FIRMATA \
|
||||
-DONEWIRE=$ONEWIRE \
|
||||
-DJSONPLAT=$JSONPLAT \
|
||||
-DIMRAA=$IMRAA \
|
||||
-DFTDI4222=$FTDI4222 \
|
||||
-DIPK=$IPK \
|
||||
-DRPM=$RPM \
|
||||
-DENABLEEXAMPLES=$ENABLEEXAMPLES \
|
||||
-DINSTALLGPIOTOOL=$INSTALLGPIOTOOL \
|
||||
-DINSTALLTOOLS=$INSTALLTOOLS \
|
||||
-DBUILDTESTS=$BUILDTESTS \
|
||||
-DUSEPYTHON3TESTS=$USEPYTHON3TESTS \
|
||||
-H. \
|
||||
-Bbuild
|
||||
|
||||
make -Cbuild
|
||||
make -Cbuild install
|
||||
|
||||
# Anotate the .java src from doxygen
|
||||
echo src/mraa.i > build/swig.i.list
|
||||
# TODO: install doxy port tool
|
||||
#doxyport \
|
||||
# build/swig.i.list \
|
||||
# -s api,api/mraa \
|
||||
# -d build/src/java \
|
||||
# --convert-protected-to-private \
|
||||
# -o mraa-java-files.txt \
|
||||
# -m examples/samples.mapping.txt
|
||||
|
||||
# Copy the STL implementation into the build/src directory
|
||||
cp $NDK_HOME/sources/cxx-stl/llvm-libc++/libs/x86/libc++_shared.so build/src/
|
||||
|
||||
|
||||
# Template for res/values/values.xml in aar
|
||||
values_xml='<?xml version="1.0" encoding="utf-8"?><resources><string name="app_name">XXX_LIBRARY</string></resources>'
|
||||
|
||||
# Template for AndroidManifest.xml in aar
|
||||
AndroidManifest_xml='<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="XXX_PACKAGE.XXX_LIBRARY"
|
||||
android:versionCode="1"
|
||||
android:versionName="XXX_VERSION" >
|
||||
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="25"/>
|
||||
<application android:allowBackup="true" android:label="@string/app_name" android:supportsRtl="true" />
|
||||
</manifest>'
|
||||
|
||||
# Package prefix
|
||||
JAVA_PKG_PREFIX_DOT="io.mraa.at"
|
||||
|
||||
# Package prefix slash to dot
|
||||
JAVA_PKG_PREFIX_SLASH="${JAVA_PKG_PREFIX_DOT//\./\/}/upm"
|
||||
|
||||
# Work in the MRAA build directory
|
||||
cd build
|
||||
|
||||
# Get the MRAA version string from the .pom file
|
||||
VERSION=`ls src/java/*.pom | sed 's/\([^-]\+\)\-\([0-9]\+\.[0-9]\+\.[0-9]\+\)\.pom/\2/'`
|
||||
|
||||
# Get the MRAA name string from the .pom file
|
||||
LIB_NAME=`ls src/java/*.pom | sed 's/^.*\/\([^-]\+\)\-\([0-9]\+\.[0-9]\+\.[0-9]\+\)\.pom/\1/'`
|
||||
|
||||
# Get the MRAA description string from the .pom file
|
||||
LIB_DESCRIPTION=$(grep -oPm1 "(?<=<description>)[^<]+" src/java/$LIB_NAME-$VERSION.pom)
|
||||
|
||||
# Bundle upload directory
|
||||
PKG_BUNDLE_DIR=BUNDLE_DIR
|
||||
mkdir -p ${PKG_BUNDLE_DIR}
|
||||
|
||||
# Create the aar directory structure
|
||||
AAR_DIRECTORY="$LIB_NAME-$VERSION"
|
||||
mkdir -p $AAR_DIRECTORY/jni/x86
|
||||
mkdir -p $AAR_DIRECTORY/res/values
|
||||
|
||||
# Write out res/values/values.xml to the aar
|
||||
echo "${values_xml/XXX_LIBRARY/$LIB_NAME}" > $AAR_DIRECTORY/res/values/values.xml
|
||||
|
||||
# Write out AndroidManifest.xml to the aar
|
||||
_tmp_manifest=${AndroidManifest_xml/XXX_PACKAGE/$JAVA_PKG_PREFIX_DOT}
|
||||
_tmp_manifest=${_tmp_manifest/XXX_LIBRARY/$LIB_NAME}
|
||||
echo "${_tmp_manifest/XXX_VERSION/$VERSION}" > $AAR_DIRECTORY/AndroidManifest.xml
|
||||
|
||||
# Copy over the so's
|
||||
cp src/*.so $AAR_DIRECTORY/jni/x86
|
||||
cp src/java/*.so $AAR_DIRECTORY/jni/x86
|
||||
|
||||
# Create javadoc jar
|
||||
javadoc src/java/*.java -d $LIB_NAME-javadoc
|
||||
jar cf $PKG_BUNDLE_DIR/$LIB_NAME-$VERSION-javadoc.jar $LIB_NAME-javadoc/*
|
||||
|
||||
# Create sources jar file for upload
|
||||
jar cf $PKG_BUNDLE_DIR/$LIB_NAME-$VERSION-sources.jar src/java/*.java
|
||||
|
||||
# HACK - mraa pom file groupId is io.mraa (AT is io.mraa.at)
|
||||
perl -p -i -e 's/(groupId>)(.*?)(<\/groupId)/\1io.mraa.at\3/' src/java/$LIB_NAME-$VERSION.pom
|
||||
|
||||
# HACK - mraa pom file packaging is 'jar' (convert this to 'aar')
|
||||
perl -p -i -e 's/(packaging>)(.*?)(<\/packaging)/\1aar\3/' src/java/$LIB_NAME-$VERSION.pom
|
||||
|
||||
# Copy pom file
|
||||
cp src/java/$LIB_NAME-$VERSION.pom $PKG_BUNDLE_DIR
|
||||
|
||||
# Copy the java module jar to classes.jar
|
||||
cp src/java/$LIB_NAME.jar $AAR_DIRECTORY/classes.jar
|
||||
|
||||
# Create the .aar
|
||||
pushd $AAR_DIRECTORY
|
||||
jar cf ../$PKG_BUNDLE_DIR/$LIB_NAME-$VERSION.aar *
|
||||
popd
|
||||
26
scripts/run-cmake.sh
Executable file
26
scripts/run-cmake.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Run cmake
|
||||
cmake \
|
||||
-DBUILDARCH=$BUILDARCH \
|
||||
-DBUILDDOC=$BUILDDOC \
|
||||
-DBUILDSWIG=$BUILDSWIG \
|
||||
-DBUILDSWIGPYTHON=$BUILDSWIGPYTHON \
|
||||
-DBUILDSWIGNODE=$BUILDSWIGNODE \
|
||||
-DBUILDSWIGJAVA=$BUILDSWIGJAVA \
|
||||
-DUSBPLAT=$USBPLAT \
|
||||
-DFIRMATA=$FIRMATA \
|
||||
-DONEWIRE=$ONEWIRE \
|
||||
-DJSONPLAT=$JSONPLAT \
|
||||
-DIMRAA=$IMRAA \
|
||||
-DFTDI4222=$FTDI4222 \
|
||||
-DIPK=$IPK \
|
||||
-DRPM=$RPM \
|
||||
-DENABLEEXAMPLES=$ENABLEEXAMPLES \
|
||||
-DINSTALLGPIOTOOL=$INSTALLGPIOTOOL \
|
||||
-DINSTALLTOOLS=$INSTALLTOOLS \
|
||||
-DBUILDTESTS=$BUILDTESTS \
|
||||
-DUSEPYTHON3TESTS=$USEPYTHON3TESTS \
|
||||
-H. \
|
||||
-Bbuild
|
||||
|
||||
68
scripts/sonar-scan.sh
Executable file
68
scripts/sonar-scan.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# The script is used for determining options and running a static code
|
||||
# analysis scan via SonarCloud.
|
||||
#
|
||||
# Author: Alex Tereschenko <alext.mkrs@gmail.com>
|
||||
#
|
||||
# All environment variables used are passed from either Travis or docker-compose.
|
||||
# See details at https://docs.sonarqube.org/display/SONAR/Analysis+Parameters.
|
||||
#
|
||||
# Travis ones are:
|
||||
# Created by us:
|
||||
# - SONAR_ORG - SonarCloud "organization", under which the project is located.
|
||||
# - SONAR_PROJ_KEY - SonarCloud project key (name) to report to.
|
||||
# - SONAR_TOKEN - access token for that project (must be protected in Travis).
|
||||
# - GITHUB_TOKEN - GH OAuth token used by SonarCloud's GH plugin to report status in PRs.
|
||||
# See details at https://docs.sonarqube.org/display/PLUG/GitHub+Plugin. Must be protected.
|
||||
# Default:
|
||||
# - All TRAVIS_* variables. They are described in Travis docs
|
||||
# at https://docs.travis-ci.com/user/environment-variables
|
||||
#
|
||||
# docker-compose ones are:
|
||||
# - MRAA_SRC_DIR - path to mraa's git clone in the Docker container.
|
||||
|
||||
bw_output_path="${MRAA_SRC_DIR}/build/bw-output"
|
||||
|
||||
sonar_cmd_base="build-wrapper-linux-x86-64 --out-dir ${bw_output_path} make clean all && \
|
||||
sonar-scanner \
|
||||
--debug \
|
||||
-Dsonar.projectKey=${SONAR_PROJ_KEY} \
|
||||
-Dsonar.projectBaseDir=${MRAA_SRC_DIR} \
|
||||
-Dsonar.sources=${MRAA_SRC_DIR} \
|
||||
-Dsonar.inclusions='api/**/*,CMakeLists.txt,examples/**/*,imraa/**/*,include/**/*,src/**/*,tests/**/*' \
|
||||
-Dsonar.coverage.exclusions='**/*' \
|
||||
-Dsonar.cfamily.build-wrapper-output=${bw_output_path} \
|
||||
-Dsonar.host.url=https://sonarqube.com \
|
||||
-Dsonar.organization=${SONAR_ORG} \
|
||||
-Dsonar.login=${SONAR_TOKEN} \
|
||||
"
|
||||
|
||||
# Some useful data for logs
|
||||
echo "TRAVIS_BRANCH: ${TRAVIS_BRANCH}"
|
||||
echo "TRAVIS_PULL_REQUEST: ${TRAVIS_PULL_REQUEST}"
|
||||
echo "TRAVIS_PULL_REQUEST_SLUG: ${TRAVIS_PULL_REQUEST_SLUG}"
|
||||
echo "TRAVIS_REPO_SLUG: ${TRAVIS_REPO_SLUG}"
|
||||
|
||||
if [ "${TRAVIS_BRANCH}" == "master" -a "${TRAVIS_PULL_REQUEST}" == "false" -a "${TRAVIS_REPO_SLUG}" == "intel-iot-devkit/mraa" ]; then
|
||||
# Master branch push - do a full-blown scan
|
||||
echo "Performing master branch push scan"
|
||||
sonar_cmd="${sonar_cmd_base}"
|
||||
elif [ "${TRAVIS_PULL_REQUEST}" != "false" -a "${TRAVIS_PULL_REQUEST_SLUG}" == "${TRAVIS_REPO_SLUG}" ]; then
|
||||
# Internal PR - do a preview scan with report to the PR
|
||||
echo "Performing internal pull request scan"
|
||||
sonar_cmd="${sonar_cmd_base} \
|
||||
-Dsonar.analysis.mode=preview \
|
||||
-Dsonar.github.pullRequest=${TRAVIS_PULL_REQUEST} \
|
||||
-Dsonar.github.repository=${TRAVIS_REPO_SLUG} \
|
||||
-Dsonar.github.oauth=${GITHUB_TOKEN} \
|
||||
"
|
||||
else
|
||||
echo "Skipping the scan - external pull request or non-master branch push"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "About to run the scan, the command is:"
|
||||
echo "${sonar_cmd}"
|
||||
|
||||
eval "${sonar_cmd}"
|
||||
Reference in New Issue
Block a user