mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
Bug 521515: Generate JNI header files as part of build
Also generate JNI header for serial component. This component does not really need it since the implementation is in one file only, but this would at least throw an error if the java part changes and the native part is not updated accordingly. Change-Id: Id598410c322580bdda37c905ed08627390c913ba Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
This commit is contained in:
parent
7120731766
commit
a025f75771
7 changed files with 118 additions and 19 deletions
11
README.md
11
README.md
|
@ -78,8 +78,9 @@ mvn generate-resources -DuseSimrelRepo -f build/org.eclipse.cdt.autotools.docs -
|
|||
|
||||
#### jniheaders
|
||||
|
||||
The `jniheaders` profile can be used on the core/org.eclipse.cdt.core.native to rebuild the
|
||||
header files for JNI natives. See also `native` property below.
|
||||
The `jniheaders` profile can be used on the core/org.eclipse.cdt.core.native and
|
||||
native/org.eclipse.cdt.native.serial to rebuild the header files for JNI natives.
|
||||
See also `native` property below.
|
||||
|
||||
### Properties
|
||||
|
||||
|
@ -114,14 +115,14 @@ For running CDT's DSF-GDB tests, this specifies the executable names of the gdbs
|
|||
|
||||
The `native` property can be used to build the native libraries. Defining the `native` property will activate profiles to add the extra steps to compile the natives libraries used by CDT. The main CDT build by default will not build the libraries, but instead use the versions of the libraries checked into git. Therefore when users modify the sources of the native libraries, they have to build and commit the changed library binaries as part of the commit.
|
||||
|
||||
The releng/scripts/check_code_cleanliness.sh, which is run on the build machine as part of the gerrit and main build flows, will ensure that the libraries that are checked in are indeed up to date with their sources. (*This is only supported for serial library at the time of writing, see [Bug 521515](https://bugs.eclipse.org/bugs/show_bug.cgi?id=521515) to track current state.)
|
||||
The `releng/scripts/check_code_cleanliness.sh`, which is run on the build machine as part of the gerrit and main build flows, will ensure that the libraries that are checked in are indeed up to date with their sources.
|
||||
|
||||
The `native` property can be one of the following:
|
||||
|
||||
- `linux.x86_64` - uses local tools and builds only linux.x86_64 libraries
|
||||
- `linux.ppc64le` - uses local tools and builds only linux.ppc64le libraries
|
||||
- `docker` - uses CDT's docker releng images to do the native builds for all platforms (*This is only supported for serial library at the time of writing, see [Bug 521515](https://bugs.eclipse.org/bugs/show_bug.cgi?id=521515) to track current state.)
|
||||
- `all` - uses local tools to do the native builds for all platforms (*This is only supported for serial library at the time of writing, see [Bug 521515](https://bugs.eclipse.org/bugs/show_bug.cgi?id=521515) to track current state.)
|
||||
- `docker` - uses CDT's docker releng images to do the native builds for all platforms
|
||||
- `all` - uses local tools to do the native builds for all platforms
|
||||
|
||||
Therefore to build all the natives using docker do `mvn process-resources -Dnative=docker`.
|
||||
|
||||
|
|
|
@ -52,20 +52,20 @@ rebuild: clean all
|
|||
# most recent git commit in this directory.
|
||||
$(OS_DIR)/win32/x86_64/serial.dll: serial.c
|
||||
mkdir -p $(dir $@)
|
||||
SOURCE_DATE_EPOCH=$(shell git log -1 --pretty=format:%ct -- .) x86_64-w64-mingw32-gcc -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" -shared -o $@ serial.c
|
||||
SOURCE_DATE_EPOCH=$(shell git log -1 --pretty=format:%ct -- .) x86_64-w64-mingw32-gcc -Iinclude -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/win32" -shared -o $@ serial.c
|
||||
|
||||
$(OS_DIR)/linux/x86_64/libserial.so: serial.c
|
||||
mkdir -p $(dir $@)
|
||||
gcc -m64 $(CFLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(LDFLAGS) -shared -o $@ serial.c
|
||||
gcc -m64 $(CFLAGS) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(LDFLAGS) -shared -o $@ serial.c
|
||||
|
||||
$(OS_DIR)/linux/aarch64/libserial.so: serial.c
|
||||
mkdir -p $(dir $@)
|
||||
aarch64-linux-gnu-gcc $(CFLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(LDFLAGS) -shared -o $@ serial.c
|
||||
aarch64-linux-gnu-gcc $(CFLAGS) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(LDFLAGS) -shared -o $@ serial.c
|
||||
|
||||
$(OS_DIR)/linux/ppc64le/libserial.so: serial.c
|
||||
mkdir -p $(dir $@)
|
||||
gcc -m64 -mcpu=power8 $(CFLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(LDFLAGS) -shared -o $@ serial.c
|
||||
gcc -m64 -mcpu=power8 $(CFLAGS) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(LDFLAGS) -shared -o $@ serial.c
|
||||
|
||||
$(OS_DIR)/macosx/x86_64/libserial.jnilib: serial.c
|
||||
mkdir -p $(dir $@)
|
||||
x86_64-apple-darwin17-clang $(CFLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin $(LDFLAGS) -dynamiclib -o $@ serial.c
|
||||
x86_64-apple-darwin17-clang $(CFLAGS) -Iinclude -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin $(LDFLAGS) -dynamiclib -o $@ serial.c
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_eclipse_cdt_serial_SerialPort */
|
||||
|
||||
#ifndef _Included_org_eclipse_cdt_serial_SerialPort
|
||||
#define _Included_org_eclipse_cdt_serial_SerialPort
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: open0
|
||||
* Signature: (Ljava/lang/String;IIII)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_eclipse_cdt_serial_SerialPort_open0
|
||||
(JNIEnv *, jobject, jstring, jint, jint, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: close0
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_close0
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: read1
|
||||
* Signature: (J[BII)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_serial_SerialPort_read1
|
||||
(JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: available0
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_serial_SerialPort_available0
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: write0
|
||||
* Signature: (JI)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_write0
|
||||
(JNIEnv *, jobject, jlong, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: write1
|
||||
* Signature: (J[BII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_eclipse_cdt_serial_SerialPort_write1
|
||||
(JNIEnv *, jobject, jlong, jbyteArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_serial_SerialPort
|
||||
* Method: getPortName
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_serial_SerialPort_getPortName
|
||||
(JNIEnv *, jclass, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -36,6 +36,7 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
#include <jni.h>
|
||||
#include <org_eclipse_cdt_serial_SerialPort.h>
|
||||
|
||||
#define FUNC(x) Java_org_eclipse_cdt_serial_SerialPort_ ## x
|
||||
|
||||
|
|
Binary file not shown.
|
@ -198,5 +198,34 @@
|
|||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jniheaders</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>headers</id>
|
||||
<phase>process-resources</phase>
|
||||
<configuration>
|
||||
<compilerArgs>
|
||||
<arg>-h</arg>
|
||||
<arg>${project.basedir}/native_src/include</arg>
|
||||
</compilerArgs>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
|
@ -105,18 +105,17 @@ done
|
|||
##
|
||||
# Make sure that natives are up to date
|
||||
##
|
||||
for p in native/org.eclipse.cdt.native.serial core/org.eclipse.cdt.core.native; do
|
||||
echo "Rebuilding $p JNI headers to make sure they match source"
|
||||
logfile=jni-headers-${p//\//-}.log
|
||||
if ! ${MVN:-mvn} -B -V process-resources -DuseSimrelRepo -P jniheaders -f $p >${logfile} 2>&1; then
|
||||
echo "Rebuilding of $p JNI headers failed. The log (${logfile}) is part of the artifacts of the build"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Rebuilding JNI headers to make sure they match source"
|
||||
logfile=jni-header.log
|
||||
if ! ${MVN:-mvn} -B -V process-resources -DuseSimrelRepo -P jniheaders -f core/org.eclipse.cdt.core.native >${logfile} 2>&1; then
|
||||
echo "Rebuilding of JNI headers failed. The log (${logfile}) is part of the artifacts of the build"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for p in native/org.eclipse.cdt.native.serial/native_src core/org.eclipse.cdt.core.native/native_src; do
|
||||
echo "Rebuilding $p natives to make sure they match source"
|
||||
logfile=make-natives-${p//\//-}.log
|
||||
if ! make -C $p rebuild >${logfile} 2>&1; then
|
||||
if ! make -C $p/native_src rebuild >${logfile} 2>&1; then
|
||||
echo "Rebuilding of $p natives failed. The log (${logfile}) is part of the artifacts of the build"
|
||||
exit 1
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue