Skip to content

Overhaul Makefile build process - #150

Open
solemnwarning wants to merge 18 commits into
pkulchenko:masterfrom
solemnwarning:makefile-refactor
Open

Overhaul Makefile build process#150
solemnwarning wants to merge 18 commits into
pkulchenko:masterfrom
solemnwarning:makefile-refactor

Conversation

@solemnwarning

Copy link
Copy Markdown
Contributor

This is a pretty big (and potentially contentious) change, but I've reworked the Makefiles for wxLua with the following goals:

  • Allow building with a host-provided Lua
  • Allow building wxLua targets as part of a larger project
  • Generate bindings on demand

In addition to the above, I made the following changes while refactoring:

  • Move public headers into an include directory to simplify use from an external project
  • Move defaults from wxluasetup.h to wxluasetup-defaults.h which can be included from a user wxluasetup.h
  • Updated CMake build scripts to build bindings on demand too

@solemnwarning

Copy link
Copy Markdown
Contributor Author

Hi @pkulchenko,

Good to see you active on this project again. What are your initial thoughts on this change? If you like them in principle I'll rebase this PR and pull in some newer build changes from my fork too.

@pkulchenko

Copy link
Copy Markdown
Owner

Hi @solemnwarning, yes, I'm interested. I realize that it's an ambitious change, but I like the direction and the simplification that it may potentially bring. I'll check on the rebased PR. Thank you!

This commit replaces the Makefile build system in wxLua with one which
doesn't make use of recursive make and allows for more flexibility when
selecting the wxWidgets/Lua libraries to build/link against.

The end goal of this work is to make it so that portions of wxLua can
be compiled into other Make-based projects by including the Makefile
and simply depending on the appropriate targets.

The C++ #include directives are reworked so that relative include paths
are *actually* relative (where appropriate) rather than depending on
the compiler include path including practically every directory in the
wxLua source tree.

The public headers have been moved to a dedicated include directory.
This commit removes all of the pre-build bindings from the source tree
and properly integrates them into the Makefile so they can be build as
dependencies of the targets that need them.
Set the WXLUA_ROOT variable before including to allow building from
another directory.

The 'all' and 'clean' targets have been renamed to 'wxlua-all' and
'wxlua-clean' to avoid conflict with other project(s).

A wrapper target for 'clean' is defined only when WXLUA_ROOT is unset.
Outputs from genwxbind.lua are always overwritten now so that their
modification timestamp accurately reflects when they were updated.
Not sure why this was here in the first place, but the result was it
skipped building the bindings for projects like luamodule.
@solemnwarning

Copy link
Copy Markdown
Contributor Author

@pkulchenko,

I've rebased it, made some further fixes to the Makefile/CMakeLists and made an initial pass at a GitHub Actions workflow to verify the myriad of configurations, which can be seen running here: https://github.com/solemnwarning/wxlua/actions/runs/34025706469

@pkulchenko

Copy link
Copy Markdown
Owner

Hi @solemnwarning, thank you for the rebased PR and the added github actions! I'm still checking, but have a couple of questions about the new bindings approach. What's the motivation behind regenerating them on the fly and always overwriting generated files. My concern is that troubleshooting a build process is already fairly complex and adding a step that requires bindings to be regenerated will further complicate it. My understanding is that the rest of your changes are independent from this regeneration. Is that not the case?

@solemnwarning

Copy link
Copy Markdown
Contributor Author

My motivation was ensuring that the bindings are always up to date - I've seen them get desync'd plenty in this repo and IMO build artifacts/intermediates don't belong in the source tree.

The change to genwxbindings.lua to make it always update the source files is because that's what most "compilers" do and what how build systems like Make expect them to behave - Make/CMake will already only update the bindings when one of their inputs changes, so there's no reason for genwxbind.lua to avoid touching the file.

The Makefile(s) were in a pretty hairy state before I started on this, so a lot of restructuring/fixes on them in particular got done at the same time just to get things to a state where they worked well enough to use as a base.

@pkulchenko

Copy link
Copy Markdown
Owner

Do you think we can split them into two PRs? I agree that people sometimes miss committing updated bindings, but this is an easy problem to fix. I'm still concerned about complicating the build process and requiring a Lua interpreter to process the binding (yes, I recognize the irony). Maybe I just need to try it a couple of times to see the effect...

@solemnwarning

solemnwarning commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

I'm not really sure how much of this can be split off into a separate PR - refactoring the makefiles touched almost everything due to the previous state of them. In the long term there's more I can do to simplify the build system, but am trying to keep this PR somewhat contained.

EDIT: The GitHub Actions workflow is self-contained if you want that separated.

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