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

Allow certain code modules to be removed from build process #1769

Merged
merged 7 commits into from
Mar 28, 2024

Conversation

rh101
Copy link
Contributor

@rh101 rh101 commented Mar 27, 2024

Describe your changes

This is an attempt at allowing a developer to turn off certain aspects of the game engine source so that they are not built, reducing build times and final binary file size.

The new options are:

option(AX_ENABLE_3D "Build 3D support" ON)
option(AX_ENABLE_PHYSICS3D "Build Physics3D support" ON)
option(AX_ENABLE_NAVMESH "Build NavMesh support" ON)
option(AX_ENABLE_MEDIA "Build media support" ON)
option(AX_ENABLE_AUDIO "Build audio support" ON)

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

@halx99
Copy link
Collaborator

halx99 commented Mar 28, 2024

Thanks, could add these new options to https://github.com/axmolengine/axmol/blob/dev/CMakeOptions.md?

@rh101
Copy link
Contributor Author

rh101 commented Mar 28, 2024

Thanks, could add these new options to https://github.com/axmolengine/axmol/blob/dev/CMakeOptions.md?

Will do!

@halx99 halx99 added this to the 2.1.3 milestone Mar 28, 2024
@halx99 halx99 added the enhancement New feature or request label Mar 28, 2024
@halx99 halx99 merged commit 4fb8452 into axmolengine:dev Mar 28, 2024
14 checks passed
@halx99
Copy link
Collaborator

halx99 commented Mar 29, 2024

@rh101 seems this PR cause crash, just enter first test of cpp-tests on linux

@halx99
Copy link
Collaborator

halx99 commented Mar 29, 2024

And recommend refactor this defines in base/Config.h, please help control per core feature by single feature macro, i.e. rename AX_USE_PHYSICS to AX_ENABLE_PHYSICS.

/** Use physics integration API. */
//  It works with:
// Chipmunk2D or Box2D
#ifndef AX_USE_PHYSICS
#    define AX_USE_PHYSICS 1
#endif
#if (AX_USE_PHYSICS)
/** Use Chipmunk2D physics 2d engine on physics integration API. */
#    ifndef AX_ENABLE_CHIPMUNK_INTEGRATION
#        define AX_ENABLE_CHIPMUNK_INTEGRATION 0
#    endif
/** or use Box2D physics 2d engine on physics integration API. */
#    ifndef AX_ENABLE_BOX2D_INTEGRATION
#        define AX_ENABLE_BOX2D_INTEGRATION 1
#    endif
#endif  // AX_USE_PHYSICS

/** Use 3d physics integration API. */
#ifndef AX_USE_3D_PHYSICS
#    if (AX_TARGET_PLATFORM == AX_PLATFORM_IOS || AX_TARGET_PLATFORM == AX_PLATFORM_MAC ||       \
         AX_TARGET_PLATFORM == AX_PLATFORM_WIN32 || AX_TARGET_PLATFORM == AX_PLATFORM_WINRT ||   \
         AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID || AX_TARGET_PLATFORM == AX_PLATFORM_LINUX || \
         AX_TARGET_PLATFORM == AX_PLATFORM_WASM)
#        define AX_USE_3D_PHYSICS 0
#    endif
#endif

#if (AX_USE_3D_PHYSICS)
/** Use bullet physics engine. */
#    ifndef AX_ENABLE_BULLET_INTEGRATION
#        define AX_ENABLE_BULLET_INTEGRATION 1
#    endif
#endif

/** Use 3D navigation API */
#ifndef AX_USE_NAVMESH
#    define AX_USE_NAVMESH 0
#endif

@rh101
Copy link
Contributor Author

rh101 commented Mar 29, 2024

And recommend refactor this defines in base/Config.h, please help control per core feature by single feature macro, i.e. rename AX_USE_PHYSICS to AX_ENABLE_PHYSICS.

Will do! I'll make the changes right now.

Regarding Linux, I don't have a test box to use, but can set one up in around 12 hours (from this post).

@rh101 rh101 deleted the build-size-reduction branch March 31, 2024 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants