mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Bug 521515: [releng] Build o.e.cdt.native.serial natives using docker
Steps: 1. Edit and commit change 2. docker run --rm -it -v $(git rev-parse --show-toplevel):/work -w /work/$(git rev-parse --show-prefix) quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest make -C jni rebuild 3. GIT_COMMITTER_DATE=$(git log -1 --pretty=format:%cI -- .) git commit --amend -a --reuse-message=HEAD Change-Id: I9d9a576fd2eb1c5edd874098d08564ecdfa6ba09
This commit is contained in:
parent
412d926a24
commit
29369a555c
9 changed files with 116 additions and 8 deletions
4
.gitattributes
vendored
4
.gitattributes
vendored
|
@ -45,12 +45,12 @@ Makefile text
|
|||
# (These should not normally be checked in, exceptions for pre-compiled libraries and tests)
|
||||
*.o binary
|
||||
*.d text
|
||||
*.dll binary
|
||||
*.dll binary diff=dll
|
||||
*.a binary
|
||||
*.exe binary
|
||||
*.out binary
|
||||
*.app binary
|
||||
*.jnilib binary
|
||||
*.jnilib binary diff=hex
|
||||
*.so binary
|
||||
|
||||
# Web/Javascript/Node
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Serial Port
|
||||
Bundle-SymbolicName: org.eclipse.cdt.native.serial
|
||||
Bundle-Version: 1.1.200.qualifier
|
||||
Bundle-Version: 1.1.300.qualifier
|
||||
Bundle-Vendor: Eclipse CDT
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Export-Package: org.eclipse.cdt.serial
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#*******************************************************************************
|
||||
# Copyright (c) 2002, 2009 QNX Software Systems and others.
|
||||
# Copyright (c) 2002, 2019 QNX Software Systems and others.
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -25,7 +25,8 @@ UNAME = $(shell uname)
|
|||
ifeq ($(UNAME),Linux)
|
||||
LIBS = \
|
||||
$(OS_DIR)/win32/x86_64/serial.dll \
|
||||
$(OS_DIR)/linux/x86_64/libserial.so
|
||||
$(OS_DIR)/linux/x86_64/libserial.so \
|
||||
$(OS_DIR)/macosx/x86_64/libserial.jnilib
|
||||
else
|
||||
ifeq ($(UNAME),Darwin)
|
||||
LIBS = \
|
||||
|
@ -43,9 +44,14 @@ clean :
|
|||
|
||||
rebuild: clean all
|
||||
|
||||
# Windows DLLs have a build timestamp in them. This makes it impossible to have reproducible builds.
|
||||
# However, x86_64-w64-mingw32-ld on Debian/Ubuntu has a patch that overrides the current date
|
||||
# using the SOURCE_DATE_EPOCH environment variable. Therefore we set SOURCE_DATE_EPOCH to a
|
||||
# consistent timestamp that can be reproduced. We base it off of the commit timestamp of the
|
||||
# most recent git commit in this directory.
|
||||
$(OS_DIR)/win32/x86_64/serial.dll: serial.c
|
||||
mkdir -p $(dir $@)
|
||||
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 -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 $@)
|
||||
|
@ -57,4 +63,4 @@ $(OS_DIR)/linux/ppc64le/libserial.so: serial.c
|
|||
|
||||
$(OS_DIR)/macosx/x86_64/libserial.jnilib: serial.c
|
||||
mkdir -p $(dir $@)
|
||||
clang $(CFLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin $(LDFLAGS) -dynamiclib -o $@ serial.c
|
||||
x86_64-apple-darwin17-clang $(CFLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin $(LDFLAGS) -dynamiclib -o $@ serial.c
|
||||
|
|
21
native/org.eclipse.cdt.native.serial/jni/Readme.md
Normal file
21
native/org.eclipse.cdt.native.serial/jni/Readme.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
### How to rebuild natives.
|
||||
|
||||
The goal of these instructions is to have a cross-platform build of the natives in CDT. Using tools in CDT's
|
||||
[docker](https://github.com/eclipse-cdt/cdt-infra/blob/master/docker/cdt-infra-eclipse-full/ubuntu-18.04/Dockerfile) build image
|
||||
(quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest).
|
||||
|
||||
It is fairly straightforward to biuild the natives, run this command:
|
||||
|
||||
```
|
||||
docker run --rm -it -v $(git rev-parse --show-toplevel):/work -w /work/$(git rev-parse --show-prefix) quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest make -C jni rebuild
|
||||
```
|
||||
|
||||
However, the challenge is that dll files on Windows have a timestamp in them. To have reproducible builds, we need to have a reproducible
|
||||
timestamp. Therefore we use the commit time of the commit to derive a timestamp (See the Makefile for more info). Because we want
|
||||
to keep the DLL checked in so that contributors don't need to rebuild it all the time we need a way to have to check in the dll with
|
||||
the same commit time. To do this we use GIT_COMMITTER_DATE. So, after editing and committing your change, you need to rebuild one last
|
||||
time with the commit date and the commit it without changing the commit date again using:
|
||||
|
||||
```
|
||||
GIT_COMMITTER_DATE=$(git log -1 --pretty=format:%cI -- .) git commit --amend -a --reuse-message=HEAD
|
||||
```
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -23,11 +23,87 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>1.1.200-SNAPSHOT</version>
|
||||
<version>1.1.300-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.native.serial</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>build-native.all</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>native</name>
|
||||
<value>all</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>natives</id>
|
||||
<phase>process-resources</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<exec executable="make" newenvironment="false" failOnError="true" dir="./jni">
|
||||
<arg value="rebuild" />
|
||||
</exec>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>build-native.docker</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>native</name>
|
||||
<value>docker</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>natives</id>
|
||||
<phase>process-resources</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<exec executable="docker" newenvironment="false" failOnError="true">
|
||||
<!-- docker run -\-rm -t -v $(git rev-parse -\-show-toplevel):/work -w /work/$(git rev-parse -\-show-prefix) quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest make -C jni rebuild -->
|
||||
<arg value="run" />
|
||||
<arg value="--rm" />
|
||||
<arg value="-t" />
|
||||
<arg value="-v" />
|
||||
<arg value="${project.basedir}/../..:/work" />
|
||||
<arg value="-w" />
|
||||
<arg value="/work/native/org.eclipse.cdt.native.serial" />
|
||||
<arg value="quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest" />
|
||||
<arg value="make" />
|
||||
<arg value="-C" />
|
||||
<arg value="jni" />
|
||||
<arg value="rebuild" />
|
||||
</exec>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>build-native.linux.x86_64</id>
|
||||
<activation>
|
||||
|
|
|
@ -83,6 +83,11 @@ git ls-files -- \*\*/.project ':!core/org.eclipse.cdt.core/.project' | while re
|
|||
fi
|
||||
done
|
||||
|
||||
##
|
||||
# Make sure that natives are up to date
|
||||
##
|
||||
make -C native/org.eclipse.cdt.native.serial/jni rebuild
|
||||
|
||||
##
|
||||
# Check that none of the above caused any changes
|
||||
##
|
||||
|
|
Loading…
Add table
Reference in a new issue