@@ -29,112 +29,108 @@ if host_machine.system() == 'windows'
2929 )
3030endif
3131
32- # --- libxml2 (static, built from source) ---
33- cc = meson .get_compiler(' c' )
34-
35- xml2_version_config = configuration_data ()
36- xml2_version_config.set(' VERSION' , ' 2.16.0' )
37- xml2_version_config.set(' LIBXML_VERSION_NUMBER' , ' 21600' )
38- xml2_version_config.set(' LIBXML_VERSION_EXTRA' , '' )
39- xml2_version_config.set(' WITH_THREADS' , 1 )
40- xml2_version_config.set(' WITH_THREAD_ALLOC' , 0 )
41- xml2_version_config.set(' WITH_OUTPUT' , 1 )
42- xml2_version_config.set(' WITH_PUSH' , 1 )
43- xml2_version_config.set(' WITH_READER' , 1 )
44- xml2_version_config.set(' WITH_PATTERN' , 0 )
45- xml2_version_config.set(' WITH_WRITER' , 1 )
46- xml2_version_config.set(' WITH_SAX1' , 0 )
47- xml2_version_config.set(' WITH_HTTP' , 0 )
48- xml2_version_config.set(' WITH_VALID' , 1 )
49- xml2_version_config.set(' WITH_HTML' , 0 )
50- xml2_version_config.set(' WITH_C14N' , 0 )
51- xml2_version_config.set(' WITH_CATALOG' , 0 )
52- xml2_version_config.set(' WITH_WINPATH' , host_machine .system() == ' windows' ? 1 : 0 )
53- xml2_version_config.set(' WITH_XPATH' , 0 )
54- xml2_version_config.set(' WITH_XPTR' , 0 )
55- xml2_version_config.set(' WITH_XINCLUDE' , 0 )
56- xml2_version_config.set(' WITH_ICONV' , 1 )
57- xml2_version_config.set(' WITH_ICU' , 0 )
58- xml2_version_config.set(' WITH_ISO8859X' , 1 )
59- xml2_version_config.set(' WITH_DEBUG' , 0 )
60- xml2_version_config.set(' WITH_REGEXPS' , 0 )
61- xml2_version_config.set(' WITH_RELAXNG' , 0 )
62- xml2_version_config.set(' WITH_SCHEMAS' , 0 )
63- xml2_version_config.set(' WITH_SCHEMATRON' , 0 )
64- xml2_version_config.set(' WITH_MODULES' , 0 )
65- xml2_version_config.set(' WITH_ZLIB' , 1 )
66- xml2_version_config.set(' MODULE_EXTENSION' , '' )
67-
68- xml2_version_h = configure_file (
69- input : ' libxml2/include/libxml/xmlversion.h.in' ,
70- output : ' xmlversion-gen.h' ,
71- configuration : xml2_version_config,
72- )
73-
74- xml2_config = configuration_data ()
75- xml2_config.set(' HAVE_STDINT_H' , 1 )
76- xml2_config.set(' HAVE_DECL_GETENTROPY' , cc.has_function(' getentropy' , prefix : ' #include <sys/random.h>' ) ? 1 : 0 )
77- xml2_config.set(' HAVE_DECL_GLOB' , cc.has_function(' glob' , prefix : ' #include <glob.h>' ) ? 1 : 0 )
78- xml2_config.set(' HAVE_DECL_MMAP' , cc.has_function(' mmap' , prefix : ' #include <sys/mman.h>' ) ? 1 : 0 )
79- xml2_config.set(' HAVE_FUNC_ATTRIBUTE_DESTRUCTOR' , cc.compiles(' void __attribute__((destructor)) f(void) {} int main(void) { return 0; }' ) ? 1 : false )
80- xml2_config.set(' HAVE_DLOPEN' , cc.has_function(' dlopen' ) ? 1 : false )
81- xml2_config.set(' XML_THREAD_LOCAL' , ' _Thread_local' )
82-
83- xml2_config_h = configure_file (
84- output : ' xml2-config.h' ,
85- configuration : xml2_config,
86- )
87-
88- libxml2_sources = files (
89- ' libxml2/buf.c' ,
90- ' libxml2/chvalid.c' ,
91- ' libxml2/dict.c' ,
92- ' libxml2/encoding.c' ,
93- ' libxml2/entities.c' ,
94- ' libxml2/error.c' ,
95- ' libxml2/globals.c' ,
96- ' libxml2/hash.c' ,
97- ' libxml2/list.c' ,
98- ' libxml2/parser.c' ,
99- ' libxml2/parserInternals.c' ,
100- ' libxml2/SAX2.c' ,
101- ' libxml2/threads.c' ,
102- ' libxml2/tree.c' ,
103- ' libxml2/uri.c' ,
104- ' libxml2/valid.c' ,
105- ' libxml2/xmlIO.c' ,
106- ' libxml2/xmlmemory.c' ,
107- ' libxml2/xmlstring.c' ,
108- ' libxml2/xmlsave.c' ,
109- ' libxml2/xmlreader.c' ,
110- ' libxml2/xmlwriter.c' ,
111- )
112-
113- libxml2_deps = [zlib]
32+ # --- libxml2 ---
33+ if host_machine .system() == ' darwin'
34+ # Build from source on macOS — Homebrew doesn't provide a static libxml2.a
35+ cc = meson .get_compiler(' c' )
36+
37+ xml2_version_config = configuration_data ()
38+ xml2_version_config.set(' VERSION' , ' 2.16.0' )
39+ xml2_version_config.set(' LIBXML_VERSION_NUMBER' , ' 21600' )
40+ xml2_version_config.set(' LIBXML_VERSION_EXTRA' , '' )
41+ xml2_version_config.set(' WITH_THREADS' , 1 )
42+ xml2_version_config.set(' WITH_THREAD_ALLOC' , 0 )
43+ xml2_version_config.set(' WITH_OUTPUT' , 1 )
44+ xml2_version_config.set(' WITH_PUSH' , 1 )
45+ xml2_version_config.set(' WITH_READER' , 1 )
46+ xml2_version_config.set(' WITH_PATTERN' , 0 )
47+ xml2_version_config.set(' WITH_WRITER' , 1 )
48+ xml2_version_config.set(' WITH_SAX1' , 0 )
49+ xml2_version_config.set(' WITH_HTTP' , 0 )
50+ xml2_version_config.set(' WITH_VALID' , 1 )
51+ xml2_version_config.set(' WITH_HTML' , 0 )
52+ xml2_version_config.set(' WITH_C14N' , 0 )
53+ xml2_version_config.set(' WITH_CATALOG' , 0 )
54+ xml2_version_config.set(' WITH_WINPATH' , 0 )
55+ xml2_version_config.set(' WITH_XPATH' , 0 )
56+ xml2_version_config.set(' WITH_XPTR' , 0 )
57+ xml2_version_config.set(' WITH_XINCLUDE' , 0 )
58+ xml2_version_config.set(' WITH_ICONV' , 1 )
59+ xml2_version_config.set(' WITH_ICU' , 0 )
60+ xml2_version_config.set(' WITH_ISO8859X' , 1 )
61+ xml2_version_config.set(' WITH_DEBUG' , 0 )
62+ xml2_version_config.set(' WITH_REGEXPS' , 0 )
63+ xml2_version_config.set(' WITH_RELAXNG' , 0 )
64+ xml2_version_config.set(' WITH_SCHEMAS' , 0 )
65+ xml2_version_config.set(' WITH_SCHEMATRON' , 0 )
66+ xml2_version_config.set(' WITH_MODULES' , 0 )
67+ xml2_version_config.set(' WITH_ZLIB' , 1 )
68+ xml2_version_config.set(' MODULE_EXTENSION' , '' )
69+
70+ xml2_version_h = configure_file (
71+ input : ' libxml2/include/libxml/xmlversion.h.in' ,
72+ output : ' xmlversion.h' ,
73+ configuration : xml2_version_config,
74+ )
11475
115- xml2_all_inc_dirs = include_directories (
116- ' .' ,
117- ' libxml2' ,
118- ' libxml2/include' ,
119- )
76+ run_command (' mkdir' , ' -p' , meson .project_build_root() / ' libxml' , check : true )
77+ run_command (' cp' , meson .project_build_root() / ' xmlversion.h' ,
78+ meson .project_build_root() / ' libxml' / ' xmlversion.h' , check : true )
79+
80+ xml2_config = configuration_data ()
81+ xml2_config.set(' HAVE_STDINT_H' , 1 )
82+ xml2_config.set(' HAVE_DECL_GETENTROPY' , cc.has_function(' getentropy' , prefix : ' #include <sys/random.h>' ) ? 1 : 0 )
83+ xml2_config.set(' HAVE_DECL_GLOB' , cc.has_function(' glob' , prefix : ' #include <glob.h>' ) ? 1 : 0 )
84+ xml2_config.set(' HAVE_DECL_MMAP' , cc.has_function(' mmap' , prefix : ' #include <sys/mman.h>' ) ? 1 : 0 )
85+ xml2_config.set(' HAVE_FUNC_ATTRIBUTE_DESTRUCTOR' , cc.compiles(' void __attribute__((destructor)) f(void) {} int main(void) { return 0; }' ) ? 1 : false )
86+ xml2_config.set(' HAVE_DLOPEN' , cc.has_function(' dlopen' ) ? 1 : false )
87+ xml2_config.set(' XML_THREAD_LOCAL' , ' _Thread_local' )
88+
89+ xml2_config_h = configure_file (
90+ output : ' xml2-config.h' ,
91+ configuration : xml2_config,
92+ )
12093
121- libxml2 = static_library (' xml2' ,
122- libxml2_sources,
123- xml2_config_h,
124- xml2_version_h,
125- include_directories : xml2_all_inc_dirs,
126- dependencies : libxml2_deps,
127- c_args : [
128- ' -include' , meson .project_build_root() / ' xml2-config.h' ,
129- ],
130- )
94+ libxml2 = static_library (' xml2' ,
95+ ' libxml2/buf.c' ,
96+ ' libxml2/chvalid.c' ,
97+ ' libxml2/dict.c' ,
98+ ' libxml2/encoding.c' ,
99+ ' libxml2/entities.c' ,
100+ ' libxml2/error.c' ,
101+ ' libxml2/globals.c' ,
102+ ' libxml2/hash.c' ,
103+ ' libxml2/list.c' ,
104+ ' libxml2/parser.c' ,
105+ ' libxml2/parserInternals.c' ,
106+ ' libxml2/SAX2.c' ,
107+ ' libxml2/threads.c' ,
108+ ' libxml2/tree.c' ,
109+ ' libxml2/uri.c' ,
110+ ' libxml2/valid.c' ,
111+ ' libxml2/xmlIO.c' ,
112+ ' libxml2/xmlmemory.c' ,
113+ ' libxml2/xmlstring.c' ,
114+ ' libxml2/xmlsave.c' ,
115+ ' libxml2/xmlreader.c' ,
116+ ' libxml2/xmlwriter.c' ,
117+ xml2_config_h,
118+ xml2_version_h,
119+ include_directories : include_directories (' libxml2' , ' libxml2/include' ),
120+ dependencies : [zlib],
121+ c_args : [' -include' , meson .project_build_root() / ' xml2-config.h' ,
122+ ' -I' + meson .project_build_root()],
123+ )
131124
132- libxml = declare_dependency (
133- link_with : libxml2,
134- include_directories : xml2_all_inc_dirs,
135- dependencies : libxml2_deps,
136- sources : xml2_version_h,
137- )
125+ libxml = declare_dependency (
126+ link_with : libxml2,
127+ include_directories : include_directories (' libxml2' , ' libxml2/include' ),
128+ dependencies : [zlib],
129+ compile_args : [' -I' + meson .project_build_root()],
130+ )
131+ else
132+ libxml = dependency (' libxml-2.0' , version : ' >= 2.7' , static : true )
133+ endif
138134
139135bison = find_program (' bison' )
140136
0 commit comments