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
50 changes: 42 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ on:
- "benchmarks/**"
- "kiwi/**"
- "py/**"
- "tests/**"
- setup.py
- pyproject.toml
- CMakeLists.txt

jobs:
lint:
Expand Down Expand Up @@ -63,15 +65,47 @@ jobs:
- uses: actions/checkout@v5
- name: Install dependencies
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get install -y g++-11
- name: Build and run benchmark (C++11)
run: cd benchmarks && ./build_and_run_bench.sh
- name: Build and run benchmark (C++20)
sudo apt-get update
sudo apt-get install -y cmake ninja-build g++-11
- name: Configure CMake
env:
CXX_COMPILER: g++-11
CXX_FLAGS: -std=c++20
run: cd benchmarks && ./build_and_run_bench.sh
CXX: g++-11
run: |
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
- name: Build benchmark
run: |
cmake --build build --target kiwi_benchmark
- name: Run benchmark
run: |
./build/benchmarks/kiwi_benchmark
cpp-tests:
name: C++ Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Release]
steps:
- uses: actions/checkout@v5
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install cmake ninja
- name: Configure CMake
run: |
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Build
run: |
cmake --build build --config ${{ matrix.build_type }}
- name: Run tests
run: |
cd build/tests/
ctest --output-on-failure -C ${{ matrix.build_type }}
tests:
name: Unit tests
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ kiwisolver.egg-info/
.mypy_cache

.idea

# clangd cache
.cache/
26 changes: 24 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --------------------------------------------------------------------------------------
# Copyright (c) 2013-2025, Nucleic Development Team.
# Copyright (c) 2013-2026, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
Expand All @@ -23,8 +23,16 @@ project(kiwi
DESCRIPTION "A fast implementation of the Cassowary constraint solver"
)

# Determine if this is the top-level project
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(KIWI_IS_TOP_LEVEL TRUE)
else()
set(KIWI_IS_TOP_LEVEL FALSE)
endif()

# Options
option(KIWI_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(KIWI_BUILD_BENCHMARKS "Build benchmarks" ${KIWI_IS_TOP_LEVEL})
option(KIWI_BUILD_TESTS "Build tests" ${KIWI_IS_TOP_LEVEL})

# C++ standard
set(CMAKE_CXX_STANDARD 11)
Expand All @@ -43,15 +51,29 @@ target_include_directories(kiwi

target_compile_features(kiwi INTERFACE cxx_std_11)

target_compile_options(kiwi INTERFACE
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:
-Wall
-Wextra
-Wpedantic
>
)

# Benchmarks
if(KIWI_BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()

# Tests
if(KIWI_BUILD_TESTS)
add_subdirectory(tests)
endif()

# Print configuration summary
message(STATUS "")
message(STATUS "Kiwi Configuration Summary:")
message(STATUS " Version: ${PROJECT_VERSION}")
message(STATUS " C++ Standard: C++${CMAKE_CXX_STANDARD}")
message(STATUS " Build benchmarks: ${KIWI_BUILD_BENCHMARKS}")
message(STATUS " Build tests: ${KIWI_BUILD_TESTS}")
message(STATUS "")
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Kiwi is licensed under the terms of the Modified BSD License (also known as
New or Revised BSD), as follows:

Copyright (c) 2013-2025, Nucleic Development Team
Copyright (c) 2013-2026, Nucleic Development Team

All rights reserved.

Expand Down Expand Up @@ -63,7 +63,7 @@ With this in mind, the following banner should be used in any source code file
to indicate the copyright and license terms:

#------------------------------------------------------------------------------
# Copyright (c) 2013-2025, Nucleic Development Team.
# Copyright (c) 2013-2026, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --------------------------------------------------------------------------------------
# Copyright (c) 2013-2025, Nucleic Development Team.
# Copyright (c) 2013-2026, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
Expand Down
12 changes: 12 additions & 0 deletions kiwi/AssocVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,24 @@ namespace Loki
std::sort(begin(), end(), me);
}

AssocVector(const AssocVector& rhs): Base(rhs), MyCompare(rhs) {}

AssocVector(AssocVector&& rhs) noexcept
: Base(std::move(rhs)), MyCompare(std::move(rhs))
{}

AssocVector& operator=(const AssocVector& rhs)
{
AssocVector(rhs).swap(*this);
return *this;
}

AssocVector& operator=(AssocVector&& rhs) noexcept
{
AssocVector(std::move(rhs)).swap(*this);
return *this;
}

// iterators:
// The following are here because MWCW gets 'using' wrong
iterator begin() { return Base::begin(); }
Expand Down
2 changes: 1 addition & 1 deletion kiwi/constraint.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion kiwi/debug.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion kiwi/errors.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion kiwi/expression.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion kiwi/kiwi.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion kiwi/maptype.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented code is there to easily check the relevance of using AssocVec vs a standard map.
I can understand the urge to remove commented out code but in this occurrence I would feel better to keep it. You may add a comment explaining why it is there.

| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
28 changes: 26 additions & 2 deletions kiwi/row.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand All @@ -26,7 +26,31 @@ class Row

Row(double constant) : m_constant(constant) {}

Row(const Row &other) = default;
Row(const Row &other) {
m_constant = other.m_constant;
m_cells = other.m_cells;
}

Row(Row &&other) noexcept {
m_constant = other.m_constant;
m_cells = std::move(other.m_cells);
}

Row& operator=(const Row &other) {
if (this != &other) {
m_constant = other.m_constant;
m_cells = other.m_cells;
}
return *this;
}

Row& operator=(Row &&other) noexcept {
if (this != &other) {
m_constant = other.m_constant;
m_cells = std::move(other.m_cells);
}
return *this;
}

~Row() = default;

Expand Down
2 changes: 1 addition & 1 deletion kiwi/shareddata.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
3 changes: 1 addition & 2 deletions kiwi/solver.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand All @@ -9,7 +9,6 @@
#include "constraint.h"
#include "debug.h"
#include "solverimpl.h"
#include "strength.h"
#include "variable.h"


Expand Down
2 changes: 1 addition & 1 deletion kiwi/solverimpl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion kiwi/strength.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion kiwi/symbol.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
12 changes: 6 additions & 6 deletions kiwi/symbolics.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down Expand Up @@ -213,7 +213,7 @@ Expression operator+( const Term& term, double constant )
inline
Expression operator-( const Term& term, const Expression& expression )
{
return -expression + term;
return Expression(term) - expression;
}


Expand Down Expand Up @@ -243,14 +243,14 @@ Expression operator-( const Term& term, double constant )
inline
Expression operator+( const Variable& variable, const Expression& expression )
{
return expression + variable;
return Expression(variable) + expression;
}


inline
Expression operator+( const Variable& variable, const Term& term )
{
return term + variable;
return Term(variable) + term;
}


Expand Down Expand Up @@ -459,7 +459,7 @@ Constraint operator==( const Term& term, double constant )
inline
Constraint operator<=( const Term& term, const Expression& expression )
{
return expression >= term;
return Expression(term) <= expression;
}


Expand Down Expand Up @@ -487,7 +487,7 @@ Constraint operator<=( const Term& term, double constant )
inline
Constraint operator>=( const Term& term, const Expression& expression )
{
return expression <= term;
return Expression(term) >= expression;
}


Expand Down
2 changes: 1 addition & 1 deletion kiwi/term.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion kiwi/util.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
4 changes: 2 additions & 2 deletions kiwi/variable.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down Expand Up @@ -72,7 +72,7 @@ class Variable
}

// operator== is used for symbolics
bool equals(const Variable &other)
bool equals(const Variable &other) const
{
return m_data == other.m_data;
}
Expand Down
2 changes: 1 addition & 1 deletion kiwi/version.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------
| Copyright (c) 2013-2025, Nucleic Development Team.
| Copyright (c) 2013-2026, Nucleic Development Team.
|
| Distributed under the terms of the Modified BSD License.
|
Expand Down
2 changes: 1 addition & 1 deletion py/kiwisolver/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --------------------------------------------------------------------------------------
# Copyright (c) 2013-2025, Nucleic Development Team.
# Copyright (c) 2013-2026, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
Expand Down
Loading
Loading