Repository navigation
Prevent invalid releases - additional tests #215
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,18 @@ | ||
| <project default="gather-props"> | ||
| <project default="gather-props" xmlns:if="ant:if"> | ||
| <!-- Properties for export to maven --> | ||
| <target name="gather-props" depends="main-props,msvc-props,xcode-props,gcc-props,unset-props,test-props"> | ||
| <target name="gather-props" depends="main-props,msvc-props,xcode-props,gcc-props,unset-props,ident-props,test-props"> | ||
| <propertyfile file="${ant.properties.file}"> | ||
| <entry key="cmake.generator.nativelibdir" value="${cmake.generator.nativelibdir}"/> | ||
| <entry key="cmake.generator.arg" value="${cmake.generator.arg}"/> | ||
| <entry key="cmake.build.arg" value="${cmake.build.arg}"/> | ||
| <entry key="maven.nativelibdir.path" value="${maven.nativelibdir.path}"/> | ||
| <entry key="maven.assembly.id" value="${maven.assembly.id}"/> | ||
| <entry key="maven.test.skip" value="${maven.test.skip}"/> | ||
| <entry key="maven.include.tests" value="${maven.include.tests}"/> | ||
| <entry key="maven.exclude.tests" value="${maven.exclude.tests}"/> | ||
| <entry key="jssc.native.version" value="${jssc.native.version}"/> | ||
| <entry key="jssc.build.rev" value="${jssc.build.rev}"/> | ||
| <entry key="jssc.build.origin" value="${jssc.build.origin}"/> | ||
| </propertyfile> | ||
| </target> | ||
|
|
||
|
|
@@ -159,8 +163,15 @@ | |
| <equals arg1="${os.target.arch}" arg2="arm_32"/> | ||
| </condition> | ||
|
|
||
| <!-- SDK from env CMAKE_OSX_SYSROOT, if set. Not SDKROOT: the xcrun shims (make, c++) read it too, | ||
| and newer Xcodes cannot resolve old SDKs --> | ||
| <property environment="env"/> | ||
| <condition property="xcode.sysroot.arg" value="-DCMAKE_OSX_SYSROOT="${env.CMAKE_OSX_SYSROOT}"" else=""> | ||
| <isset property="env.CMAKE_OSX_SYSROOT"/> | ||
| </condition> | ||
|
|
||
| <!-- Set cmake property "CMAKE_OSX_ARCHITECTURES" --> | ||
| <property name="cmake.generator.arg" value="-DCMAKE_OSX_ARCHITECTURES=${xcode.arch}"/> | ||
| <property name="cmake.generator.arg" value="-DCMAKE_OSX_ARCHITECTURES=${xcode.arch} ${xcode.sysroot.arg}"/> | ||
| </target> | ||
|
|
||
| <target name="gcc-props" if="use.gcc"> | ||
|
|
@@ -192,17 +203,23 @@ | |
| <property description="fallback value" name="cmake.generator.nativelibdir" value=""/> | ||
| </target> | ||
|
|
||
| <target name="ident-props"> | ||
| <!-- Build ident: blank lets CMake take the revision from git and set origin "local" --> | ||
| <property description="fallback value" name="jssc.build.rev" value=""/> | ||
| <property description="fallback value" name="jssc.build.origin" value=""/> | ||
| <!-- Native version: jssc.native.version if given, else project.version, | ||
| without its qualifier if jssc.native.release=true --> | ||
| <condition property="jssc.native.version" value="${release.version}" else="${project.version}"> | ||
| <istrue value="${jssc.native.release}"/> | ||
| </condition> | ||
| </target> | ||
|
|
||
| <target name="test-props"> | ||
| <!-- Calculate if tests will run --> | ||
| <condition property="maven.test.skip" value="false" else="true"> | ||
| <!-- Honor existing flag if set --> | ||
| <and> | ||
| <not> | ||
| <isset property="maven.test.skip"/> | ||
| </not> | ||
| <!-- Run tests if detected system matches target system --> | ||
| <equals arg1="${os.target.classifier}" arg2="${os.detected.classifier}"/> | ||
| </and> | ||
| <!-- Tests run unless maven.test.skip or skipTests is set --> | ||
| <property name="maven.test.skip" value="false"/> | ||
| <!-- All tests if host matches target; otherwise only NativeIdentTest, which reads the library without loading it --> | ||
| <condition property="maven.include.tests" value="**/*Test.java" else="**/NativeIdentTest.java"> | ||
| <equals arg1="${os.target.classifier}" arg2="${os.detected.classifier}"/> | ||
| </condition> | ||
|
|
||
| <!-- Skip ManualBootLibraryPathTest test if we're not building a native lib --> | ||
|
|
@@ -211,14 +228,20 @@ | |
| </condition> | ||
|
|
||
| <!-- Summarize host/target --> | ||
| <echo level="info">Tests will run only if the TARGET and HOST match:${line.separator}${line.separator}</echo> | ||
| <echo level="info">All tests will run only if the TARGET and HOST match:${line.separator}${line.separator}</echo> | ||
| <echo level="info">TARGET: ${os.target.classifier}</echo> | ||
| <echo level="info">DETECTED: ${os.detected.classifier}</echo> | ||
| <echo level="info"/> | ||
|
|
||
| <!-- Negate result for human readability --> | ||
| <condition property="maven.test.message" value="Tests will NOT run" else="Tests WILL run"> | ||
| <equals arg1="${maven.test.skip}" arg2="true"/> | ||
| <condition property="maven.test.message" value="Tests will NOT run"> | ||
| <or> | ||
| <istrue value="${maven.test.skip}"/> | ||
| <istrue value="${skipTests}"/> | ||
| </or> | ||
| </condition> | ||
| <condition property="maven.test.message" value="Tests WILL run" else="Only NativeIdentTest will run"> | ||
| <equals arg1="${maven.include.tests}" arg2="**/*Test.java"/> | ||
| </condition> | ||
| <echo level="info">===== ${maven.test.message} =====</echo> | ||
| <echo level="info"/> | ||
|
|
@@ -258,15 +281,7 @@ | |
| <echo level="info"></echo> | ||
| </target> | ||
|
|
||
| <target name="cmake-generate"> | ||
| <!-- Build ident: blank lets CMake take the revision from git and say "local" (cross-compile.yml sets both) --> | ||
| <property description="fallback value" name="jssc.build.rev" value=""/> | ||
| <property description="fallback value" name="jssc.build.origin" value=""/> | ||
| <!-- Native version defaults to the pom version as is, unless jssc.native.version is given | ||
| or jssc.native.release=true is set which drops the qualifier (used in cross-compilation ahead of release) --> | ||
| <condition property="jssc.native.version" value="${release.version}" else="${project.version}"> | ||
| <istrue value="${jssc.native.release}"/> | ||
| </condition> | ||
| <target name="cmake-generate" depends="ident-props"> | ||
| <mkdir dir="${cmake.generated.directory}"/> | ||
| <exec executable="cmake" dir="${cmake.generated.directory}" failonerror="true"> | ||
| <arg line="${ant.project.basedir}"/> | ||
|
|
@@ -292,6 +307,32 @@ | |
| <copy todir="${cmake.generated.directory}" flatten="true" overwrite="true" verbose="true" failonerror="false" quiet="true"> | ||
| <fileset dir="${cmake.generated.directory}/../nar/" includes="**/*.h"/> | ||
| </copy> | ||
| <!-- The committed JNI header follows the generated one, so a JNI change is a change in src/main/cpp. | ||
| Unlike the natives, the build writes it to the source tree: it is a source, and CI fails when a build | ||
| changed it (build.yml), so an updated header can't be left out of a commit --> | ||
| <property name="jni.header.generated" location="${cmake.generated.directory}/jssc_SerialNativeInterface.h"/> | ||
| <property name="jni.header.committed" location="${ant.project.basedir}/src/main/cpp/jssc_SerialNativeInterface.h"/> | ||
| <fail message="No JNI header was generated at ${jni.header.generated}"> | ||
| <condition> | ||
| <not><available file="${jni.header.generated}"/></not> | ||
| </condition> | ||
| </fail> | ||
| <!-- The header as it is committed, the same on every OS and JDK: javac on Windows writes long constants | ||
| with MSVC's i64 suffix, which GCC and Clang reject, so they get LL as elsewhere --> | ||
| <property name="jni.header.expected" location="${cmake.generated.directory}/committed/jssc_SerialNativeInterface.h"/> | ||
| <copy file="${jni.header.generated}" tofile="${jni.header.expected}" overwrite="true"> | ||
| <filterchain> | ||
| <fixcrlf eol="lf"/> | ||
| <tokenfilter><replaceregex pattern="^(#define \S+ -?[0-9]+)i64$" replace="\1LL"/></tokenfilter> | ||
| </filterchain> | ||
| </copy> | ||
| <!-- Line endings don't count, so a checkout with CRLF is left alone --> | ||
| <condition property="jni.header.outdated"> | ||
| <not><filesmatch file1="${jni.header.expected}" file2="${jni.header.committed}" textfile="true"/></not> | ||
| </condition> | ||
| <copy if:set="jni.header.outdated" file="${jni.header.expected}" tofile="${jni.header.committed}" overwrite="true"/> | ||
| <echo if:set="jni.header.outdated" level="warning" | ||
| message="The JNI surface of SerialNativeInterface.java changed: updated ${jni.header.committed}, commit it"/> | ||
|
Comment on lines
+310
to
+335
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our java builds generate jni header and use it for compilation, so the committed one is unused. This part detects that the generated output is the same as the committed, and if not - replaces the committed one so the author of the change may commit it and keep in sync. I run tests against JDK 8, 11, 17, 21 and 25 and confirm, they all produce identical output, so this should not randomly change, but with one quirk: The header generator distinguishes between Windows and other OSes, so on Windows the headers have 1 difference: This is a compatibility layer that to my research, is a relic of 1998 era of MSVC compilers, and the We don't want Windows users see this as a change, and especially to make them commit i64 which I found is NOT accepted on Linux, so the code above replaces Anyway, the header that current build generates is still one that the compiler uses, so the replacement is a form of tracking changes in the repo rather than a rewrite of the compilation process. |
||
| <exec executable="cmake" dir="${cmake.generated.directory}" failonerror="true"> | ||
| <arg line="--build"/> | ||
| <arg line="."/> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this section from
cmake-generatesection below. These props are now exported back to maven and to java/junit.