@@ -11,23 +11,22 @@ pub fn build(b: *std.Build) void {
1111 const strip = b .option (bool , "strip" , "Omit debug information" );
1212 const pic = b .option (bool , "pie" , "Produce Position Independent Code" );
1313
14- // if (version.major != 1) {
15- // // The versioning used for the shared libraries assumes that the major
16- // // version of xkbcommon as a whole will increase to 2 if and only if there
17- // // is an ABI break, at which point we should probably bump the SONAME of
18- // // all libraries to .so.2.
19- // @compileError("We probably need to bump the SONAME of libxkbcommon");
20- // }
21- // // To avoid an unnecessary SONAME bump, xkbcommon 1.x.y produces
22- // // libxkbcommon.so.0.x.y, libxkbcommon-x11.so.0.x.y, libxkbregistry.so.0.x.y.
23- // const soname_version: std.SemanticVersion = .{
24- // .major = 0,
25- // .minor = version.minor,
26- // .patch = version.patch,
27- // .pre = version.pre,
28- // .build = version.build,
29- // };
30- const soname_version : std.SemanticVersion = .{ .major = 0 , .minor = 0 , .patch = 0 };
14+ if (version .major != 1 ) {
15+ // The versioning used for the shared libraries assumes that the major
16+ // version of xkbcommon as a whole will increase to 2 if and only if there
17+ // is an ABI break, at which point we should probably bump the SONAME of
18+ // all libraries to .so.2.
19+ @compileError ("We probably need to bump the SONAME of libxkbcommon" );
20+ }
21+ // To avoid an unnecessary SONAME bump, xkbcommon 1.x.y produces
22+ // libxkbcommon.so.0.x.y, libxkbcommon-x11.so.0.x.y, libxkbregistry.so.0.x.y.
23+ const soname_version : std.SemanticVersion = .{
24+ .major = 0 ,
25+ .minor = version .minor ,
26+ .patch = version .patch ,
27+ .pre = version .pre ,
28+ .build = version .build ,
29+ };
3130
3231 // Most of these config options have not been tested.
3332
@@ -59,20 +58,20 @@ pub fn build(b: *std.Build) void {
5958 .DEFAULT_XKB_RULES = default_rules ,
6059 .DEFAULT_XKB_MODEL = default_model ,
6160 .DEFAULT_XKB_LAYOUT = default_layout ,
62- // .DEFAULT_XKB_VARIANT
63- // .DEFAULT_XKB_OPTIONS
61+ .DEFAULT_XKB_VARIANT = .null ,
62+ .DEFAULT_XKB_OPTIONS = .null ,
6463 .HAVE_UNISTD_H = 1 ,
6564 .HAVE___BUILTIN_EXPECT = 1 ,
66- .HAVE_EACCESS = 1 ,
67- .HAVE_EUIDACCESS = 1 ,
68- .HAVE_MMAP = 1 ,
69- .HAVE_MKOSTEMP = 1 ,
70- .HAVE_POSIX_FALLOCATE = 1 ,
71- .HAVE_STRNDUP = 1 ,
65+ .HAVE_EACCESS = if ( target . result . os . tag == .linux ) @as ( i64 , 1 ) else null ,
66+ .HAVE_EUIDACCESS = if ( target . result . os . tag == .linux ) @as ( i64 , 1 ) else null ,
67+ .HAVE_MMAP = if ( target . result . os . tag != .windows ) @as ( i64 , 1 ) else null ,
68+ .HAVE_MKOSTEMP = if ( target . result . os . tag != .windows ) @as ( i64 , 1 ) else null ,
69+ .HAVE_POSIX_FALLOCATE = if ( target . result . os . tag != .windows ) @as ( i64 , 1 ) else null ,
70+ .HAVE_STRNDUP = if ( target . result . os . tag != .windows ) @as ( i64 , 1 ) else null ,
7271 .HAVE_ASPRINTF = 1 ,
73- // .HAVE_VASPRINTF = 1 ,
74- .HAVE_SECURE_GETENV = 1 ,
75- // .HAVE___SECURE_GETENV = 1 ,
72+ .HAVE_VASPRINTF = null ,
73+ .HAVE_OPEN_MEMSTREAM = if ( target . result . os . tag != .windows ) @as ( i64 , 1 ) else null ,
74+ . HAVE_SECURE_GETENV = if ( target . result . os . tag != .windows ) @as ( i64 , 1 ) else null ,
7675 .PATH_MAX = @as (i64 , if (target .result .os .tag == .windows ) 260 else 4096 ),
7776 });
7877 if (default_variant ) | variant | {
@@ -120,14 +119,14 @@ pub fn build(b: *std.Build) void {
120119 .link_libc = true ,
121120 .strip = strip ,
122121 .pic = pic ,
122+ .sanitize_c = if (@hasDecl (std .zig , "SanitizeC" )) .off else false ,
123123 }),
124124 });
125125 xkbcommon .root_module .addCSourceFiles (.{
126126 .files = libxkbcommon_sources ,
127127 .root = upstream .path ("" ),
128128 .flags = cflags ,
129129 });
130- xkbcommon .root_module .sanitize_c = false ;
131130 xkbcommon .root_module .addConfigHeader (config_header );
132131 xkbcommon .root_module .addCSourceFile (.{ .file = parser_c });
133132 xkbcommon .root_module .addIncludePath (parser_h .dirname ());
@@ -136,6 +135,7 @@ pub fn build(b: *std.Build) void {
136135 xkbcommon .installHeader (upstream .path ("include/xkbcommon/xkbcommon-compose.h" ), "xkbcommon/xkbcommon-compose.h" );
137136 xkbcommon .installHeader (upstream .path ("include/xkbcommon/xkbcommon-keysyms.h" ), "xkbcommon/xkbcommon-keysyms.h" );
138137 xkbcommon .installHeader (upstream .path ("include/xkbcommon/xkbcommon-names.h" ), "xkbcommon/xkbcommon-names.h" );
138+ xkbcommon .root_module .addIncludePath (upstream .path ("." ));
139139 xkbcommon .root_module .addIncludePath (upstream .path ("src" ));
140140 xkbcommon .root_module .addIncludePath (upstream .path ("include" ));
141141 xkbcommon .version_script = upstream .path ("xkbcommon.map" );
@@ -197,6 +197,8 @@ pub fn build(b: *std.Build) void {
197197 const link_system_libxml = b .systemIntegrationOption ("libxml2" , .{});
198198 if (link_system_libxml ) {
199199 libxkbregistry .root_module .linkSystemLibrary ("libxml-2.0" , .{});
200+ libxkbregistry .root_module .addCMacro ("HAVE_XML_CTXT_SET_ERRORHANDLER" , "0" ); // TODO Since libxml-2.13
201+ libxkbregistry .root_module .addCMacro ("HAVE_XML_CTXT_PARSE_DTD" , "0" ); // TODO Since libxml-2.14
200202 } else if (b .lazyDependency ("libxml2" , .{
201203 .target = target ,
202204 .optimize = optimize ,
@@ -205,6 +207,8 @@ pub fn build(b: *std.Build) void {
205207 .sax1 = true ,
206208 })) | libxml2 | {
207209 libxkbregistry .root_module .linkLibrary (libxml2 .artifact ("xml" ));
210+ libxkbregistry .root_module .addCMacro ("HAVE_XML_CTXT_SET_ERRORHANDLER" , "1" );
211+ libxkbregistry .root_module .addCMacro ("HAVE_XML_CTXT_PARSE_DTD" , "1" );
208212 }
209213 }
210214}
@@ -252,6 +256,7 @@ fn generateParser(
252256}
253257
254258const cflags : []const []const u8 = &.{
259+ "-std=c11" ,
255260 "-fno-strict-aliasing" ,
256261 "-Wno-unused-parameter" ,
257262 "-Wno-missing-field-initializers" ,
@@ -263,10 +268,11 @@ const cflags: []const []const u8 = &.{
263268 "-Wnested-externs" ,
264269 "-Wbad-function-cast" ,
265270 "-Wshadow" ,
266- // "-Wlogical-op",
271+ "-Wlogical-op" ,
267272 "-Wdate-time" ,
268273 "-Wwrite-strings" ,
269274 "-Wno-documentation-deprecated-sync" ,
275+ "-Wno-pedantic" ,
270276};
271277
272278const libxkbcommon_sources : []const []const u8 = &.{
@@ -293,13 +299,17 @@ const libxkbcommon_sources: []const []const u8 = &.{
293299 "src/context.c" ,
294300 "src/context-priv.c" ,
295301 "src/keysym.c" ,
302+ "src/keysym-case-mappings.c" ,
296303 "src/keysym-utf.c" ,
297304 "src/keymap.c" ,
298305 "src/keymap-priv.c" ,
306+ "src/scanner-utils.c" ,
299307 "src/state.c" ,
300308 "src/text.c" ,
301309 "src/utf8.c" ,
310+ "src/utf8-decoding.c" ,
302311 "src/utils.c" ,
312+ "src/utils-paths.c" ,
303313};
304314
305315const libxkbcommon_x11_sources : []const []const u8 = &.{
0 commit comments