@@ -7,6 +7,10 @@ pub fn build(b: *std.Build) void {
7
7
const target = b .standardTargetOptions (.{});
8
8
const optimize = b .standardOptimizeOption (.{});
9
9
10
+ const linkage = b .option (std .builtin .LinkMode , "linkage" , "Link mode" ) orelse .static ;
11
+ const strip = b .option (bool , "strip" , "Omit debug information" );
12
+ const pic = b .option (bool , "pie" , "Produce Position Independent Code" );
13
+
10
14
// Most of these config options have not been tested.
11
15
12
16
const minimum = b .option (bool , "minimum" , "build a minimally sized library (default=false)" ) orelse false ;
@@ -203,55 +207,60 @@ pub fn build(b: *std.Build) void {
203
207
config_header .addValues (.{ .XML_THREAD_LOCAL = ._Thread_local });
204
208
}
205
209
206
- const xml_lib = b .addStaticLibrary (.{
210
+ const xml_lib = b .addLibrary (.{
211
+ .linkage = linkage ,
207
212
.name = "xml" ,
208
- .target = target ,
209
- .optimize = optimize ,
210
213
.version = version ,
211
- .link_libc = true ,
214
+ .root_module = b .createModule (.{
215
+ .target = target ,
216
+ .optimize = optimize ,
217
+ .link_libc = true ,
218
+ .strip = strip ,
219
+ .pic = pic ,
220
+ }),
212
221
});
213
222
b .installArtifact ((xml_lib ));
214
- xml_lib .addConfigHeader (config_header );
215
- xml_lib .addConfigHeader (xml_version_header );
223
+ xml_lib .root_module . addConfigHeader (config_header );
224
+ xml_lib .root_module . addConfigHeader (xml_version_header );
216
225
xml_lib .installHeader (xml_version_header .getOutput (), "libxml/xmlversion.h" );
217
- xml_lib .addIncludePath (upstream .path ("include" ));
218
- xml_lib .addCSourceFiles (.{ .files = xml_src , .root = upstream .path ("" ), .flags = xml_flags });
226
+ xml_lib .root_module . addIncludePath (upstream .path ("include" ));
227
+ xml_lib .root_module . addCSourceFiles (.{ .files = xml_src , .root = upstream .path ("" ), .flags = xml_flags });
219
228
xml_lib .installHeadersDirectory (upstream .path ("include/libxml" ), "libxml" , .{});
220
229
if (target .result .os .tag != .windows ) xml_lib .root_module .addCMacro ("HAVE_PTHREAD_H" , "1" );
221
230
if (target .result .os .tag == .windows ) xml_lib .root_module .addCMacro ("LIBXML_STATIC" , "1" );
222
- if (c14n ) xml_lib .addCSourceFile (.{ .file = upstream .path ("c14n.c" ), .flags = xml_flags });
223
- if (catalog ) xml_lib .addCSourceFile (.{ .file = upstream .path ("catalog.c" ), .flags = xml_flags });
224
- if (debug ) xml_lib .addCSourceFile (.{ .file = upstream .path ("debugXML.c" ), .flags = xml_flags });
225
- if (ftp ) xml_lib .addCSourceFile (.{ .file = upstream .path ("nanoftp.c" ), .flags = xml_flags });
226
- if (html ) xml_lib .addCSourceFiles (.{ .files = &.{ "HTMLparser.c" , "HTMLtree.c" }, .root = upstream .path ("" ), .flags = xml_flags });
227
- if (http ) xml_lib .addCSourceFile (.{ .file = upstream .path ("nanohttp.c" ), .flags = xml_flags });
228
- if (legacy ) xml_lib .addCSourceFile (.{ .file = upstream .path ("legacy.c" ), .flags = xml_flags });
229
- if (lzma ) xml_lib .addCSourceFile (.{ .file = upstream .path ("xzlib.c" ), .flags = xml_flags });
230
- // if (modules) xml_lib.addCSourceFile(.{ .file = upstream.path("xmlmodule.c"), .flags = xml_flags });
231
- if (output ) xml_lib .addCSourceFile (.{ .file = upstream .path ("xmlsave.c" ), .flags = xml_flags });
232
- if (pattern ) xml_lib .addCSourceFile (.{ .file = upstream .path ("pattern.c" ), .flags = xml_flags });
233
- if (reader ) xml_lib .addCSourceFile (.{ .file = upstream .path ("xmlreader.c" ), .flags = xml_flags });
234
- if (regexps ) xml_lib .addCSourceFiles (.{ .files = &.{ "xmlregexp.c" , "xmlunicode.c" }, .root = upstream .path ("" ), .flags = xml_flags });
235
- if (schemas ) xml_lib .addCSourceFiles (.{ .files = &.{ "relaxng.c" , "xmlschemas.c" , "xmlschemastypes.c" }, .root = upstream .path ("" ), .flags = xml_flags });
236
- if (schematron ) xml_lib .addCSourceFile (.{ .file = upstream .path ("schematron.c" ), .flags = xml_flags });
237
- if (writer ) xml_lib .addCSourceFile (.{ .file = upstream .path ("xmlwriter.c" ), .flags = xml_flags });
238
- if (xinclude ) xml_lib .addCSourceFile (.{ .file = upstream .path ("xinclude.c" ), .flags = xml_flags });
239
- if (xpath ) xml_lib .addCSourceFile (.{ .file = upstream .path ("xpath.c" ), .flags = xml_flags });
240
- if (xptr ) xml_lib .addCSourceFiles (.{ .files = &.{ "xlink.c" , "xpointer.c" }, .root = upstream .path ("" ), .flags = xml_flags });
231
+ if (c14n ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("c14n.c" ), .flags = xml_flags });
232
+ if (catalog ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("catalog.c" ), .flags = xml_flags });
233
+ if (debug ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("debugXML.c" ), .flags = xml_flags });
234
+ if (ftp ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("nanoftp.c" ), .flags = xml_flags });
235
+ if (html ) xml_lib .root_module . addCSourceFiles (.{ .files = &.{ "HTMLparser.c" , "HTMLtree.c" }, .root = upstream .path ("" ), .flags = xml_flags });
236
+ if (http ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("nanohttp.c" ), .flags = xml_flags });
237
+ if (legacy ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("legacy.c" ), .flags = xml_flags });
238
+ if (lzma ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("xzlib.c" ), .flags = xml_flags });
239
+ // if (modules) xml_lib.root_module. addCSourceFile(.{ .file = upstream.path("xmlmodule.c"), .flags = xml_flags });
240
+ if (output ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("xmlsave.c" ), .flags = xml_flags });
241
+ if (pattern ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("pattern.c" ), .flags = xml_flags });
242
+ if (reader ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("xmlreader.c" ), .flags = xml_flags });
243
+ if (regexps ) xml_lib .root_module . addCSourceFiles (.{ .files = &.{ "xmlregexp.c" , "xmlunicode.c" }, .root = upstream .path ("" ), .flags = xml_flags });
244
+ if (schemas ) xml_lib .root_module . addCSourceFiles (.{ .files = &.{ "relaxng.c" , "xmlschemas.c" , "xmlschemastypes.c" }, .root = upstream .path ("" ), .flags = xml_flags });
245
+ if (schematron ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("schematron.c" ), .flags = xml_flags });
246
+ if (writer ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("xmlwriter.c" ), .flags = xml_flags });
247
+ if (xinclude ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("xinclude.c" ), .flags = xml_flags });
248
+ if (xpath ) xml_lib .root_module . addCSourceFile (.{ .file = upstream .path ("xpath.c" ), .flags = xml_flags });
249
+ if (xptr ) xml_lib .root_module . addCSourceFiles (.{ .files = &.{ "xlink.c" , "xpointer.c" }, .root = upstream .path ("" ), .flags = xml_flags });
241
250
if (readline ) {
242
- xml_lib .linkSystemLibrary ("readline" );
251
+ xml_lib .root_module . linkSystemLibrary ("readline" , .{} );
243
252
xml_lib .root_module .addCMacro ("HAVE_LIBREADLINE" , "1" );
244
253
}
245
254
if (history ) {
246
- xml_lib .linkSystemLibrary ("history" );
255
+ xml_lib .root_module . linkSystemLibrary ("history" , .{} );
247
256
xml_lib .root_module .addCMacro ("HAVE_LIBHISTORY" , "1" );
248
257
}
249
- if (zlib ) xml_lib .linkSystemLibrary ("zlib" );
250
- if (lzma ) xml_lib .linkSystemLibrary ("lzma" );
251
- if (icu ) xml_lib .linkSystemLibrary ("icu-i18n" );
252
- if (iconv ) xml_lib .linkSystemLibrary ("iconv" );
253
- if (target .result .os .tag == .windows ) xml_lib .linkSystemLibrary ("bcrypt" );
254
- if (http and target .result .os .tag == .windows ) xml_lib .linkSystemLibrary ("ws2_32" );
258
+ if (zlib ) xml_lib .root_module . linkSystemLibrary ("zlib" , .{} );
259
+ if (lzma ) xml_lib .root_module . linkSystemLibrary ("lzma" , .{} );
260
+ if (icu ) xml_lib .root_module . linkSystemLibrary ("icu-i18n" , .{} );
261
+ if (iconv ) xml_lib .root_module . linkSystemLibrary ("iconv" , .{} );
262
+ if (target .result .os .tag == .windows ) xml_lib .root_module . linkSystemLibrary ("bcrypt" , .{} );
263
+ if (http and target .result .os .tag == .windows ) xml_lib .root_module . linkSystemLibrary ("ws2_32" , .{} );
255
264
}
256
265
257
266
pub const xml_src : []const []const u8 = &.{
0 commit comments