Add asprintf_safe helper function
[platform/upstream/libxkbcommon.git] / meson.build
index 6f48c65..30ba76b 100644 (file)
@@ -77,9 +77,13 @@ configh_data.set_quoted('DEFAULT_XKB_MODEL', get_option('default-model'))
 configh_data.set_quoted('DEFAULT_XKB_LAYOUT', get_option('default-layout'))
 if get_option('default-variant') != ''
     configh_data.set_quoted('DEFAULT_XKB_VARIANT', get_option('default-variant'))
+else
+    configh_data.set('DEFAULT_XKB_VARIANT', 'NULL')
 endif
 if get_option('default-options') != ''
     configh_data.set_quoted('DEFAULT_XKB_OPTIONS', get_option('default-options'))
+else
+    configh_data.set('DEFAULT_XKB_OPTIONS', 'NULL')
 endif
 if cc.links('int main(){if(__builtin_expect(1<0,0)){}}', name: '__builtin_expect')
     configh_data.set('HAVE___BUILTIN_EXPECT', 1)
@@ -262,16 +266,6 @@ You can disable X11 support with -Denable-x11=false.''')
         'src/atom.h',
         'src/atom.c',
     ]
-    libxkbcommon_x11_internal = static_library(
-        'xkbcommon-x11-internal',
-        libxkbcommon_x11_sources,
-        include_directories: include_directories('src'),
-        link_with: libxkbcommon,
-        dependencies: [
-            xcb_dep,
-            xcb_xkb_dep,
-        ],
-    )
     libxkbcommon_x11_link_args = []
     if have_version_script
         libxkbcommon_x11_link_args += '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbcommon-x11.map')
@@ -306,6 +300,53 @@ You can disable X11 support with -Denable-x11=false.''')
     )
 endif
 
+# libxkbregistry
+if get_option('enable-xkbregistry')
+    dep_libxml = dependency('libxml-2.0')
+    deps_libxkbregistry = [dep_libxml]
+    libxkbregistry_sources = [
+        'src/registry.c',
+        'src/utils.h',
+        'src/utils.c',
+        'src/util-list.h',
+        'src/util-list.c',
+    ]
+    libxkbregistry_link_args = []
+    if have_version_script
+        libxkbregistry_link_args += '-Wl,--version-script=' + join_paths(meson.source_root(), 'xkbregistry.map')
+    endif
+    libxkbregistry = library(
+        'xkbregistry',
+        'xkbcommon/xkbregistry.h',
+        libxkbregistry_sources,
+        link_args: libxkbregistry_link_args,
+        link_depends: 'xkbregistry.map',
+        dependencies: deps_libxkbregistry,
+        version: '0.0.0',
+        install: true,
+        include_directories: include_directories('src'),
+    )
+    install_headers(
+        'xkbcommon/xkbregistry.h',
+        subdir: 'xkbcommon',
+    )
+    pkgconfig.generate(
+        name: 'xkbregistry',
+        filebase: 'xkbregistry',
+        libraries: libxkbregistry,
+        version: meson.project_version(),
+        description: 'XKB API to query available rules, models, layouts, variants and options',
+    )
+
+    dep_libxkbregistry = declare_dependency(
+                                include_directories: include_directories('xkbcommon'),
+                                link_with: libxkbregistry
+                                )
+    executable('xkbcommon-registry-list',
+               'tools/registry-list.c',
+               dependencies: dep_libxkbregistry,
+               install: false)
+endif
 
 # Tests
 test_env = environment()
@@ -333,6 +374,16 @@ test_dep = declare_dependency(
     link_with: libxkbcommon_test_internal,
 )
 if get_option('enable-x11')
+    libxkbcommon_x11_internal = static_library(
+        'xkbcommon-x11-internal',
+        libxkbcommon_x11_sources,
+        include_directories: include_directories('src'),
+        link_with: libxkbcommon_test_internal,
+        dependencies: [
+            xcb_dep,
+            xcb_xkb_dep,
+        ],
+    )
     x11_test_dep = declare_dependency(
         link_with: libxkbcommon_x11_internal,
         dependencies: [
@@ -421,6 +472,11 @@ test(
     env: test_env,
 )
 test(
+    'utils',
+    executable('test-utils', 'test/utils.c', dependencies: test_dep),
+    env: test_env,
+)
+test(
     'symbols-leak-test',
     find_program('test/symbols-leak-test.bash'),
     env: test_env,
@@ -435,7 +491,15 @@ if get_option('enable-x11')
     # See: https://github.com/xkbcommon/libxkbcommon/issues/30
     executable('test-x11comp', 'test/x11comp.c', dependencies: x11_test_dep)
 endif
-
+if get_option('enable-xkbregistry')
+    test(
+        'registry',
+        executable('test-registry', 'test/registry.c',
+                   include_directories: include_directories('src'),
+                   dependencies: dep_libxkbregistry),
+        env: test_env,
+    )
+endif
 
 # Fuzzing target programs.
 executable('fuzz-keymap', 'fuzz/keymap/target.c', dependencies: test_dep)
@@ -443,16 +507,35 @@ executable('fuzz-compose', 'fuzz/compose/target.c', dependencies: test_dep)
 
 
 # Demo programs.
+libxkbcommon_tools_internal = static_library(
+    'tools-internal',
+    'tools/tools-common.h',
+    'tools/tools-common.c',
+    libxkbcommon_sources,
+    include_directories: include_directories('src'),
+)
+tools_dep = declare_dependency(
+    include_directories: [include_directories('src'), include_directories('tools')],
+    link_with: libxkbcommon_tools_internal,
+)
+
 if cc.has_header_symbol('getopt.h', 'getopt_long', prefix: '#define _GNU_SOURCE')
-    executable('rmlvo-to-kccgst', 'test/rmlvo-to-kccgst.c', dependencies: test_dep)
-    executable('rmlvo-to-keymap', 'test/rmlvo-to-keymap.c', dependencies: test_dep)
-    executable('print-compiled-keymap', 'test/print-compiled-keymap.c', dependencies: test_dep)
+    executable('xkbcommon-rmlvo-to-keymap', 'tools/rmlvo-to-keymap.c', dependencies: tools_dep)
+    executable('xkbcommon-how-to-type', 'tools/how-to-type.c', dependencies: tools_dep)
 endif
 if cc.has_header('linux/input.h')
-    executable('interactive-evdev', 'test/interactive-evdev.c', dependencies: test_dep)
+    executable('xkbcommon-interactive-evdev', 'tools/interactive-evdev.c', dependencies: tools_dep)
 endif
 if get_option('enable-x11')
-    executable('interactive-x11', 'test/interactive-x11.c', dependencies: x11_test_dep)
+    x11_tools_dep = declare_dependency(
+        link_with: libxkbcommon_x11_internal,
+        dependencies: [
+            tools_dep,
+            xcb_dep,
+            xcb_xkb_dep,
+        ],
+    )
+    executable('xkbcommon-interactive-x11', 'tools/interactive-x11.c', dependencies: x11_tools_dep)
 endif
 if get_option('enable-wayland')
     wayland_client_dep = dependency('wayland-client', version: '>=1.2.0', required: false)
@@ -480,7 +563,10 @@ You can disable the Wayland demo programs with -Denable-wayland=false.''')
         wayland_scanner_code_gen.process(xdg_shell_xml),
         wayland_scanner_client_header_gen.process(xdg_shell_xml),
     ]
-    executable('interactive-wayland', 'test/interactive-wayland.c', xdg_shell_sources, dependencies: [test_dep, wayland_client_dep])
+    executable('xkbcommon-interactive-wayland',
+               'tools/interactive-wayland.c',
+               xdg_shell_sources,
+               dependencies: [tools_dep, wayland_client_dep])
 endif
 
 # xkeyboard-config "verifier"
@@ -542,10 +628,13 @@ You can disable the documentation with -Denable-docs=false.''')
         'doc/doxygen-extra.css',
         'doc/quick-guide.md',
         'doc/compat.md',
+        'doc/user-configuration.md',
+        'doc/rules-format.md',
         'xkbcommon/xkbcommon.h',
         'xkbcommon/xkbcommon-names.h',
         'xkbcommon/xkbcommon-x11.h',
         'xkbcommon/xkbcommon-compose.h',
+        'xkbcommon/xkbregistry.h',
     ]
     doxygen_data = configuration_data()
     doxygen_data.set('PACKAGE_NAME', meson.project_name())