Skip to content

Commit

Permalink
Remove javah support (#10104)
Browse files Browse the repository at this point in the history
* Remove javah support

* Remove unused compiler option

* Osx pom.xml update
  • Loading branch information
argrento authored Feb 3, 2022
1 parent f929b0f commit 9518b7e
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 45 deletions.
3 changes: 2 additions & 1 deletion apps/android_camera/app/src/main/jni/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ set -x
PATH="$PATH:/usr/local/bin"
CURR_DIR=$(cd `dirname $0`; pwd)
ROOT_DIR="$CURR_DIR/../../../../../.."
javah -o $CURR_DIR/org_apache_tvm_native_c_api.h -cp "$ROOT_DIR/jvm/core/target/*" org.apache.tvm.LibInfo || exit -1
javac -h $CURR_DIR -classpath "$ROOT_DIR/jvm/core/target/*" $ROOT_DIR/jvm/core/src/main/java/org/apache/tvm/LibInfo.java || exit -1
mv $CURR_DIR/org_apache_tvm_LibInfo.h $CURR_DIR/org_apache_tvm_native_c_api.h
cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc $CURR_DIR/ || exit -1
cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ || exit -1
rm -rf $CURR_DIR/../libs
Expand Down
3 changes: 2 additions & 1 deletion apps/android_deploy/app/src/main/jni/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
PATH="$PATH:/usr/local/bin"
CURR_DIR=$(cd `dirname $0`; pwd)
ROOT_DIR="$CURR_DIR/../../../../../.."
javah -o $CURR_DIR/org_apache_tvm_native_c_api.h -cp "$ROOT_DIR/jvm/core/target/*" org.apache.tvm.LibInfo || exit -1
javac -h $CURR_DIR -classpath "$ROOT_DIR/jvm/core/target/*" $ROOT_DIR/jvm/core/src/main/java/org/apache/tvm/LibInfo.java || exit -1
mv $CURR_DIR/org_apache_tvm_LibInfo.h $CURR_DIR/org_apache_tvm_native_c_api.h
cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc $CURR_DIR/ || exit -1
cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ || exit -1
rm -rf $CURR_DIR/../libs
Expand Down
3 changes: 2 additions & 1 deletion apps/android_rpc/app/src/main/jni/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
PATH="$PATH:/usr/local/bin"
CURR_DIR=$(cd `dirname $0`; pwd)
ROOT_DIR="$CURR_DIR/../../../../../.."
javah -o $CURR_DIR/org_apache_tvm_native_c_api.h -cp "$ROOT_DIR/jvm/core/target/*" org.apache.tvm.LibInfo || exit -1
javac -h $CURR_DIR -classpath "$ROOT_DIR/jvm/core/target/*" $ROOT_DIR/jvm/core/src/main/java/org/apache/tvm/LibInfo.java || exit -1
mv $CURR_DIR/org_apache_tvm_LibInfo.h $CURR_DIR/org_apache_tvm_native_c_api.h
cp -f $ROOT_DIR/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc $CURR_DIR/ || exit -1
cp -f $ROOT_DIR/jvm/native/src/main/native/jni_helper_func.h $CURR_DIR/ || exit -1
rm -rf $CURR_DIR/../libs
Expand Down
65 changes: 44 additions & 21 deletions jvm/native/linux-x86_64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,59 @@ under the License.
</dependencies>

<build>
<sourceDirectory>${basedir}/../../core/src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>header-generation</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-h</arg>
<arg>${basedir}/generated</arg>
<arg>-classpath</arg>
<arg>${project.build.directory}/classes:${project.build.directory}/../../../core/tvm4j-core-0.0.1-SNAPSHOT.jar</arg>/
</compilerArgs>
<includes>
<include>org/apache/tvm/LibInfo.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>

<!-- Rename and move generated 'org_apache_tvm_LibInfo.h' to 'org_apache_tvm_native_c_api.h'-->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy-header</id>
<phase>process-sources</phase>
<configuration>
<target>
<copy file="${basedir}/generated/org_apache_tvm_LibInfo.h"
tofile="${basedir}/../src/main/native/org_apache_tvm_native_c_api.h" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<!-- trigger javah -->
<javahOS>linux</javahOS>
<compilerProvider>generic-classic</compilerProvider>
<compilerExecutable>${cxx}</compilerExecutable>
Expand All @@ -77,6 +118,8 @@ under the License.
</compilerStartOptions>
<compilerEndOptions>
<compilerEndOption>-I../../../include</compilerEndOption>
<compilerEndOption>-I${JAVA_HOME}/include</compilerEndOption>
<compilerEndOption>-I${JAVA_HOME}/include/linux</compilerEndOption>
<compilerEndOption>${cflags}</compilerEndOption>
</compilerEndOptions>
<linkerStartOptions>
Expand All @@ -86,26 +129,6 @@ under the License.
<linkerEndOption>${ldflags}</linkerEndOption>
</linkerEndOptions>
</configuration>

<executions>
<execution>
<id>javah</id>
<phase>generate-sources</phase>
<configuration>
<javahOS>linux</javahOS>
<javahProvider>default</javahProvider>
<javahOutputDirectory>${project.build.directory}/custom-javah</javahOutputDirectory>
<workingDirectory>${basedir}</workingDirectory>
<javahOutputFileName>org_apache_tvm_native_c_api.h</javahOutputFileName>
<javahClassNames>
<javahClassName>org.apache.tvm.LibInfo</javahClassName>
</javahClassNames>
</configuration>
<goals>
<goal>javah</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
64 changes: 44 additions & 20 deletions jvm/native/osx-x86_64/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,52 @@ under the License.
</dependencies>

<build>
<sourceDirectory>${basedir}/../../core/src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>header-generation</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-h</arg>
<arg>${basedir}/generated</arg>
<arg>-classpath</arg>
<arg>${project.build.directory}/classes:${project.build.directory}/../../../core/tvm4j-core-0.0.1-SNAPSHOT.jar</arg>/
</compilerArgs>
<includes>
<include>org/apache/tvm/LibInfo.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>

<!-- Rename and move generated 'org_apache_tvm_LibInfo.h' to 'org_apache_tvm_native_c_api.h'-->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy-header</id>
<phase>process-sources</phase>
<configuration>
<target>
<copy file="${basedir}/generated/org_apache_tvm_LibInfo.h"
tofile="${basedir}/../src/main/native/org_apache_tvm_native_c_api.h" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
Expand All @@ -77,6 +119,8 @@ under the License.
</compilerStartOptions>
<compilerEndOptions>
<compilerEndOption>-I../../../include</compilerEndOption>
<compilerEndOption>-I${JAVA_HOME}/include</compilerEndOption>
<compilerEndOption>-I${JAVA_HOME}/include/linux</compilerEndOption
<compilerEndOption>${cflags}</compilerEndOption>
</compilerEndOptions>
<linkerStartOptions>
Expand All @@ -92,26 +136,6 @@ under the License.
<linkerEndOption>${ldflags}</linkerEndOption>
</linkerEndOptions>
</configuration>

<executions>
<execution>
<id>javah</id>
<phase>generate-sources</phase>
<configuration>
<javahOS>darwin</javahOS>
<javahProvider>default</javahProvider>
<javahOutputDirectory>${project.build.directory}/custom-javah</javahOutputDirectory>
<workingDirectory>${basedir}</workingDirectory>
<javahOutputFileName>org_apache_tvm_native_c_api.h</javahOutputFileName>
<javahClassNames>
<javahClassName>org.apache.tvm.LibInfo</javahClassName>
</javahClassNames>
</configuration>
<goals>
<goal>javah</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion jvm/native/src/main/native/org_apache_tvm_native_c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* \file org_apache_tvm_native_c_api.cc
* \brief tvm4j jni source file
*/
#include "org_apache_tvm_native_c_api.h" // generated by javah
#include "org_apache_tvm_native_c_api.h" // generated by javac
#ifdef TVM4J_ANDROID
#include "tvm_runtime.h"
#else
Expand Down

0 comments on commit 9518b7e

Please sign in to comment.