diff options
author | David Robillard <d@drobilla.net> | 2022-09-16 15:39:48 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-09-16 22:31:06 -0400 |
commit | 49dab5622b31421eb6af84eae376d73fae1cd4a0 (patch) | |
tree | 86290707551320ab35952bccc11c66df05714b26 | |
parent | 342a22b6d75597ee22c195b60607402e3ed028b2 (diff) | |
download | chilbert-49dab5622b31421eb6af84eae376d73fae1cd4a0.tar.gz chilbert-49dab5622b31421eb6af84eae376d73fae1cd4a0.tar.bz2 chilbert-49dab5622b31421eb6af84eae376d73fae1cd4a0.zip |
Switch to meson build system
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 99 | ||||
-rw-r--r-- | benchmark/bench_bitvec.cpp (renamed from test/bench_bitvec.cpp) | 0 | ||||
-rw-r--r-- | benchmark/bench_hilbert.cpp (renamed from test/bench_hilbert.cpp) | 0 | ||||
-rw-r--r-- | benchmark/bench_utils.hpp (renamed from test/bench_utils.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/BoundedBitVec.hpp (renamed from chilbert/BoundedBitVec.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/DynamicBitVec.hpp (renamed from chilbert/DynamicBitVec.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/SmallBitVec.hpp (renamed from chilbert/SmallBitVec.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/StaticBitVec.hpp (renamed from chilbert/StaticBitVec.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/chilbert.hpp (renamed from chilbert/chilbert.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/chilbert.ipp (renamed from chilbert/chilbert.ipp) | 8 | ||||
-rw-r--r-- | include/chilbert/detail/BitVecIndex.hpp (renamed from chilbert/detail/BitVecIndex.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/detail/BitVecIterator.hpp (renamed from chilbert/detail/BitVecIterator.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/detail/BitVecMask.hpp (renamed from chilbert/detail/BitVecMask.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/detail/MultiBitVec.hpp (renamed from chilbert/detail/MultiBitVec.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/detail/gray_code_rank.hpp (renamed from chilbert/detail/gray_code_rank.hpp) | 2 | ||||
-rw-r--r-- | include/chilbert/detail/operations.hpp (renamed from chilbert/detail/operations.hpp) | 12 | ||||
-rw-r--r-- | include/chilbert/detail/traits.hpp (renamed from chilbert/detail/traits.hpp) | 0 | ||||
-rw-r--r-- | include/chilbert/operators.hpp (renamed from chilbert/operators.hpp) | 0 | ||||
-rw-r--r-- | meson.build | 150 | ||||
-rw-r--r-- | meson/warnings/meson.build | 196 | ||||
-rw-r--r-- | meson_options.txt | 8 | ||||
-rw-r--r-- | src/chilbert_obj.cpp (renamed from bin/chilbert_obj.cpp) | 0 | ||||
-rw-r--r-- | src/chilbert_svg.cpp (renamed from bin/chilbert_svg.cpp) | 0 |
24 files changed, 366 insertions, 110 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/
\ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 3a8b625..0000000 --- a/Makefile +++ /dev/null @@ -1,99 +0,0 @@ -################# -# Configuration # -################# - -# User variables -DEBUG ?= 0 -TEST ?= 0 - -prefix ?= /usr/local -includedir ?= $(prefix)/include -bindir ?= $(prefix)/bin - -# Wipe user flags if DEBUG is on -ifeq ($(DEBUG), 1) -CXXFLAGS = -O0 -g -endif - -# Append mandatory flags -CXXFLAGS += -I. -std=c++14 - -# Set strict debugging flags for known compilers -ifeq ($(DEBUG), 1) - -ifeq ($(findstring clang,$(CXX)),clang) - CXXFLAGS += -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -else ifeq ($(findstring g++,$(CXX)),g++) - CXXFLAGS += -ftree-vrp -ftrapv -Waddress -Wall -Warray-bounds=2 -Wbool-compare -Wc++14-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wchkp -Wclobbered -Wcomment -Wconditionally-supported -Wconversion -Wcoverage-mismatch -Wdate-time -Wdelete-incomplete -Wdisabled-optimization -Wdouble-promotion -Wduplicated-cond -Wempty-body -Wenum-compare -Werror=pedantic -Wextra -Wfloat-conversion -Wfloat-equal -Wformat -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat-y2k -Wformat=2 -Wframe-address -Whsa -Wignored-attributes -Wignored-qualifiers -Winit-self -Winline -Winvalid-memory-model -Winvalid-pch -Wlogical-not-parentheses -Wlogical-op -Wmain -Wmaybe-uninitialized -Wmemset-transposed-args -Wmisleading-indentation -Wmissing-declarations -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wno-aggressive-loop-optimizations -Wno-attributes -Wno-builtin-macro-redefined -Wno-cpp -Wno-deprecated -Wno-deprecated-declarations -Wno-div-by-zero -Wno-endif-labels -Wno-format-contains-nul -Wno-format-extra-args -Wno-free-nonheap-object -Wno-int-to-pointer-cast -Wno-invalid-offsetof -Wno-multichar -Wno-overflow -Wno-pedantic-ms-format -Wno-pragmas -Wno-return-local-addr -Wno-scalar-storage-order -Wno-undef -Wno-unused-result -Wnonnull -Wnonnull-compare -Wnormalized -Wnull-dereference -Wodr -Wopenmp-simd -Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wparentheses -Wpedantic -Wplacement-new=2 -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value -Wshift-overflow -Wshift-overflow=2 -Wsign-compare -Wsign-conversion -Wsizeof-array-argument -Wsizeof-pointer-memaccess -Wstack-protector -Wstrict-aliasing -Wstrict-overflow -Wsubobject-linkage -Wsuggest-attribute=const -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-final-methods -Wsuggest-final-types -Wsuggest-override -Wswitch -Wswitch-bool -Wswitch-default -Wswitch-enum -Wsync-nand -Wtautological-compare -Wtrampolines -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations -Wunused -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-const-variable -Wunused-const-variable=2 -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-parameter -Wunused-value -Wunused-variable -Wuseless-cast -Wvariadic-macros -Wvector-operation-performance -Wvla -Wvolatile-register-var -Wwrite-strings -Wzero-as-null-pointer-constant -fstrict-aliasing -fstrict-overflow -pedantic-errors -else -$(info warning: Unknown compiler, not setting strict debugging flags) -$(info ) -endif - -endif # DEBUG - - -############### -# Build Rules # -############### - -HEADERS = $(wildcard chilbert/*.hpp) $(wildcard chilbert/*.ipp) -DETAIL_HEADERS = $(wildcard chilbert/detail/*.hpp) -TESTS = test/test_bitvec test/test_gray_code_rank test/test_hilbert -BENCHMARKS = test/bench_bitvec test/bench_hilbert -PROGS = bin/chilbert_obj bin/chilbert_svg - -ALL_HEADERS = $(HEADERS) $(DETAIL_HEADERS) -PROG_NAMES = $(subst bin/,,$(PROGS)) - -all: $(PROGS) - -tests: $(TESTS) - -benchmarks: $(BENCHMARKS) - -test/%: test/%.cpp $(ALL_HEADERS) - $(CXX) $(CXXFLAGS) -o $@ $@.cpp - -test/test_hilbert: test/test_hilbert.cpp $(ALL_HEADERS) - $(CXX) $(CXXFLAGS) -lgmp -lgmpxx -o $@ $@.cpp - -bin/%: bin/%.cpp $(ALL_HEADERS) - $(CXX) $(CXXFLAGS) -o $@ $@.cpp - - -################## -# Forced Targets # -################## - -FORCE: - -clean: - rm -f $(PROGS) $(TESTS) $(BENCHMARKS) - -%.run: % - $* - -test: tests $(addsuffix .run, $(TESTS)) FORCE - -bench: $(BENCHMARKS) - mkdir -p benchmarks - cd benchmarks && ../test/bench_bitvec - cd benchmarks && ../test/bench_hilbert - cd benchmarks && ./plot.py - -install: FORCE - install -d $(DESTDIR)$(includedir)/chilbert/ - install -d $(DESTDIR)$(includedir)/chilbert/detail/ - install -d $(DESTDIR)$(bindir)/ - - install -m 755 -t $(DESTDIR)$(includedir)/chilbert/ $(HEADERS) - install -m 755 -t $(DESTDIR)$(includedir)/chilbert/detail/ $(DETAIL_HEADERS) - install -m 755 -t $(DESTDIR)$(bindir)/ $(PROGS) - -uninstall: FORCE - rm -f $(subst bin/,$(DESTDIR)$(bindir)/,$(PROGS)) - rm -f $(subst chilbert/,$(DESTDIR)$(includedir)/chilbert/,$(ALL_HEADERS)) - - -rmdir $(DESTDIR)$(bindir)/ - -rmdir -p $(DESTDIR)$(includedir)/chilbert/detail/ diff --git a/test/bench_bitvec.cpp b/benchmark/bench_bitvec.cpp index 6580af9..6580af9 100644 --- a/test/bench_bitvec.cpp +++ b/benchmark/bench_bitvec.cpp diff --git a/test/bench_hilbert.cpp b/benchmark/bench_hilbert.cpp index 52c12dc..52c12dc 100644 --- a/test/bench_hilbert.cpp +++ b/benchmark/bench_hilbert.cpp diff --git a/test/bench_utils.hpp b/benchmark/bench_utils.hpp index a3f7f81..a3f7f81 100644 --- a/test/bench_utils.hpp +++ b/benchmark/bench_utils.hpp diff --git a/chilbert/BoundedBitVec.hpp b/include/chilbert/BoundedBitVec.hpp index fa414ca..fa414ca 100644 --- a/chilbert/BoundedBitVec.hpp +++ b/include/chilbert/BoundedBitVec.hpp diff --git a/chilbert/DynamicBitVec.hpp b/include/chilbert/DynamicBitVec.hpp index 722b689..722b689 100644 --- a/chilbert/DynamicBitVec.hpp +++ b/include/chilbert/DynamicBitVec.hpp diff --git a/chilbert/SmallBitVec.hpp b/include/chilbert/SmallBitVec.hpp index 599f789..599f789 100644 --- a/chilbert/SmallBitVec.hpp +++ b/include/chilbert/SmallBitVec.hpp diff --git a/chilbert/StaticBitVec.hpp b/include/chilbert/StaticBitVec.hpp index 9aff3ad..9aff3ad 100644 --- a/chilbert/StaticBitVec.hpp +++ b/include/chilbert/StaticBitVec.hpp diff --git a/chilbert/chilbert.hpp b/include/chilbert/chilbert.hpp index c55fc14..c55fc14 100644 --- a/chilbert/chilbert.hpp +++ b/include/chilbert/chilbert.hpp diff --git a/chilbert/chilbert.ipp b/include/chilbert/chilbert.ipp index fca7516..7a5b9b7 100644 --- a/chilbert/chilbert.ipp +++ b/include/chilbert/chilbert.ipp @@ -161,7 +161,7 @@ template <class I> inline void update1(const I& l, const I& t, const I& w, const size_t n, I& e, size_t& d) { - assert(0 <= d && d < n); + assert(d < n); e = l; e.flip(d); //#D d == n-1 ? 0 : d+1 ); @@ -173,7 +173,7 @@ update1(const I& l, const I& t, const I& w, const size_t n, I& e, size_t& d) if (d >= n) { d -= n; } - assert(0 <= d && d < n); + assert(d < n); if (!w.test(0)) { e.flip(d == 0 ? n - 1 : d - 1); //#D d ); @@ -185,7 +185,7 @@ template <class I> inline void update2(const I& l, const I& t, const size_t n, I& e, size_t& d) { - assert(0 <= d && d < n); + assert(d < n); e = l; e.flip(d); //#D d == n-1 ? 0 : d+1 ); @@ -197,7 +197,7 @@ update2(const I& l, const I& t, const size_t n, I& e, size_t& d) if (d >= n) { d -= n; } - assert(0 <= d && d < n); + assert(d < n); } template <class P, class H, class I> diff --git a/chilbert/detail/BitVecIndex.hpp b/include/chilbert/detail/BitVecIndex.hpp index e7b385e..e7b385e 100644 --- a/chilbert/detail/BitVecIndex.hpp +++ b/include/chilbert/detail/BitVecIndex.hpp diff --git a/chilbert/detail/BitVecIterator.hpp b/include/chilbert/detail/BitVecIterator.hpp index 8902747..8902747 100644 --- a/chilbert/detail/BitVecIterator.hpp +++ b/include/chilbert/detail/BitVecIterator.hpp diff --git a/chilbert/detail/BitVecMask.hpp b/include/chilbert/detail/BitVecMask.hpp index 03eaf5f..03eaf5f 100644 --- a/chilbert/detail/BitVecMask.hpp +++ b/include/chilbert/detail/BitVecMask.hpp diff --git a/chilbert/detail/MultiBitVec.hpp b/include/chilbert/detail/MultiBitVec.hpp index 573deef..573deef 100644 --- a/chilbert/detail/MultiBitVec.hpp +++ b/include/chilbert/detail/MultiBitVec.hpp diff --git a/chilbert/detail/gray_code_rank.hpp b/include/chilbert/detail/gray_code_rank.hpp index b17f193..03c1169 100644 --- a/chilbert/detail/gray_code_rank.hpp +++ b/include/chilbert/detail/gray_code_rank.hpp @@ -155,7 +155,7 @@ extract_mask(const size_t* const ms, I& mask, size_t& b) { - assert(0 <= d && d < n); + assert(d < n); assert(mask.size() == n); mask.reset(); diff --git a/chilbert/detail/operations.hpp b/include/chilbert/detail/operations.hpp index 1c6b8bf..7e846b3 100644 --- a/chilbert/detail/operations.hpp +++ b/include/chilbert/detail/operations.hpp @@ -102,17 +102,17 @@ set_bit(T& field, const size_t index, const bool value) /// Return 1 + the index of the least significant 1-bit of `field`, or zero template <typename T> -int pop_count(const T& field); +inline int pop_count(const T& field); template <> -int +inline int pop_count<unsigned long>(const unsigned long& field) { return __builtin_popcountl(field); } template <> -int +inline int pop_count<unsigned long long>(const unsigned long long& field) { return __builtin_popcountll(field); @@ -120,17 +120,17 @@ pop_count<unsigned long long>(const unsigned long long& field) /// Return 1 + the index of the least significant 1-bit of `field`, or zero template <typename T> -int find_first(const T field); +inline int find_first(const T field); template <> -int +inline int find_first<unsigned long>(const unsigned long field) { return __builtin_ffsl(static_cast<long>(field)); } template <> -int +inline int find_first<unsigned long long>(const unsigned long long field) { return __builtin_ffsll(static_cast<long long>(field)); diff --git a/chilbert/detail/traits.hpp b/include/chilbert/detail/traits.hpp index 0cb0f03..0cb0f03 100644 --- a/chilbert/detail/traits.hpp +++ b/include/chilbert/detail/traits.hpp diff --git a/chilbert/operators.hpp b/include/chilbert/operators.hpp index efad7f4..efad7f4 100644 --- a/chilbert/operators.hpp +++ b/include/chilbert/operators.hpp diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..2dabce7 --- /dev/null +++ b/meson.build @@ -0,0 +1,150 @@ +# Copyright 2019-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR GPL-2.0-or-later + +project('chilbert', ['cpp'], + version: '0.0.1', + license: 'GPLv2+', + meson_version: '>= 0.56.0', + default_options: [ + 'b_ndebug=if-release', + 'buildtype=release', + 'cpp_std=c++14', + ]) + +major_version = meson.project_version().split('.')[0] +versioned_name = 'chilbert-@0@'.format(major_version) + +####################### +# Compilers and Flags # +####################### + +# Required tools +pkg = import('pkgconfig') +cpp = meson.get_compiler('cpp') + +# Set global warning flags +if get_option('strict') + if not meson.is_subproject() + subdir('meson/warnings') + add_project_arguments(all_cpp_warnings, language: ['cpp']) + endif + + cpp_suppressions = [] + if cpp.get_id() == 'gcc' + cpp_suppressions += [ + '-Wno-effc++', + '-Wno-volatile', + ] + elif cpp.get_id() == 'msvc' + cpp_suppressions += [ + '/wd4028', # formal parameter different from declaration + '/wd4204', # non-constant aggregate initializer + '/wd4514', # unreferenced inline function has been removed + '/wd4668', # not defined as a preprocessor macro + '/wd4706', # assignment within conditional expression + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4820', # padding added after construct + '/wd5045', # will insert Spectre mitigation + ] + endif + + add_project_arguments( + cpp.get_supported_arguments(cpp_suppressions), + language: ['cpp'], + ) +endif + +########### +# Library # +########### + +include_dirs = include_directories('include') + +headers = [ + 'include/chilbert/BoundedBitVec.hpp', + 'include/chilbert/DynamicBitVec.hpp', + 'include/chilbert/SmallBitVec.hpp', + 'include/chilbert/StaticBitVec.hpp', + 'include/chilbert/chilbert.hpp', + 'include/chilbert/chilbert.ipp', + 'include/chilbert/operators.hpp', +] + +detail_headers = [ + 'include/chilbert/detail/BitVecIndex.hpp', + 'include/chilbert/detail/BitVecIterator.hpp', + 'include/chilbert/detail/BitVecMask.hpp', + 'include/chilbert/detail/MultiBitVec.hpp', + 'include/chilbert/detail/gray_code_rank.hpp', + 'include/chilbert/detail/operations.hpp', + 'include/chilbert/detail/traits.hpp', +] + +# Declare dependency for internal meson dependants +spaix_dep = declare_dependency(include_directories: include_dirs) + +# Generage pkg-config file for external dependants +pkg.generate( + description: 'Implementation of Compact Hilbert Indices', + filebase: versioned_name, + name: 'Chilbert', + subdirs: [versioned_name], + version: meson.project_version(), +) + +# Install headers to a versioned include directory +install_headers(headers, subdir: versioned_name / 'chilbert') +install_headers(headers, subdir: versioned_name / 'chilbert' / 'detail') + +###################### +# Tests / Benchmarks # +###################### + +# Build and run tests +if not get_option('tests').disabled() + foreach name : ['bitvec', 'gray_code_rank'] + full_name = 'test_@0@'.format(name) + test( + full_name, + executable( + full_name, + 'test/@0@.cpp'.format(full_name), + include_directories: include_directories('include'), + ), + timeout: 1200, + ) + endforeach + + gmp_dep = cpp.find_library('gmp', required: false) + gmpxx_dep = cpp.find_library('gmpxx', required: false) + if gmp_dep.found() and gmpxx_dep.found() + test( + 'test_hilbert', + executable( + 'test_hilbert', + 'test/test_hilbert.cpp', + include_directories: include_directories('include'), + dependencies: [gmp_dep, gmpxx_dep], + ), + ) + endif +endif + +# Build benchmarks +if not get_option('benchmarks').disabled() + foreach name : ['bitvec', 'hilbert'] + executable( + 'bench_@0@'.format(name), + files('benchmark/bench_@0@.cpp'.format(name)), + include_directories: include_directories('include', 'test'), + ) + endforeach +endif + +# Display configuration summary +if not meson.is_subproject() + summary('Tests', not get_option('tests').disabled(), bool_yn: true) + summary('Install prefix', get_option('prefix')) + summary('Headers', get_option('prefix') / get_option('includedir')) +endif diff --git a/meson/warnings/meson.build b/meson/warnings/meson.build new file mode 100644 index 0000000..ef0dd47 --- /dev/null +++ b/meson/warnings/meson.build @@ -0,0 +1,196 @@ +# Copyright 2020-2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: CC0-1.0 OR GPL-3.0-only + +# General code to enable approximately all warnings in GCC 12, clang, and MSVC. +# +# This is trivial for clang and MSVC, but GCC doesn't have an "everything" +# option, so we need to enable everything we want explicitly. Wall is assumed, +# but Wextra is not, for stability. +# +# These are collected from common.opt and c.opt in the GCC source, and manually +# curated with the help of the GCC documentation. Warnings that are +# application-specific, historical, or about compatibility between specific +# language revisions are omitted. The intent here is to have roughly the same +# meaning as clang's Weverything: extremely strict, but general. Specifically +# omitted are: +# +# General: +# +# Wabi= +# Waggregate-return +# Walloc-size-larger-than=BYTES +# Walloca-larger-than=BYTES +# Wframe-larger-than=BYTES +# Wlarger-than=BYTES +# Wstack-usage=BYTES +# Wsystem-headers +# Wtraditional +# Wtraditional-conversion +# Wtrampolines +# Wvla-larger-than=BYTES +# +# Build specific: +# +# Wpoison-system-directories +# +# C Specific: +# +# Wc11-c2x-compat +# Wc90-c99-compat +# Wc99-c11-compat +# Wdeclaration-after-statement +# Wtraditional +# Wtraditional-conversion +# +# C++ Specific: +# +# Wc++0x-compat +# Wc++1z-compat +# Wc++2a-compat +# Wctad-maybe-unsupported +# Wnamespaces +# Wtemplates + +gcc_common_warnings = [ + '-Walloc-zero', + '-Walloca', + '-Wanalyzer-too-complex', + '-Warith-conversion', + '-Warray-bounds=2', + '-Wattribute-alias=2', + '-Wbidi-chars=ucn', + '-Wcast-align=strict', + '-Wcast-function-type', + '-Wcast-qual', + '-Wclobbered', + '-Wconversion', + '-Wdate-time', + '-Wdisabled-optimization', + '-Wdouble-promotion', + '-Wduplicated-branches', + '-Wduplicated-cond', + '-Wempty-body', + '-Wendif-labels', + '-Wfloat-equal', + '-Wformat-overflow=2', + '-Wformat-signedness', + '-Wformat-truncation=2', + '-Wformat=2', + '-Wignored-qualifiers', + '-Wimplicit-fallthrough=3', + '-Winit-self', + '-Winline', + '-Winvalid-pch', + '-Wlogical-op', + '-Wmissing-declarations', + '-Wmissing-field-initializers', + '-Wmissing-include-dirs', + '-Wmultichar', + '-Wnormalized=nfc', + '-Wnull-dereference', + '-Wopenacc-parallelism', + '-Woverlength-strings', + '-Wpacked', + '-Wpacked-bitfield-compat', + '-Wpadded', + '-Wpointer-arith', + '-Wredundant-decls', + '-Wshadow', + '-Wshift-negative-value', + '-Wshift-overflow=2', + '-Wstack-protector', + '-Wstrict-aliasing=3', + '-Wstrict-overflow=5', + '-Wstring-compare', + '-Wstringop-overflow=3', + '-Wsuggest-attribute=cold', + '-Wsuggest-attribute=const', + '-Wsuggest-attribute=format', + '-Wsuggest-attribute=malloc', + '-Wsuggest-attribute=noreturn', + '-Wsuggest-attribute=pure', + '-Wswitch-default', + '-Wswitch-enum', + '-Wtrampolines', + '-Wtrivial-auto-var-init', + '-Wtype-limits', + '-Wundef', + '-Wuninitialized', + '-Wunsafe-loop-optimizations', + '-Wunused', + '-Wunused-const-variable=2', + '-Wunused-macros', + '-Wvector-operation-performance', + '-Wvla', + '-Wwrite-strings', +] + +####### +# C++ # +####### + +if is_variable('cpp') + all_cpp_warnings = [] + + if cpp.get_id() == 'clang' + all_cpp_warnings += [ + '-Weverything', + '-Wno-c++98-compat', + '-Wno-c++98-compat-pedantic' + ] + + if not meson.is_cross_build() + all_cpp_warnings += [ + '-Wno-poison-system-directories', + ] + endif + + elif cpp.get_id() == 'gcc' + all_cpp_warnings += gcc_common_warnings + [ + '-Wabi-tag', + '-Waligned-new=all', + '-Wcatch-value=3', + '-Wcomma-subscript', + '-Wconditionally-supported', + '-Wctor-dtor-privacy', + '-Wdelete-non-virtual-dtor', + '-Wdeprecated', + '-Wdeprecated-copy', + '-Wdeprecated-copy-dtor', + '-Wdeprecated-enum-enum-conversion', + '-Wdeprecated-enum-float-conversion', + '-Weffc++', + '-Wexpansion-to-defined', + '-Wextra-semi', + '-Wimport', + '-Winvalid-imported-macros', + '-Wmismatched-tags', + '-Wmultiple-inheritance', + '-Wnoexcept', + '-Wnoexcept-type', + '-Wnon-virtual-dtor', + '-Wold-style-cast', + '-Woverloaded-virtual', + '-Wplacement-new=2', + '-Wredundant-move', + '-Wredundant-tags', + '-Wregister', + '-Wsign-compare', + '-Wsign-promo', + '-Wsized-deallocation', + '-Wstrict-null-sentinel', + '-Wsuggest-final-methods', + '-Wsuggest-final-types', + '-Wsuggest-override', + '-Wuseless-cast', + '-Wvirtual-inheritance', + '-Wvolatile', + '-Wzero-as-null-pointer-constant', + ] + + elif cpp.get_id() == 'msvc' + all_cpp_warnings += ['/Wall'] + endif + + all_cpp_warnings = cpp.get_supported_arguments(all_cpp_warnings) +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..4f5c9b4 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,8 @@ +option('benchmarks', type: 'feature', value: 'auto', yield: true, + description: 'Build benchmarks') + +option('strict', type: 'boolean', value: false, yield: true, + description: 'Enable ultra-strict warnings') + +option('tests', type: 'feature', value: 'auto', yield: true, + description: 'Build tests') diff --git a/bin/chilbert_obj.cpp b/src/chilbert_obj.cpp index 0f31fbd..0f31fbd 100644 --- a/bin/chilbert_obj.cpp +++ b/src/chilbert_obj.cpp diff --git a/bin/chilbert_svg.cpp b/src/chilbert_svg.cpp index dd4a3d4..dd4a3d4 100644 --- a/bin/chilbert_svg.cpp +++ b/src/chilbert_svg.cpp |