Skip to content

Commit c5ff1f1

Browse files
committed
Add GitHub CI with Windows JNI harness
1 parent 95a7181 commit c5ff1f1

7 files changed

Lines changed: 474 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
YICES_REF: 016a6243de768046f4fba6f88a8659ce1a18d261
12+
13+
jobs:
14+
unix:
15+
name: ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os:
21+
- ubuntu-latest
22+
- macos-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Checkout Yices
28+
uses: actions/checkout@v4
29+
with:
30+
repository: SRI-CSL/yices2
31+
ref: ${{ env.YICES_REF }}
32+
path: yices2
33+
34+
- name: Set up Java
35+
uses: actions/setup-java@v4
36+
with:
37+
distribution: temurin
38+
java-version: "17"
39+
40+
- name: Install Linux dependencies
41+
if: runner.os == 'Linux'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y ant autoconf automake g++ gcc gperf libgmp-dev libtool m4 make pkg-config
45+
46+
- name: Install macOS dependencies
47+
if: runner.os == 'macOS'
48+
env:
49+
HOMEBREW_NO_AUTO_UPDATE: "1"
50+
run: |
51+
brew install ant autoconf automake gmp gperf libtool make pkg-config
52+
53+
- name: Build and test
54+
env:
55+
YICES_SRC: ${{ github.workspace }}/yices2
56+
YICES_PREFIX: ${{ runner.temp }}/yices-install
57+
run: bash scripts/ci-build-test-unix.sh
58+
59+
windows:
60+
name: windows-latest
61+
runs-on: windows-latest
62+
63+
steps:
64+
- run: git config --global core.autocrlf false && git config --global core.eol lf
65+
66+
- uses: actions/checkout@v4
67+
68+
- name: Checkout Yices
69+
uses: actions/checkout@v4
70+
with:
71+
repository: SRI-CSL/yices2
72+
ref: ${{ env.YICES_REF }}
73+
path: yices2
74+
75+
- name: Set up Java
76+
uses: actions/setup-java@v4
77+
with:
78+
distribution: temurin
79+
java-version: "17"
80+
81+
- name: Install Ant
82+
shell: powershell
83+
run: choco install ant -y
84+
85+
- name: Install Cygwin dependencies
86+
uses: cygwin/cygwin-install-action@v4
87+
with:
88+
packages: |
89+
autoconf,
90+
automake,
91+
cmake,
92+
coreutils,
93+
curl,
94+
gperf,
95+
libtool,
96+
m4,
97+
make,
98+
mingw64-x86_64-gcc-core,
99+
mingw64-x86_64-gcc-g++,
100+
moreutils,
101+
wget
102+
103+
- name: Build and test
104+
shell: bash
105+
env:
106+
CYGWIN: winsymlinks:native binmode
107+
YICES_SRC: ${{ github.workspace }}/yices2
108+
YICES_PREFIX: /tmp/yices-install
109+
run: bash scripts/ci-build-test-windows.sh

ant.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/bin/bash
22

33
#uses the build.sh to mimic what 'ant install' does without 'ant'
4+
set -e
5+
46
REPO_ROOT=${PWD}
57

68
YC=${REPO_ROOT}/build/classes
79
YI=${REPO_ROOT}/dist/lib
810

911
YICES_CLASSPATH=${YC} YICES_JNI=${YI} ./build.sh
1012

11-
jar -cvfm ${YI}/yices.jar ${REPO_ROOT}/MANIFEST.txt -C ${YC} ${YC}/com/sri/yices/*.class
13+
jar -cvfm ${YI}/yices.jar ${REPO_ROOT}/MANIFEST.txt -C ${YC} .
1214

1315
java -Djava.library.path=${REPO_ROOT}/dist/lib -jar ${REPO_ROOT}/dist/lib/yices.jar

build.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
<echo> Executing "make ${library}" in ${code} </echo>
224224
<exec executable="make"
225225
dir="${code}"
226-
failifexecutionfails="true">
226+
failonerror="true">
227227
<arg line="${library}"/>
228228
</exec>
229229

@@ -233,7 +233,7 @@
233233

234234
<exec executable="make"
235235
dir="${code}"
236-
failifexecutionfails="true">
236+
failonerror="true">
237237
<arg line="install"/>
238238
</exec>
239239

@@ -250,7 +250,7 @@
250250

251251
<exec executable="make"
252252
dir="${code}"
253-
failifexecutionfails="true">
253+
failonerror="true">
254254
<arg line="clean"/>
255255
</exec>
256256
</target>
@@ -286,6 +286,7 @@
286286
<test name="com.sri.yices.TestTypes"/>
287287
<test name="com.sri.yices.TestYices"/>
288288
<test name="com.sri.yices.TestModels"/>
289+
<test name="com.sri.yices.TestTermComponents"/>
289290
<!-- <test name="com.sri.yices.TestDelegates"/> -->
290291
<!-- <test name="com.sri.yices.TestDimacs"/> -->
291292
<test name="com.sri.yices.TestThreads"/>

scripts/ci-build-test-unix.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6+
YICES_SRC="${YICES_SRC:?set YICES_SRC}"
7+
YICES_PREFIX="${YICES_PREFIX:?set YICES_PREFIX}"
8+
9+
configure_brew_env() {
10+
if [[ "$(uname)" != "Darwin" ]]; then
11+
return
12+
fi
13+
14+
local brew_prefix
15+
if [[ -d /opt/homebrew ]]; then
16+
brew_prefix=/opt/homebrew
17+
else
18+
brew_prefix=/usr/local
19+
fi
20+
21+
export CPPFLAGS="-I${brew_prefix}/include ${CPPFLAGS:-}"
22+
export LDFLAGS="-L${brew_prefix}/lib ${LDFLAGS:-}"
23+
export PKG_CONFIG_PATH="${brew_prefix}/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
24+
export DYLD_LIBRARY_PATH="${brew_prefix}/lib${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}"
25+
}
26+
27+
build_yices() {
28+
rm -rf "${YICES_PREFIX}"
29+
mkdir -p "${YICES_PREFIX}"
30+
pushd "${YICES_SRC}" >/dev/null
31+
autoconf
32+
./configure --prefix="${YICES_PREFIX}" --enable-thread-safety
33+
make MODE=release
34+
make MODE=release install
35+
popd >/dev/null
36+
}
37+
38+
run_java_ci() {
39+
export CPPFLAGS="-I${YICES_PREFIX}/include ${CPPFLAGS:-}"
40+
export LDFLAGS="-L${YICES_PREFIX}/lib ${LDFLAGS:-}"
41+
42+
if [[ "$(uname)" == "Darwin" ]]; then
43+
export DYLD_LIBRARY_PATH="${YICES_PREFIX}/lib${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}"
44+
else
45+
export LD_LIBRARY_PATH="${YICES_PREFIX}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
46+
fi
47+
48+
export YICES_JNI="${REPO_ROOT}/dist/lib"
49+
export YICES_CLASSPATH="${REPO_ROOT}/build/classes"
50+
51+
pushd "${REPO_ROOT}" >/dev/null
52+
ant clean test
53+
popd >/dev/null
54+
}
55+
56+
configure_brew_env
57+
build_yices
58+
run_java_ci

scripts/ci-build-test-windows.sh

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6+
YICES_SRC="$(cygpath -u "${YICES_SRC:?set YICES_SRC}")"
7+
YICES_PREFIX="${YICES_PREFIX:?set YICES_PREFIX}"
8+
JAVA_HOME_UNIX="$(cygpath -u "${JAVA_HOME:?set JAVA_HOME}")"
9+
JAVAC="${JAVA_HOME_UNIX}/bin/javac"
10+
JAVA="${JAVA_HOME_UNIX}/bin/java"
11+
JAR="${JAVA_HOME_UNIX}/bin/jar"
12+
13+
win_path() {
14+
cygpath -w "$1"
15+
}
16+
17+
win_path_list() {
18+
cygpath -wp "$1"
19+
}
20+
21+
build_gmp() {
22+
mkdir -p /tools/dynamic_gmp /tools/static_gmp
23+
pushd /tools >/dev/null
24+
25+
local archive=gmp-6.3.0.tar.xz
26+
if [[ ! -f "${archive}" ]]; then
27+
curl -fL --retry 5 --retry-delay 2 --connect-timeout 20 --max-time 600 \
28+
https://ftp.gnu.org/gnu/gmp/${archive} -o "${archive}" || \
29+
wget --tries=5 --timeout=20 -O "${archive}" https://ftp.gnu.org/gnu/gmp/${archive} || \
30+
curl -fL --retry 5 --retry-delay 2 --connect-timeout 20 --max-time 600 \
31+
https://mirrors.kernel.org/gnu/gmp/${archive} -o "${archive}" || \
32+
wget --tries=5 --timeout=20 -O "${archive}" https://mirrors.kernel.org/gnu/gmp/${archive} || \
33+
curl -fL --retry 5 --retry-delay 2 --connect-timeout 20 --max-time 600 \
34+
https://gmplib.org/download/gmp/${archive} -o "${archive}" || \
35+
wget --tries=5 --timeout=20 -O "${archive}" https://gmplib.org/download/gmp/${archive}
36+
fi
37+
38+
rm -rf gmp-6.3.0
39+
tar xf "${archive}"
40+
cd gmp-6.3.0
41+
./configure --host=x86_64-w64-mingw32 --build=i686-pc-cygwin --enable-cxx --enable-shared --disable-static --prefix=/tools/dynamic_gmp
42+
make
43+
make install
44+
make clean
45+
./configure --host=x86_64-w64-mingw32 --build=i686-pc-cygwin --enable-cxx --enable-static --disable-shared --prefix=/tools/static_gmp
46+
make
47+
make install
48+
49+
popd >/dev/null
50+
}
51+
52+
build_yices() {
53+
pushd "${YICES_SRC}" >/dev/null
54+
autoconf
55+
./configure \
56+
--host=x86_64-w64-mingw32 \
57+
--enable-thread-safety \
58+
CPPFLAGS="-I/tools/dynamic_gmp/include" \
59+
LDFLAGS="-L/tools/dynamic_gmp/lib" \
60+
--with-static-gmp=/tools/static_gmp/lib/libgmp.a \
61+
--with-static-gmp-include-dir=/tools/static_gmp/include
62+
export LD_LIBRARY_PATH="/usr/local/lib/:${LD_LIBRARY_PATH:-}"
63+
make OPTION=mingw64 MODE=release dist
64+
65+
local dist_dir
66+
dist_dir="$(find build -type d -path '*/release/dist' | head -n 1)"
67+
if [[ -z "${dist_dir}" ]]; then
68+
echo "failed to locate Yices dist directory" >&2
69+
exit 1
70+
fi
71+
72+
rm -rf "${YICES_PREFIX}"
73+
mkdir -p "${YICES_PREFIX}"
74+
cp -R "${dist_dir}/." "${YICES_PREFIX}/"
75+
popd >/dev/null
76+
}
77+
78+
build_java_bindings() {
79+
mkdir -p "${REPO_ROOT}/build/classes" "${REPO_ROOT}/build/test_classes" "${REPO_ROOT}/dist/lib"
80+
81+
pushd "${REPO_ROOT}" >/dev/null
82+
find src/main/java/com/sri/yices -name '*.java' | sort > build/main-sources.txt
83+
"${JAVAC}" \
84+
-d "$(win_path "${REPO_ROOT}/build/classes")" \
85+
-h "$(win_path "${REPO_ROOT}/src/main/java/com/sri/yices")" \
86+
@"build/main-sources.txt"
87+
88+
x86_64-w64-mingw32-g++ \
89+
-I "${JAVA_HOME_UNIX}/include" \
90+
-I "${JAVA_HOME_UNIX}/include/win32" \
91+
-I "${YICES_PREFIX}/include" \
92+
-I /tools/dynamic_gmp/include \
93+
-g -Wall -fpermissive \
94+
-c src/main/java/com/sri/yices/yicesJNIforWindows.cpp \
95+
-o build/yicesJNIforWindows.o
96+
97+
x86_64-w64-mingw32-g++ \
98+
-shared \
99+
-o dist/lib/yices2java.dll \
100+
build/yicesJNIforWindows.o \
101+
-L "${YICES_PREFIX}/lib" \
102+
-L /tools/dynamic_gmp/lib \
103+
-lyices -lgmp
104+
105+
"${JAR}" -cvfm \
106+
"$(win_path "${REPO_ROOT}/dist/lib/yices.jar")" \
107+
"$(win_path "${REPO_ROOT}/MANIFEST.txt")" \
108+
-C "$(win_path "${REPO_ROOT}/build/classes")" .
109+
popd >/dev/null
110+
}
111+
112+
stage_runtime_dlls() {
113+
cp "${YICES_PREFIX}/bin/libyices.dll" "${REPO_ROOT}/dist/lib/"
114+
cp /tools/dynamic_gmp/bin/libgmp-10.dll "${REPO_ROOT}/dist/lib/"
115+
cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libstdc++-6.dll "${REPO_ROOT}/dist/lib/"
116+
cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libgcc_s_seh-1.dll "${REPO_ROOT}/dist/lib/"
117+
cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll "${REPO_ROOT}/dist/lib/"
118+
}
119+
120+
run_tests() {
121+
pushd "${REPO_ROOT}" >/dev/null
122+
find src/test/java -name '*.java' | sort > build/test-sources.txt
123+
124+
local compile_cp
125+
compile_cp="$(win_path_list "${REPO_ROOT}/dist/lib/yices.jar:${REPO_ROOT}/lib/junit-4.12.jar:${REPO_ROOT}/lib/hamcrest-core-1.3.jar")"
126+
"${JAVAC}" \
127+
-cp "${compile_cp}" \
128+
-d "$(win_path "${REPO_ROOT}/build/test_classes")" \
129+
@"build/test-sources.txt"
130+
131+
local runtime_cp runtime_path
132+
runtime_cp="$(win_path_list "${REPO_ROOT}/build/test_classes:${REPO_ROOT}/dist/lib/yices.jar:${REPO_ROOT}/lib/junit-4.12.jar:${REPO_ROOT}/lib/hamcrest-core-1.3.jar")"
133+
runtime_path="$(win_path_list "${REPO_ROOT}/dist/lib:/tools/dynamic_gmp/bin:/usr/x86_64-w64-mingw32/sys-root/mingw/bin")"
134+
135+
env PATH="${runtime_path}" \
136+
"${JAVA}" \
137+
"-Djava.library.path=$(win_path "${REPO_ROOT}/dist/lib")" \
138+
-cp "${runtime_cp}" \
139+
org.junit.runner.JUnitCore \
140+
com.sri.yices.TestBigRationals \
141+
com.sri.yices.TestConstructor \
142+
com.sri.yices.TestContext \
143+
com.sri.yices.TestStatus \
144+
com.sri.yices.TestTypes \
145+
com.sri.yices.TestYices \
146+
com.sri.yices.TestModels \
147+
com.sri.yices.TestTermComponents \
148+
com.sri.yices.TestThreads
149+
popd >/dev/null
150+
}
151+
152+
build_gmp
153+
build_yices
154+
build_java_bindings
155+
stage_runtime_dlls
156+
run_tests

0 commit comments

Comments
 (0)