Use libiconv instead of the system iconv in libretro builds

This commit is contained in:
刘皓 2025-04-12 16:40:50 -04:00
parent 8c16bc0092
commit 07a03be7df
No known key found for this signature in database
GPG key ID: 7901753DB465B711
4 changed files with 77 additions and 13 deletions

View file

@ -8,10 +8,27 @@ if is_libretro
global_args += '-DMPG123_NO_LARGENAME'
global_args += '-DGL_GLES_PROTOTYPES=0'
global_dependencies += dependency('iconv', static: core_is_static or host_system == 'windows')
global_dependencies += subproject('libretro-common').get_variable('libretro_common')
uchardet_options = cmake.subproject_options()
uchardet_options.add_cmake_defines({
'CMAKE_POLICY_VERSION_MINIMUM': '3.10',
'CMAKE_C_FLAGS': ' '.join(global_args),
'CMAKE_CXX_FLAGS': ' '.join(global_args + global_cpp_args),
'CMAKE_POSITION_INDEPENDENT_CODE': use_pic,
'BUILD_BINARY': false,
'BUILD_SHARED_LIBS': false,
})
global_dependencies += cmake.subproject('uchardet', options: uchardet_options).dependency('libuchardet')
libiconv_options = [
'cflags=@0@'.format(','.join(global_args)),
'cppflags=@0@'.format(','.join(global_args)),
'default_library=static',
'b_staticpic=@0@'.format(use_pic),
]
global_dependencies += subproject('libiconv', default_options: libiconv_options).get_variable('libiconv')
boost_options = cmake.subproject_options()
boost_options.add_cmake_defines({
'CMAKE_POLICY_VERSION_MINIMUM': '3.10',
@ -262,17 +279,6 @@ if is_libretro
'zlib=disabled',
]
global_dependencies += subproject('freetype', default_options: freetype_options).get_variable('freetype_dep')
uchardet_options = cmake.subproject_options()
uchardet_options.add_cmake_defines({
'CMAKE_POLICY_VERSION_MINIMUM': '3.10',
'CMAKE_C_FLAGS': ' '.join(global_args),
'CMAKE_CXX_FLAGS': ' '.join(global_args + global_cpp_args),
'CMAKE_POSITION_INDEPENDENT_CODE': use_pic,
'BUILD_BINARY': false,
'BUILD_SHARED_LIBS': false,
})
global_dependencies += cmake.subproject('uchardet', options: uchardet_options).dependency('libuchardet')
else
physfs = dependency('physfs', version: '>=2.1', static: build_static)
openal = dependency('openal', static: build_static, method: 'pkg-config')

View file

@ -0,0 +1,6 @@
[wrap-file]
source_url = https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.18.tar.gz
source_filename = libiconv.tar.gz
source_hash = 3b08f5f4f9b4eb82f151a7040bfd6fe6c6fb922efe4b1659c66ea933276965e8
directory = libiconv-1.18
patch_directory = libiconv

View file

@ -0,0 +1,50 @@
project('libiconv', 'c', meson_version: '>=1.3.0')
configuration = {
'BROKEN_WCHAR_H': 0,
'DLL_VARIABLE': '',
'EILSEQ': '',
'HAVE_VISIBILITY': meson.get_compiler('c').compiles('__attribute__((__visibility__("default"))) void f(void) {}', name: 'GNU visibility attribute support check') ? 1 : 0,
'ICONV_CONST': '',
'USE_MBSTATE_T': 0,
}
libiconv = declare_dependency(
include_directories: '.',
link_with: library(
'iconv',
link_with: static_library(
'localcharset',
c_args: get_option('cflags').split(',') + ['-DBUILDING_LIBCHARSET'],
include_directories: 'libcharset/include',
sources: [
configure_file(
input: 'libcharset/config.h.in',
output: 'config.h',
copy: true,
),
'libcharset/lib/localcharset.c',
],
pic: get_option('b_staticpic'),
gnu_symbol_visibility: 'hidden',
install: false,
),
c_args: get_option('cflags').split(',') + ['-DBUILDING_LIBICONV', '-DBUILDING_LIBCHARSET', '-DICONV_CONST=' + configuration['ICONV_CONST'], '-DENABLE_EXTRA'],
include_directories: 'include',
sources: [
configure_file(
input: 'libcharset/include/localcharset.h.build.in',
output: 'localcharset.h',
configuration: configuration,
),
configure_file(
input: 'include/iconv.h.build.in',
output: 'iconv.h',
configuration: configuration,
),
'lib/iconv.c',
],
pic: get_option('b_staticpic'),
gnu_symbol_visibility: 'hidden',
),
)

View file

@ -0,0 +1,2 @@
option('cflags', type: 'string')
option('cppflags', type: 'string')