aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meson.build8
-rw-r--r--meson_options.txt3
-rw-r--r--tools/.clang-tidy7
-rw-r--r--tools/chilbert_obj.cpp (renamed from src/chilbert_obj.cpp)3
-rw-r--r--tools/chilbert_svg.cpp (renamed from src/chilbert_svg.cpp)7
-rw-r--r--tools/meson.build15
6 files changed, 39 insertions, 4 deletions
diff --git a/meson.build b/meson.build
index 8d3152c..c71fdfc 100644
--- a/meson.build
+++ b/meson.build
@@ -86,7 +86,7 @@ detail_headers = files(
)
# Declare dependency for internal meson dependants
-spaix_dep = declare_dependency(include_directories: include_dirs)
+chilbert_dep = declare_dependency(include_directories: include_dirs)
# Generage pkg-config file for external dependants
pkg.generate(
@@ -101,6 +101,12 @@ pkg.generate(
install_headers(headers, subdir: versioned_name / 'chilbert')
install_headers(detail_headers, subdir: versioned_name / 'chilbert' / 'detail')
+#########
+# Tools #
+#########
+
+subdir('tools')
+
######################
# Tests / Benchmarks #
######################
diff --git a/meson_options.txt b/meson_options.txt
index e090a29..3210b0d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -9,3 +9,6 @@ option('strict', type: 'boolean', value: false, yield: true,
option('tests', type: 'feature', value: 'auto', yield: true,
description: 'Build tests')
+
+option('tools', type: 'feature', value: 'auto', yield: true,
+ description: 'Build command line utilities')
diff --git a/tools/.clang-tidy b/tools/.clang-tidy
new file mode 100644
index 0000000..2bcf741
--- /dev/null
+++ b/tools/.clang-tidy
@@ -0,0 +1,7 @@
+# Copyright 2020-2022 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: 0BSD OR GPL-2.0-or-later
+
+Checks: >
+ -*-vararg,
+ -cert-err33-c,
+InheritParentConfig: true
diff --git a/src/chilbert_obj.cpp b/tools/chilbert_obj.cpp
index 76039d0..b80fa91 100644
--- a/src/chilbert_obj.cpp
+++ b/tools/chilbert_obj.cpp
@@ -4,6 +4,7 @@
#include "chilbert/chilbert.hpp"
#include <array>
+#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
@@ -24,7 +25,7 @@ main(int argc, char** argv)
// Vertices
for (uint64_t i = 0; i < num_points; ++i) {
- std::array<uint32_t, 3> point;
+ std::array<uint32_t, 3> point{};
chilbert::index_to_coords(point, 16, 3, i);
printf("v %u %u %u\n", point[0], point[1], point[2]);
}
diff --git a/src/chilbert_svg.cpp b/tools/chilbert_svg.cpp
index a572f68..140b99a 100644
--- a/src/chilbert_svg.cpp
+++ b/tools/chilbert_svg.cpp
@@ -4,6 +4,7 @@
#include "chilbert/chilbert.hpp"
#include <array>
+#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
@@ -24,7 +25,9 @@ main(int argc, char** argv)
}
const uint32_t w =
- uint32_t(sqrt(1 << uint32_t(ceil(log2(double(num_points)))))) - 1;
+ static_cast<uint32_t>(sqrt(1U << static_cast<uint32_t>(ceil(
+ log2(static_cast<double>(num_points)))))) -
+ 1U;
// Header
printf("<svg xmlns='http://www.w3.org/2000/svg'"
@@ -37,7 +40,7 @@ main(int argc, char** argv)
// One polyline through all vertices
for (uint64_t i = 0; i <= num_points; ++i) {
- std::array<uint32_t, 2> point;
+ std::array<uint32_t, 2> point{};
chilbert::index_to_coords(point, 32, 2, i);
printf("%u,%u ", point[0], point[1]);
}
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..1a12aba
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,15 @@
+# Copyright 2019-2022 David Robillard <d@drobilla.net>
+# SPDX-License-Identifier: 0BSD OR GPL-2.0-or-later
+
+tools = [
+ 'chilbert_obj',
+ 'chilbert_svg',
+]
+
+foreach tool : tools
+ executable(
+ tool,
+ files('@0@.cpp'.format(tool)),
+ dependencies: [chilbert_dep],
+ )
+endforeach