Skip to content

[StubGen/JsonGen] Add project-dir option - #326

Merged
sebaszm merged 5 commits into
masterfrom
development/project-dir
Sep 1, 2026
Merged

sebaszm merged 5 commits into
masterfrom
development/project-dir

Conversation

@sebaszm

@sebaszm sebaszm commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

folder where the generators look for Ids.h and Module.h (e.g. when interfaces are in a folder hierarchy)

Copilot AI lite review requested due to automatic review settings August 31, 2026 16:00
@github-actions

Copy link
Copy Markdown

LuaGenerator Results

View Results

No changes detected.

Copilot AI 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.

Pull request overview

This PR adds a “project directory” concept to the StubGen/JsonGen tooling so generators can locate Ids.h and Module.h outside the immediate interface header directory (useful for nested interface hierarchies), and modernizes some CLI/CMake option names while keeping deprecated aliases.

Changes:

  • ProxyStubGenerator: add --project-dir (and deprecated --projectdir) and update output directory flag to --output-dir (keeping deprecated --outdir).
  • JsonGenerator: introduce --project-dir so C++ header loading can source Ids.h/Module.h from a project root.
  • CMake: update FindProxyStubGenerator.cmake.in and FindJsonGenerator.cmake.in to prefer the new output-dir style options (with deprecated aliases).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ProxyStubGenerator/StubGenerator.py Adds --project-dir and uses it when locating Module.h/Ids.h; renames output arg to --output-dir (keeps deprecated --outdir).
JsonGenerator/source/header_loader.py Loads Module.h/Ids.h from config.PROJECT_DIRECTORY when provided.
JsonGenerator/source/config.py Adds PROJECT_DIRECTORY config and CLI --project-dir argument.
cmake/FindProxyStubGenerator.cmake.in Adds OUTPUT_DIR/PROJECT_DIR CMake args and forwards them to the StubGenerator CLI.
cmake/FindJsonGenerator.cmake.in Adds OUTPUT_DIR/CPP_OUTPUT_DIR CMake args and maps deprecated OUTPUT/CPP_OUTPUT to the new CLI flags.
Suppressed comments (1)

cmake/FindJsonGenerator.cmake.in:192

  • PROJECT_DIR is parsed (after adding it to oneValueArgs) but never forwarded to JsonGenerator.py; without this, the new --project-dir feature is unavailable from CMake.
    if (Argument_OUTPUT_DIR)
        file(MAKE_DIRECTORY "${Argument_OUTPUT_DIR}")
        list(APPEND _execute_command  "--output-dir" "${Argument_OUTPUT_DIR}")
    endif()


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread JsonGenerator/source/config.py
Comment thread cmake/FindJsonGenerator.cmake.in Outdated
Comment thread cmake/FindProxyStubGenerator.cmake.in
@github-actions

Copy link
Copy Markdown

ProxyStubGenerator Results

View Results

No changes detected.

@github-actions

Copy link
Copy Markdown

JsonGenerator Results

View Results

No changes detected.

Copilot AI review requested due to automatic review settings August 31, 2026 21:43

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Suppressed comments (5)

Previously missed (4) — in code that hasn't changed since the last review.

ProxyStubGenerator/StubGenerator.py:2901

  • --project-dir is documented as a directory, but the value is not validated before being used; passing a file path or non-existent path will lead to confusing downstream errors when building include paths.
    OUTPUT_DIRECTORY = args.output_directory

ProxyStubGenerator/StubGenerator.py:3028

  • When --output-dir is used with --lua-code, the output directory may not exist, causing open(output_file, "w") to fail. The C++ output path creates directories, but the Lua output path currently does not.
                name = "protocol-thunder-comrpc.data"
                output_file = os.path.join(("." if not OUTPUT_DIRECTORY else OUTPUT_DIRECTORY), name)
                lua_file = open(output_file, "w")

JsonGenerator/source/config.py:434

  • --project-dir is treated as a directory elsewhere (e.g., header_loader joins filenames to it), but the parsed value is not validated. This can produce hard-to-debug parse failures when an invalid path is passed.
    PROJECT_DIRECTORY = args.project_dir

cmake/FindJsonGenerator.cmake.in:197

  • If both OUTPUT_DIR (new) and OUTPUT (deprecated) are passed, the deprecated value currently overrides the new one because it is appended later. Consider ignoring the deprecated arg when the new one is set to avoid surprising precedence.

This issue also appears on line 204 of the same file.

    if (Argument_OUTPUT)
        file(MAKE_DIRECTORY "${Argument_OUTPUT}")
        list(APPEND _execute_command  "--output-dir" "${Argument_OUTPUT}")
    endif()

cmake/FindJsonGenerator.cmake.in:207

  • Similarly, if both CPP_OUTPUT_DIR (new) and CPP_OUTPUT (deprecated) are provided, the deprecated value currently overrides the new one. Guarding the deprecated option avoids duplicate flags and surprising precedence.
    if (Argument_CPP_OUTPUT)
        file(MAKE_DIRECTORY "${Argument_CPP_OUTPUT}")
        list(APPEND _execute_command  "--cpp-output-dir" "${Argument_CPP_OUTPUT}")
    endif()

Comment thread cmake/FindProxyStubGenerator.cmake.in Outdated
@github-actions

Copy link
Copy Markdown

JsonGenerator Results

View Results

No changes detected.

Copilot AI review requested due to automatic review settings September 1, 2026 09:05

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread ProxyStubGenerator/StubGenerator.py
Comment thread JsonGenerator/source/config.py
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

LuaGenerator Results

View Results

No changes detected.

Copilot AI review requested due to automatic review settings September 1, 2026 09:18

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

LuaGenerator Results

View Results

No changes detected.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

ProxyStubGenerator Results

View Results

No changes detected.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

JsonGenerator Results

View Results

No changes detected.

@sebaszm
sebaszm requested a review from MFransen69 September 1, 2026 10:22
Copilot AI review requested due to automatic review settings September 1, 2026 12:19

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment on lines +2828 to 2832
dest="output_directory",
metavar="DIR",
action="store",
default="",
default=None,
help="specify output directory (default: generate files in the same directory as source)")
Comment on lines +436 to +440
if args.project_dir:
if not os.path.isdir(args.project_dir):
sys.exit("ERROR: Project path '%s' is not a valid directory" % args.project_dir)
else:
PROJECT_DIRECTORY = args.project_dir
Comment on lines +2906 to +2910
if args.project_directory:
if not os.path.isdir(args.project_directory):
sys.exit("ERROR: Project path '%s' is not a valid directory" % args.project_directory)
else:
PROJECT_DIRECTORY = args.project_directory
@sebaszm
sebaszm merged commit 4d150e2 into master Sep 1, 2026
112 checks passed
@sebaszm
sebaszm deleted the development/project-dir branch September 1, 2026 13:53
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants