meson: add uchardet port

Meson port instead of using CMake as I ran into issues with the
src directory (where uchardet.h is located) not being appended
to the include path, and on Windows I ran into a Meson issue
where a -D macro definition was being interpreted as a filename.
In the end a Meson port seemed simpler than working out the CMake
issues, as the CMakeLists.txt files were straightforward and easy
to port.

Note that because of the directory structure of the uchardet source
I had to change the include directive from uchardet/uchardet.h
to just uchardet.h. This is actually more in line with the uchardet
pkg-config file, which appends /usr/include/uchardet to the include path.
This commit is contained in:
Myaamori 2021-04-07 12:32:33 +01:00 committed by Ryan Lucia
parent c43e4fba3c
commit 84ac716972
5 changed files with 81 additions and 2 deletions

View File

@ -22,7 +22,7 @@
#include "libaegisub/scoped_ptr.h"
#ifdef WITH_UCHARDET
#include <uchardet/uchardet.h>
#include <uchardet.h>
#endif
namespace agi { namespace charset {

View File

@ -184,7 +184,7 @@ foreach dep: [
# other
['fftw3', '', 'FFTW3', []],
['hunspell', '', 'Hunspell', ['hunspell', 'hunspell_dep']],
['uchardet', '', 'uchardet', []], # needs a proper port
['uchardet', '', 'uchardet', ['uchardet', 'uchardet_dep']],
]
dep_version = dep[1] != '' ? dep[1] : '>=0'
# [provide] section is ignored if required is false;

View File

@ -0,0 +1,16 @@
project('uchardet', 'cpp', version: '0.0.7', meson_version: '>=0.57.0')
inc = include_directories('src')
cpp = meson.get_compiler('cpp')
if cpp.has_argument('-msse2') and cpp.has_argument('-mfpmath=sse')
add_project_arguments('-msse2', '-mfpmath=sse', language: 'cpp')
elif cpp.has_argument('-ffloat-store')
add_project_arguments('-ffloat-store', language: 'cpp')
endif
subdir('src')
uchardet_dep = declare_dependency(link_with: uchardet,
include_directories: inc)

View File

@ -0,0 +1,54 @@
uchardet_sources = files([
'CharDistribution.cpp',
'JpCntx.cpp',
'LangModels/LangArabicModel.cpp',
'LangModels/LangBulgarianModel.cpp',
'LangModels/LangCroatianModel.cpp',
'LangModels/LangCzechModel.cpp',
'LangModels/LangEsperantoModel.cpp',
'LangModels/LangEstonianModel.cpp',
'LangModels/LangFinnishModel.cpp',
'LangModels/LangFrenchModel.cpp',
'LangModels/LangDanishModel.cpp',
'LangModels/LangGermanModel.cpp',
'LangModels/LangGreekModel.cpp',
'LangModels/LangHungarianModel.cpp',
'LangModels/LangHebrewModel.cpp',
'LangModels/LangIrishModel.cpp',
'LangModels/LangItalianModel.cpp',
'LangModels/LangLithuanianModel.cpp',
'LangModels/LangLatvianModel.cpp',
'LangModels/LangMalteseModel.cpp',
'LangModels/LangPolishModel.cpp',
'LangModels/LangPortugueseModel.cpp',
'LangModels/LangRomanianModel.cpp',
'LangModels/LangRussianModel.cpp',
'LangModels/LangSlovakModel.cpp',
'LangModels/LangSloveneModel.cpp',
'LangModels/LangSwedishModel.cpp',
'LangModels/LangSpanishModel.cpp',
'LangModels/LangThaiModel.cpp',
'LangModels/LangTurkishModel.cpp',
'LangModels/LangVietnameseModel.cpp',
'nsHebrewProber.cpp',
'nsCharSetProber.cpp',
'nsBig5Prober.cpp',
'nsEUCJPProber.cpp',
'nsEUCKRProber.cpp',
'nsEUCTWProber.cpp',
'nsEscCharsetProber.cpp',
'nsEscSM.cpp',
'nsGB2312Prober.cpp',
'nsMBCSGroupProber.cpp',
'nsMBCSSM.cpp',
'nsSBCSGroupProber.cpp',
'nsSBCharSetProber.cpp',
'nsSJISProber.cpp',
'nsUTF8Prober.cpp',
'nsLatin1Prober.cpp',
'nsUniversalDetector.cpp',
'uchardet.cpp',
])
uchardet = library('uchardet', uchardet_sources)

View File

@ -0,0 +1,9 @@
[wrap-file]
directory = uchardet-0.0.7
source_url = https://www.freedesktop.org/software/uchardet/releases/uchardet-0.0.7.tar.xz
source_filename = uchardet-0.0.7.tar.gz
source_hash = 3fc79408ae1d84b406922fa9319ce005631c95ca0f34b205fad867e8b30e45b1
patch_directory = uchardet
[provides]
uchardet = uchardet_dep