From 0bf88b9f5f6baaf911d3f9b9219d512c2a3a637f Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Fri, 16 Aug 2024 10:48:44 -0400 Subject: [PATCH 1/5] libxkbcommon --- .github/workflows/ci.yml | 1 + .gitmodules | 3 + libxkbcommon | 1 + patches/libxkbcommon.patch | 323 +++++++++++++++++++++++++++++++++++++ scripts/common.py | 22 +++ scripts/libxkbcommon.py | 12 ++ scripts/meson-cross.ini | 12 ++ 7 files changed, 374 insertions(+) create mode 160000 libxkbcommon create mode 100644 patches/libxkbcommon.patch create mode 100644 scripts/libxkbcommon.py create mode 100644 scripts/meson-cross.ini diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebba55b..5705e1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: python scripts/json-c.py python scripts/marisa.py python scripts/libthai.py + python scripts/libxkbcommon.py - name: Release if: ${{ github.ref == 'refs/heads/master' }} diff --git a/.gitmodules b/.gitmodules index 00df8ff..5f2a3c8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "libthai"] path = libthai url = https://github.com/tlwg/libthai +[submodule "libxkbcommon"] + path = libxkbcommon + url = https://github.com/xkbcommon/libxkbcommon diff --git a/libxkbcommon b/libxkbcommon new file mode 160000 index 0000000..7a31e35 --- /dev/null +++ b/libxkbcommon @@ -0,0 +1 @@ +Subproject commit 7a31e3585edf78be281559377e26d15f8c4bc655 diff --git a/patches/libxkbcommon.patch b/patches/libxkbcommon.patch new file mode 100644 index 0000000..90a74de --- /dev/null +++ b/patches/libxkbcommon.patch @@ -0,0 +1,323 @@ +diff --git a/meson.build b/meson.build +index 2de4ee9..1a42dcc 100644 +--- a/meson.build ++++ b/meson.build +@@ -94,12 +94,6 @@ endif + if cc.links('int main(){if(__builtin_expect(1<0,0)){}}', name: '__builtin_expect') + configh_data.set('HAVE___BUILTIN_EXPECT', 1) + endif +-if cc.has_header_symbol('unistd.h', 'eaccess', prefix: system_ext_define) +- configh_data.set('HAVE_EACCESS', 1) +-endif +-if cc.has_header_symbol('unistd.h', 'euidaccess', prefix: system_ext_define) +- configh_data.set('HAVE_EUIDACCESS', 1) +-endif + if cc.has_header_symbol('sys/mman.h', 'mmap') + configh_data.set('HAVE_MMAP', 1) + endif +@@ -600,281 +594,6 @@ configure_file(input: 'test/xkeyboard-config-test.py.in', + output: 'xkeyboard-config-test', + configuration: xkct_config) + +-# Tests +-test_env = environment() +-test_env.set('XKB_LOG_LEVEL', 'debug') +-test_env.set('XKB_LOG_VERBOSITY', '10') +-test_env.set('top_srcdir', meson.current_source_dir()) +-test_env.set('top_builddir', meson.current_build_dir()) +-test_env.set('HAVE_XKBCLI_INTERACTIVE_EVDEV', configh_data.get('HAVE_XKBCLI_INTERACTIVE_EVDEV', 0).to_string()) +-test_env.set('HAVE_XKBCLI_INTERACTIVE_WAYLAND', configh_data.get('HAVE_XKBCLI_INTERACTIVE_WAYLAND', 0).to_string()) +-test_env.set('HAVE_XKBCLI_INTERACTIVE_X11', configh_data.get('HAVE_XKBCLI_INTERACTIVE_X11', 0).to_string()) +-test_env.set('HAVE_XKBCLI_LIST', configh_data.get('HAVE_XKBCLI_LIST', 0).to_string()) +- +-test_configh_data = configuration_data() +-test_configh_data.set_quoted('TEST_XKB_CONFIG_ROOT', meson.current_source_dir()/'test'/'data') +-configure_file(output: 'test-config.h', configuration: test_configh_data) +- +-# Some tests need to use unexported symbols, so we link them against +-# an internal copy of libxkbcommon with all symbols exposed. +-libxkbcommon_test_internal = static_library( +- 'xkbcommon-test-internal', +- 'test/common.c', +- 'test/test.h', +- 'test/evdev-scancodes.h', +- 'bench/bench.c', +- 'bench/bench.h', +- libxkbcommon_sources, +- include_directories: include_directories('src', 'include'), +- c_args: ['-DENABLE_PRIVATE_APIS'], +-) +-test_dep = declare_dependency( +- include_directories: include_directories('src', 'include'), +- link_with: libxkbcommon_test_internal, +- dependencies: [tools_dep], +-) +-if get_option('enable-x11') +- libxkbcommon_x11_test_internal = static_library( +- 'xkbcommon-x11-internal', +- libxkbcommon_x11_sources, +- 'test/xvfb-wrapper.c', +- 'test/xvfb-wrapper.h', +- include_directories: include_directories('src', 'include'), +- link_with: libxkbcommon_test_internal, +- dependencies: [ +- xcb_dep, +- xcb_xkb_dep, +- ], +- ) +- x11_test_dep = declare_dependency( +- link_with: libxkbcommon_x11_test_internal, +- dependencies: [ +- test_dep, +- xcb_dep, +- xcb_xkb_dep, +- ], +- ) +-endif +-# TODO: version range? +-keysyms_test_dep = [test_dep] +-keysyms_test_c_args = ['-DENABLE_PRIVATE_APIS'] +-icu_dep = dependency('icu-uc', required: false) +-if icu_dep.found() +- keysyms_test_dep += [icu_dep] +- configh_data.set10('HAVE_ICU', true) +-endif +-test( +- 'keysym', +- executable('test-keysym', 'test/keysym.c', 'test/keysym.h', +- dependencies: keysyms_test_dep, +- c_args: keysyms_test_c_args), +- env: test_env, +-) +-test( +- 'keymap', +- executable('test-keymap', 'test/keymap.c', 'test/keysym.h', +- dependencies: test_dep), +- env: test_env, +-) +-test( +- 'filecomp', +- executable('test-filecomp', 'test/filecomp.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'context', +- executable('test-context', 'test/context.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'rules-file', +- executable('test-rules-file', 'test/rules-file.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'rules-file-includes', +- executable('test-rules-file-includes', 'test/rules-file-includes.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'stringcomp', +- executable('test-stringcomp', 'test/stringcomp.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'buffercomp', +- executable('test-buffercomp', 'test/buffercomp.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'log', +- executable('test-log', 'test/log.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'atom', +- executable('test-atom', 'test/atom.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'utf8', +- executable('test-utf8', 'test/utf8.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'state', +- executable('test-state', 'test/state.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'keyseq', +- executable('test-keyseq', 'test/keyseq.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'rulescomp', +- executable('test-rulescomp', 'test/rulescomp.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'compose', +- executable('test-compose', 'test/compose.c', dependencies: test_dep), +- 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.py'), +- env: test_env, +- suite: ['python-tests'], +-) +-test( +- 'modifiers', +- executable('test-modifiers', 'test/modifiers.c', dependencies: test_dep), +- env: test_env, +-) +-test( +- 'messages', +- executable( +- 'test-messages', +- 'test/messages.c', +- 'tools/messages.c', +- 'tools/messages.h', +- include_directories: include_directories('src', 'include', 'tools'), +- dependencies: test_dep), +- env: test_env, +-) +-if get_option('enable-x11') +- test( +- 'x11', +- executable('test-x11', 'test/x11.c', dependencies: x11_test_dep), +- env: test_env, +- is_parallel : false, +- ) +- test( +- 'x11comp', +- executable('test-x11comp', 'test/x11comp.c', dependencies: x11_test_dep), +- env: test_env, +- is_parallel : false, +- ) +-endif +-if get_option('enable-xkbregistry') +- test( +- 'registry', +- executable('test-registry', 'test/registry.c', +- include_directories: include_directories('src'), +- dependencies: [dep_libxkbregistry, test_dep]), +- env: test_env, +- ) +-endif +-if build_tools +- test('tool-option-parsing', +- find_program('test/tool-option-parsing.py'), +- env: test_env, +- suite: ['python-tests']) +- +- # A set of keysyms to test for. Add one or two symbols to this array +- # whenever the xorgproto gets updated to make sure we resolve them. +- keysyms_to_test = [ +- 'XF86Macro23', +- ] +- +- env = environment() +- env.set('XKB_CONFIG_ROOT', meson.current_source_dir()/'test'/'data') +- foreach keysym: keysyms_to_test +- test('keysym-test-@0@'.format(keysym), +- find_program('test/test-keysym.py'), +- env: env, +- args: [keysym, '--tool', xkbcli_compile_keymap], +- suite: ['python-tests']) +- endforeach +-endif +- +-valgrind = find_program('valgrind', required: false) +-if valgrind.found() +- add_test_setup('valgrind', +- exe_wrapper: [valgrind, +- '--leak-check=full', +- '--track-origins=yes', +- '--gen-suppressions=all', +- '--error-exitcode=99'], +- timeout_multiplier : 10) +-else +- message('valgrind not found, disabling valgrind test setup') +-endif +- +- +-# Fuzzing target programs. +-executable('fuzz-keymap', 'fuzz/keymap/target.c', dependencies: test_dep) +-executable('fuzz-compose', 'fuzz/compose/target.c', dependencies: test_dep) +- +- +-# Benchmarks. +-bench_env = environment() +-bench_env.set('top_srcdir', meson.current_source_dir()) +-benchmark( +- 'key-proc', +- executable('bench-key-proc', 'bench/key-proc.c', dependencies: test_dep), +- env: bench_env, +-) +-benchmark( +- 'rules', +- executable('bench-rules', 'bench/rules.c', dependencies: test_dep), +- env: bench_env, +-) +-benchmark( +- 'rulescomp', +- executable('bench-rulescomp', 'bench/rulescomp.c', dependencies: test_dep), +- env: bench_env, +-) +-benchmark( +- 'compose', +- executable('bench-compose', 'bench/compose.c', dependencies: test_dep), +- env: bench_env, +-) +-benchmark( +- 'compose-traversal', +- executable('bench-compose-traversal', 'bench/compose-traversal.c', dependencies: test_dep), +- env: bench_env, +-) +-benchmark( +- 'atom', +- executable('bench-atom', 'bench/atom.c', dependencies: test_dep), +- env: bench_env, +-) +-if get_option('enable-x11') +- benchmark( +- 'x11', +- executable('bench-x11', 'bench/x11.c', dependencies: x11_test_dep), +- env: bench_env, +- ) +-endif +- +- + # Documentation. + if get_option('enable-docs') + doxygen = find_program('doxygen', required: false) +diff --git a/src/utils.h b/src/utils.h +index 7fd13bf..750a8e1 100644 +--- a/src/utils.h ++++ b/src/utils.h +@@ -289,13 +289,13 @@ open_file(const char *path); + + /* Compiler Attributes */ + +-#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__) +-# define XKB_EXPORT __attribute__((visibility("default"))) +-#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) +-# define XKB_EXPORT __global +-#else /* not gcc >= 4 and not Sun Studio >= 8 */ ++// #if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__) ++// # define XKB_EXPORT __attribute__((visibility("default"))) ++// #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) ++// # define XKB_EXPORT __global ++// #else /* not gcc >= 4 and not Sun Studio >= 8 */ + # define XKB_EXPORT +-#endif ++// #endif + + #if defined(__MINGW32__) + # define ATTR_PRINTF(x,y) __attribute__((__format__(__MINGW_PRINTF_FORMAT, x, y))) diff --git a/scripts/common.py b/scripts/common.py index 36b0d9d..8ca8176 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -60,3 +60,25 @@ def exec(self): self.build() self.install() self.package() + + +class MesonBuilder(Builder): + def configure(self): + os.chdir(f'{self.root}/{self.name}') + ensure('meson', [ + 'setup', + 'build', + '--cross-file=../scripts/meson-cross.ini', + '--buildtype=release', + '--prefix=/usr', + '--default-library=static', + *self.options + ]) + + def build(self): + ensure('ninja', ['-C', 'build', 'clean']) + ensure('ninja', ['-C', 'build']) + + def install(self): + os.environ['DESTDIR'] = self.destdir + ensure('ninja', ['-C', 'build', 'install']) diff --git a/scripts/libxkbcommon.py b/scripts/libxkbcommon.py new file mode 100644 index 0000000..cf5087e --- /dev/null +++ b/scripts/libxkbcommon.py @@ -0,0 +1,12 @@ +from common import MesonBuilder, patch + +project = 'libxkbcommon' +patch(project, f'{project}.patch') +MesonBuilder(project, [ + '-Denable-tools=false', + '-Denable-x11=false', + '-Denable-docs=false', + '-Denable-wayland=false', + '-Denable-bash-completion=false', + '-Denable-xkbregistry=false' +]).exec() diff --git a/scripts/meson-cross.ini b/scripts/meson-cross.ini new file mode 100644 index 0000000..1da503a --- /dev/null +++ b/scripts/meson-cross.ini @@ -0,0 +1,12 @@ +[binaries] +c = 'emcc' +cpp = 'em++' +ar = 'emar' +strip = 'emstrip' +pkg-config = 'pkg-config' + +[host_machine] +system = 'wasm' +cpu_family = 'wasm' +cpu = 'wasm' +endian = 'little' From fc270a755106b4818a418ce573b74993be721d8e Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Fri, 16 Aug 2024 11:58:08 -0400 Subject: [PATCH 2/5] iso-codes --- .github/workflows/ci.yml | 1 + .gitmodules | 3 +++ iso-codes | 1 + scripts/common.py | 18 ++++++++++++++++++ scripts/iso-codes.py | 3 +++ 5 files changed, 26 insertions(+) create mode 160000 iso-codes create mode 100644 scripts/iso-codes.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5705e1f..0d0c6f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,7 @@ jobs: run: | . emsdk/emsdk_env.sh python scripts/fmt.py + python scripts/iso-codes.py python scripts/json.py python scripts/json-c.py python scripts/marisa.py diff --git a/.gitmodules b/.gitmodules index 5f2a3c8..fea7b4a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "libxkbcommon"] path = libxkbcommon url = https://github.com/xkbcommon/libxkbcommon +[submodule "iso-codes"] + path = iso-codes + url = https://salsa.debian.org/iso-codes-team/iso-codes diff --git a/iso-codes b/iso-codes new file mode 160000 index 0000000..c2fcaad --- /dev/null +++ b/iso-codes @@ -0,0 +1 @@ +Subproject commit c2fcaadc832ed9f858950a43994973442d85ef4f diff --git a/scripts/common.py b/scripts/common.py index 8ca8176..b43d41b 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -82,3 +82,21 @@ def build(self): def install(self): os.environ['DESTDIR'] = self.destdir ensure('ninja', ['-C', 'build', 'install']) + + +class MakeBuilder(Builder): + def configure(self): + os.chdir(f'{self.root}/{self.name}') + ensure('./configure', [ + '-C', + '--prefix=/usr', + *self.options + ]) + + def build(self): + ensure('make', ['-j8']) + + def install(self): + os.environ['DESTDIR'] = self.destdir + ensure('make', ['install']) + \ No newline at end of file diff --git a/scripts/iso-codes.py b/scripts/iso-codes.py new file mode 100644 index 0000000..3f9086a --- /dev/null +++ b/scripts/iso-codes.py @@ -0,0 +1,3 @@ +from common import MakeBuilder + +MakeBuilder('iso-codes').exec() From d12e8a5313cc3c4cc1564600a86cb3bcf55def88 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Fri, 16 Aug 2024 12:20:14 -0400 Subject: [PATCH 3/5] libexpat --- .github/workflows/ci.yml | 1 + .gitmodules | 3 +++ libexpat | 1 + scripts/common.py | 4 +++- scripts/libexpat.py | 7 +++++++ 5 files changed, 15 insertions(+), 1 deletion(-) create mode 160000 libexpat create mode 100644 scripts/libexpat.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d0c6f9..ffab982 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: python scripts/json.py python scripts/json-c.py python scripts/marisa.py + python scripts/libexpat.py python scripts/libthai.py python scripts/libxkbcommon.py diff --git a/.gitmodules b/.gitmodules index fea7b4a..d83e98f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "iso-codes"] path = iso-codes url = https://salsa.debian.org/iso-codes-team/iso-codes +[submodule "libexpat"] + path = libexpat + url = https://github.com/libexpat/libexpat diff --git a/libexpat b/libexpat new file mode 160000 index 0000000..dfa90b8 --- /dev/null +++ b/libexpat @@ -0,0 +1 @@ +Subproject commit dfa90b81153a18555d78d4441697aba68ee61a68 diff --git a/scripts/common.py b/scripts/common.py index b43d41b..3c1ddb5 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -26,16 +26,18 @@ def patch(project: str, src: str, dst: str | None = None): class Builder: - def __init__(self, name: str, options: list[str] | None=None): + def __init__(self, name: str, options: list[str] | None=None, src='.'): self.name = name self.root = os.getcwd() self.destdir = f'{self.root}/build/{self.name}' self.options = options or [] + self.src = src def configure(self): os.chdir(f'{self.root}/{self.name}') ensure('emcmake', ['cmake', '-B', 'build', '-G', 'Ninja', + '-S', self.src, '-DBUILD_SHARED_LIBS=OFF', f'-DCMAKE_INSTALL_PREFIX={INSTALL_PREFIX}', '-DCMAKE_BUILD_TYPE=Release', diff --git a/scripts/libexpat.py b/scripts/libexpat.py new file mode 100644 index 0000000..010dd10 --- /dev/null +++ b/scripts/libexpat.py @@ -0,0 +1,7 @@ +from common import Builder + +Builder('libexpat', [ + '-DEXPAT_BUILD_TOOLS=OFF', + '-DEXPAT_BUILD_EXAMPLES=OFF', + '-DEXPAT_BUILD_TESTS=OFF' +], src='expat').exec() From 3c9553cb10dffc2a0ac106bb5ead4a53aba98ebd Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Fri, 16 Aug 2024 21:38:12 -0400 Subject: [PATCH 4/5] xkeyboard-config --- .github/workflows/ci.yml | 1 + .gitmodules | 3 +++ scripts/xkeyboard-config.py | 3 +++ xkeyboard-config | 1 + 4 files changed, 8 insertions(+) create mode 100644 scripts/xkeyboard-config.py create mode 160000 xkeyboard-config diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffab982..f150067 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: python scripts/libexpat.py python scripts/libthai.py python scripts/libxkbcommon.py + python scripts/xkeyboard-config.py - name: Release if: ${{ github.ref == 'refs/heads/master' }} diff --git a/.gitmodules b/.gitmodules index d83e98f..981d759 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "libexpat"] path = libexpat url = https://github.com/libexpat/libexpat +[submodule "xkeyboard-config"] + path = xkeyboard-config + url = https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config diff --git a/scripts/xkeyboard-config.py b/scripts/xkeyboard-config.py new file mode 100644 index 0000000..08db8e2 --- /dev/null +++ b/scripts/xkeyboard-config.py @@ -0,0 +1,3 @@ +from common import MesonBuilder, patch + +MesonBuilder('xkeyboard-config').exec() diff --git a/xkeyboard-config b/xkeyboard-config new file mode 160000 index 0000000..ee603e0 --- /dev/null +++ b/xkeyboard-config @@ -0,0 +1 @@ +Subproject commit ee603e0d368adf48b3e15dca6d33a8c6e351d922 From 610a75f7aa5de6ef1565ffd850449ed2db4a99aa Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Fri, 16 Aug 2024 23:42:41 -0400 Subject: [PATCH 5/5] install meson --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f150067..9ef0a85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,8 @@ jobs: - name: Install dependencies run: | - sudo apt install -y ninja-build + sudo apt install -y ninja-build \ + meson - name: Install emsdk run: | @@ -39,11 +40,11 @@ jobs: python scripts/iso-codes.py python scripts/json.py python scripts/json-c.py - python scripts/marisa.py python scripts/libexpat.py python scripts/libthai.py python scripts/libxkbcommon.py python scripts/xkeyboard-config.py + python scripts/marisa.py - name: Release if: ${{ github.ref == 'refs/heads/master' }}