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

SDL2_mixer + libxmp #497

Merged
merged 10 commits into from Feb 4, 2024
18 changes: 9 additions & 9 deletions .github/workflows/compilation.yml
Expand Up @@ -45,7 +45,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -y install cmake cmake-data libargtable2-dev libcunit1-dev \
libopenal-dev libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev \
libsdl2-mixer-dev libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev \
clang-tidy ${{ matrix.config.cc }}

- name: Build tests
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get -y install cmake libargtable2-dev libcunit1-dev libopenal-dev \
sudo apt-get -y install cmake libargtable2-dev libcunit1-dev libsdl2-mixer-dev \
libconfuse-dev libenet-dev libsdl2-dev libxmp-dev libpng-dev

- name: Generate Release
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
maintainer: ${{ github.repository_owner }}
version: 0.6.6-${{ steps.slug.outputs.sha8 }}
arch: 'amd64'
depends: 'libargtable2, libopenal, libconfuse, libenet, libsdl2, libxmp, libpng'
depends: 'libargtable2, libsdl2-mixer, libconfuse, libenet, libsdl2, libxmp, libpng'
desc: 'One Must Fall 2097 Remake'

- name: Upload DEB artifact
Expand All @@ -121,16 +121,16 @@ jobs:
build_macos:
needs: [unittest, formatting-check]

name: Build macos-11
runs-on: macos-11
name: Build macos-12
runs-on: macos-12

steps:
- uses: actions/checkout@v3

- name: Install Mac Dependencies
run: |
brew update
brew install cmake argtable cunit openal-soft confuse enet sdl2 libxmp libpng
brew install cmake argtable cunit sdl2_mixer confuse enet sdl2 libxmp libpng

- name: Generate Release
run: |
Expand All @@ -146,13 +146,13 @@ jobs:
- name: Generate ZIP package
run: |
cd build-release/release
zip -r ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos11.zip .
zip -r ${GITHUB_WORKSPACE}/openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12.zip .

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos11
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos11.zip
name: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12
path: openomf_0.6.6-${{ steps.slug.outputs.sha8 }}_macos12.zip

# Build windows package, release artifact and update "latest" release if necessary.
# -----------------------------------------------------------------------------------------------
Expand Down
67 changes: 8 additions & 59 deletions CMakeLists.txt
Expand Up @@ -13,10 +13,6 @@ set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
# Options
OPTION(USE_TESTS "Build unittests" OFF)
OPTION(USE_TOOLS "Build tools" OFF)
OPTION(USE_OGGVORBIS "Add support for Ogg Vorbis audio" OFF)
OPTION(USE_DUMB "Use libdumb for module playback" OFF)
OPTION(USE_XMP "Use libxmp for module playback" ON)
OPTION(USE_OPENAL "Support OpenAL for audio playback" ON)
OPTION(USE_SANITIZERS "Enable Asan and Ubsan" OFF)
OPTION(USE_TIDY "Use clang-tidy for checks" OFF)
OPTION(USE_FORMAT "Use clang-format for checks" OFF)
Expand Down Expand Up @@ -46,6 +42,8 @@ endif()

# System packages (hard dependencies)
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(xmp)
find_package(enet)
find_package(confuse)
find_package(argtable2)
Expand All @@ -56,29 +54,6 @@ find_package(ZLIB)
check_symbol_exists(strdup "string.h" HAVE_STD_STRDUP)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/platform.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/platform.h)

# If USE_DUMB flag is on, turn on libdumb
if(USE_DUMB)
find_package(dumb)
add_definitions(-DUSE_DUMB)
if(MINGW)
add_definitions(-D_FILE_OFFSET_BITS=64)
endif()
endif()

# If XMP has been selected, attempt to find it
if(USE_XMP)
find_package(xmp)
add_definitions(-DUSE_XMP)
endif()

# Audio sink selection
if(USE_OPENAL)
find_package(OpenAL)
add_definitions(-DUSE_OPENAL)
else()
message(STATUS "Note! No audio sink selected; Music/sounds will not play.")
endif()

# When building with MingW, do not look for Intl
if(MINGW)
set(LIBINTL_INCLUDE_DIR "")
Expand All @@ -87,13 +62,6 @@ else()
find_package(Intl)
endif()

# If we want to build support for vorbis streaming, find these too
if(USE_OGGVORBIS)
find_package(ogg)
find_package(vorbis)
add_definitions(-DUSE_OGGVORBIS)
endif()

# If tests are enabled, find CUnit
if(USE_TESTS)
find_package(CUnit)
Expand All @@ -112,46 +80,26 @@ set(COREINCS
src
${CMAKE_CURRENT_BINARY_DIR}/src/
${SDL2_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS}
${CONFUSE_INCLUDE_DIR}
${Intl_INCLUDE_DIR}
${XMP_INCLUDE_DIR}
${ENET_INCLUDE_DIR}
${ARGTABLE2_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
)

set(CORELIBS
${SDL2_LIBRARIES}
${CONFUSE_LIBRARY}
${Intl_LIBRARIES}
${XMP_LIBRARY}
${ENET_LIBRARY}
${ARGTABLE2_LIBRARY}
${PNG_LIBRARY}
${ZLIB_LIBRARY}
)

# Handle module playback libraries
if(USE_DUMB)
set(CORELIBS ${CORELIBS} ${DUMB_LIBRARY})
set(COREINCS ${COREINCS} ${DUMB_INCLUDE_DIR})
endif()
if(USE_XMP)
set(CORELIBS ${CORELIBS} ${XMP_LIBRARY})
set(COREINCS ${COREINCS} ${XMP_INCLUDE_DIR})
endif()

# Audio sinks
if(USE_OPENAL)
set(CORELIBS ${CORELIBS} ${OPENAL_LIBRARY})
set(COREINCS ${COREINCS} ${OPENAL_INCLUDE_DIR})
endif()

# If we support ogg vorbis, add library includes etc.
if(USE_OGGVORBIS)
set(COREINCS ${COREINCS} ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
set(CORELIBS ${CORELIBS} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
endif()

# MingW build should add mingw32 lib
if(MINGW)
set(CORELIBS mingw32 ${CORELIBS})
Expand Down Expand Up @@ -290,8 +238,9 @@ endif()

# Make sure libraries are linked
target_link_libraries(openomf ${CORELIBS})
target_link_libraries(openomf SDL2::Main SDL2::Mixer)
foreach(TARGET ${TOOL_TARGET_NAMES})
target_link_libraries(${TARGET} ${CORELIBS})
target_link_libraries(${TARGET} ${CORELIBS} SDL2::Main SDL2::Mixer)
endforeach()

# Testing stuff
Expand All @@ -309,7 +258,7 @@ if(CUNIT_FOUND)
target_compile_definitions(openomf_test_main PRIVATE
TESTS_ROOT_DIR="${CMAKE_SOURCE_DIR}/testing")

target_link_libraries(openomf_test_main ${CORELIBS})
target_link_libraries(openomf_test_main ${CORELIBS} SDL2::Main SDL2::Mixer)

if(MINGW)
# Always build as a console executable with mingw
Expand Down
31 changes: 5 additions & 26 deletions INSTALL.md
Expand Up @@ -47,27 +47,20 @@ Required:
* Gettext (if you have problems with libintl)
* Enet: http://enet.bespin.org/
* libargtable2: http://argtable.sourceforge.net/
* libpng: http://www.libpng.org/pub/png/libpng.html (for .PNG screenshots)
* libpng: http://www.libpng.org/pub/png/libpng.html
* zlib: http://www.zlib.net/ (for libpng)

Recommended:
* OpenAL: http://kcat.strangesoft.net/openal.html (for audio)
* libxmp: https://github.com/cmatsuoka/libxmp (for module music)

Optional:
* libvorbis: https://www.xiph.org/downloads/
* libogg: https://www.xiph.org/downloads/
* libdumb (>=2.0.0): https://bitbucket.org/kode54/dumb (for module music)
* SDL2_Mixer (>=2.0.4): https://github.com/libsdl-org/SDL_mixer
* libxmp: https://github.com/cmatsuoka/libxmp


On debian, it is possible to pull some libraries using apt-get.
```
apt-get install libsdl2-dev libopenal-dev libpng-dev libconfuse-dev libenet-dev libargtable2-dev libxmp-dev
apt-get install libsdl2-dev libsdl2-mixer-dev libpng-dev libconfuse-dev libenet-dev libargtable2-dev libxmp-dev
```

On Mac, you can use brew:
```
brew install argtable openal-soft confuse enet sdl2 libxmp libpng
brew install argtable sdl2_mixer confuse enet sdl2 libxmp libpng
```

### Acquiring the sources
Expand Down Expand Up @@ -100,26 +93,12 @@ Some useful CMake flags:
|----------------------|-----------------------------------------|-----------------|---------|
| CMAKE_BUILD_TYPE | Chooses between build types | -/Debug/Release | - |
| CMAKE_INSTALL_PREFIX | Installation path | - | - |
| USE_OGGVORBIS | Selects Vorbis support | On/Off | Off |
| USE_OPENAL | Selects OpenAL support | On/Off | On |
| USE_DUMB | Selects libdumb support | On/Off | Off |
| USE_XMP | Selects libxmp support | On/Off | On |
| USE_TESTS | Enables unittests (dev only!) | On/Off | Off |
| USE_TOOLS | Enables format editor tools (dev only!) | On/Off | Off |
| USE_SANITIZERS | Enables asan and ubsan (dev only!) | On/Off | Off |
| USE_FORMAT | Enables clang-format (dev only!) | On/Off | Off |
| USE_TIDY | Enables clang-tidy (dev only!) | On/Off | Off |

Ogg Vorbis support is required if you wish to replace original OMF soundtracks with OGG files.
Otherwise, the switch is optional.

For music playback, select at least one (or more) of the module player libraries.
XMP is recommended due to ease of installation, but DUMB will also work just fine.

It is technically possible to select more than one audio sink, or none. Currently, only one
audio sink is supported (OpenAL). If all audio sinks are off, then no audio will be played.
This will also of course reduce cpu usage a bit.

Note that when USE_FORMAT is selected, you can run command "make clangformat" to run code
formatter to the entire codebase.

Expand Down