Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Checks: >
-clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-optin.cplusplus.UninitializedObject,
bugprone-assert-side-effect,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-narrowing-conversions,
bugprone-unused-raii,
bugprone-use-after-move,
clang-analyzer-core.DivideZero,
misc-unused-using-decls,
modernize-deprecated-headers,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
# modernize-return-braced-init-list,
modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-nodiscard,
modernize-use-nullptr,
modernize-use-override,
modernize-use-using,
-performance-avoid-endl,
performance-faster-string-find,
performance-for-range-copy,
performance-inefficient-algorithm,
performance-inefficient-vector-operation,
performance-noexcept-move-constructor,
performance-move-constructor-init,
performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
readability-const-return-type,
readability-container-size-empty,
readability-convert-member-functions-to-static,
readability-else-after-return,
readability-identifier-naming,
readability-make-member-function-const,
readability-qualified-auto,
readability-redundant-control-flow,
readability-redundant-member-init,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-simplify-boolean-expr

CheckOptions:
- key: bugprone-assert-side-effect.AssertMacros
value: 'ASSERT'
- key: readability-identifier-naming.ClassCase
value: 'CamelCase'
- key: readability-identifier-naming.EnumCase
value: 'CamelCase'
- key: readability-identifier-naming.FunctionCase
value: 'lower_case'
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: >-
(^.*nVars.*$|
|^.*limitK$|
|^.*limitM$)
- key: readability-identifier-naming.ParameterCase
value: 'lower_case'
- key: readability-identifier-naming.ParameterIgnoredRegexp
value: >-
(^_.*$|
|^.*limitK$|
|^.*limitM$)
- key: readability-identifier-naming.PrivateMemberCase
value: 'lower_case'
# - key: readability-identifier-naming.PrivateMemberSuffix
# value: '_'
- key: readability-identifier-naming.StructCase
value: 'CamelCase'

- key: readability-identifier-naming.UnionCase
value: 'CamelCase'
- key: readability-identifier-naming.VariableCase
value: 'lower_case'

HeaderFilterRegex: '^./src/.*'

UseColor: true

WarningsAsErrors: ''

## The version here is arbitrary since any change to this file will
## trigger a full run of clang-tidy against all files.
## It can be useful as it seems some header changes may not trigger the
## expected rerun.
# v0
68 changes: 65 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,39 @@ jobs:
fail-fast: true

matrix:
os: [ubuntu-latest, macos-15, ubuntu-24.04-arm, macos-15-intel]
os: [ubuntu-latest, macos-15, ubuntu-24.04-arm, macos-15-intel, windows-latest]
build_type: [Release]
shared_libs: [ON, OFF]
exclude:
# Windows only builds statically: the shared build scatters DLLs
# across _deps subdirs so approxmc.exe can't find them at runtime.
- os: windows-latest
shared_libs: ON

steps:
- name: Set up MSYS2
if: contains(matrix.os, 'windows')
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
mingw-w64-x86_64-gmp
mingw-w64-x86_64-mpfr
mingw-w64-x86_64-zlib
mingw-w64-x86_64-pkgconf
make

- uses: actions/setup-python@v5
if: "!contains(matrix.os, 'windows')"
with:
python-version: '3.10'

- name: Install python dependencies
if: "!contains(matrix.os, 'windows')"
run: |
pip install numpy lit

Expand Down Expand Up @@ -76,6 +99,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install -yq help2man libgmp-dev libmpfr-dev

- name: Setup ccache
if: "!contains(matrix.os, 'windows')"
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.shared_libs }}
Expand All @@ -86,7 +110,8 @@ jobs:
path: project
submodules: 'true'

- name: Build project
- name: Build project (non-Windows)
if: "!contains(matrix.os, 'windows')"
run: |
cd project
mkdir -p build && cd build
Expand All @@ -98,10 +123,25 @@ jobs:
-S ..
cmake --build . --config ${{matrix.build_type}} -v

- name: Build project (Windows)
if: contains(matrix.os, 'windows')
shell: msys2 {0}
run: |
cd project
mkdir -p build && cd build
cmake \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} \
-G Ninja \
-S ..
cmake --build . --config ${{matrix.build_type}} -v

- name: Test
if: "!contains(matrix.os, 'windows')"
run: ctest -C ${{matrix.build_type}} --verbose

- name: run it to check it executes
- name: run it to check it executes (non-Windows)
if: "!contains(matrix.os, 'windows')"
run: |
echo "Running version command"
./project/build/approxmc --version
Expand All @@ -110,6 +150,18 @@ jobs:
./project/build/approxmc --help
echo $?

- name: run it to check it executes (Windows)
if: contains(matrix.os, 'windows')
shell: msys2 {0}
run: |
EXE=./project/build/approxmc.exe
echo "Running: $EXE --version"
$EXE --version
echo $?
echo "Running: $EXE --help"
$EXE --help
echo $?

- name: Upload Artifact - Linux
if: matrix.os == 'ubuntu-latest' && matrix.shared_libs == 'OFF'
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -149,3 +201,13 @@ jobs:
project/build/approxmc
project/build/lib/*
project/build/include/*

- name: Upload Artifact - Windows
if: matrix.os == 'windows-latest' && matrix.shared_libs == 'OFF'
uses: actions/upload-artifact@v4
with:
name: approxmc-windows-x86_64
path: |
project/build/approxmc.exe
project/build/lib/*
project/build/include/*
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ set_target_properties(approxmc PROPERTIES
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
# On MinGW both DLL and EXE import libs share the libapproxmc.dll.a name,
# so the approxmc library and approxmc-bin executable (OUTPUT_NAME=approxmc)
# collide on the import lib. Rename the library's output on Windows to
# avoid the clash.
if(WIN32)
set_target_properties(approxmc PROPERTIES OUTPUT_NAME approxmcwin)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set_target_properties(approxmc-bin PROPERTIES
Expand Down
Loading