diff options
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | GNUmakefile | 17 | ||||
-rwxr-xr-x | build-aux/stack.c.gen | 6 | ||||
-rw-r--r-- | libcr/coroutine.c | 2 | ||||
-rw-r--r-- | libmisc/tests/test_assert.c | 2 | ||||
-rw-r--r-- | libmisc/tests/test_log.c | 2 | ||||
-rw-r--r-- | libmisc/tests/test_rand.c | 6 |
7 files changed, 30 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e7b4682..e4f4d91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,13 @@ pico_sdk_init() add_compile_options(-Wall -Wextra -Wswitch-enum -Werror) +string(TOUPPER "${CMAKE_BUILD_TYPE}" _upper_cmake_build_type) +string(REPLACE " " ";" _build_type_flags "${CMAKE_C_FLAGS_${_upper_cmake_build_type}}") +if ("-DNDEBUG" IN_LIST _build_type_flags) + add_compile_options(-Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable) + target_compile_definitions(pico_printf INTERFACE PICO_PRINTF_ALWAYS_INCLUDED=1) +endif() + function(_suppress_tinyusb_warnings) __suppress_tinyusb_warnings() set_source_files_properties( diff --git a/GNUmakefile b/GNUmakefile index 9f5ad61..098f076 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -61,24 +61,25 @@ generate-clean: # `build` and `check` ########################################################## platforms := $(shell sed -nE 's/if *\(PICO_PLATFORM STREQUAL "(.*)"\)/\1/p' cmd/*/CMakeLists.txt) +build_types = Debug Release RelWithDebInfo MinSizeRel -build: $(foreach p,$(platforms),build/$p/build) +build: $(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/build)) .PHONY: build -$(foreach p,$(platforms),build/$p/Makefile): build/%/Makefile: - mkdir -p $(@D) && cd $(@D) && cmake -DCMAKE_BUILD_TYPE=Debug -DPICO_PLATFORM=$* ../.. +$(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/Makefile)): build/%/Makefile: + mkdir -p $(@D) && cd $(@D) && cmake -DPICO_PLATFORM=$(firstword $(subst -, ,$*)) -DCMAKE_BUILD_TYPE=$(lastword $(subst -, ,$*)) ../.. -$(foreach p,$(platforms),build/$p/build): build/%/build: build/%/Makefile generate +$(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/build)): build/%/build: build/%/Makefile generate $(MAKE) -C $(<D) -.PHONY: $(foreach p,$(platforms),build/$p/build) +.PHONY: $(foreach t,$(build_types),$(foreach p,$(platforms),build/$p-$t/build)) check: build - $(MAKE) -j1 -k $(foreach p,$(platforms),build/$p/check) + $(MAKE) -j1 -k $(foreach t,$(build-types),$(foreach p,$(platforms),build/$p-$t/check)) .PHONY: check -$(foreach p,$(platforms),build/$p/check): build/%/check: build/%/Makefile +$(foreach t,$(build-types),$(foreach p,$(platforms),build/$p-$t/check)): build/%/check: build/%/Makefile CTEST_OUTPUT_ON_FAILURE=1 $(MAKE) -C $(<D) test -.PHONY: $(foreach p,$(platforms),build/$p/check) +.PHONY: $(foreach t,$(build-types),$(foreach p,$(platforms),build/$p-$t/check)) # `lint` and `format` ########################################################## diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen index dd7aff9..61d7bce 100755 --- a/build-aux/stack.c.gen +++ b/build-aux/stack.c.gen @@ -463,10 +463,8 @@ def main( return True if ( len(chain) >= sbc_9p_max_depth - and call.endswith("/srv.c:util_release") - and all( - c.endswith("/srv.c:util_release") for c in chain[-sbc_9p_max_depth:] - ) + and "/srv.c:util_release" in call + and all(("/srv.c:util_release" in c) for c in chain[-sbc_9p_max_depth:]) ): return True return False diff --git a/libcr/coroutine.c b/libcr/coroutine.c index 32253c8..129f4da 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -761,6 +761,7 @@ cid_t cr_getcid(void) { return coroutine_running; } +#ifndef NDEBUG void cr_assert_in_coroutine(void) { assert(!cr_plat_is_in_intrhandler()); assert_cid_state(coroutine_running, state == CR_RUNNING); @@ -769,6 +770,7 @@ void cr_assert_in_coroutine(void) { void cr_assert_in_intrhandler(void) { assert(cr_plat_is_in_intrhandler()); } +#endif /* cr_cid_info() **************************************************************/ diff --git a/libmisc/tests/test_assert.c b/libmisc/tests/test_assert.c index 0c51bbd..3c2d6b6 100644 --- a/libmisc/tests/test_assert.c +++ b/libmisc/tests/test_assert.c @@ -74,6 +74,7 @@ int __lm_printf(const char *format, ...) { static_assert(sizeof(char) == 1); int main() { +#ifndef NDEBUG test_should_succeed(assert(true)); test_should_fail(assert(false), "error: ASSERT: "__FILE__":"LM_STR_(__LINE__)":main(): assertion \"false\" failed\n"); @@ -88,5 +89,6 @@ int main() { free(global_log); global_log = NULL; } +#endif return 0; } diff --git a/libmisc/tests/test_log.c b/libmisc/tests/test_log.c index e819c09..49a76ca 100644 --- a/libmisc/tests/test_log.c +++ b/libmisc/tests/test_log.c @@ -57,6 +57,7 @@ int main() { errorf("val=%d", 42)); should_print("info : FROBNICATE: val=0\n", infof("val=%d", 0)); +#ifndef NDEBUG #define CONFIG_FROBNICATE_DEBUG 1 should_print("debug: FROBNICATE: val=-2\n", debugf("val=%d", -2)); @@ -64,5 +65,6 @@ int main() { #define CONFIG_FROBNICATE_DEBUG 0 should_print(NULL, debugf("val=%d", -2)); +#endif return 0; } diff --git a/libmisc/tests/test_rand.c b/libmisc/tests/test_rand.c index 282c6a4..8076155 100644 --- a/libmisc/tests/test_rand.c +++ b/libmisc/tests/test_rand.c @@ -14,6 +14,7 @@ /* Intercept failures *********************************************************/ +#ifndef NDEBUG jmp_buf *__catch; void __lm_abort(void) { @@ -34,6 +35,7 @@ void __lm_abort(void) { __catch = old_catch; \ } \ } while (0); +#endif /* Actual tests ***************************************************************/ @@ -42,7 +44,11 @@ void __lm_abort(void) { static void test_n(uint64_t cnt) { if (cnt == 0 || cnt > UINT64_C(1)<<63) { +#ifndef NDEBUG should_abort(rand_uint63n(cnt)); +#else + return; +#endif } else { double sum = 0; bool seen[MAX_SEE_ALL] = {0}; |