From c251d0a38c58d6f93192b78b6274226b325cdb24 Mon Sep 17 00:00:00 2001 From: Rafik Saliev Date: Wed, 19 Aug 2026 03:39:01 -0700 Subject: [PATCH 1/3] [C API] Move C API samples to the examples directory * Move `bindings/c/samples` to `examples/c` * Add CMake option `SVS_BUID_C_API` to the project root * Update CI scripts accordinly --- .github/scripts/build-c-api-bindings.sh | 5 +++-- .github/scripts/test-c-api-unit.sh | 2 +- CMakeLists.txt | 4 ++++ bindings/c/CMakeLists.txt | 4 ---- cmake/options.cmake | 5 +++++ examples/CMakeLists.txt | 4 ++++ {bindings/c/samples => examples/c}/CMakeLists.txt | 2 +- {bindings/c/samples => examples/c}/dynamic.c | 0 {bindings/c/samples => examples/c}/save_load.c | 0 {bindings/c/samples => examples/c}/simple.c | 0 10 files changed, 18 insertions(+), 8 deletions(-) rename {bindings/c/samples => examples/c}/CMakeLists.txt (95%) rename {bindings/c/samples => examples/c}/dynamic.c (100%) rename {bindings/c/samples => examples/c}/save_load.c (100%) rename {bindings/c/samples => examples/c}/simple.c (100%) diff --git a/.github/scripts/build-c-api-bindings.sh b/.github/scripts/build-c-api-bindings.sh index 6967b6def..dc2a117b5 100755 --- a/.github/scripts/build-c-api-bindings.sh +++ b/.github/scripts/build-c-api-bindings.sh @@ -40,11 +40,12 @@ echo "compiler: $(${CXX:-c++} --version | head -1)" rm -rf "${BUILD_DIR}" "${INSTALL_DIR}" -cmake -B"${BUILD_DIR}" -S"${WORKSPACE}/bindings/c" \ +cmake -B"${BUILD_DIR}" -S"${WORKSPACE}" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ -DCMAKE_INSTALL_LIBDIR=lib \ - -DSVS_BUILD_C_API_TESTS=ON \ + -DSVS_BUILD_C_API=ON \ + -DSVS_BUILD_TESTS=ON \ -DSVS_BUILD_EXAMPLES=ON \ -DSVS_RUNTIME_ENABLE_LVQ_LEANVEC="${ENABLE_LVQ_LEANVEC}" \ -DSVS_REQUIRE_LTO_ARCHIVE="${REQUIRE_LTO_ARCHIVE}" diff --git a/.github/scripts/test-c-api-unit.sh b/.github/scripts/test-c-api-unit.sh index 7ea6e322e..a787e526a 100755 --- a/.github/scripts/test-c-api-unit.sh +++ b/.github/scripts/test-c-api-unit.sh @@ -42,6 +42,6 @@ ctest --test-dir "${BUILD_DIR}" --output-on-failure --no-tests=error # exit once already, so they are part of the gate. for sample in c_api_simple c_api_save_load c_api_dynamic; do echo "::group::${sample}" - "${BUILD_DIR}/samples/${sample}" + "${BUILD_DIR}/examples/c/${sample}" echo "::endgroup::" done diff --git a/CMakeLists.txt b/CMakeLists.txt index 62377bef9..418079e22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,10 @@ endif() ##### Build Objects ##### +if(SVS_BUILD_C_API) + add_subdirectory(bindings/c) +endif() + if(SVS_BUILD_BINARIES) add_subdirectory(utils) endif() diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt index 9ed1247b4..5d9a7c456 100644 --- a/bindings/c/CMakeLists.txt +++ b/bindings/c/CMakeLists.txt @@ -270,7 +270,3 @@ if(SVS_BUILD_C_API_TESTS) endif() add_subdirectory(tests) endif() - -if(SVS_BUILD_EXAMPLES) - add_subdirectory(samples) -endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index b02b6785c..ff429373a 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -31,6 +31,11 @@ option(SVS_BUILD_BINARIES OFF # enabled by default ) +option(SVS_BUILD_C_API + "Build C API bindings" + OFF # disabled by default +) + option(SVS_BUILD_TESTS "Build the unit test suite." OFF # disabled by default diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index eaabf8f1e..c16d7cd62 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,3 +13,7 @@ # limitations under the License. add_subdirectory(cpp) + +if(SVS_BUILD_C_API) + add_subdirectory(c) +endif() diff --git a/bindings/c/samples/CMakeLists.txt b/examples/c/CMakeLists.txt similarity index 95% rename from bindings/c/samples/CMakeLists.txt rename to examples/c/CMakeLists.txt index c23b1a022..a92ef392b 100644 --- a/bindings/c/samples/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +project(svs_c_api_samples LANGUAGES C) foreach(SAMPLE_NAME simple save_load dynamic) set(SAMPLE_TARGET c_api_${SAMPLE_NAME}) list(APPEND SAMPLE_TARGETS ${SAMPLE_TARGET}) diff --git a/bindings/c/samples/dynamic.c b/examples/c/dynamic.c similarity index 100% rename from bindings/c/samples/dynamic.c rename to examples/c/dynamic.c diff --git a/bindings/c/samples/save_load.c b/examples/c/save_load.c similarity index 100% rename from bindings/c/samples/save_load.c rename to examples/c/save_load.c diff --git a/bindings/c/samples/simple.c b/examples/c/simple.c similarity index 100% rename from bindings/c/samples/simple.c rename to examples/c/simple.c From 99130ff7ade541b9f16227b873b71631e02b979e Mon Sep 17 00:00:00 2001 From: Rafik Saliev Date: Wed, 19 Aug 2026 04:05:01 -0700 Subject: [PATCH 2/3] [C API] Rename build option for C API tests to SVS_BUILD_C_API_TESTS --- .github/scripts/build-c-api-bindings.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/build-c-api-bindings.sh b/.github/scripts/build-c-api-bindings.sh index dc2a117b5..fdc2f1f80 100755 --- a/.github/scripts/build-c-api-bindings.sh +++ b/.github/scripts/build-c-api-bindings.sh @@ -45,7 +45,7 @@ cmake -B"${BUILD_DIR}" -S"${WORKSPACE}" \ -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ -DCMAKE_INSTALL_LIBDIR=lib \ -DSVS_BUILD_C_API=ON \ - -DSVS_BUILD_TESTS=ON \ + -DSVS_BUILD_C_API_TESTS=ON \ -DSVS_BUILD_EXAMPLES=ON \ -DSVS_RUNTIME_ENABLE_LVQ_LEANVEC="${ENABLE_LVQ_LEANVEC}" \ -DSVS_REQUIRE_LTO_ARCHIVE="${REQUIRE_LTO_ARCHIVE}" From a4fde7a3fed147038ea742113f707f625e35d248 Mon Sep 17 00:00:00 2001 From: Rafik Saliev Date: Wed, 19 Aug 2026 05:43:03 -0700 Subject: [PATCH 3/3] Eanble testing in ther root directory --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 418079e22..d71f6dd68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,10 @@ endif() if(SVS_BUILD_C_API) add_subdirectory(bindings/c) + if(SVS_BUILD_C_API_TESTS) + include(CTest) + enable_testing() + endif() endif() if(SVS_BUILD_BINARIES) @@ -103,6 +107,9 @@ if(SVS_BUILD_BINARIES) endif() if(SVS_BUILD_TESTS) + # Add test to CTest + include(CTest) + enable_testing() add_subdirectory(tests) endif()