From 84ac7169728ea6c1f92547563057f28b895ef230 Mon Sep 17 00:00:00 2001 From: Myaamori Date: Wed, 7 Apr 2021 12:32:33 +0100 Subject: [PATCH] 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. --- libaegisub/common/charset.cpp | 2 +- meson.build | 2 +- subprojects/packagefiles/uchardet/meson.build | 16 ++++++ .../packagefiles/uchardet/src/meson.build | 54 +++++++++++++++++++ subprojects/uchardet.wrap | 9 ++++ 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 subprojects/packagefiles/uchardet/meson.build create mode 100644 subprojects/packagefiles/uchardet/src/meson.build create mode 100644 subprojects/uchardet.wrap diff --git a/libaegisub/common/charset.cpp b/libaegisub/common/charset.cpp index 81008538b..fa25eea83 100644 --- a/libaegisub/common/charset.cpp +++ b/libaegisub/common/charset.cpp @@ -22,7 +22,7 @@ #include "libaegisub/scoped_ptr.h" #ifdef WITH_UCHARDET -#include +#include #endif namespace agi { namespace charset { diff --git a/meson.build b/meson.build index 54675d5c0..a8480e927 100644 --- a/meson.build +++ b/meson.build @@ -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; diff --git a/subprojects/packagefiles/uchardet/meson.build b/subprojects/packagefiles/uchardet/meson.build new file mode 100644 index 000000000..85732e17f --- /dev/null +++ b/subprojects/packagefiles/uchardet/meson.build @@ -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) diff --git a/subprojects/packagefiles/uchardet/src/meson.build b/subprojects/packagefiles/uchardet/src/meson.build new file mode 100644 index 000000000..cf5dd2a38 --- /dev/null +++ b/subprojects/packagefiles/uchardet/src/meson.build @@ -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) diff --git a/subprojects/uchardet.wrap b/subprojects/uchardet.wrap new file mode 100644 index 000000000..052c757c3 --- /dev/null +++ b/subprojects/uchardet.wrap @@ -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