Repository navigation
fix(build): compile C++ libraries carried in a STruC++ upload - #177
Open
MatthewReed303 wants to merge 5 commits into
Open
MatthewReed303 wants to merge 5 commits into
MatthewReed303 wants to merge 5 commits into
Conversation
GEN_CPP globbed the top level only, so a library under core/generated/libraries/<name>/ was never compiled and its headers were off the include path. Discover sources recursively, add each library's src/ as an include root, and mkdir the object directory for nested sources.
…resource-library-includes
6 of 9 tasks
…source libraries - Retain store no longer discards stored values when the program MD5 changes. The layout hash check one layer up decides whether they still fit. - Makefile.strucpp now compiles .c files in vendored libraries with $(CC). It also reads `defines=` from each library's library.properties as -D flags.
…resource-library-includes
…fusal reasons, 25 MB limit - Retain restore: plc_retain_read() queued every restored value on the debug-write journal, drained at the end of a cycle, so scan 1 ran on initial values and the restore then overwrote what it wrote; with more retained leaves than the journal holds (128) the rest were dropped. Restore now runs after journal_init() and applies each write immediately, before any task is released. - Retain save: the file store committed on a fixed timer, so a setpoint change waited up to a whole period. Now nothing is written without a change; a change after a quiet period is committed at once; changes within flush_seconds are held and committed, latest values only, when the period ends. Default flush_seconds 5 -> 10. - Upload refusals: analyze_zip sent its reasons (a file over the limit, an unsafe path, a disallowed type, the compression ratio, the total size) only to the server logger, so the editor and CLI saw "Compilation failed" with empty logs. Each reason now also goes to the build log the status endpoint returns. - Upload limit: a program with many function-block instances produces a debug-map.json over 10 MB (16.9 MB seen), so it was refused. The per-file limit is now 25 MB and the total 100 MB. MAX_CONTENT_LENGTH follows MAX_FILE_SIZE. Tests: host test for the save timing, pytest for the refusal reasons.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An upload can carry ordinary C++ library folders under
core/generated/libraries/<name>/, butMakefile.strucppcould not build them:GEN_CPP := $(wildcard $(GENERATED_DIR)/*.cpp)globbed the top level only, so alibrary's sources were never compiled and the link failed on its symbols.
#include <Foo.h>did not resolve.%.opattern rule assumed a flat object tree, so a nested source hadnowhere to build to.
Three changes:
RESOURCE_LIB_INCderives an include root per library folder — itssrc/whenit has one, the folder itself otherwise — and adds them with
addprefix -I.find, so any depth is covered. Wrapped insortfor a reproducible order across filesystems.
mkdir -p $(@D), sincelibraries/foo/src/transport/bar.cppnow builds to$(BUILD_DIR)/libraries/foo/src/transport/bar.o.An upload with no
libraries/directory compiles exactly as before —findreturns the same set the old
wildcarddid, andRESOURCE_LIB_INCis empty.This is the runtime half of an editor change that lets a
.stlibship the C/C++sources its blocks compile against; the Arduino half needs nothing from here.
Ticket
How it was tested
Built
openplc-runtimein Docker from this branch, uploaded a program using alibrary that ships its protocol sources as resources, and confirmed the runtime
compiled and loaded it:
Every part of the change is exercised: the per-library include roots, recursive
discovery, and
mkdir -p $(@D)for the nested objects. The loadedlibplc_*.socarries the library's symbols as real objects in the link.
Also confirmed an upload carrying no
libraries/directory builds unchanged.Checklist
bash scripts/run-pytest.shpassespre-commit runcleandocs/pr-reviews/PR_REVIEW_CHECKLIST.md