mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Add all dependencies of libretro build as Meson subprojects
This commit is contained in:
parent
54f9055ee1
commit
77b7dda096
11 changed files with 235 additions and 35 deletions
21
.github/workflows/autobuild.yml
vendored
21
.github/workflows/autobuild.yml
vendored
|
@ -329,7 +329,6 @@ jobs:
|
|||
run: |
|
||||
cd retro
|
||||
make WASI_SDK=${{ runner.temp }}/wasi-sdk
|
||||
cd ..
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
@ -352,7 +351,7 @@ jobs:
|
|||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: mingw64
|
||||
install: base-devel git mingw-w64-x86_64-cmake mingw-w64-x86_64-meson mingw-w64-x86_64-autotools mingw-w64-x86_64-gcc mingw-w64-x86_64-zlib
|
||||
install: base-devel git mingw-w64-x86_64-make mingw-w64-x86_64-cmake mingw-w64-x86_64-meson mingw-w64-x86_64-gcc
|
||||
|
||||
- name: Build phase 2
|
||||
shell: msys2 {0}
|
||||
|
@ -428,12 +427,10 @@ jobs:
|
|||
echo 'Components: main universe' | sudo tee -a /etc/apt/sources.list.d/ubuntu.sources
|
||||
fi
|
||||
sudo apt update
|
||||
sudo apt install git curl build-essential automake libtool meson cmake -y
|
||||
sudo apt install git build-essential make meson cmake -y
|
||||
if [ '${{ matrix.arch_mkxpz }}' != 'x86_64' ]
|
||||
then
|
||||
sudo apt install gcc-${{ matrix.arch_gcc }} g++-${{ matrix.arch_gcc }} zlib1g-dev:${{ matrix.arch_debian }} -y
|
||||
else
|
||||
sudo apt install zlib1g-dev -y
|
||||
sudo apt install gcc-${{ matrix.arch_gcc }} g++-${{ matrix.arch_gcc }} -y
|
||||
fi
|
||||
|
||||
- name: Build phase 2
|
||||
|
@ -471,21 +468,13 @@ jobs:
|
|||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
brew install -q git make pkgconf meson cmake
|
||||
|
||||
- name: Build zlib
|
||||
run: |
|
||||
git clone https://github.com/madler/zlib ${{ runner.temp }}/zlib -b v1.3.1
|
||||
cd ${{ runner.temp }}/zlib
|
||||
cmake -DCMAKE_MAKE_PROGRAM=gmake -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/deps -B build
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
brew install -q git make meson cmake
|
||||
|
||||
- name: Build phase 2
|
||||
run: |
|
||||
mkdir ${{ runner.temp }}/retro-phase2
|
||||
cp retro/core.info ${{ runner.temp }}/retro-phase2/libretro-mkxp-z.info
|
||||
PKG_CONFIG_PATH=${{ runner.temp }}/deps/share/pkgconfig meson setup build -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 -Dretro_lookup_method=pkg-config
|
||||
meson setup build -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1
|
||||
cd build
|
||||
ninja -v
|
||||
mv libretro-mkxp-z.dylib ${{ runner.temp }}/retro-phase2
|
||||
|
|
74
meson.build
74
meson.build
|
@ -1,4 +1,4 @@
|
|||
project('mkxp-z', 'c', 'cpp', version: '2.4.2', meson_version: '>=0.56.0', default_options: ['cpp_std=c++14', 'buildtype=release'])
|
||||
project('mkxp-z', 'c', 'cpp', version: '2.4.2', meson_version: '>=0.63.0', default_options: ['cpp_std=c++14', 'buildtype=release'])
|
||||
|
||||
host_system = host_machine.system()
|
||||
host_endian = host_machine.endian()
|
||||
|
@ -35,30 +35,67 @@ if get_option('retro') == true
|
|||
|
||||
cmake = import('cmake')
|
||||
|
||||
zlib_options = cmake.subproject_options()
|
||||
zlib_options.add_cmake_defines({
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'BUILD_SHARED_LIBS': false,
|
||||
'ZLIB_BUILD_EXAMPLES': false,
|
||||
})
|
||||
|
||||
bzip2_options = cmake.subproject_options()
|
||||
bzip2_options.add_cmake_defines({
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'ENABLE_STATIC_LIB': true,
|
||||
'ENABLE_LIB_ONLY': true,
|
||||
})
|
||||
|
||||
bzip2_options = cmake.subproject_options()
|
||||
bzip2_options.add_cmake_defines({
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'ENABLE_STATIC_LIB': true,
|
||||
'ENABLE_LIB_ONLY': true,
|
||||
})
|
||||
|
||||
lzma_options = cmake.subproject_options()
|
||||
lzma_options.add_cmake_defines({
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'BUILD_SHARED_LIBS': false,
|
||||
'ENABLE_NLS': false,
|
||||
'ENABLE_THREADS': 'OFF',
|
||||
})
|
||||
|
||||
zstd_options = cmake.subproject_options()
|
||||
zstd_options.add_cmake_defines({
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'ZSTD_BUILD_STATIC': true,
|
||||
'ZSTD_BUILD_SHARED': false,
|
||||
'ZSTD_BUILD_PROGRAMS': false,
|
||||
'ZSTD_BUILD_TESTS': false,
|
||||
'ZSTD_BUILD_CONTRIB': false,
|
||||
'ZSTD_MULTITHREAD_SUPPORT': false,
|
||||
})
|
||||
|
||||
libzip_options = cmake.subproject_options()
|
||||
libzip_options.add_cmake_defines({
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
'BUILD_SHARED_LIBS': false,
|
||||
'LIBZIP_DO_INSTALL': false,
|
||||
'BUILD_TOOLS': false,
|
||||
'BUILD_REGRESS': false,
|
||||
'BUILD_OSSFUZZ': false,
|
||||
'BUILD_EXAMPLES': false,
|
||||
'BUILD_DOC': false,
|
||||
'ENABLE_COMMONCRYPTO': false,
|
||||
'ENABLE_GNUTLS': false,
|
||||
'ENABLE_MBEDTLS': false,
|
||||
'ENABLE_OPENSSL': false,
|
||||
'ENABLE_WINDOWS_CRYPTO': false,
|
||||
'ENABLE_FDOPEN': false,
|
||||
'ENABLE_BZIP2': false,
|
||||
'ENABLE_LZMA': false,
|
||||
'ENABLE_ZSTD': false,
|
||||
'ENABLE_BZIP2': true,
|
||||
'ENABLE_LZMA': true,
|
||||
'ENABLE_ZSTD': true,
|
||||
})
|
||||
|
||||
retro_deps = []
|
||||
if get_option('retro_lookup_method') == 'pkg-config'
|
||||
retro_deps += dependency('zlib', static: true)
|
||||
else
|
||||
retro_deps += compilers['cpp'].find_library('z', required: true, static: true)
|
||||
endif
|
||||
retro_deps += cmake.subproject('libzip', options: libzip_options).dependency('zip')
|
||||
|
||||
retro_defines = [
|
||||
'-DWASM_RT_TRAP_HANDLER=mkxp_sandbox_trap_handler',
|
||||
'-DMKXPZ_RETRO=1',
|
||||
|
@ -69,7 +106,13 @@ if get_option('retro') == true
|
|||
|
||||
library(
|
||||
'retro-' + meson.project_name(),
|
||||
dependencies: retro_deps,
|
||||
dependencies: [
|
||||
cmake.subproject('zlib', options: zlib_options).dependency('zlibstatic'),
|
||||
cmake.subproject('bzip2', options: bzip2_options).dependency('bz2_static'),
|
||||
cmake.subproject('lzma', options: lzma_options).dependency('liblzma'),
|
||||
cmake.subproject('zstd', options: zstd_options).dependency('libzstd_static'),
|
||||
cmake.subproject('libzip', options: libzip_options).dependency('zip'),
|
||||
],
|
||||
c_args: [
|
||||
'-fno-optimize-sibling-calls',
|
||||
'-frounding-math',
|
||||
|
@ -81,10 +124,7 @@ if get_option('retro') == true
|
|||
'-Wno-ignored-optimization-argument',
|
||||
] + retro_defines,
|
||||
cpp_args: retro_defines,
|
||||
link_args: [
|
||||
host_system == 'darwin' ? '' : ('-Wl,--version-script=' + join_paths(meson.current_source_dir(), 'retro/link.T')),
|
||||
],
|
||||
gnu_symbol_visibility: host_system == 'darwin' ? 'hidden' : '',
|
||||
gnu_symbol_visibility: 'hidden',
|
||||
include_directories: [
|
||||
include_directories(retro_phase1),
|
||||
include_directories(join_paths(retro_phase1, 'wasm2c')),
|
||||
|
|
|
@ -24,4 +24,3 @@ option('gfx_backend', type: 'combo', value: 'gl', choices: ['gl', 'gles'], descr
|
|||
|
||||
option('retro', type: 'boolean', value: false, description: 'Build a libretro core instead of an executable')
|
||||
option('retro_phase1_path', type: 'string', value: '', description: 'Path to retro-phase1 for libretro builds')
|
||||
option('retro_lookup_method', type: 'combo', value: 'compiler', choices: ['compiler', 'pkg-config'], description: 'Method to use to locate software libraries for libretro builds')
|
||||
|
|
3
subprojects/.gitignore
vendored
3
subprojects/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/libzip
|
||||
/**/
|
||||
!/packagefiles
|
||||
|
|
5
subprojects/bzip2.wrap
Normal file
5
subprojects/bzip2.wrap
Normal file
|
@ -0,0 +1,5 @@
|
|||
[wrap-git]
|
||||
url = https://gitlab.com/bzip2/bzip2
|
||||
# 2023-06-01
|
||||
revision = 66c46b8c9436613fd81bc5d03f63a61933a4dcc3
|
||||
depth = 1
|
|
@ -2,3 +2,4 @@
|
|||
url = https://github.com/nih-at/libzip
|
||||
revision = v1.11.2
|
||||
depth = 1
|
||||
diff_files = libzip.patch
|
||||
|
|
4
subprojects/lzma.wrap
Normal file
4
subprojects/lzma.wrap
Normal file
|
@ -0,0 +1,4 @@
|
|||
[wrap-git]
|
||||
url = https://github.com/ShiftMediaProject/liblzma
|
||||
revision = v5.6.3
|
||||
depth = 1
|
101
subprojects/packagefiles/libzip.patch
Normal file
101
subprojects/packagefiles/libzip.patch
Normal file
|
@ -0,0 +1,101 @@
|
|||
# This patch prevents libzip's build system from trying to look for zlib, bzip2, lzma and zstd since Meson already handles that.
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -198,66 +198,17 @@ int main(int argc, char *argv[]) { }" HAVE_NULLABLE)
|
||||
|
||||
test_big_endian(WORDS_BIGENDIAN)
|
||||
|
||||
-find_package(ZLIB 1.1.2 REQUIRED)
|
||||
-# so developers on systems where zlib is named differently (Windows, sometimes)
|
||||
-# can override the name used in the pkg-config file
|
||||
-if (NOT ZLIB_LINK_LIBRARY_NAME)
|
||||
- set(ZLIB_LINK_LIBRARY_NAME "z")
|
||||
-
|
||||
- # Get the correct name in common cases
|
||||
- list(LENGTH ZLIB_LIBRARIES N_ZLIB_LIBRARIES)
|
||||
- if(N_ZLIB_LIBRARIES EQUAL 1)
|
||||
- set(ZLIB_FILENAME ${ZLIB_LIBRARIES})
|
||||
- elseif(N_ZLIB_LIBRARIES EQUAL 4)
|
||||
- # ZLIB_LIBRARIES might have the target_link_library() format like
|
||||
- # "optimized;path/to/zlib.lib;debug;path/to/zlibd.lib". Use the 'optimized'
|
||||
- # case unless we know we are in a Debug build.
|
||||
- if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
- list(FIND ZLIB_LIBRARIES "debug" ZLIB_LIBRARIES_INDEX_OF_CONFIG)
|
||||
- else()
|
||||
- list(FIND ZLIB_LIBRARIES "optimized" ZLIB_LIBRARIES_INDEX_OF_CONFIG)
|
||||
- endif()
|
||||
- if(ZLIB_LIBRARIES_INDEX_OF_CONFIG GREATER_EQUAL 0)
|
||||
- math(EXPR ZLIB_FILENAME_INDEX "${ZLIB_LIBRARIES_INDEX_OF_CONFIG}+1")
|
||||
- list(GET ZLIB_LIBRARIES ${ZLIB_FILENAME_INDEX} ZLIB_FILENAME)
|
||||
- endif()
|
||||
- endif()
|
||||
- if(ZLIB_FILENAME)
|
||||
- get_filename_component(ZLIB_FILENAME ${ZLIB_FILENAME} NAME_WE)
|
||||
- string(REGEX REPLACE "^lib" "" ZLIB_LINK_LIBRARY_NAME ${ZLIB_FILENAME})
|
||||
- endif()
|
||||
-endif(NOT ZLIB_LINK_LIBRARY_NAME)
|
||||
|
||||
if(ENABLE_BZIP2)
|
||||
- find_package(BZip2)
|
||||
- if(BZIP2_FOUND)
|
||||
set(HAVE_LIBBZ2 1)
|
||||
- else()
|
||||
- message(WARNING "-- bzip2 library not found; bzip2 support disabled")
|
||||
- endif(BZIP2_FOUND)
|
||||
endif(ENABLE_BZIP2)
|
||||
|
||||
if(ENABLE_LZMA)
|
||||
- find_package(LibLZMA 5.2)
|
||||
- if(LIBLZMA_FOUND)
|
||||
set(HAVE_LIBLZMA 1)
|
||||
- else()
|
||||
- message(WARNING "-- lzma library not found; lzma/xz support disabled")
|
||||
- endif(LIBLZMA_FOUND)
|
||||
endif(ENABLE_LZMA)
|
||||
|
||||
if(ENABLE_ZSTD)
|
||||
- find_package(zstd 1.4.0)
|
||||
- if(zstd_FOUND)
|
||||
set(HAVE_LIBZSTD 1)
|
||||
- if(TARGET zstd::libzstd_shared AND BUILD_SHARED_LIBS)
|
||||
- set(zstd_TARGET zstd::libzstd_shared)
|
||||
- else()
|
||||
- set(zstd_TARGET zstd::libzstd_static)
|
||||
- endif()
|
||||
- else()
|
||||
- message(WARNING "-- zstd library not found; zstandard support disabled")
|
||||
- endif(zstd_FOUND)
|
||||
endif(ENABLE_ZSTD)
|
||||
|
||||
if (COMMONCRYPTO_FOUND)
|
||||
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
|
||||
--- a/lib/CMakeLists.txt
|
||||
+++ b/lib/CMakeLists.txt
|
||||
@@ -140,17 +140,14 @@ endif(WIN32)
|
||||
|
||||
if(HAVE_LIBBZ2)
|
||||
target_sources(zip PRIVATE zip_algorithm_bzip2.c)
|
||||
- target_link_libraries(zip PRIVATE BZip2::BZip2)
|
||||
endif()
|
||||
|
||||
if(HAVE_LIBLZMA)
|
||||
target_sources(zip PRIVATE zip_algorithm_xz.c)
|
||||
- target_link_libraries(zip PRIVATE LibLZMA::LibLZMA)
|
||||
endif()
|
||||
|
||||
if(HAVE_LIBZSTD)
|
||||
target_sources(zip PRIVATE zip_algorithm_zstd.c)
|
||||
- target_link_libraries(zip PRIVATE ${zstd_TARGET})
|
||||
endif()
|
||||
|
||||
if(HAVE_COMMONCRYPTO)
|
||||
@@ -178,7 +175,6 @@ if(SHARED_LIB_VERSIONNING)
|
||||
set_target_properties(zip PROPERTIES VERSION 5.5 SOVERSION 5 MACHO_CURRENT_VERSION 6.5 MACHO_COMPATIBILITY_VERSION 6)
|
||||
endif()
|
||||
|
||||
-target_link_libraries(zip PRIVATE ZLIB::ZLIB)
|
||||
target_include_directories(zip
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib>
|
51
subprojects/packagefiles/zstd.patch
Normal file
51
subprojects/packagefiles/zstd.patch
Normal file
|
@ -0,0 +1,51 @@
|
|||
diff --git a/build/cmake/CMakeLists.txt b/CMakeLists.txt
|
||||
rename from build/cmake/CMakeLists.txt
|
||||
rename to CMakeLists.txt
|
||||
--- a/build/cmake/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -23,8 +23,8 @@ cmake_policy(VERSION ${ZSTD_CMAKE_POLICY_VERSION})
|
||||
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH on)
|
||||
|
||||
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
|
||||
-set(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/CMakeModules")
|
||||
+set(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
|
||||
# Parse version
|
||||
include(GetZstdLibraryVersion)
|
||||
@@ -143,7 +143,7 @@ endif ()
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add source directories
|
||||
#-----------------------------------------------------------------------------
|
||||
-add_subdirectory(lib)
|
||||
+add_subdirectory(build/cmake/lib)
|
||||
|
||||
option(ZSTD_PROGRAMS_LINK_SHARED "PROGRAMS LINK SHARED" OFF)
|
||||
|
||||
@@ -186,7 +186,7 @@ add_custom_target(clean-all
|
||||
#-----------------------------------------------------------------------------
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/build/cmake/zstdConfigVersion.cmake"
|
||||
VERSION ${zstd_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
@@ -205,12 +205,12 @@ install(EXPORT zstdExports
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
configure_package_config_file(
|
||||
- zstdConfig.cmake.in
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
+ build/cmake/zstdConfig.cmake.in
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/build/cmake/zstdConfig.cmake"
|
||||
INSTALL_DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
install(FILES
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/build/cmake/zstdConfig.cmake"
|
||||
+ "${CMAKE_CURRENT_BINARY_DIR}/build/cmake/zstdConfigVersion.cmake"
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
4
subprojects/zlib.wrap
Normal file
4
subprojects/zlib.wrap
Normal file
|
@ -0,0 +1,4 @@
|
|||
[wrap-git]
|
||||
url = https://github.com/madler/zlib
|
||||
revision = v1.3.1
|
||||
depth = 1
|
5
subprojects/zstd.wrap
Normal file
5
subprojects/zstd.wrap
Normal file
|
@ -0,0 +1,5 @@
|
|||
[wrap-git]
|
||||
url = https://github.com/facebook/zstd
|
||||
revision = v1.5.6
|
||||
depth = 1
|
||||
diff_files = zstd.patch
|
Loading…
Add table
Reference in a new issue