Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Java build #1193

Merged
merged 18 commits into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,8 @@ library_example_gcov: vw_gcov
python: vw
cd python; $(MAKE) things

ifneq ($(JAVA_HOME),)
java: vw
cd java; $(MAKE) things
endif

.FORCE:

Expand All @@ -137,7 +135,7 @@ bigtests: .FORCE vw
(cd big_tests && $(MAKE) $(MAKEFLAGS))

install: $(BINARIES)
cd vowpalwabbit; cp $(BINARIES) /usr/local/bin; cd ../cluster; $(MAKE) install
cd vowpalwabbit; cp $(BINARIES) /usr/local/bin; cd ../cluster; $(MAKE) install; cd ../java; $(MAKE) install;

doc:
(cd doc && doxygen Doxyfile)
Expand All @@ -147,8 +145,6 @@ clean:
cd cluster && $(MAKE) clean
cd library && $(MAKE) clean
cd python && $(MAKE) clean
ifneq ($(JAVA_HOME),)
cd java && $(MAKE) clean
endif

.PHONY: all clean install doc
24 changes: 16 additions & 8 deletions java/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
ifeq ($(JAVA_HOME),)
$(warning No JAVA_HOME found, JNI building will fail. Please set JAVA_HOME when using JNI)
exit 1
endif

VWLIBS := -L../vowpalwabbit -l vw
STDLIBS = $(BOOST_LIBRARY) $(LIBS)
JAVA_INCLUDE = -I $(JAVA_HOME)/include
LIBRARY_NAME = vw_jni

ifeq ($(UNAME), Linux)
JAVA_INCLUDE += -I $(JAVA_HOME)/include/linux
SHARED_LIBRARY = lib$(LIBRARY_NAME).so
INSTALL_PATH = /usr/lib
endif
ifeq ($(UNAME), FreeBSD)
JAVA_INCLUDE += -I $(JAVA_HOME)/include/linux
SHARED_LIBRARY = lib$(LIBRARY_NAME).so
INSTALL_PATH = /usr/lib
endif
ifeq "CYGWIN" "$(findstring CYGWIN,$(UNAME))"
JAVA_INCLUDE += -I $(JAVA_HOME)/include/linux
SHARED_LIBRARY = lib$(LIBRARY_NAME).so
INSTALL_PATH = /usr/lib
endif
ifeq ($(UNAME), Darwin)
JAVA_INCLUDE += -I $(JAVA_HOME)/include/darwin
SHARED_LIBRARY = lib$(LIBRARY_NAME).dylib
INSTALL_PATH = /Library/Java/Extensions
endif

LOCAL_LIBRARY = target/$(SHARED_LIBRARY)
jni_SRCS = $(shell find src/main/c++ -name "*.cc")
jni_OBJS = $(jni_SRCS:.cc=.o)

Expand All @@ -29,14 +34,14 @@ all:
test:
cd ..; $(MAKE) test

things: pom_version target/vw_jni.lib
things: pom_version $(LOCAL_LIBRARY)

pom_version: pom.xml
ver=$$(grep AC_INIT ../configure.ac | cut -d '[' -f 3 | cut -d ']' -f 1) && \
newVer=$$(perl -e "@a=split('\.', '$$ver'); \$$a[2]++; print(join('.', @a))") && \
perl -pi -e "s/(\s*)<version>.*-SNAPSHOT/\1<version>$$newVer-SNAPSHOT/" pom.xml

target/vw_jni.lib: $(jni_OBJS) ../vowpalwabbit/main.o ../vowpalwabbit/libvw.a ../vowpalwabbit/liballreduce.a
$(LOCAL_LIBRARY): $(jni_OBJS) ../vowpalwabbit/main.o ../vowpalwabbit/libvw.a ../vowpalwabbit/liballreduce.a
mkdir -p target;
$(CXX) -shared $(FLAGS) -o $@ $^ $(VWLIBS) $(STDLIBS) $(JAVA_INCLUDE)

Expand All @@ -48,7 +53,10 @@ target/vw_jni.lib: $(jni_OBJS) ../vowpalwabbit/main.o ../vowpalwabbit/libvw.a ..

-include $(jni_SRCS:.cc=.o)

install: $(LOCAL_LIBRARY)
cp $(LOCAL_LIBRARY) $(INSTALL_PATH);

.PHONY: clean
clean:
rm -f target/vw_jni.lib
rm -f $(LOCAL_LIBRARY)
rm -f $(jni_SRCS:.cc=.o)
31 changes: 17 additions & 14 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.johnlangford</groupId>
<artifactId>vw-jni</artifactId>
<version>8.3.3-SNAPSHOT</version>
<version>8.3.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Vowpal Wabbit JNI Layer</name>
<description>
Expand Down Expand Up @@ -155,6 +155,8 @@
</executions>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<forkMode>once</forkMode>
<argLine>-Djava.library.path=${project.build.directory}</argLine>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -205,6 +207,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand All @@ -219,22 +234,10 @@
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
171 changes: 0 additions & 171 deletions java/src/main/bin/build.sh

This file was deleted.

60 changes: 0 additions & 60 deletions java/src/main/bin/release.sh

This file was deleted.

4 changes: 4 additions & 0 deletions java/src/main/java/vowpalWabbit/VW.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import vowpalWabbit.learner.VWLearners;

public final class VW {
static {
System.loadLibrary("vw_jni");
}

/**
* Should not be directly instantiated.
*/
Expand Down
Loading