I found myself repeating things, so I scripted it. I may have gone overboard
This tool is a python based build automation framework, designed specifically to handle the explosion in variation that comes from projects that contain configurable features, cross platform support, multiple toolchains, etc.
it grew out of my desire to build a cmake solution for godot-cpp, and verify that the build flags match the existing tools.
- Python: Version 3.8 or higher.
- Python Libraries:
richfor console output formatting.pyfigletfor ASCII art titles.gitpythonfor Git operations.pathlibfor path handling.
- Operating Systems: Tested on Windows, macOS, and linux.
- External Tools:
- Git (
git) for source repository management. - SCons and/or CMake for build execution.
- Android SDK (with
sdkmanager) for Android builds. - Emscripten SDK for WebAssembly builds.
- Toolchain-specific dependencies (e.g., Visual Studio for MSVC, LLVM for Clang).
- Git (
Run the build system using cli.py:
python cli.py [options] [actions]--debug: Enable debug mode for detailed error output.--dry: Perform a dry run without executing commands.-q, --quiet: Suppress console output.-v, --verbose: Show detailed configuration output.--list: List available toolchains, projects, and build configurations, then exit.--show: Show detailed configuration, then exit.-j, --jobs <n>: Set the number of parallel jobs (default: CPU count - 1).-t, --toolchain-regex <regex>: Filter toolchains by name (e.g.,msvc,llvm).-p, --project-regex <regex>: Filter projects by name (e.g.,godot-cpp).-b, --build-regex <regex>: Filter build configurations by name.--giturl <url>: Override the Git repository URL.--gitref <ref>: Override the Git reference (e.g., commit hash, branch).actions: Additional actions to perform (e.g.,fetch,build,test).
-
List all available configurations:
python cli.py --list
-
Build all configurations for the
godot-cppproject:python cli.py build
-
Build only MSVC-based configurations in debug mode:
python cli.py --toolchain-regex msvc --build-regex debug build
-
Perform a dry run for Android builds:
python cli.py --dry --build-regex android build
- Include and exclude:
-
^.*(?=(words|to|include))(?!.*(?:exclude|these|things)).*
- Create a
config.pyfile in a project directory (e.g.,myproject/config.py). - Implement a
generatefunction that returns a dictionary of project configurations, similar to thegodot-cppexample inconfig.py.- Define the project name, Git repository details (
gitdef), and build configurations (build_configs). - Use expansion functions (e.g.,
expand_scons,expand_cmake) to generate build variants.
- Define the project name, Git repository details (
- Ensure the project directory is in the same parent directory as
cli.pyfor automatic detection via globbing (*/config.py). - Run
python cli.py --listto verify the project is detected.
- In
toolchains.py, add a new toolchain function (e.g.,my_toolchain()) that returns aSimpleNamespacewith:name: Toolchain identifier (e.g.,mytoolchain).desc: Description of the toolchain.arch: Supported architectures (e.g.,['x86_64', 'arm64']).platform: Supported platforms (e.g.,['win32', 'darwin']).- Optional:
shell,env,cmake,verbs,update, orscript_partsfor custom behavior.
- Add the toolchain to the appropriate platform list (e.g.,
windows_toolchainsordarwin_toolchains). - Update
config.pyto support the new toolchain inexpand_toolchainsor related functions, if necessary.