Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further improved include error messages #2265

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

richard-sim
Copy link
Contributor

@richard-sim richard-sim commented Sep 28, 2024

What does this PR do?

This is a continuation of my previous PR (CC @samsinsane - it's me again sorry!), improving the error message output for include() a bit, making it more precise and with less redundancy. I've also given the same love I gave to include() to includeexternal(), since it's essentially the same function.

How does this PR change Premake's behavior?

includeexternal() did not used to return the result of executing the included script, whereas include() did. I believe this was an oversight, as the documentation states that includeexternal() "works just like include()". I don't see this change causing harm since it was previously not returning any value, so I doubt there's any code relying on it returning nil. I have run the unit tests to be sure, and they're all green.

Example of an error from an include directly in the root premake5.lua

Error: ** Error: D:\dev\build-sys-eval\foobar\src\premake5.lua(36): include($/self-test/test_declare.lua) execution error: [string "self-test/test_declare.lua"]:6: attempt to index a nil value (local 'm')

Examples of errors from nested includes, with multiple-levels of include context

Example output of a missing include file:

Error: ** Error: D:\dev\build-sys-eval\foobar\src\premake5.lua(33): include(tools/premake/badcode.lua) execution error: ** Error: D:\dev\build-sys-eval\foobar\src\tools\premake\badcode.lua(1): include(no-file-here) not found or failed to load: ** Error: Cannot find neither no-file-here nor no-file-here.lua nor no-file-here/premake5.lua nor no-file-here/premake4.lua

Example output of a syntax error in an include file:

Error: ** Error: D:\dev\build-sys-eval\foobar\src\premake5.lua(21): include(foobar/L1a) not found or failed to load: ** Error: Error loading 'foobar/L1a: D:/dev/build-sys-eval/foobar/src/foobar/L1a/premake5.lua:8: syntax error near ']'

Example output of an incorrectly loaded internal script:

Error: ** Error: D:\dev\build-sys-eval\foobar\src\foobar\L1a\premake5.lua(30): include(tools/premake/badcode.lua) execution error: ** Error: D:\dev\build-sys-eval\foobar\src\tools\premake\badcode.lua(59): include($/self-test/test_declare.lua) execution error: [string "self-test/test_declare.lua"]:6: attempt to index a nil value (local 'm')

Anything else we should know?

n/a

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

@Jarod42
Copy link
Contributor

Jarod42 commented Sep 30, 2024

Conflicts to resolve, and wonder if includeexternal should have same changes to support embed script.
Sad that those 2 equivalent functions are separated in 2 files :/

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