From 207a083c898bfbe2f5d7dcc304a3aa74576d79f3 Mon Sep 17 00:00:00 2001 From: Ankith Date: Sun, 6 Oct 2024 16:10:11 +0530 Subject: [PATCH] Add build --sdl3 flag --- .github/workflows/build-sdl3.yml | 8 ++------ dev.py | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-sdl3.yml b/.github/workflows/build-sdl3.yml index b4e86af529..10fef700a2 100644 --- a/.github/workflows/build-sdl3.yml +++ b/.github/workflows/build-sdl3.yml @@ -74,12 +74,8 @@ jobs: cmake --build . --config Release --parallel sudo cmake --install . --config Release - - name: Make sdist and install it - run: > - python3 -m pip install . -v -Csetup-args=-Dsdl_api=3 - -Csetup-args=-Dimage=disabled - -Csetup-args=-Dmixer=disabled - -Csetup-args=-Dfont=disabled + - name: Build with SDL3 + run: python3 dev.py build --sdl3 # - name: Run tests # env: diff --git a/dev.py b/dev.py index a7458616d1..27922d0fd1 100644 --- a/dev.py +++ b/dev.py @@ -21,6 +21,13 @@ venv_path = source_tree / VENV_NAME pyproject_path = source_tree / "pyproject.toml" +SDL3_ARGS = [ + "-Csetup-args=-Dsdl_api=3", + "-Csetup-args=-Dimage=disabled", + "-Csetup-args=-Dmixer=disabled", + "-Csetup-args=-Dfont=disabled", +] + class Colors(Enum): RESET = "\033[0m" @@ -168,8 +175,14 @@ def cmd_build(self): editable = not self.args.get("install", True) debug = self.args.get("debug", False) lax = self.args.get("lax", False) + sdl3 = self.args.get("sdl3", False) + + build_suffix = "-sdl3" if sdl3 else "" + install_args = [ + "--no-build-isolation", + f"-Cbuild-dir=.mesonpy-build{build_suffix}", + ] - install_args = ["--no-build-isolation", "-Cbuild-dir=.mesonpy-build"] if editable: install_args.append("--editable") @@ -182,6 +195,9 @@ def cmd_build(self): # use the same flags as CI install_args.extend(get_cibw_setup_args()) + if sdl3: + install_args.extend(SDL3_ARGS) + pprint(f"Building pygame (with {editable=}, {debug=}, and {lax=})") pip_install(self.py, install_args) @@ -278,6 +294,11 @@ def parse_args(self): action="store_true", help="Be lax about build warnings, allow the build to succeed with them", ) + build_parser.add_argument( + "--sdl3", + action="store_true", + help="Build against SDL3 instead of the default SDL2", + ) # Docs command docs_parser = subparsers.add_parser("docs", help="Generate docs")