fix(build): compile C++ libraries carried in a STruC++ upload - #177
Open
MatthewReed303 wants to merge 1 commit into
Open
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.
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