/ltmain.sh
/missing
/ar-lib
+/jni/
*.jar
*.class
*.o
*.lo
*.la
+*.aar
+*.pom
.deps/
.libs/
.dirstamp
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ This file is part of the sigrok-androidutils project.
+
+ Copyright (C) 2016 Marcus Comstedt <marcus@mc.pp.se>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU 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 Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.sigrok.sigrok-core-android"
+ android:versionCode="${bindings.versioncode}"
+ android:versionName="${bindings.version}" >
+
+ <uses-sdk
+ android:minSdkVersion="12" />
+
+ <application>
+ <meta-data android:name="org.sigrok.androidutils.jni_libs_resource_id" android:resource="@array/sigrok_androidutils_jni_libs"/>
+ </application>
+
+</manifest>
jardir = $(prefix)/jar
jar_DATA = $(UTILS_JAR) $(ANTTASKS_JAR)
+mvndir = $(prefix)/.m2/repository/org/sigrok/sigrok-core-android/$(BINDINGS_VERSION)
+mvn_DATA = $(SIGROK_CORE_AAR) $(SIGROK_CORE_POM)
+
UTILS_JAR = sigrok-androidutils.jar
ANTTASKS_JAR = ant/sigrok-androidutils-anttasks.jar
-ANTFLAGS = -Dandroid.sdk=$(ANDROID_SDK) -Dandroid.platform=$(ANDROID_PLATFORM)
+BINDINGS_VERSION = $(LIBSIGROKCXX_VERSION)
+
+SIGROK_CORE_AAR = sigrok-core-android-$(BINDINGS_VERSION).aar
+SIGROK_CORE_POM = sigrok-core-android-$(BINDINGS_VERSION).pom
+
+ANTFLAGS = -Dandroid.sdk=$(ANDROID_SDK) -Dandroid.platform=$(ANDROID_PLATFORM) \
+ -Dprefix=$(prefix) -Dbindings.version=$(BINDINGS_VERSION)
EXTRA_DIST = build.xml src ant/src ant/resources
$(ANTTASKS_JAR): always
$(AM_V_GEN)ant -S -q anttasks
+$(SIGROK_CORE_AAR): always $(UTILS_JAR) $(ANTTASKS_JAR) $(lib_LTLIBRARIES)
+ $(AM_V_GEN)ant -S -q $(ANTFLAGS) aar
+
+$(SIGROK_CORE_POM): always
+ $(AM_V_GEN)ant -S -q $(ANTFLAGS) pom
+
clean-local:
- -rm -rf build ant/build
+ -rm -rf build ant/build jni
-rm -f $(UTILS_JAR) $(ANTTASKS_JAR)
+ -rm -f $(SIGROK_CORE_AAR) $(SIGROK_CORE_POM) classes.jar
.PHONY: always
import java.util.TreeSet;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DynamicAttribute;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
import org.apache.tools.ant.types.resources.FileProvider;
import org.apache.tools.ant.types.selectors.SelectorUtils;
-public class CopyLibsTask extends Task
+public class CopyLibsTask extends Task implements DynamicAttribute
{
private static final HashMap<String,String> blacklist;
protected File getDestName(File dest)
{
- File d = new File(dest, subdir);
+ File d = (subdir == null? dest : new File(dest, subdir));
File f = new File(d, destname);
return f;
}
protected Vector<ResourceCollection> rcs = new Vector<ResourceCollection>();
protected PatternSet patterns = new PatternSet();
protected String property = null;
+ protected Vector<String> rpath = new Vector<String>();
public void setTodir(File destDir)
{
this.destDir = destDir;
}
+ public void setDynamicAttribute(String name, String value)
+ {
+ if ("rpath-link".equals(name))
+ this.rpath.add(value);
+ else
+ throw new BuildException("copylibs doesn't support the \"" + name + "\" attribute");
+ }
+
public void addFileset(FileSet set)
{
add(set);
}
Integer m = new Integer(l.elf.header.e_machine);
Worker w = workers.get(m);
- if (w == null)
+ if (w == null) {
workers.put(m, (w = new Worker(m.intValue())));
+ w.addRpath(rpath);
+ }
w.addWork(l);
}
}
<project>
+ <property name="android.abi" value="armeabi"/>
+
<target name="utils" >
<mkdir dir="build"/>
<javac srcdir="src" destdir="build" includeantruntime="no"
- classpath="${android.sdk}/platforms/${android.platform}/android.jar"/>
+ classpath="${android.sdk}/platforms/${android.platform}/android.jar"/>
<jar destfile="sigrok-androidutils.jar">
<fileset dir="build" />
</jar>
</jar>
</target>
+ <target name="-declare-anttasks">
+ <taskdef resource="anttasks.properties"
+ classpath="ant/sigrok-androidutils-anttasks.jar"/>
+ </target>
+
+ <target name="aar" depends="-declare-anttasks">
+ <copylibs todir="jni/${android.abi}" property="bundled_libs" rpath-link="${prefix}/lib">
+ <fileset file="${prefix}/lib/jni/libsigrok_java_core_classes.so" />
+ <exclude name="libc.so"/>
+ <exclude name="libm.so"/>
+ <exclude name="libdl.so"/>
+ <exclude name="liblog.so"/>
+ <exclude name="libstdc++.so"/>
+ <exclude name="libz.so"/>
+ </copylibs>
+ <copy file=".libs/libsigrokandroidutils.so" todir="jni/${android.abi}" />
+ <mkdir dir="aidl" />
+ <loadresource property="bindings.versioncode">
+ <propertyresource name="bindings.version" />
+ <filterchain>
+ <tokenfilter>
+ <filetokenizer />
+ <replaceregex pattern="[0-9]+" replace="0000\0" flags="g" />
+ <replaceregex pattern="0*([0-9]{3})\.?" replace="\1" flags="g" />
+ <replaceregex pattern="0*([1-9][0-9]*|0)([^0-9].*)?$" replace="\1" />
+ </tokenfilter>
+ </filterchain>
+ </loadresource>
+ <jar destfile="classes.jar">
+ <zipfileset includes="**/*.class" src="sigrok-androidutils.jar" />
+ <zipfileset includes="**/*.class" src="${prefix}/share/java/sigrok-core.jar" />
+ </jar>
+ <zip destfile="sigrok-core-android-${bindings.version}.aar">
+ <zipfileset dir="aidl" prefix="aidl" />
+ <zipfileset dir="jni" prefix="jni" />
+ <zipfileset dir="." includes="classes.jar" />
+ <mappedresources>
+ <concat>
+ <fileset file="AndroidManifest.xml.in" />
+ <filterchain>
+ <expandproperties />
+ </filterchain>
+ </concat>
+ <mergemapper to="AndroidManifest.xml" />
+ </mappedresources>
+ <mappedresources>
+ <concat><![CDATA[<?xml version='1.0' encoding='utf-8'?>
+<resources>
+ <array name="sigrok_androidutils_jni_libs">
+ ${bundled_libs}
+ </array>
+</resources>]]></concat>
+ <mergemapper to="res/values/sigrok_androidutils_jni_libs.xml" />
+ </mappedresources>
+ </zip>
+ </target>
+
+ <target name="pom" >
+ <echo file="sigrok-core-android-${bindings.version}.pom"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.sigrok</groupId>
+ <artifactId>sigrok-core-android</artifactId>
+ <version>${bindings.version}</version>
+ <packaging>aar</packaging>
+</project>
+]]></echo>
+ </target>
+
</project>
AC_PROG_CXX
AM_PROG_CC_C_O
+PKG_CHECK_MODULES([LIBSIGROKCXX], [libsigrokcxx], [
+ LIBSIGROKCXX_VERSION=`$PKG_CONFIG --modversion "libsigrokcxx" 2>&AS_MESSAGE_LOG_FD`
+])
+
AC_SUBST([ANDROID_SDK])
AC_SUBST([ANDROID_PLATFORM])
+AC_SUBST([LIBSIGROKCXX_VERSION])
AC_OUTPUT([Makefile lib/libsigrokandroidutils.pc])
--- /dev/null
+/*
+ * This file is part of the sigrok-androidutils project.
+ *
+ * Copyright (C) 2016 Marcus Comstedt <marcus@mc.pp.se>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sigrok.androidutils;
+
+import android.app.Application;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.util.Log;
+
+public class SigrokApplication extends Application {
+
+ private static final String JNI_LIBS_RESOURCE_ID_META =
+ "org.sigrok.androidutils.jni_libs_resource_id";
+
+ public SigrokApplication()
+ {
+ }
+
+ public static void initSigrok(Context context)
+ {
+ ApplicationInfo appInfo = context.getApplicationInfo();
+ Environment.initEnvironment(appInfo.sourceDir);
+ UsbHelper.setContext(context);
+ try {
+ appInfo = context.getPackageManager().
+ getApplicationInfo(context.getPackageName(),
+ PackageManager.GET_META_DATA);
+ } catch (PackageManager.NameNotFoundException exc) {
+ }
+ if (appInfo.metaData != null &&
+ appInfo.metaData.containsKey(JNI_LIBS_RESOURCE_ID_META)) {
+ int resId = appInfo.metaData.getInt(JNI_LIBS_RESOURCE_ID_META);
+ String[] libs = context.getResources().getStringArray(resId);
+ int numLibs = libs.length;
+ for (int i = 0; i < numLibs; i++) {
+ String libName = libs[i];
+ System.loadLibrary(libName);
+ }
+ }
+ }
+
+ @Override
+ public void onCreate()
+ {
+ super.onCreate();
+ initSigrok(getApplicationContext());
+ }
+}