Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Dec 10, 2023
2 parents 7910168 + 497dfd9 commit 7050157
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 28 deletions.
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Tilen Majerle <tilen.majerle@gmail.com>
Tilen Majerle <tilen@majerle.eu>
Brian <bayuan@purdue.edu>
Peter Maxwell Warasila <madmaxwell@soundcomesout.com>
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Develop

## v1.0.5

- Fix building the library with `LWPRINTF_CFG_OS=1` and `LWPRINTF_CFG_OS_MANUAL_PROTECT=0` options

## v1.0.4

- Fix calculation for NULL terminated string and precision with 0 as an input
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ else()
)

# Add subdir with lwprintf and link to the project
set(LWPRINTF_OPTS_DIR ${CMAKE_CURRENT_LIST_DIR}/dev)
add_subdirectory(lwprintf)
target_link_libraries(${PROJECT_NAME} lwprintf)
endif()
10 changes: 5 additions & 5 deletions dev/lwprintf_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#ifndef LWPRINTF_HDR_OPTS_H
#define LWPRINTF_HDR_OPTS_H
Expand All @@ -42,10 +42,10 @@
* Open "include/lwprintf/lwprintf_opt.h" and
* copy & replace here settings you want to change values
*/
#define LWPRINTF_CFG_OS 1
#define LWPRINTF_CFG_OS_MUTEX_HANDLE HANDLE
#define LWPRINTF_CFG_OS 1
#define LWPRINTF_CFG_OS_MUTEX_HANDLE HANDLE

#define LWPRINTF_CFG_SUPPORT_LONG_LONG 1
#define LWPRINTF_CFG_OS_MANUAL_PROTECT 1
#define LWPRINTF_CFG_SUPPORT_LONG_LONG 1
#define LWPRINTF_CFG_OS_MANUAL_PROTECT 1

#endif /* OW_HDR_OPTS_H */
8 changes: 8 additions & 0 deletions docs/authors/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _authors:

Authors
=======

List of authors and contributors to the library

.. literalinclude:: ../../AUTHORS
18 changes: 16 additions & 2 deletions docs/get-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ Add library to project
^^^^^^^^^^^^^^^^^^^^^^

At this point it is assumed that you have successfully download library, either cloned it or from releases page.
Next step is to add the library to the project, by means of source files to compiler inputs and header files in search path
Next step is to add the library to the project, by means of source files to compiler inputs and header files in search path.

*CMake* is the main supported build system. Package comes with the ``CMakeLists.txt`` and ``library.cmake`` files, both located in the ``lwprintf`` directory:

* ``CMakeLists.txt``: Is a wrapper and only includes ``library.cmake`` file. It is used if target application uses ``add_subdirectory`` and then uses ``target_link_libraries`` to include the library in the project
* ``library.cmake``: It is a fully configured set of variables. User must use ``include(path/to/library.cmake)`` to include the library and must manually add files/includes to the final target

.. tip::
Open ``library.cmake`` file and manually analyze all the possible variables you can set for full functionality.

If you do not use the *CMake*, you can do the following:

* Copy ``lwprintf`` folder to your project, it contains library files
* Add ``lwprintf/src/include`` folder to `include path` of your toolchain. This is where `C/C++` compiler can find the files during compilation process. Usually using ``-I`` flag
Expand All @@ -78,7 +88,11 @@ and it should be copied (or simply renamed in-place) and named ``lwprintf_opts.h
File must be renamed to ``lwprintf_opts.h`` first and then copied to the project directory where compiler
include paths have access to it by using ``#include "lwprintf_opts.h"``.

List of configuration options are available in the :ref:`api_lwprintf_opt` section.
.. tip::
If you are using *CMake* build system, define the variable ``LWPRINTF_OPTS_DIR`` before adding library's directory to the *CMake* project.
Variable must set the output directory path. CMake will copy the template file there, and name it as required.

Configuration options list is available available in the :ref:`api_lwprintf_opt` section.
If any option is about to be modified, it should be done in configuration file

.. literalinclude:: ../../lwprintf/src/include/lwprintf/lwprintf_opts_template.h
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Table of contents
test-results/index
examples/index
changelog/index
authors/index

.. toctree::
:maxdepth: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#ifndef LWPRINTF_HDR_OPTS_H
#define LWPRINTF_HDR_OPTS_H
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "LwPRINTF",
"version": "1.0.4",
"version": "1.0.5",
"description": "Lightweight printf and sprintf library for embedded systems",
"keywords": "printf, lightweight, lwprintf, sprintf, snprintf, embedded, stdio, manager, library",
"repository": {
Expand Down
10 changes: 1 addition & 9 deletions lwprintf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
cmake_minimum_required(VERSION 3.22)

# Register core library
add_library(lwprintf INTERFACE)
target_sources(lwprintf PUBLIC ${CMAKE_CURRENT_LIST_DIR}/src/lwprintf/lwprintf.c)
target_include_directories(lwprintf INTERFACE ${CMAKE_CURRENT_LIST_DIR}/src/include)

if (DEFINED LWPRINTF_SYS_PORT)
target_sources(lwprintf PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/system/lwprintf_sys_${LWPRINTF_SYS_PORT}.c)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/library.cmake)
41 changes: 41 additions & 0 deletions lwprintf/library.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# This file provides set of variables for end user
# and also generates one (or more) libraries, that can be added to the project using target_link_libraries(...)
#
# Before this file is included to the root CMakeLists file (using include() function), user can set some variables:
#
# LWPRINTF_SYS_PORT: If defined, it will include port source file from the library.
# LWPRINTF_OPTS_DIR: If defined, it should set the folder path where options file shall be generated.
# LWPRINTF_COMPILE_OPTIONS: If defined, it provide compiler options for generated library.
# LWPRINTF_COMPILE_DEFINITIONS: If defined, it provides "-D" definitions to the library build
#

# Library core sources
set(lwprintf_core_SRCS
${CMAKE_CURRENT_LIST_DIR}/src/lwprintf/lwprintf.c
)

# Add system port
if(DEFINED LWPRINTF_SYS_PORT)
set(lwprintf_core_SRCS
${lwprintf_core_SRCS}
${CMAKE_CURRENT_LIST_DIR}/src/system/lwprintf_sys_${LWPRINTF_SYS_PORT}.c
)
endif()

# Setup include directories
set(lwprintf_include_DIRS
${CMAKE_CURRENT_LIST_DIR}/src/include
)

# Register library to the system
add_library(lwprintf INTERFACE)
target_sources(lwprintf INTERFACE ${lwprintf_core_SRCS})
target_include_directories(lwprintf INTERFACE ${lwprintf_include_DIRS})
target_compile_options(lwprintf PRIVATE ${LWPRINTF_COMPILE_OPTIONS})
target_compile_definitions(lwprintf PRIVATE ${LWPRINTF_COMPILE_DEFINITIONS})

# Create config file
if(DEFINED LWPRINTF_OPTS_DIR AND NOT EXISTS ${LWPRINTF_OPTS_DIR}/lwprintf_opts.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/src/include/lwprintf/lwprintf_opts_template.h ${LWPRINTF_OPTS_DIR}/lwprintf_opts.h COPYONLY)
endif()
2 changes: 1 addition & 1 deletion lwprintf/src/include/lwprintf/lwprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#ifndef LWPRINTF_HDR_H
#define LWPRINTF_HDR_H
Expand Down
2 changes: 1 addition & 1 deletion lwprintf/src/include/lwprintf/lwprintf_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#ifndef LWPRINTF_OPT_HDR_H
#define LWPRINTF_OPT_HDR_H
Expand Down
2 changes: 1 addition & 1 deletion lwprintf/src/include/lwprintf/lwprintf_opts_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#ifndef LWPRINTF_OPTS_HDR_H
#define LWPRINTF_OPTS_HDR_H
Expand Down
2 changes: 1 addition & 1 deletion lwprintf/src/include/system/lwprintf_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#ifndef LWPRINTF_SYS_HDR_H
#define LWPRINTF_SYS_HDR_H
Expand Down
6 changes: 3 additions & 3 deletions lwprintf/src/lwprintf/lwprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#include "lwprintf/lwprintf.h"
#include <float.h>
Expand Down Expand Up @@ -838,7 +838,7 @@ prv_format(lwprintf_int_t* lwi, va_list arg) {
const char* fmt = lwi->fmt;

#if LWPRINTF_CFG_OS && !LWPRINTF_CFG_OS_MANUAL_PROTECT
if (IS_PRINT_MODE(p) && /* OS protection only for print */
if (IS_PRINT_MODE(lwi) && /* OS protection only for print */
(!lwprintf_sys_mutex_isvalid(&lwi->lwobj->mutex) /* Invalid mutex handle */
|| !lwprintf_sys_mutex_wait(&lwi->lwobj->mutex))) { /* Cannot acquire mutex */
return 0;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ prv_format(lwprintf_int_t* lwi, va_list arg) {
}
lwi->out_fn(lwi, '\0'); /* Output last zero number */
#if LWPRINTF_CFG_OS && !LWPRINTF_CFG_OS_MANUAL_PROTECT
if (IS_PRINT_MODE(p)) { /* Mutex only for print operation */
if (IS_PRINT_MODE(lwi)) { /* Mutex only for print operation */
lwprintf_sys_mutex_release(&lwi->lwobj->mutex);
}
#endif /* LWPRINTF_CFG_OS && !LWPRINTF_CFG_OS_MANUAL_PROTECT */
Expand Down
2 changes: 1 addition & 1 deletion lwprintf/src/system/lwprintf_sys_cmsis_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#include "system/lwprintf_sys.h"

Expand Down
2 changes: 1 addition & 1 deletion lwprintf/src/system/lwprintf_sys_threadx.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#include "system/lwprintf_sys.h"

Expand Down
2 changes: 1 addition & 1 deletion lwprintf/src/system/lwprintf_sys_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* This file is part of LwPRINTF - Lightweight stdio manager library.
*
* Author: Tilen MAJERLE <tilen@majerle.eu>
* Version: v1.0.4
* Version: v1.0.5
*/
#include "system/lwprintf_sys.h"

Expand Down

0 comments on commit 7050157

Please sign in to comment.