Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/setup-ninja/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runs:
echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
- name: 'Restore cached ${{ steps.calc.outputs.archive }}'
id: cache-restore
uses: actions/cache/restore@v4
uses: actions/cache/restore@v6
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
Expand All @@ -47,7 +47,7 @@ runs:
Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
- name: 'Cache ${{ steps.calc.outputs.archive }}'
if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
uses: actions/cache/save@v4
uses: actions/cache/save@v6
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
Expand Down
71 changes: 11 additions & 60 deletions .github/workflows/CMake-MSVC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,33 @@ name: CMake MSVC
on: push

jobs:
yasm:
runs-on: windows-latest
steps:
- name: Restore yasm
id: restore-yasm
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/yasm
key: yasm
- name: Checkout sources
uses: actions/checkout@v4
- name: Download yasm sources
if: ${{ !steps.restore-yasm.outputs.cache-hit }}
uses: actions/checkout@v4
with:
repository: yasm/yasm
path: yasm-src
- name: Setup vcvars
if: ${{ !steps.restore-yasm.outputs.cache-hit }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Setup ninja
if: ${{ !steps.restore-yasm.outputs.cache-hit }}
uses: ./.github/actions/setup-ninja
- name: Build and install yasm
if: ${{ !steps.restore-yasm.outputs.cache-hit }}
run: |
cmake -S yasm-src -B yasm-build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/yasm -DCMAKE_INSTALL_LIBDIR=bin -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build yasm-build --parallel
cmake --install yasm-build
- name: Cache yasm
if: ${{ !steps.restore-yasm.outputs.cache-hit }}
uses: actions/cache/save@v4
with:
path: |
${{ github.workspace }}/yasm
key: yasm
build:
name: ${{ matrix.os }} ${{ matrix.arch }} ${{ (matrix.nasm && 'nasm') || 'msasm' }} ${{ (matrix.shared && 'shared') || 'static' }}
defaults:
run:
shell: cmd
needs:
yasm
strategy:
fail-fast: false
matrix:
# currently windows-latest==windows-2022
# windows-2025: VS2026
# windows-2022: VS2022
# windows-2019: VS2019
os: [windows-2022, windows-2019]
arch: [x86, x64, amd64_arm, amd64_arm64]
shared: [ON, OFF]
yasm: [true, false]
os: [windows-2025, windows-2022]
arch: [x86, x64, amd64_arm64]
# FIXME: amd64_arm is only supported by older MSVC toolchains (not available on GitHub actions)
shared: [true, false]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Restore yasm
if: ${{ matrix.yasm }}
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/yasm
key: yasm
- name: Add yasm to PATH
if: ${{ matrix.yasm }}
run: echo "${{ github.workspace }}/yasm/bin" >> %GITHUB_PATH%"
- uses: ilammy/setup-nasm@v1
if: ${{ matrix.nasm }}
- uses: actions/checkout@v7
- name: Setup vcvars
uses: ilammy/msvc-dev-cmd@v1
uses: TheMrMilchmann/setup-msvc-dev@v4
with:
arch: ${{ matrix.arch }}
sdK: ${{ (matrix.arch == 'amd64_arm' && '10.0.22621.0') || '' }}
- name: Setup ninja
uses: ./.github/actions/setup-ninja
- name: CMake (configure)
run: cmake -S ports/cmake -B build -GNinja ${{ (matrix.yasm && format('-DYASM_ASSEMBLER={0}/yasm/bin/vsyasm.exe', github.workspace)) || '' }} -DBUILD_SHARED_LIBS=${{ matrix.shared }}
run: cmake -S ports/cmake -B build -GNinja -DBUILD_SHARED_LIBS=${{ matrix.shared }}
- name: CMake (Build)
run: cmake --build build --verbose
6 changes: 3 additions & 3 deletions .github/workflows/CMake-macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
os: [macos-latest, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install ninja & yasm
run: brew install ninja yasm
- uses: actions/checkout@v7
- name: Setup ninja
uses: ./.github/actions/setup-ninja
- name: Configure (CMake)
run: |
cmake -S ports/cmake -B build -GNinja
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/MSYS2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- { sys: MINGW32, rep: mingw32, env: i686, mpg123build: x86 }
- { sys: MINGW64, rep: mingw64, env: x86_64, mpg123build: x86_64 }
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
os: [ubuntu-22.04, ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: install updates
run: sudo apt-get update
- name: install build system
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron-git.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout git mpg123 clone"
uses: "actions/checkout@v4"
uses: "actions/checkout@v7"
with:
fetch-depth: 0
token: ${{ secrets.PUSH_GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cron-pr.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
if: ${{ github.repository == 'madebr/mpg123' }}
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: "Setup python"
uses: actions/setup-python@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion ports/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(MPG123_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../..")
include(cmake/read_api_version.cmake)
read_project_version(MPG123_VERSION)

project(mpg123 VERSION ${MPG123_VERSION} LANGUAGES C ASM)
project(mpg123 VERSION ${MPG123_VERSION} LANGUAGES C)
set(CMAKE_C_STANDARD 99)

option(BUILD_LIBOUT123 "build libout123 (prerequisite for included programs)" ON)
Expand Down
2 changes: 1 addition & 1 deletion ports/cmake/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ add_compile_definitions(
$<$<BOOL:${NEWOLD_WRITE_SAMPLE}>:NEWOLD_WRITE_SAMPLE>)

add_compile_options(
$<$<BOOL:${MSVC}>:/wd4996>)
$<$<AND:$<BOOL:${MSVC}>,$<COMPILE_LANGUAGE:C>>:/wd4996>)

add_subdirectory("compat")
add_subdirectory("libmpg123")
Expand Down
84 changes: 53 additions & 31 deletions ports/cmake/src/libmpg123/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,39 @@ else()
set(INCLUDE_SYS_TYPE_H "/* #include <sys/types.h> is not available on this system */")
endif()

macro(libmpg123_assembly_sources TARGET)
cmake_parse_arguments(ARG "" "MSVC_ASM_LANGUAGE" "SOURCES;DEFINITIONS" ${ARGN})

if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(assembly_sources )
set(cc_flags "${CMAKE_C_FLAGS}")
separate_arguments(cc_flags NATIVE_COMMAND)
list(APPEND cc_flags -nologo)
set(asm_definitions "${ARG_DEFINITIONS}")
list(TRANSFORM asm_definitions PREPEND /D)
foreach(platform_source ${ARG_SOURCES})
get_filename_component(source_name "${platform_source}" NAME)
set(preprocessed_path "${CMAKE_CURRENT_BINARY_DIR}/${source_name}")
set(preproc_command ${CMAKE_C_COMPILER} /nologo ${cc_flags} ${asm_definitions} "/I${PROJECT_SOURCE_DIR}/../../src" "/I${PROJECT_BINARY_DIR}/src" /EP "/Tc${platform_source}" ">${preprocessed_path}")
add_custom_command(OUTPUT "${preprocessed_path}"
COMMAND ${preproc_command}
MAIN_DEPENDENCY "${platform_source}"
)
list(APPEND assembly_sources "${preprocessed_path}")
endforeach()

enable_language(${ARG_MSVC_ASM_LANGUAGE})
target_sources(${TARGET} PRIVATE ${assembly_sources})
set_property(SOURCE ${assembly_sources} PROPERTY LANGUAGE ${ARG_MSVC_ASM_LANGUAGE})
target_compile_options(${TARGET} PRIVATE $<$<COMPILE_LANGUAGE:${ARG_MSVC_ASM_LANGUAGE}>:-nologo>)
else()
set(assembly_sources ${ARG_SOURCES})

enable_language(ASM)
target_sources(${TARGET} PRIVATE ${assembly_sources})
set_property(SOURCE ${assembly_sources} PROPERTY LANGUAGE ASM)
endif()
endmacro()


# PPC with AltiVec is missing. But probably obsolete enough for CMake users.
Expand Down Expand Up @@ -65,13 +98,7 @@ add_library(${TARGET}
$<TARGET_OBJECTS:compat>)

if(MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(MACHINE MATCHES "x86|amd64")
find_program(YASM_ASSEMBLER yasm)
if(NOT YASM_ASSEMBLER)
message(WARNING "Couldn't find yasm assembler for optimizded decoders. Please set YASM_ASSEMBLER variable")
set(MACHINE generic)
endif()
else()
if(NOT MACHINE MATCHES "x86|amd64")
message(WARNING "Need work to support non-x86 assembly optimizations with MSVC.")
set(MACHINE generic)
endif()
Expand All @@ -91,22 +118,31 @@ if(MACHINE STREQUAL "amd64")
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_avx_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_float.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_s32.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_x86_64.S")
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_x86_64.S"
)
target_sources(${TARGET} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dither.c")
if(ACCURATE_ROUNDING)
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64_accurate.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64_accurate.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_accurate.S")
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx_accurate.S"
)
else()
list(APPEND PLATFORM_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_x86_64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_x86_64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_x86_64.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_stereo_avx.S"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_avx.S")
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_avx.S"
)
endif()

libmpg123_assembly_sources(${TARGET}
SOURCES ${PLATFORM_SOURCES}
DEFINITIONS ${PLATFORM_DEFINITIONS}
MSVC_ASM_LANGUAGE ASM_MASM
)
else()
set(PLATFORM_DEFINITIONS OPT_GENERIC)
endif()
Expand Down Expand Up @@ -141,6 +177,12 @@ elseif(MACHINE STREQUAL "x86")
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_sse.S")
endif()
endif()

libmpg123_assembly_sources(${TARGET}
SOURCES ${PLATFORM_SOURCES}
DEFINITIONS ${PLATFORM_DEFINITIONS}
MSVC_ASM_LANGUAGE ASM_MASM
)
elseif(MACHINE STREQUAL "arm64")
set(PLATFORM_DEFINITIONS OPT_MULTI OPT_GENERIC OPT_GENERIC_DITHER OPT_NEON64)
set(PLATFORM_SOURCES
Expand Down Expand Up @@ -210,6 +252,7 @@ set_target_properties(${TARGET} PROPERTIES PREFIX lib)
set_target_properties(${TARGET} PROPERTIES SOVERSION ${mpg123_soversion})
set_target_properties(${TARGET} PROPERTIES VERSION ${mpg123_version})
set_target_properties(${TARGET} PROPERTIES DLL_NAME_WITH_SOVERSION TRUE)
set_target_properties(${TARGET} PROPERTIES DEFINE_SYMBOL "")

target_compile_definitions(${TARGET} PRIVATE
$<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC>)
Expand All @@ -219,27 +262,6 @@ target_compile_definitions(${TARGET} PRIVATE
$<$<BOOL:${HAVE_FPU}>:REAL_IS_FLOAT>
$<$<NOT:$<BOOL:${HAVE_FPU}>>:REAL_IS_FIXED>)

if(MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" AND MACHINE MATCHES "x86|amd64" AND YASM_ASSEMBLER)
list(TRANSFORM PLATFORM_DEFINITIONS PREPEND /D)
foreach(FILE ${PLATFORM_SOURCES})
get_filename_component(FILENAME ${FILE} NAME)
add_custom_command(
OUTPUT ${FILENAME}.asm
COMMAND ${CMAKE_C_COMPILER} /NOLOGO /DASMALIGN_BALIGN ${PLATFORM_DEFINITIONS}
/I"${PROJECT_SOURCE_DIR}/../../src" /I"${PROJECT_BINARY_DIR}/src" /P /Fi${FILENAME}.asm /Tc "${FILE}"
DEPENDS ${FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_command(
OUTPUT ${FILENAME}.obj
COMMAND ${YASM_ASSEMBLER} -a x86 -m ${MACHINE} -p gas -r raw -f win32 -g null -o ${FILENAME}.obj ${FILENAME}.asm
DEPENDS ${FILENAME}.asm
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
target_sources(${TARGET} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}.obj")
endforeach()
else()
target_sources(${TARGET} PRIVATE ${PLATFORM_SOURCES})
endif()

if(HAVE_M)
string(APPEND LIBMPG123_LIBS " -lm")
endif()
Expand Down
1 change: 1 addition & 0 deletions ports/cmake/src/libout123/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set_target_properties(${TARGET} PROPERTIES PREFIX lib)
set_target_properties(${TARGET} PROPERTIES SOVERSION ${out123_soversion})
set_target_properties(${TARGET} PROPERTIES VERSION ${out123_version})
set_target_properties(${TARGET} PROPERTIES DLL_NAME_WITH_SOVERSION TRUE)
set_target_properties(${TARGET} PROPERTIES DEFINE_SYMBOL "")

if(HAVE_UNIX_DL)
string(APPEND LIBOUT123_LIBS " -ldl")
Expand Down
1 change: 1 addition & 0 deletions ports/cmake/src/libsyn123/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set_target_properties(${TARGET} PROPERTIES PREFIX lib)
set_target_properties(${TARGET} PROPERTIES SOVERSION ${syn123_soversion})
set_target_properties(${TARGET} PROPERTIES VERSION ${syn123_version})
set_target_properties(${TARGET} PROPERTIES DLL_NAME_WITH_SOVERSION TRUE)
set_target_properties(${TARGET} PROPERTIES DEFINE_SYMBOL "")

target_include_directories(${TARGET} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
Expand Down
Loading
Loading