Skip to content

Improved library support - #40

Open
4lon wants to merge 5 commits into
greenforge-labs:mainfrom
Pumpkin-Engineering:improved-library-support
Open

4lon wants to merge 5 commits into
greenforge-labs:mainfrom
Pumpkin-Engineering:improved-library-support

Conversation

@4lon

@4lon 4lon commented Sep 1, 2026

Copy link
Copy Markdown

This modifies the export lib to files function so that the destination is a new POUs directory. This means that running export lib to files and regular export to files do not clobber each other, and they are now both compatible in one project.

This also adds a new import lib from files command, which operates much like the import from files command, but for 'POUs' objects. This allows for better plaintext syncing of libraries/shared elements in a project.

@4lon

4lon commented Sep 1, 2026

Copy link
Copy Markdown
Author

While I have implemented this as a separate command, I would be interested in hearing your thoughts on merging the export/import lib and non lib commands, since they no longer clobber each other with these changes.

@4lon

4lon commented Sep 3, 2026

Copy link
Copy Markdown
Author

I've also discovered I think the save as template function is not stripping out the library files. Since this adds support for library import/export i think save as template should also strip out the library files? Let me know what you think of this PR and how you may want to proceed, particularly if you want to consider merging the lib and non-lib import/export

@gsokoll gsokoll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alon. Your questions: keep the two import commands separate. Save As Template should not strip library files until Update From Template also reads the POUs folder; otherwise every root POU is lost. Three changes before merge:

  1. Name the folder <project_name>.POUs so two projects in one directory do not overwrite each other.
  2. Skip the generated Library Information objects on export and on import. Otherwise the import fails with a duplicate name after it has removed the other root objects.
  3. #38 adds a check that refuses library export on a project with a device. I will resolve that conflict when the second of the two PRs merges.

@gsokoll

gsokoll commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Thanks Alon for updating the folder name. There is still one open item: on a library with generated Library Information objects, the import removes the root objects and then stops with a duplicate-name error. Suggest you skip those objects on export and on import.

@4lon

4lon commented Sep 14, 2026

Copy link
Copy Markdown
Author

Thanks for your time and help @gsokoll. Our team doesn't work with codesys libraries much so I had missed that workflow thank you. I believe adding the ignore on export should be enough (assuming you haven't run an export with the older version I had pushed here that did create a Library Information folder), because the import won't try to recreate it if the directory/files that conflict aren't there. Let me know if you want the import to also have a specific ignore list/error handling.

You also mentioned earlier that "Save As Template should not strip library files until Update From Template also reads the POUs folder", would you like me to work on this in a follow up PR or do you prefer the current behavior?

@gsokoll

gsokoll commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Thanks Alon. Yes, please add the import-side skip too. Preserve the generated Library Information objects during cleanup and ignore that directory in older exports. The export change does not protect those existing exports.

I'd prefer to keep Save As Template unchanged for now. Update From Template does not read .POUs, so any future change must update both commands together.

Once the import fix is verified with both fresh and older exports, I’m happy to merge.

The library export used to export to the device folder and wiped out any
files that had been exported with the normal export to files command.

Now the export lib files land in a POUs folder beside the device folder
so that they can be exported without collision.
This adds a new command that enables importing a codesys project library
files (those that are underneath the POUs tab) back in from an export.

Some files need to be ignored in the current project as they cannot be
deleted as they are core to codesys.
These were causing errors on import as they cannot be removed and would
conflict.
Previous exports generated this folder (no longer exported). However if
they were exported, they would conflict with the existing instances that
can't be removed from a codesys project.
@4lon
4lon force-pushed the improved-library-support branch from 0a32ca7 to 1a42e83 Compare September 18, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants