Skip to content

Commit ee1de67

Browse files
Add Darwin-arm64 and vcpkg for Windows (#33)
- [x] Fixed getlibs.sh and compile.sh for native macOS tools - [x] Add Darwin-arm64 to GH CI - [x] Fixed Windows build to use vcpkg instead of getlibs
2 parents 636dcbb + 9836d97 commit ee1de67

File tree

6 files changed

+97
-48
lines changed

6 files changed

+97
-48
lines changed

.github/workflows/build.yml

Lines changed: 63 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
run: clang-format --version
1818
- name: Formatting
1919
run: find src include test -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\)$' | xargs clang-format -n -Werror
20+
2021
build-linux:
2122
runs-on: ubuntu-24.04
2223
env:
@@ -34,17 +35,18 @@ jobs:
3435
CORES=$(nproc)
3536
echo "CMAKE_BUILD_PARALLEL_LEVEL=$CORES" >> $GITHUB_ENV
3637
echo "CTEST_PARALLEL_LEVEL=$CORES" >> $GITHUB_ENV
38+
echo "BUILD=build-${TARGET}-${CMAKE_BUILD_TYPE,,}" >> $GITHUB_ENV
3739
- name: Get Libs
3840
run: |
3941
CMAKE_BUILD_TYPE=Release ./getlibs.sh $TARGET
40-
- name: Build
41-
run: |
42-
BUILD=build-${TARGET}-${CMAKE_BUILD_TYPE,,}
43-
cmake -S . -B "$BUILD" -DCMAKE_PREFIX_PATH="$PWD/local/${TARGET}" -DUBSAN=ON -DASAN=ON -DFIND_FATAL=ON
44-
cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
45-
ctest --test-dir "$BUILD" -C $CMAKE_BUILD_TYPE
42+
- name: Configure
43+
run: cmake -S . -B "$BUILD" -DCMAKE_PREFIX_PATH="$PWD/local/${TARGET}" -DUBSAN=ON -DASAN=ON -DFIND_FATAL=ON
44+
- name: Compile
45+
run: cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
46+
- name: Test
47+
run: ctest --test-dir "$BUILD" -C $CMAKE_BUILD_TYPE
4648

47-
build-win:
49+
build-mingw:
4850
runs-on: ubuntu-24.04
4951
env:
5052
TARGET: x86_64-w64-mingw32
@@ -60,25 +62,25 @@ jobs:
6062
run: |
6163
sudo apt-get -qq update
6264
sudo apt-get -qq install cmake ninja-build g++-mingw-w64-x86-64 mingw-w64-x86-64-dev mingw-w64-tools wine wine-binfmt
63-
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
64-
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
65+
sudo update-alternatives --set ${TARGET}-gcc /usr/bin/${TARGET}-gcc-posix
66+
sudo update-alternatives --set ${TARGET}-g++ /usr/bin/${TARGET}-g++-posix
6567
WINEPATH=$(./winepath-for $TARGET)
6668
echo "WINEPATH=$WINEPATH" >> $GITHUB_ENV
6769
CORES=$(nproc)
6870
echo "CMAKE_BUILD_PARALLEL_LEVEL=$CORES" >> $GITHUB_ENV
6971
echo "CTEST_PARALLEL_LEVEL=$CORES" >> $GITHUB_ENV
70-
72+
echo "BUILD=build-${TARGET}-${CMAKE_BUILD_TYPE,,}" >> $GITHUB_ENV
7173
- name: Get Libs
7274
run: |
7375
CMAKE_BUILD_TYPE=Release ./getlibs.sh $TARGET
74-
- name: Build
75-
run: |
76-
BUILD=build-${TARGET}-${CMAKE_BUILD_TYPE,,}
77-
cmake -S . -B "$BUILD" -DCMAKE_PREFIX_PATH="$PWD/local/${TARGET}" -DFIND_FATAL=ON
78-
cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
79-
ctest --test-dir "$BUILD" -C $CMAKE_BUILD_TYPE
76+
- name: Configure
77+
run: cmake -S . -B "$BUILD" -DCMAKE_PREFIX_PATH="$PWD/local/${TARGET}" -DFIND_FATAL=ON
78+
- name: Compile
79+
run: cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
80+
- name: Test
81+
run: ctest --test-dir "$BUILD" -C $CMAKE_BUILD_TYPE
8082

81-
build-macos:
83+
build-macos-x86_64:
8284
runs-on: macos-latest
8385
env:
8486
TARGET: x86_64-darwin
@@ -94,34 +96,65 @@ jobs:
9496
CORES=$(sysctl -n hw.ncpu)
9597
echo "CMAKE_BUILD_PARALLEL_LEVEL=$CORES" >> $GITHUB_ENV
9698
echo "CTEST_PARALLEL_LEVEL=$CORES" >> $GITHUB_ENV
99+
echo "BUILD=build-${TARGET}-debug" >> $GITHUB_ENV
97100
- name: Get Libs
98101
run: |
99102
CMAKE_BUILD_TYPE=Release ./getlibs.sh $TARGET
100-
- name: Build with getlibs
103+
- name: Configure
104+
run: cmake -S . -B "$BUILD" -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain/${TARGET}.cmake" -DCMAKE_PREFIX_PATH="$PWD/local/$TARGET" -DFIND_FATAL=ON
105+
- name: Compile
106+
run: cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
107+
- name: Test
108+
run: ctest --test-dir "$BUILD" -C $CMAKE_BUILD_TYPE
109+
110+
build-macos-arm64:
111+
runs-on: macos-latest
112+
env:
113+
TARGET: arm64-darwin
114+
CMAKE_GENERATOR: Ninja
115+
CMAKE_BUILD_TYPE: Debug
116+
CTEST_OUTPUT_ON_FAILURE: 1
117+
CTEST_TEST_TIMEOUT: 20
118+
steps:
119+
- uses: actions/checkout@v4
120+
- name: Install Ninja
101121
run: |
102-
BUILD=build-${TARGET}-debug
103-
cmake -S . -B "$BUILD" -DCMAKE_PREFIX_PATH="$PWD/local/x86_64-darwin" -DFIND_FATAL=ON
104-
cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
105-
ctest --test-dir "$BUILD" -C $CMAKE_BUILD_TYPE
122+
brew install ninja
123+
CORES=$(sysctl -n hw.ncpu)
124+
echo "CMAKE_BUILD_PARALLEL_LEVEL=$CORES" >> $GITHUB_ENV
125+
echo "CTEST_PARALLEL_LEVEL=$CORES" >> $GITHUB_ENV
126+
echo "BUILD=build-${TARGET}-debug" >> $GITHUB_ENV
127+
- name: Get Libs
128+
run: |
129+
CMAKE_BUILD_TYPE=Release ./getlibs.sh $TARGET
130+
- name: Configure
131+
run: cmake -S . -B "$BUILD" -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain/${TARGET}.cmake" -DCMAKE_PREFIX_PATH="$PWD/local/$TARGET" -DFIND_FATAL=ON
132+
- name: Compile
133+
run: cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
134+
- name: Test
135+
run: ctest --test-dir "$BUILD" -C $CMAKE_BUILD_TYPE
106136

107137
build-windows:
108138
runs-on: windows-latest
109139
env:
140+
TARGET: x86_64-windows
110141
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
111142
CMAKE_BUILD_TYPE: Debug
112143
STATIC: ON
113144
CTEST_TEST_TIMEOUT: 20
114145
CTEST_OUTPUT_ON_FAILURE: 1
115146
steps:
116147
- uses: actions/checkout@v4
148+
- name: Setup
149+
run: |
150+
echo "BUILD=build-$env:TARGET-debug" >> $env:GITHUB_ENV
117151
- name: Get Libs
118152
run: |
119153
vcpkg integrate install
120-
vcpkg install doctest --triplet x64-windows
121-
pwsh -Command { $env:CMAKE_BUILD_TYPE=Release; bash ./getlibs.sh x86_64-w64-mingw32 }
122-
- name: Build
123-
run: |
124-
$env:BUILD='build-x86_64-windows-debug'
125-
cmake -S . -B $env:BUILD -DCMAKE_PREFIX_PATH=${{ github.workspace }}/local/x86_64-w64-mingw32
126-
cmake --build $env:BUILD --config $env:CMAKE_BUILD_TYPE
127-
ctest --test-dir $env:BUILD -C $env:CMAKE_BUILD_TYPE
154+
vcpkg install xxhash boost-math doctest benchmark --triplet x64-windows
155+
- name: Connfigure
156+
run: cmake -S . -B $env:BUILD
157+
- name: Compile
158+
run: cmake --build $env:BUILD --config $env:CMAKE_BUILD_TYPE
159+
- name: Test
160+
run: ctest --test-dir $env:BUILD -C $env:CMAKE_BUILD_TYPE

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ build-*
55
local
66
cmake-build-*
77
.idea
8+
.vs

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ UUtils also depends on libraries `xxHash`, `doctest`, `benchmark`, `boost`, whic
1111
## Build, Test and Install
1212
```shell
1313
git clone https://github.com/UPPAALModelChecker/UUtils
14-
cmake -S UUtils -B build
14+
cd UUtils
15+
./getlibs.sh
16+
cmake -B build
1517
cmake --build build
1618
ctest --test-dir build --output-on-failure
1719
sudo cmake --install build

compile.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ if [ $# -eq 0 ] ; then
3232
if [ -n "$(command -v x86_64-w64-mingw32-g++)" ]; then
3333
targets="$targets x86_64-w64-mingw32-release"
3434
fi
35+
if [ "$kernel" == "Darwin" ] && [ "$machine" == "arm64" ]; then
36+
targets="$targets x86_64-darwin-release"
37+
fi
3538
echo "Guessing: $targets"
3639
else
3740
case "$1" in
@@ -88,7 +91,7 @@ for target in $targets ; do
8891
BUILD_TARGET=x86_64-darwin
8992
;;
9093
arm64-darwin*)
91-
BUILD_TARGET=x86_64-darwin
94+
BUILD_TARGET=arm64-darwin
9295
;;
9396
*)
9497
echo "Failed to recognize target platform: $target"

getlibs.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ for target in $targets ; do
7373
else
7474
pushd "$SOURCES"
7575
[ -r "${ARCHIVE}" ] || curl -sL "https://github.com/Cyan4973/xxHash/archive/refs/tags/v$VERSION.tar.gz" -o "${ARCHIVE}"
76-
if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi
76+
if [ -n "$(command -v shasum)" ]; then
77+
echo "$SHA256 $ARCHIVE" | shasum -a256 --check -
78+
fi
7779
[ -d "$SOURCE" ] || tar xf "${ARCHIVE}"
7880
popd
7981
echo "Building $LIBRARY in $BUILD from $SOURCE"
@@ -98,7 +100,9 @@ for target in $targets ; do
98100
else
99101
pushd "$SOURCES"
100102
[ -r "${ARCHIVE}" ] || curl -sL "https://github.com/boostorg/boost/releases/download/${LIBRARY}/${ARCHIVE}" -o "${ARCHIVE}"
101-
if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi
103+
if [ -n "$(command -v shasum)" ]; then
104+
echo "$SHA256 $ARCHIVE" | shasum -a256 --check -
105+
fi
102106
[ -d "${SOURCE}" ] || tar xf "${ARCHIVE}"
103107
popd
104108
echo "Building $LIBRARY in $BUILD from $SOURCE"
@@ -125,7 +129,9 @@ for target in $targets ; do
125129
else
126130
pushd "${SOURCES}"
127131
[ -r "${ARCHIVE}" ] || curl -sL "https://github.com/doctest/doctest/archive/refs/tags/v$VERSION.tar.gz" -o "${ARCHIVE}"
128-
if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi
132+
if [ -n "$(command -v shasum)" ]; then
133+
echo "$SHA256 $ARCHIVE" | shasum -a256 --check -
134+
fi
129135
[ -d "${SOURCE}" ] || tar xf "${ARCHIVE}"
130136
popd
131137
echo "Building $LIBRARY in $BUILD from $SOURCE"
@@ -150,7 +156,9 @@ for target in $targets ; do
150156
else
151157
pushd "$SOURCES"
152158
[ -r "$ARCHIVE" ] || curl -sL "https://github.com/google/benchmark/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE"
153-
if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi
159+
if [ -n "$(command -v shasum)" ]; then
160+
echo "$SHA256 $ARCHIVE" | shasum -a256 --check -
161+
fi
154162
[ -d "$LIBRARY" ] || tar -xf "$ARCHIVE"
155163
popd
156164
echo "Building $LIBRARY in $BUILD from $SOURCE"

test/base/test_randomness.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#include <random>
1414
#include <cmath>
1515

16-
static double fracInRange(const std::vector<int>& values, int length, double from, double till)
16+
static double fracInRange(const std::vector<int>& values, double from, double till)
1717
{
18+
const int length = values.size();
1819
double count = 0;
1920
for (int i = 0; i < length; ++i)
2021
if (from <= values[i] && values[i] < till)
@@ -29,8 +30,9 @@ using boost::math::quantile;
2930
using std::cout;
3031
using std::endl;
3132

32-
static bool frequency_analysis(int n, const std::vector<int>& values, int range, double alpha)
33+
static bool frequency_analysis(int n, const std::vector<int>& values, double alpha)
3334
{
35+
const int range = values.size();
3436
const auto sqrt_n = std::sqrt(n);
3537
auto sum = 0., sumsq = 0.;
3638
auto minv = std::numeric_limits<double>::infinity();
@@ -73,14 +75,14 @@ static bool frequency_analysis(int n, const std::vector<int>& values, int range,
7375
cout << "Sd^2: " << var << " (" << n << ")" << endl;
7476
cout << "Sd: " << Sd << " (" << sqrt_n << ")" << endl;
7577
cout << "Sd/mean: " << std::fixed << std::setprecision(4) << Sd / mean << " (" << sqrt_n / mean << ")" << endl;
76-
cout << " -3*Sd: " << fracInRange(values, range, 0, mean - 3 * Sd) * 100 << "% (0.1%)" << endl;
77-
cout << "-3-2*Sd: " << fracInRange(values, range, mean - 3 * Sd, mean - 2 * Sd) * 100 << "% (2.1%)" << endl;
78-
cout << "-2-1*Sd: " << fracInRange(values, range, mean - 2 * Sd, mean - 1 * Sd) * 100 << "% (13.6%)" << endl;
79-
cout << "-1-0*Sd: " << fracInRange(values, range, mean - Sd, mean) * 100 << "% (34.1%)" << endl;
80-
cout << "+0-1*Sd: " << fracInRange(values, range, mean, mean + 1 * Sd) * 100 << "% (34.1%)" << endl;
81-
cout << "+1-2*Sd: " << fracInRange(values, range, mean + 1 * Sd, mean + 2 * Sd) * 100 << "% (13.6%)" << endl;
82-
cout << "+2-3*Sd: " << fracInRange(values, range, mean + 2 * Sd, mean + 3 * Sd) * 100 << "% (2.1%)" << endl;
83-
cout << "+3- *Sd: " << fracInRange(values, range, mean + 3 * Sd, std::numeric_limits<double>::infinity()) * 100
78+
cout << " -3*Sd: " << fracInRange(values, 0, mean - 3 * Sd) * 100 << "% (0.1%)" << endl;
79+
cout << "-3-2*Sd: " << fracInRange(values, mean - 3 * Sd, mean - 2 * Sd) * 100 << "% (2.1%)" << endl;
80+
cout << "-2-1*Sd: " << fracInRange(values, mean - 2 * Sd, mean - 1 * Sd) * 100 << "% (13.6%)" << endl;
81+
cout << "-1-0*Sd: " << fracInRange(values, mean - Sd, mean) * 100 << "% (34.1%)" << endl;
82+
cout << "+0-1*Sd: " << fracInRange(values, mean, mean + 1 * Sd) * 100 << "% (34.1%)" << endl;
83+
cout << "+1-2*Sd: " << fracInRange(values, mean + 1 * Sd, mean + 2 * Sd) * 100 << "% (13.6%)" << endl;
84+
cout << "+2-3*Sd: " << fracInRange(values, mean + 2 * Sd, mean + 3 * Sd) * 100 << "% (2.1%)" << endl;
85+
cout << "+3- *Sd: " << fracInRange(values, mean + 3 * Sd, std::numeric_limits<double>::infinity()) * 100
8486
<< "% (0.1%)" << endl;
8587
cout << "Skew: " << skewness << " (0.0)" << endl;
8688
cout << "Kurtosis: " << kurtosis << " (0.0)" << endl;
@@ -123,7 +125,7 @@ static bool floating_point_test(int n, int range, int offset, double alpha)
123125
}
124126
}
125127
cout << endl;
126-
return frequency_analysis(n, values, range, alpha);
128+
return frequency_analysis(n, values, alpha);
127129
}
128130

129131
/** returns true if passed, otherwise false. */
@@ -146,7 +148,7 @@ static bool integer_test(int n, int range, int offset, double alpha)
146148
}
147149
}
148150
cout << endl;
149-
return frequency_analysis(n, values, range, alpha);
151+
return frequency_analysis(n, values, alpha);
150152
}
151153

152154
struct step_t

0 commit comments

Comments
 (0)