Skip to content
Open
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
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# publishing.
#
# Two stages: (1) build the CAS BACnet Stack shared library from the stack submodule into
# submodules/cas-bacnet-stack/bin/ with the stack's CMake, its only build (the windows-x64-dll
# preset on Windows, linux-x64-release-shared on Linux, then `cmake --install` into bin/ -
# submodules/cas-bacnet-stack/dist/ with the stack's CMake, its only build (the windows-x64-dll
# preset on Windows, linux-x64-release-shared on Linux, then `cmake --install` into dist/ -
# README "Build"), then (2) `go build` this project with cgo. The executable loads the library
# at run time (the stack's own adapter in DLL mode): it has no load-time dependency on it, and
# finds it next to itself or, in this checkout, in submodules/cas-bacnet-stack/bin/.
# finds it next to itself or, in this checkout, in submodules/cas-bacnet-stack/dist/.
#
# THE STACK LIBRARY IS NEVER RELEASED. It is built here only to compile and test the example.
# A release ships the example's executable and docs; the "Package" step fails if any
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
install: mingw-w64-x86_64-gcc
path-type: inherit

- name: Build the CAS BACnet Stack library (Windows - CMake preset windows-x64-dll, into the submodule's bin/)
- name: Build the CAS BACnet Stack library (Windows - CMake preset windows-x64-dll, into the submodule's dist/)
if: runner.os == 'Windows'
shell: pwsh
working-directory: submodules/cas-bacnet-stack
Expand All @@ -88,9 +88,9 @@ jobs:
if ($LASTEXITCODE -ne 0) { throw "windows-x64-dll build failed" }
cmake --install build-windows-x64-dll --config Release
if ($LASTEXITCODE -ne 0) { throw "windows-x64-dll install failed" }
Get-ChildItem bin\CASBACnetStack_x64_Release.dll
Get-ChildItem dist\CASBACnetStack_x64_Release.dll

- name: Build the CAS BACnet Stack library (Linux - CMake preset linux-x64-release-shared, into the submodule's bin/)
- name: Build the CAS BACnet Stack library (Linux - CMake preset linux-x64-release-shared, into the submodule's dist/)
if: runner.os == 'Linux'
shell: bash
working-directory: submodules/cas-bacnet-stack
Expand All @@ -100,7 +100,7 @@ jobs:
cmake --preset linux-x64-release-shared
cmake --build --preset linux-x64-release-shared
cmake --install build-linux-x64-release-shared
ls -la bin/libCASBACnetStack_x64_Release.so
ls -la dist/libCASBACnetStack_x64_Release.so

- name: go vet + go build (CGO_ENABLED=1)
shell: bash
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:

# Rule 2b: the released executable, run where there is no stack library, must say so
# clearly and exit 1 - never an OS loader error. It runs from an empty folder outside
# this checkout, so the development fallback (submodules/cas-bacnet-stack/bin/) is not found.
# this checkout, so the development fallback (submodules/cas-bacnet-stack/dist/) is not found.
- name: Packaged executable without the stack library - clear message, exit 1
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bacnet-b-ss-go
*.out

# The CAS BACnet Stack library is never committed (and never released): build it
# from the submodule into submodules/cas-bacnet-stack/bin/ (README "Build").
# from the submodule into submodules/cas-bacnet-stack/dist/ (README "Build").
*.dll
*.so
*.so.*
Expand Down
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ go vet . ./cgobridge ./common
`go build` does not build the stack's shared library - that is the separate
CMake step in README "Build". CMake is the stack's only build: it no longer has
`projects/msvs/` or `projects/linux/` (removed before `6.x` @ `29b83de6`).
`cmake --install` puts the library in the submodule's `bin/`, where the example
`cmake --install` puts the library in the submodule's `dist/`, where the example
loads it from. Always a customer-interface build, never the test-tool library.
A gcc must be on `PATH` for cgo (MinGW-w64 on Windows). Do not use `./...`: it
walks into the submodule's own Go files. **Never commit or release the stack's
DLL / `.so`** - it lives in the submodule's `bin/` (gitignored there), and
DLL / `.so`** - it lives in the submodule's `dist/` (gitignored there), and
`git ls-files | grep -iE '\.(dll|so|node|lib|a)$'` must print nothing.

## Run
Expand All @@ -82,7 +82,7 @@ DLL / `.so`** - it lives in the submodule's `bin/` (gitignored there), and

The stack library is loaded at run time (the stack's `adapters/cpp/` in DLL mode,
compiled in place by `cgobridge/stack_adapter.c`) from the executable's folder,
else from `submodules/cas-bacnet-stack/bin/`; without it the program prints the
else from `submodules/cas-bacnet-stack/dist/`; without it the program prints the
series' missing-library message (rule 2b) and exits 1. Interactive commands: `h`, `q`, `u`, `d`, each followed by
Enter.

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this example. The format is based on

## [Unreleased]

### Changed

- Updated to CAS BACnet Stack 6.x `83e04a2d` (6.1.2, 2026-12-02).
- The stack library is now found in the submodule's `dist/` folder, where 6.1.2's `cmake --install` puts it (it was `bin/`). The CI workflow, the run-time search and the build instructions all use `dist/`.

## [1.2.1] - 2026-11-02

Built on CAS BACnet Stack 6.x (`1e7dffe2b`).
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ This is a **self-contained** project. It ships:
- `submodules/cas-bacnet-stack/` - the **CAS BACnet Stack as a git submodule**
(private; requires a license - see above). cgo includes its
`source/CASBACnetStackDLL.h` in place; its CMake build produces the shared
library, which `cmake --install` puts in its own `bin/` folder.
library, which `cmake --install` puts in its own `dist/` folder.

## Prerequisites

Expand Down Expand Up @@ -199,15 +199,15 @@ Already cloned without `--recursive`? Run `git submodule update --init --recursi

### 1. Build the CAS BACnet Stack library from the submodule

The library goes into the submodule's own `bin/` folder, where the example
The library goes into the submodule's own `dist/` folder, where the example
finds it at run time when it is run from this checkout. Do not commit it to this
repository (it is gitignored, and never part of a release).

The stack has **one build, CMake** (`CMakeLists.txt` and `CMakePresets.json`
in the submodule; its README's "Building and testing" and AGENTS.md
"Building" list the presets). Each preset builds into
`submodules/cas-bacnet-stack/build-<preset>/`, and `cmake --install
build-<preset>` copies the library into the submodule's `bin/`, under exactly
build-<preset>` copies the library into the submodule's `dist/`, under exactly
the name the example loads. It is a customer-interface build (no test-tool
exports). Run the commands from the submodule's folder, because `cmake
--preset` reads `CMakePresets.json` from the current directory.
Expand All @@ -220,7 +220,7 @@ Visual Studio 2022). PowerShell or a Developer Prompt:
cd submodules\cas-bacnet-stack
cmake --preset windows-x64-dll
cmake --build --preset windows-x64-dll-release
cmake --install build-windows-x64-dll --config Release # -> bin\CASBACnetStack_x64_Release.dll
cmake --install build-windows-x64-dll --config Release # -> dist\CASBACnetStack_x64_Release.dll
cd ..\..
```

Expand All @@ -234,11 +234,11 @@ static-library name and stays in the build tree; the example does not need it
cd submodules/cas-bacnet-stack
cmake --preset linux-x64-release-shared
cmake --build --preset linux-x64-release-shared
cmake --install build-linux-x64-release-shared # -> bin/libCASBACnetStack_x64_Release.so
cmake --install build-linux-x64-release-shared # -> dist/libCASBACnetStack_x64_Release.so
cd ../..
```

The stack's own `.gitignore` already ignores `build-*/` and `bin/`, so the
The stack's own `.gitignore` already ignores `build-*/` and `dist/`, so the
submodule stays clean. Only the **Release** library is used: the adapter loads
`CASBACnetStack_x64_Release` (`BACNET_LIB_FILE`).

Expand Down Expand Up @@ -267,7 +267,7 @@ The executable loads the stack library at run time (not the operating system
at start-up), from the first of these folders that has it:

1. the **run directory** - the folder that holds the executable;
2. in a development checkout, `submodules/cas-bacnet-stack/bin/` (found by
2. in a development checkout, `submodules/cas-bacnet-stack/dist/` (found by
looking upwards from the executable's folder) - so `build/BACnetExampleBSS`
in this checkout needs no set-up.

Expand Down Expand Up @@ -382,7 +382,7 @@ The scripts are the C++ edition's `tests/`, with this port's default port
| `failure_modes_test.py` | **The Failure Modes.** Breaks the simulated sensor wire: `Reliability` `open-loop`, `Status_Flags` FAULT, a frozen reading; repairs it: all clear, the reading moves. Then the errors for an unknown object / property / array index, and the Reject for a WriteProperty. |

Run them all after the build (the executable finds the library in the
submodule's `bin/`, see [Run](#run)):
submodule's `dist/`, see [Run](#run)):

```bash
python tests/run_wire_tests.py # default --exe build/BACnetExampleBSS(.exe), --port 47822
Expand Down
2 changes: 1 addition & 1 deletion TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ callbacks in `property_dispatch.go`.)

| Symptom | Cause / fix |
|---------|-------------|
| `ERROR: This example cannot run without the CAS BACnet Stack library.` (exit code 1) | The stack library is in none of the folders the message lists. Build it from the submodule (README "Build", step 1) and put it next to the executable, or run the executable from this checkout (it also looks in `submodules/cas-bacnet-stack/bin/`). |
| `ERROR: This example cannot run without the CAS BACnet Stack library.` (exit code 1) | The stack library is in none of the folders the message lists. Build it from the submodule (README "Build", step 1) and put it next to the executable, or run the executable from this checkout (it also looks in `submodules/cas-bacnet-stack/dist/`). |
| `Error: failed to load the CAS BACnet Stack from <folder>: ...` | The library was found but could not be used: a different architecture (it must be x64), a stack from another major version (`stack API major version ...`), or a missing export (`missing export: ...` - a wrong or corrupt build). Rebuild it from the submodule at this Stack Pin. |
| `go build`: `cgo: C compiler "gcc" not found` | cgo needs a gcc. On Windows install MinGW-w64 (MSYS2) and put its `bin` on `PATH`. |
| `go build`: `CASBACnetStackDLL.h: No such file or directory` | Submodules not checked out: `git submodule update --init --recursive`. |
Expand Down
10 changes: 5 additions & 5 deletions cgobridge/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// BACnet Stack"). Nothing from the stack is copied into this repository.
//
// FindStackLibrary() looks for the library in the executable's folder first,
// then, for a development checkout, in submodules/cas-bacnet-stack/bin/ above
// then, for a development checkout, in submodules/cas-bacnet-stack/dist/ above
// it (where README "Build" builds it).
//
// cgo cannot call a C function-pointer variable from Go, so each stack call
Expand Down Expand Up @@ -79,7 +79,7 @@ func StackLibraryFileName() string {

// FindStackLibrary looks for the stack library in the run directory (the
// folder that holds this executable) and then, for a development checkout, in
// submodules/cas-bacnet-stack/bin/ in that folder or one of its parents.
// submodules/cas-bacnet-stack/dist/ in that folder or one of its parents.
// It returns the folder it was found in ("" if none) and every folder it
// looked in, in order.
func FindStackLibrary() (found string, searched []string) {
Expand All @@ -94,9 +94,9 @@ func FindStackLibrary() (found string, searched []string) {
runDirectory := filepath.Dir(executable)
candidates = append(candidates, runDirectory)
for directory, level := runDirectory, 0; level < 3; level++ {
bin := filepath.Join(directory, "submodules", "cas-bacnet-stack", "bin")
if info, err := os.Stat(bin); err == nil && info.IsDir() {
candidates = append(candidates, bin)
dist := filepath.Join(directory, "submodules", "cas-bacnet-stack", "dist")
if info, err := os.Stat(dist); err == nil && info.IsDir() {
candidates = append(candidates, dist)
break
}
parent := filepath.Dir(directory)
Expand Down
2 changes: 1 addition & 1 deletion cgobridge/stack_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// Where the library is loaded from: the adapter opens BACNET_LIB_FILE.
// - Windows: the default, the bare name "CASBACnetStack_x64_Release.dll", which
// LoadLibrary looks for in the executable's folder first. For the submodule
// bin/ fallback, cgobridge_load_stack() adds that folder with SetDllDirectory.
// dist/ fallback, cgobridge_load_stack() adds that folder with SetDllDirectory.
// - Linux: the default is "./libCASBACnetStack_x64_Release.so", relative to the
// CURRENT directory, not the executable's - so this file defines
// BACNET_LIB_FILE (the adapter's documented override) as the full path the
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func run() int {
// does not include. It is loaded at run time (cgobridge, through the stack's
// own adapter in DLL mode - LoadBACnetFunctions() in the C++ edition), from
// the folder that holds this executable or, in a development checkout, from
// submodules/cas-bacnet-stack/bin/. No other BACnetStack_* call may come
// submodules/cas-bacnet-stack/dist/. No other BACnetStack_* call may come
// before it. --help and --version still work without it.
arguments := os.Args[1:]
stackFolder, searchedFolders := cgobridge.FindStackLibrary()
Expand Down
2 changes: 1 addition & 1 deletion submodules/cas-bacnet-stack
Loading