Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,30 @@ jobs:
# default token (which only works if the stack is made accessible).
token: ${{ secrets.CAS_STACK_PAT || github.token }}

- name: Configure
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
# Published binaries are built with CAS_BACNET_STACK_LINK=SOURCE - the stack is
# compiled from source straight into the executable. Stated EXPLICITLY rather than
# relying on it being the CMake default, because what we publish must not change if
# that default ever moves.
#
# Why SOURCE for a release: the artifact is a single self-contained executable. STATIC
# would need a prebuilt library built and matched here first, and DLL would require
# shipping CASBACnetStack_x64_Release.dll alongside the exe and would fail at start-up
# for anyone who downloaded only the binary. Those two modes are for integrators
# choosing them deliberately in their own build, not for a downloadable demo.
- name: Configure (SOURCE link mode - self-contained binary)
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCAS_BACNET_STACK_LINK=SOURCE

- name: Confirm the link mode CMake actually used
shell: bash
run: |
# Fail loudly if the cache does not say SOURCE - a published binary that silently
# needs a DLL beside it is the failure we are guarding against.
# Anchor on the colon: without it this also matches the
# CAS_BACNET_STACK_LINK-STRINGS:INTERNAL=SOURCE;STATIC;DLL helper entry and the
# comparison below never matches.
mode=$(grep -E '^CAS_BACNET_STACK_LINK:' build/CMakeCache.txt | cut -d= -f2)
echo "CAS_BACNET_STACK_LINK=$mode"
[ "$mode" = "SOURCE" ] || { echo "FAIL: expected SOURCE, got '$mode'"; exit 1; }

- name: Build
run: cmake --build build --config Release
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# CMake build output
build/

build-static/
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **Links the CAS BACnet Stack through the `CASBACnetStack::Adapter` CMake
target instead of hand-globbing the stack's `source/*.cpp`.** `main.cpp` and
`common/CASExampleHelper.cpp` now include `CASBACnetStackAdapter.h` and call
`LoadBACnetFunctions()` once at the top of `main()`; every `BACnetStack_*`
call site is otherwise unchanged. `CAS_BACNET_STACK_LINK` (`SOURCE` default,
or `STATIC`/`DLL`) picks the link mode — see the README's new "Link modes"
section. **All three modes are verified**: `SOURCE` and `STATIC` build and run
against a live client, and `DLL` mode now loads the stack, binds all 213
exports, passes the version handshake and runs — plus both of its failure
paths (library absent; library present but missing an export) report a
readable error and exit cleanly rather than crashing.
The stack submodule is pinned to `6.x-TestTool` @ `756371c1`, which carries the
adapter work merged as cas-bacnet-stack PRs #267 and #268.
common/ bumped to v1.5.1 (see `common/CHANGELOG.md`) — this is a contract
change every example in the series needs when it re-syncs.
- **Documentation corrections from a five-persona review** (lead developer,
educator, junior developer, BACnet newcomer, staff architect): the version
banner and sample output now match the shipped `common/` version (they claimed
v1.3.0 against a v1.5.0 tree — in a project whose own docs teach "the printed
versions are how you detect drift"); the BIBB `-A`/`-B` suffix convention,
`Protocol_Revision`, BACnet/SC and "BACnet internetwork" are now defined at
first use; the Verify section names free clients (YABE, Wireshark) alongside
the commercial one; and two new sections cover what in `common/` is demo-only
versus production-worthy, and the `BACnetStack_Tick()` cadence and
single-threading contract.
- **Stack pin moved to `6.x-TestTool` @ `b681f58d` (2026-07-31).** 38 commits
ahead of the previous pin (`92c91d74`); includes the removal of the 13
`RegisterHookProperty*` exports, the `DecodeAsXML`/`DecodeAsJSON` →
`DecodeAs` fold, the `SetCOVMultipleSettings` rename, the
`SetBackupAndRestoreEnabled` signature change (absorbs
`backupFailureTimeout`), and the removal of `SetObjectTypeSupported` — none
of which this example calls. Known cosmetic side effect: the newly merged
BACnet/SC datalink logs a one-time "UUID has not been set" error on the
debug callback at start-up in applications that never configure BACnet/SC;
it latches its error flag and goes quiet. Functionality is unaffected.
- **Stack pin moved to the series `6.x` branch (CAS BACnet Stack 6.0.0.0).**
Which stack version this example requires is a material licensing fact.
- The commandable-setup loop carries `{type, instance}` pairs instead of a
Expand Down
43 changes: 22 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# =============================================================================
# CMake build for the BACnet B-ASC (Application Specific Controller) C++ example.
#
# This example links the CAS BACnet Stack by COMPILING IT FROM SOURCE: it builds
# every file in the stack's source/ folder straight into the executable and
# calls the stack's C API (CASBACnetStackDLL.h) directly. There is no DLL/.so to
# build, copy, or ship first - everything compiles into one self-contained
# executable.
# This example links the CAS BACnet Stack through the CASBACnetStack::Adapter CMake
# target (submodules/cas-bacnet-stack/adapters/cpp) and calls the stack's C API
# (BACnetStack_*, via CASBACnetStackAdapter.h) directly - no fp* indirection, the same
# call in every link mode. CAS_BACNET_STACK_LINK picks the mode (see below); it defaults
# to SOURCE, which compiles every file in the stack's source/ folder straight into the
# executable - there is no DLL/.so to build, copy, or ship first.
#
# NOTE: the first build compiles the entire stack (~600 source files), so it
# NOTE: the first SOURCE-mode build compiles the entire stack (~600 source files), so it
# takes a few minutes. Subsequent incremental builds are fast.
#
# Build:
# cmake -B build -S .
# cmake --build build --config Release
# Build against a prebuilt DLL/.so instead of compiling from source:
# cmake -B build -S . -DCAS_BACNET_STACK_LINK=DLL
# Run (from the example folder):
# ./build/BACnetExampleBASC (Linux/macOS)
# .\build\Release\BACnetExampleBASC.exe (Windows)
Expand Down Expand Up @@ -49,23 +52,20 @@ endif()
if(NOT DEFINED CAS_STACK_DIR)
set(CAS_STACK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/submodules/cas-bacnet-stack")
endif()
set(CAS_STACK_SOURCE_DIR "${CAS_STACK_DIR}/source")

if(NOT EXISTS "${CAS_STACK_SOURCE_DIR}/CASBACnetStackDLL.h")
if(NOT EXISTS "${CAS_STACK_DIR}/adapters/cpp/CMakeLists.txt")
message(FATAL_ERROR
"CAS BACnet Stack source not found at: ${CAS_STACK_SOURCE_DIR}\n"
"CAS BACnet Stack adapter not found under: ${CAS_STACK_DIR}\n"
"The stack is a git submodule. After cloning this repository, run:\n"
" git submodule update --init --recursive\n"
"Or pass -D CAS_STACK_DIR=/path/to/cas-bacnet-stack to use a stack elsewhere.")
endif()

# --- Gather the CAS BACnet Stack source -------------------------------------
# Compiling from source: grab every .cpp/.c in the stack's source/ folder. The
# example calls the stack's C API (CASBACnetStackDLL.h) directly, so no adapter
# layer is needed.
file(GLOB CAS_STACK_SOURCES
"${CAS_STACK_SOURCE_DIR}/*.cpp"
"${CAS_STACK_SOURCE_DIR}/*.c")
# --- The CAS BACnet Stack, via its CMake adapter target ---------------------
# CAS_BACNET_STACK_LINK is the adapter's own cache variable (SOURCE/STATIC/DLL,
# default SOURCE) - set it BEFORE add_subdirectory() so the adapter target picks it up.
# See submodules/cas-bacnet-stack/adapters/cpp/CMakeLists.txt for what each mode does.
add_subdirectory("${CAS_STACK_DIR}/adapters/cpp" cas-bacnet-stack-adapter)

# --- The shared example helper ----------------------------------------------
set(COMMON_SOURCES
Expand All @@ -75,16 +75,17 @@ set(COMMON_SOURCES
# --- The executable ---------------------------------------------------------
add_executable(BACnetExampleBASC
main.cpp
${COMMON_SOURCES}
${CAS_STACK_SOURCES})
${COMMON_SOURCES})

target_include_directories(BACnetExampleBASC PRIVATE
"${EXAMPLES_COMMON_DIR}"
"${CAS_STACK_SOURCE_DIR}")
"${EXAMPLES_COMMON_DIR}")

target_link_libraries(BACnetExampleBASC PRIVATE CASBACnetStack::Adapter)

# --- Warnings on OUR sources only -------------------------------------------
# Apply strict warnings to the example + helper sources, but NOT to the bundled
# third-party stack (~600 files) which would be noisy and isn't ours to fix.
# third-party stack (~600 files, built inside the CASBACnetStack::Adapter target)
# which would be noisy and isn't ours to fix.
if(MSVC)
set(EXAMPLE_WARNINGS "/W4")
else()
Expand Down
Loading
Loading