Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Commit

Permalink
clean up build system to use variables and run the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
eighthave committed Mar 25, 2014
1 parent 5cce7a1 commit a0913cf
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 34 deletions.
11 changes: 10 additions & 1 deletion README.md
Expand Up @@ -23,6 +23,10 @@ instead of loading a .so lib.

## Setup for Building

You will need a JUnit jar to run the tests. If your system does not provide
one already, you can download the jar and put it into the build/ directory of
this project.

### Debian/Ubuntu/Mint/etc

sudo apt-get install default-jdk make ant build-essential \
Expand All @@ -45,10 +49,15 @@ it from Homebrew, MacPorts, or Fink. Or you can install

## Building

To build the gnupg-for-java.jar in build/jar/, run this:
To build the `gnupg-for-java.jar` and `libgnupg-for-java.so` in build/, run
this:

ant clean release

You can run the test suite using `ant` also:

ant test

If you want the optional javadoc in build/docs/, run:

ant javadoc
Expand Down
44 changes: 22 additions & 22 deletions build.xml
Expand Up @@ -2,19 +2,23 @@
<project name="gnupg-for-java" default="release" basedir=".">
<property file="build.properties"/>

<property name="build.dir" location="build" />
<property name="classes.dir" location="${build.dir}/classes" />
<property name="docs.dir" location="${build.dir}/docs" />
<property name="jarfile" value="${build.dir}/${app.name}-${app.version}.jar"/>

<target name="prepare" description="Create the necessary directories and files for the build">
<mkdir dir="build"/>
<mkdir dir="dist"/>
<mkdir dir="${build.dir}"/>
</target>

<target name="clean" depends="clean-native" description="Remove all generated dirs and files...">
<delete dir="build"/>
<delete dir="dist"/>
<delete file="${jarfile}"/>
<delete dir="${classes.dir}" includeEmptyDirs="true"/>
</target>

<target name="compile-java" depends="prepare" description="Compile the Java code for the GnuPG-Library">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes" debug="on">
<mkdir dir="${classes.dir}"/>
<javac srcdir="src" destdir="${classes.dir}" debug="on">
<src path="src"/>
</javac>
</target>
Expand All @@ -29,13 +33,11 @@
<mkdir dir="/tmp/gnupg-for-java-tests"/>
<java classname="junit.${TestEnv}.TestRunner" fork ="yes">
<classpath>
<pathelement location="build/jar/${app.name}-${app.version}.jar"/>
<pathelement location="lib/junit-3.8.1.jar"/>
<fileset dir="${build.dir}" includes="*.jar"/>
<fileset dir="${classes.dir}"/>
</classpath>
<!--classpath refid="compile.classpath"/-->
<sysproperty key="java.library.path" value="${build.dir}"/>
<arg value="com.freiheit.gnupg.tests.GnuPGTestSuite"/>
<sysproperty key="java.library.path"
value="${basedir}/jni"/>
</java>
</target>

Expand All @@ -44,12 +46,12 @@
</target>

<target name="jar" depends="compile-java" description="Use this, if you only want to recompile changed java code">
<jar jarfile="build/jar/${app.name}-${app.version}.jar" basedir="build/classes" />
<jar jarfile="${jarfile}" basedir="${classes.dir}" />
</target>

<target name="clean-native" description="calls make clean in the c/ directory">
<exec executable="make" dir="jni" failonerror="false">
<arg value="-e"/>
<arg value="BUILD_DIR=${build.dir}"/>
<arg value="clean"/>
</exec>
</target>
Expand All @@ -59,8 +61,8 @@

<target name="generate-jni-headers" depends="compile-java" description="Use this, if you want to generate headers without resolving dependencies automatically">
<exec executable="make" dir="jni" failonerror="true">
<arg value="CLASSES_DIR=${classes.dir}"/>
<arg value="headers"/>
<arg value="-e"/>
</exec>
</target>

Expand All @@ -70,8 +72,8 @@

<target name="recompile-c-code" description="Use this, if you just want to compile without resolving dependencies automatically">
<exec executable="make" dir="jni" failonerror="true">
<arg value="BUILD_DIR=${build.dir}"/>
<arg value="lib"/>
<arg value="-e"/>
</exec>
</target>

Expand All @@ -80,20 +82,18 @@
</target>

<target name="javadoc" description="Create Javadoc-API documentation">
<mkdir dir="build/docs/api"/>
<mkdir dir="build/docs/images"/>
<copy todir="build/docs/images" file="etc/guardianproject-logo.png"/>
<copy todir="build/docs/images" file="etc/fdc.javadoc.png"/>
<mkdir dir="${docs.dir}/images"/>
<copy todir="${docs.dir}/images" file="etc/guardianproject-logo.png"/>
<copy todir="${docs.dir}/images" file="etc/fdc.javadoc.png"/>

<javadoc sourcepath="src"
destdir="build/docs/${app.name}-${app.version}"
destdir="${docs.dir}/${app.name}-${app.version}"
windowtitle="${app.name} (Version ${app.version})"
doctitle="${app.name} (Version ${app.version})"
bottom="&#169; ${app.year} ${app.vendor}"
header="freiheit.com technologies gmbh &amp; The Guardian Project"
packagenames="com.freiheit.*"
overview="${etc}/overview.html">
<!--classpath refid="compile.classpath"/-->
<!--
!!! relative path for headers does NOT work !!!
header="&lt;img src='../images/fdc.javadoc.png'&gt;"
Expand All @@ -104,7 +104,7 @@
</target>

<target name="zip_javadoc" depends="javadoc" description="Create a zip-file for API-Javadoc">
<zip zipfile="build/${app.name}-${app.version}-javadoc.zip" basedir="build/docs/${app.name}-${app.version}"/>
<zip zipfile="build/${app.name}-${app.version}-javadoc.zip" basedir="${docs.dir}/${app.name}-${app.version}"/>
</target>

</project>
12 changes: 5 additions & 7 deletions jni/GNUmakefile
Expand Up @@ -5,8 +5,6 @@ JNI_HEADERS := $(patsubst %.c, com_freiheit_gnupg_%.h, $(JNI_SOURCES))
SOURCES := $(JNI_SOURCES) gpgmeutils.c
OBJECTS := $(SOURCES:.c=.o)

JAVA_BUILD := ../build/classes

DEBUG := -g
ALL_CFLAGS := -Werror -Wall -Wno-deprecated-declarations -fPIC
ALL_CPPFLAGS = -D_REENTRANT -D_THREAD_SAFE -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1 \
Expand All @@ -20,7 +18,7 @@ ifeq (MINGW,$(findstring MINGW,$(UNAME)))
ALL_LDFLAGS := -s -shared -Wl,--enable-auto-import
ALL_LIBS := -L"$(PROGRAMFILES)/GNU/GnuPG" -lgpgme-11
JAVA_HOME := $(PROGRAMFILES)/Java/jdk1.7.0_51
GNUPG_LIB := ../lib/gnupg-for-java.dll
GNUPG_LIB := $(BUILD_DIR)/gnupg-for-java.dll
else
ifeq ($(UNAME),Darwin)
CC := gcc
Expand All @@ -29,14 +27,14 @@ else
ALL_LIBS := -L/usr/local/MacGPG2/lib -framework MacGPGME
JAVA_HOME := $(shell /usr/libexec/java_home \
|| echo /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home)
GNUPG_LIB := ../lib/libgnupg-for-java.dylib
GNUPG_LIB := $(BUILD_DIR)/libgnupg-for-java.dylib
else
CC := gcc
ALL_CFLAGS += $(shell gpgme-config --cflags)
ALL_CPPFLAGS += -I"$(JAVA_HOME)/include/linux"
ALL_LDFLAGS := -shared
ALL_LIBS := $(shell gpgme-config --thread=pthread --libs)
GNUPG_LIB := ../lib/libgnupg-for-java.so
GNUPG_LIB := $(BUILD_DIR)/libgnupg-for-java.so
# to override this JAVA_HOME, use the `-e' flag to make, or call it like:
# make JAVA_HOME=/opt/java
JAVA_HOME := $(shell readlink -f /usr/bin/javac | sed "s:/bin/javac::")
Expand Down Expand Up @@ -68,10 +66,10 @@ lib: $(GNUPG_LIB)
headers: $(JNI_HEADERS)

$(JNI_HEADERS):
$(JAVAH) -classpath $(JAVA_BUILD) -jni $(JNI_CLASSES)
$(JAVAH) -classpath $(CLASSES_DIR) -jni $(JNI_CLASSES)

mids:
$(JAVAP) -classpath $(JAVA_BUILD) -s -p $(JNI_CLASSES)
$(JAVAP) -classpath $(CLASSES_DIR) -s -p $(JNI_CLASSES)

clean:
rm -f $(OBJECTS) *~
Expand Down
Binary file removed lib/junit-3.8.1.jar
Binary file not shown.
4 changes: 0 additions & 4 deletions runTests.sh

This file was deleted.

0 comments on commit a0913cf

Please sign in to comment.