Using RCSW#

As a Dependency#

The recommended way to consume RCSW in a CMake project is via CPM:

CPMAddPackage(
  NAME rcsw
  GITHUB_REPOSITORY jharwell/rcsw
  VERSION <version>
)
target_link_libraries(myapp PRIVATE rcsw::rcsw)

Or, if you have installed RCSW via cmake --install:

find_package(rcsw REQUIRED)
target_link_libraries(myapp PRIVATE rcsw::rcsw)

Which targets you link depends on how RCSW was built:

  • Monolithic build: one target, rcsw::rcsw, as above.

  • Component build: one target per component. Link the components you use; each one brings its own dependencies (see Components and Linking).

Either way, include paths, compile definitions, and transitive dependencies are propagated automatically through the targets.

As a Developer#

From the root of the repo:

cmake --preset debug <ARGS>

<ARGS> is a list of cmake arguments. You can pass any option that LIBRA supports (see Luigi Builds Reusable Automation) or any RCSW option listed below.

CMake Configuration#

Note

All cmake options with a direct code analogue are prefixed RCSW_CONFIG_; options that affect only the build system (e.g., RCSW_SUMMARY) are prefixed RCSW_.

Build Targets#

RCSW_BUILD_FOR#
Default:

POSIX

Target platform. Valid values:

  • POSIX — Linux and POSIX-compatible OSes. Enables the full feature set including multithread, multiprocess, and swbus.

  • BAREMETAL — Bare-metal environments without an OS. Enables stdlib from the selected compiler. To also strip stdlib, pass LIBRA_NOSTDLIB (see LIBRA docs); this restricts which modules are usable. See Components for the full breakdown.

RCSW_CONFIG_LIBTYPE#
Default:

STATIC

Whether to build RCSW as a SHARED or STATIC library.

RCSW_CONFIG_NO_STDIO#
Default:

NO

Exclude the STDIO module from compilation. Useful on POSIX targets when you are linking against libc and do not need the printf replacement.

RCSW_SUMMARY#
Default:

YES

Print a summary of all RCSW-specific cmake variables at configure time.

Memory Allocation#

RCSW_CONFIG_NOALLOC#
Default:

NO

Disallow all dynamic heap allocation. When YES, implies RCSW_NOALLOC_META, RCSW_NOALLOC_DATA, and RCSW_NOALLOC_HANDLE for all modules that support them.

You can also set these flags individually at run time, in the flags field of each module’s xx_config struct. See Memory Model.

Some parts of RCSW can’t work without a heap, and fail to initialize in such a build:

  • the LOG4CL ER plugin, whose module table is a heap-allocated list; use the simple plugin instead;

  • dynmatrix, whose rows are always heap-allocated;

  • the dynamic-programming algorithms (edit distance, LCS, matrix chain optimization), whose scratch tables are heap-allocated;

  • darray growth beyond its initial capacity, and unbounded (max_elts = -1) structures.

Tests tagged [noalloc] are exactly the ones that run without a heap; run only those ("[noalloc]" as the Catch2 test spec) in a RCSW_CONFIG_NOALLOC build.

RCSW_CONFIG_ZALLOC#
Default:

NO

Zero-initialize all memory (whether dynamically allocated or caller-supplied) before use, as if RCSW_ZALLOC were passed everywhere. See Memory Model.

RCSW_CONFIG_PTR_ALIGN#
Default:

8 on 64-bit and 4 on 32-bit known architectures; 1 otherwise

Override the pointer alignment used to store all application data managed by RCSW.

Some architectures trap on unaligned accesses (e.g., strict ARM variants); others handle them silently or in hardware. RCSW detects the best value for known architectures, but falls back to byte alignment (1) for unknown targets. Override if you know your target requires or benefits from a specific alignment.

Must be one of [1, 2, 4, 8]. See Memory Model for how to choose.

STDIO / printf Replacement#

RCSW_CONFIG_STDIO_PUTCHAR#
Default:

putchar

Name of the putchar()-compatible function RCSW’s printf will call to emit characters. Must have the same signature as putchar(). Override when linking to a custom BSP output routine. In a shared build the function must be resolvable when RCSW itself is linked; see Components and Linking.

RCSW_CONFIG_STDIO_GETCHAR#
Default:

getchar

Name of the getchar()-compatible function stdio_getchar() calls to read characters (minimon reads its input this way). Must have the same signature as getchar(). The same linking rule as RCSW_CONFIG_STDIO_PUTCHAR applies.

printf() formatting behavior (float support, buffer sizes, precision, etc.) is controlled by the eyalroz/printf dependency, which RCSW pulls in via CPM. To override an upstream option, set it in your CMake invocation before including RCSW — CPM respects already-set cache variables.

Event Reporting#

RCSW_CONFIG_ER_PLUGIN#
Default:

LOG4CL

The ER plugin to build against. See Event Reporting (ER) for plugin details and tradeoffs.

RCSW_CONFIG_ER_PLUGIN_PATH#
Default:

(empty)

Absolute or relative (to the build directory) path to the #include file defining the custom ER plugin macros. Only required when RCSW_CONFIG_ER_PLUGIN=CUSTOM. This file is not installed with RCSW; ensure it is findable by any application that links against RCSW. See the Custom plugin tab in Event Reporting (ER) for required macro definitions.

Instrumentation#

RCSW_CONFIG_NO_GRIND#
Default:

NO

Compile out the timing/profiling macros RCSW_GRIND_START(), RCSW_GRIND_END(), RCSW_GRIND_COUNT(), and RCSW_GRIND_TICK(). Allows timing instrumentation to be left in application source and enabled only when profiling is needed, without runtime cost otherwise.