diff --git a/.gitattributes b/.gitattributes index 195fe440a7f..2ff4f62ad07 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF b/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF index 1a90e5ed722..9347970cf04 100644 --- a/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF +++ b/native/org.eclipse.cdt.native.serial/META-INF/MANIFEST.MF @@ -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 diff --git a/native/org.eclipse.cdt.native.serial/jni/Makefile b/native/org.eclipse.cdt.native.serial/jni/Makefile index 8c07bd926e2..72c59e6e8ac 100644 --- a/native/org.eclipse.cdt.native.serial/jni/Makefile +++ b/native/org.eclipse.cdt.native.serial/jni/Makefile @@ -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 diff --git a/native/org.eclipse.cdt.native.serial/jni/Readme.md b/native/org.eclipse.cdt.native.serial/jni/Readme.md new file mode 100644 index 00000000000..9e8d9f663bd --- /dev/null +++ b/native/org.eclipse.cdt.native.serial/jni/Readme.md @@ -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 +``` diff --git a/native/org.eclipse.cdt.native.serial/os/linux/x86_64/libserial.so b/native/org.eclipse.cdt.native.serial/os/linux/x86_64/libserial.so index 268ae8165e2..274eab0d844 100755 Binary files a/native/org.eclipse.cdt.native.serial/os/linux/x86_64/libserial.so and b/native/org.eclipse.cdt.native.serial/os/linux/x86_64/libserial.so differ diff --git a/native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib b/native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib index 4676dd78dd2..26ce721366e 100755 Binary files a/native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib and b/native/org.eclipse.cdt.native.serial/os/macosx/x86_64/libserial.jnilib differ diff --git a/native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll b/native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll index e1c1019bfa5..d33554a6afd 100755 Binary files a/native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll and b/native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll differ diff --git a/native/org.eclipse.cdt.native.serial/pom.xml b/native/org.eclipse.cdt.native.serial/pom.xml index d6db49c7dae..de6ac78ae72 100644 --- a/native/org.eclipse.cdt.native.serial/pom.xml +++ b/native/org.eclipse.cdt.native.serial/pom.xml @@ -23,11 +23,87 @@ ../../pom.xml - 1.1.200-SNAPSHOT + 1.1.300-SNAPSHOT org.eclipse.cdt.native.serial eclipse-plugin + + build-native.all + + + native + all + + + + + + maven-antrun-plugin + + + natives + process-resources + + + + + + + + + run + + + + + + + + + build-native.docker + + + native + docker + + + + + + maven-antrun-plugin + + + natives + process-resources + + + + + + + + + + + + + + + + + + + + + run + + + + + + + build-native.linux.x86_64 diff --git a/releng/scripts/check_code_cleanliness.sh b/releng/scripts/check_code_cleanliness.sh index 306d74fe744..d71d05d6c64 100755 --- a/releng/scripts/check_code_cleanliness.sh +++ b/releng/scripts/check_code_cleanliness.sh @@ -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 ##