Skip to content

Commit

Permalink
meson: add uchardet port
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Myaamori authored and CoffeeFlux committed May 22, 2021
1 parent c43e4fb commit 84ac716
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libaegisub/common/charset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "libaegisub/scoped_ptr.h"

#ifdef WITH_UCHARDET
#include <uchardet/uchardet.h>
#include <uchardet.h>
#endif

namespace agi { namespace charset {
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions subprojects/packagefiles/uchardet/meson.build
Original file line number Diff line number Diff line change
@@ -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)
54 changes: 54 additions & 0 deletions subprojects/packagefiles/uchardet/src/meson.build
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions subprojects/uchardet.wrap
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 84ac716

Please sign in to comment.