make all non hardware_ libraries foo add C preprocessor definition LIB_FOO=1, and remove bespoke definitions which were all undocumented anyway (#374)

This commit is contained in:
Graham Sanderson
2021-05-04 08:00:17 -05:00
committed by GitHub
parent 6796faf0d5
commit b7da70a53b
46 changed files with 114 additions and 183 deletions

View File

@ -1,12 +1,9 @@
if (NOT TARGET pico_printf)
# library to be depended on - we make this depend on particular implementations using per target generator expressions
add_library(pico_printf INTERFACE)
pico_add_impl_library(pico_printf)
# no custom implementation; falls thru to compiler
add_library(pico_printf_compiler INTERFACE)
target_compile_definitions(pico_printf_compiler INTERFACE
PICO_PRINTF_COMPILER=1
)
pico_add_impl_library(pico_printf_compiler)
add_library(pico_printf_headers INTERFACE)
target_include_directories(pico_printf_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
@ -20,28 +17,20 @@ if (NOT TARGET pico_printf)
target_link_libraries(pico_printf INTERFACE
$<IF:$<BOOL:$<TARGET_PROPERTY:PICO_TARGET_PRINTF_IMPL>>,$<TARGET_PROPERTY:PICO_TARGET_PRINTF_IMPL>,${PICO_DEFAULT_PRINTF_IMPL}>)
add_library(pico_printf_pico INTERFACE)
pico_add_impl_library(pico_printf_pico)
target_sources(pico_printf_pico INTERFACE
${CMAKE_CURRENT_LIST_DIR}/printf.c
)
target_compile_definitions(pico_printf_pico INTERFACE
PICO_PRINTF_PICO=1
)
target_link_libraries(pico_printf_pico INTERFACE pico_printf_headers)
add_library(pico_printf_none INTERFACE)
pico_add_impl_library(pico_printf_none)
target_sources(pico_printf_none INTERFACE
${CMAKE_CURRENT_LIST_DIR}/printf_none.S
)
target_link_libraries(pico_printf_none INTERFACE pico_printf_headers)
target_compile_definitions(pico_printf_none INTERFACE
PICO_PRINTF_NONE=1
)
function(wrap_printf_functions TARGET)
# note that printf and vprintf are in pico_stdio so we can provide thread safety
pico_wrap_function(${TARGET} sprintf)

View File

@ -55,7 +55,7 @@ extern "C" {
#endif
#endif
#if PICO_PRINTF_PICO
#if LIB_PICO_PRINTF_PICO
// weak raw printf may be a puts if printf has not been called,
// so that we can support gc of printf when it isn't called
//

View File

@ -918,7 +918,7 @@ int vfctprintf(void (*out)(char character, void *arg), void *arg, const char *fo
return _vsnprintf(_out_fct, (char *) (uintptr_t) &out_fct_wrap, (size_t) -1, format, va);
}
#if PICO_PRINTF_PICO
#if LIB_PICO_PRINTF_PICO
#if !PICO_PRINTF_ALWAYS_INCLUDED
bool weak_raw_printf(const char *fmt, ...) {
va_list va;