diff --git a/.gitignore b/.gitignore index 72923bda..931e60a2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /aclocal.m4 /aminclude_static.am /autom4te.cache +/build/ /build-aux/ /bus/tmpfiles.d/dbus.conf /ci-build*/ @@ -25,6 +26,7 @@ file*.lst /libtool /m4/libtool.m4 /m4/lt*.m4 +/src-from-dist/ /stamp-h /stamp-h.in /stamp-h1 @@ -48,5 +50,6 @@ file*.lst .libs/ Makefile Makefile.in +__pycache__/ cscope.out tags diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5591da74..ba9200d6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,6 +34,7 @@ stages: - build variables: + builddir: "build" ci_in_docker: "yes" ci_local_packages: "yes" ci_parallel: "2" @@ -44,7 +45,7 @@ variables: # If you are hacking on them or need a them to rebuild, its enough # to change any part of the string of the image you want. ### - WINDOWS_TAG: "2022-01-07.1" + WINDOWS_TAG: "2022-02-06.2" UPSTREAM_BRANCH: 'master' UPSTREAM_REPO: 'dbus/dbus' @@ -74,9 +75,22 @@ variables: when: always paths: - $CI_PROJECT_DIR/test-results.xml + - "build/config.h" reports: junit: $CI_PROJECT_DIR/test-results.xml +.meson-common: + variables: + ci_buildsys: "meson" + artifacts: + reports: + junit: "build/meson-logs/testlog.junit.xml" + name: "dbus-$CI_JOB_NAME" + when: always + paths: + - "build/config.h" + - "build/meson-logs/*.txt" + windows amd64 image: stage: "build docker" variables: @@ -165,6 +179,13 @@ debian cmake: variables: ci_buildsys: "cmake-dist" +debian meson: + extends: + - .meson-common + - .debian-build + variables: + ci_buildsys: "meson-dist" + debian mingw32 autotools debug: extends: .debian-build variables: @@ -179,6 +200,14 @@ debian mingw32 cmake: variables: ci_host: "i686-w64-mingw32" +debian mingw32 meson: + extends: + - .meson-common + - .debian-build + when: manual + variables: + ci_host: "i686-w64-mingw32" + debian mingw64 autotools: extends: .debian-build variables: @@ -194,6 +223,15 @@ debian mingw64 cmake debug: ci_host: "x86_64-w64-mingw32" ci_variant: "debug" +debian mingw64 meson debug: + extends: + - .meson-common + - .debian-build + when: manual + variables: + ci_host: "x86_64-w64-mingw32" + ci_variant: "debug" + debian buster autotools: extends: .debian-build when: manual @@ -240,6 +278,18 @@ opensuse mingw64 cmake debug: ci_local_packages: "no" ci_variant: "debug" +opensuse mingw64 meson debug: + extends: + - .meson-common + - .suse-build + variables: + ci_host: "x86_64-w64-mingw32" + ci_local_packages: "no" + # TODO: Tests in this configuration fail to find the mingw builds + # of expat and GLib in /usr/x86_64-w64-mingw32/sys-root/mingw/bin + ci_test: "no" + ci_variant: "debug" + .ubuntu-build: extends: .unix-host-build image: "ubuntu:latest" @@ -271,6 +321,11 @@ ubuntu jammy autotools: windows msys64 ucrt64 cmake: extends: .win-build + artifacts: + name: dbus-$CI_JOB_NAME + when: always + paths: + - "build/config.h" script: - $env:MSYSTEM = "UCRT64" - $env:CHERE_INVOKING = "1" @@ -290,4 +345,42 @@ windows vs15-64 cmake: # FIXME: a few tests timeout on gitlab runner for unknown reason - cd build ; ctest -C Debug -VV --timeout 1200 -E '(dbus-daemon|monitor)' --output-junit $ci_cmake_junit_output +windows-meson-mingw-ucrt64: + extends: .win-build + script: + - $env:MSYSTEM = "UCRT64" + - $env:CHERE_INVOKING = "1" + - $env:MSYS2_PATH_TYPE = "inherit" + - $env:PATH += ";C:\msys64\usr\bin" + # FIXME: -j1: for some reason on CI ninja: fatal: pipe: Too many open files + - C:\msys64\usr\bin\bash -lc " + meson build && + ninja -j1 -C build && + meson test --no-suite=runs-dbus-daemon -C build" + artifacts: + reports: + junit: "build/meson-logs/testlog.junit.xml" + name: "dbus-$CI_JOB_NAME" + when: always + paths: + - "build/config.h" + - "build/meson-logs/*.txt" + +windows-meson-vs15-x86: + extends: .win-build + script: + # FIXME: tests that run dbus-daemon time out on the Gitlab runner + - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=x86 && + meson --force-fallback-for=expat,glib,zlib build && + meson compile -C build && + meson test --no-suite=runs-dbus-daemon -C build" + artifacts: + reports: + junit: "build/meson-logs/testlog.junit.xml" + name: "dbus-$CI_JOB_NAME" + when: always + paths: + - "build/config.h" + - "build/meson-logs/*.txt" + # vim:set sw=2 sts=2 et: diff --git a/CMakeLists.txt b/CMakeLists.txt index 47953aa3..c7090d01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,10 +209,6 @@ include(ConfigureChecks) # make some more macros available include(MacroLibrary) -if(VCS) - set(DBUS_VERBOSE_C_S 1 CACHE STRING "verbose mode" FORCE) -endif() - if(MSVC) # controll folders in msvc projects include(ProjectSourceGroup) diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt new file mode 100644 index 00000000..137069b8 --- /dev/null +++ b/LICENSES/Apache-2.0.txt @@ -0,0 +1,73 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/Makefile.am b/Makefile.am index 6078e33c..d9371958 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,7 @@ EXTRA_DIST = \ dbus-1.pc.in \ cleanup-man-pages.sh \ LICENSES/AFL-2.1.txt \ + LICENSES/Apache-2.0.txt \ LICENSES/GPL-2.0-or-later.txt \ LICENSES/MIT.txt \ NEWS.pre-1-0 \ @@ -27,6 +28,11 @@ EXTRA_DIST = \ bus/CMakeLists.txt \ dbus/CMakeLists.txt \ doc/CMakeLists.txt \ + meson.build \ + meson_options.txt \ + meson_post_install.py \ + subprojects/expat.wrap \ + subprojects/glib.wrap \ test/CMakeLists.txt \ test/name-test/CMakeLists.txt \ tools/CMakeLists.txt \ @@ -36,7 +42,7 @@ EXTRA_DIST = \ all-local: Doxyfile update-authors: - ( cd $(srcdir) && git shortlog -s -e ) | cut -c 8- | sort > $(srcdir)/AUTHORS + cd $(srcdir) && ./maint/update-authors.sh DISTCHECK_CONFIGURE_FLAGS = \ --enable-xml-docs \ diff --git a/README b/README index fe16284b..183ee49a 100644 --- a/README +++ b/README @@ -80,28 +80,62 @@ Development snapshots make no ABI stability guarantees for new ABI introduced since the last stable release. Development snapshots are likely to have more bugs than stable releases, obviously. -Configuration +Configuration === -dbus could be build by using autotools or cmake. +This branch of dbus can be built by using Autotools, CMake or Meson. +The Meson build system is currently considered experimental, but is +likely to become the recommended build system in future. -When using autotools the configure step is initiated by running ./configure +Older versions of dbus required Autotools or CMake, with Autotools +recommended for Unix systems and CMake recommended for Windows systems. + +When using Autotools, the configure step is initiated by running ./configure with or without additional configuration flags. dbus requires GNU Make (on BSD systems, this is typically called gmake) or a "make" implementation with compatible extensions. -When using cmake the configure step is initiated by running the cmake -program with or without additional configuration flags. +When using CMake, the configure step is initiated by running the cmake +program with or without additional configuration flags. + +Meson only supports out-of-tree builds, and must be passed a directory to put +built and generated sources into. We'll call that directory "build" here. It's +recommended to create a separate build directory for each configuration you +might want to use. + +Basic configuration is done with: + +``` sh +meson build/ +``` + +This will create the build directory. If any dependencies are missing, you can +install them, or try to remove the dependency with a Meson configuration option +(see below). Configuration flags === -When using autotools, run "./configure --help" to see the possible +When using Autotools, run "./configure --help" to see the possible configuration options and environment variables. -When using cmake, inspect README.cmake to see the possible +When using CMake, inspect README.cmake to see the possible configuration options and environment variables. - + +When using Meson, to review the options which Meson chose, run: + +``` sh +meson configure build/ +``` + +With additional arguments meson configure can be used to change options for a +previously configured build directory. All options passed to this command are in +the form `-D "option"="value"`. For example: + +``` sh +meson configure build/ -Dprefix=/tmp/install +``` + API/ABI Policy === diff --git a/bus/Makefile.am b/bus/Makefile.am index 1595432c..51a8de81 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -220,10 +220,15 @@ endif DBUS_UNIX EXTRA_DIST += \ dbus.service.in \ dbus.socket.in \ + legacy-config/meson.build \ + meson.build \ systemd-user/dbus.service.in \ systemd-user/dbus.socket.in \ + systemd-user/meson.build \ sysusers.d/dbus.conf.in \ + sysusers.d/meson.build \ tmpfiles.d/dbus.conf.in \ + tmpfiles.d/meson.build \ $(NULL) if HAVE_SYSTEMD diff --git a/bus/legacy-config/meson.build b/bus/legacy-config/meson.build new file mode 100644 index 00000000..1e635713 --- /dev/null +++ b/bus/legacy-config/meson.build @@ -0,0 +1,36 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +if platform_unix + configure_file( + input: 'system.conf.in', + output: 'system.conf', + configuration: data_config, + install_dir: get_option('sysconfdir') / 'dbus-1', + ) +endif + +configure_file( + input: 'session.conf.in', + output: 'session.conf', + configuration: data_config, + install_dir: get_option('sysconfdir') / 'dbus-1', +) diff --git a/bus/meson.build b/bus/meson.build new file mode 100644 index 00000000..1aaaf48d --- /dev/null +++ b/bus/meson.build @@ -0,0 +1,223 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +session_conf = configure_file( + input: 'session.conf.in', + output: 'session.conf', + configuration: data_config, + install_dir: get_option('datadir') / 'dbus-1', +) + +if platform_unix + configure_file( + input: 'system.conf.in', + output: 'system.conf', + configuration: data_config, + install_dir: get_option('datadir') / 'dbus-1', + ) +endif + +configure_file( + input: 'example-system-enable-stats.conf.in', + output: 'example-system-enable-stats.conf', + configuration: data_config, + install_dir: get_option('datadir') / 'doc' / 'dbus' / 'examples', +) + +configure_file( + input: 'example-session-disable-stats.conf.in', + output: 'example-session-disable-stats.conf', + configuration: data_config, + install_dir: get_option('datadir') / 'doc' / 'dbus' / 'examples', +) + +install_data( + 'example-system-hardening-without-traditional-activation.conf', + install_dir: get_option('datadir') / 'doc' / 'dbus' / 'examples', +) + +if use_launchd + configure_file( + input: 'org.freedesktop.dbus-session.plist.in', + output: 'org.freedesktop.dbus-session.plist', + configuration: data_config, + install_dir: launchd_agent_dir, + ) +endif + +if use_systemd + configure_file( + input: 'dbus.service.in', + output: 'dbus.service', + configuration: data_config, + install_dir: systemd_system_unitdir, + ) + configure_file( + input: 'dbus.socket.in', + output: 'dbus.socket', + configuration: data_config, + install_dir: systemd_system_unitdir, + ) + subdir('sysusers.d') + subdir('tmpfiles.d') + + if enable_user_session + subdir('systemd-user') + endif +endif + +subdir('legacy-config') + + +libdbus_daemon_internal_sources = [ + 'activation.c', + 'apparmor.c', + 'audit.c', + 'bus.c', + 'config-loader-expat.c', + 'config-parser-common.c', + 'config-parser.c', + 'connection.c', + 'containers.c', + 'desktop-file.c', + 'dispatch.c', + 'driver.c', + 'expirelist.c', + 'policy.c', + 'selinux.c', + 'services.c', + 'signals.c', + 'stats.c', + 'test.c', + 'utils.c', +] + +if use_kqueue + libdbus_daemon_internal_sources += 'dir-watch-kqueue.c' +elif use_inotify + libdbus_daemon_internal_sources += 'dir-watch-inotify.c' +else + libdbus_daemon_internal_sources += 'dir-watch-default.c' +endif + +libdbus_daemon_internal = static_library('dbus-daemon-internal', + libdbus_daemon_internal_sources, + include_directories: root_include, + dependencies: [ + adt_libs, + apparmor, + expat, + network_libs, + selinux, + threads, + ], + link_with: [ + libdbus, + libdbus_internal, + ], +) + +dbus_daemon = executable('dbus-daemon', + 'main.c', + include_directories: root_include, + link_with: libdbus_daemon_internal, + install: true, +) + + +if platform_unix and use_traditional_activation + liblaunch_helper_internal_sources = [ + 'config-loader-expat.c', + 'config-parser-common.c', + 'config-parser-trivial.c', + 'desktop-file.c', + 'utils.c', + ] + liblaunch_helper_internal = static_library('launch-helper-internal', + liblaunch_helper_internal_sources, + include_directories: root_include, + link_with: [ + libdbus, + libdbus_internal, + ], + dependencies: [ + expat, + network_libs, + threads, + ], + install: false, + ) + + dbus_daemon_launch_helper_sources = [ + 'activation-helper.c', + 'activation-helper-bin.c', + ] + + # This is the installed launch helper with the setuid checks + # All files that have special cases #ifdef ACTIVATION_LAUNCHER_TEST must + # be listed here and included in test/bus/launch-helper-for-tests.c, + # not in liblaunch_helper_internal. + dbus_daemon_launch_helper = executable('dbus-daemon-launch-helper', + dbus_daemon_launch_helper_sources, + include_directories: root_include, + link_with: liblaunch_helper_internal, + install: true, + install_dir: get_option('libexecdir'), + ) +endif + +install_emptydirs += [ + get_option('datadir') / 'dbus-1' / 'session.d', + get_option('datadir') / 'dbus-1' / 'services', +] + +if platform_unix + install_emptydirs += [ + get_option('localstatedir') / 'run' / 'dbus', + get_option('datadir') / 'dbus-1' / 'system.d', + get_option('datadir') / 'dbus-1' / 'system-services', + ] +endif + +if use_systemd + install_symlinks += [ + { + 'link_name': 'dbus.service', + 'install_dir': systemd_system_unitdir / 'multi-user.target.wants', + 'pointing_to': '../dbus.service', + }, + { + 'link_name': 'dbus.socket', + 'install_dir': systemd_system_unitdir / 'sockets.target.wants', + 'pointing_to': '../dbus.socket', + }, + ] +endif + +if use_systemd and get_option('user_session') + install_symlinks += [ + { + 'link_name': 'dbus.socket', + 'install_dir': systemd_user_unitdir / 'sockets.target.wants', + 'pointing_to': '../dbus.socket', + }, + ] +endif diff --git a/bus/systemd-user/meson.build b/bus/systemd-user/meson.build new file mode 100644 index 00000000..1f95c4ee --- /dev/null +++ b/bus/systemd-user/meson.build @@ -0,0 +1,34 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +configure_file( + input: 'dbus.service.in', + output: 'dbus.service', + configuration: data_config, + install_dir: systemd_user_unitdir, +) + +configure_file( + input: 'dbus.socket.in', + output: 'dbus.socket', + configuration: data_config, + install_dir: systemd_user_unitdir, +) diff --git a/bus/sysusers.d/meson.build b/bus/sysusers.d/meson.build new file mode 100644 index 00000000..1e03896c --- /dev/null +++ b/bus/sysusers.d/meson.build @@ -0,0 +1,27 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +configure_file( + input: 'dbus.conf.in', + output: 'dbus.conf', + configuration: data_config, + install_dir: get_option('prefix') / 'lib' / 'sysusers.d', +) diff --git a/bus/tmpfiles.d/meson.build b/bus/tmpfiles.d/meson.build new file mode 100644 index 00000000..f866879c --- /dev/null +++ b/bus/tmpfiles.d/meson.build @@ -0,0 +1,27 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +configure_file( + input: 'dbus.conf.in', + output: 'dbus.conf', + configuration: data_config, + install_dir: get_option('prefix') / 'lib' / 'tmpfiles.d', +) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 8009effa..01c80437 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -10,36 +10,23 @@ check_include_file(alloca.h HAVE_ALLOCA_H) check_include_file(byteswap.h HAVE_BYTESWAP_H) check_include_file(crt/externs.h HAVE_CRT_EXTERNS_H) check_include_file(dirent.h HAVE_DIRENT_H) # dbus-sysdeps-util.c -check_include_file(dlfcn.h HAVE_DLFCN_H) -check_include_file(execinfo.h HAVE_EXECINFO_H) check_include_file(errno.h HAVE_ERRNO_H) # dbus-sysdeps.c -check_include_file(expat.h HAVE_EXPAT_H) -check_include_file(grp.h HAVE_GRP_H) # dbus-sysdeps-util-win.c check_include_file(inttypes.h HAVE_INTTYPES_H) # dbus-pipe.h check_include_file(io.h HAVE_IO_H) # internal check_include_file(linux/close_range.h HAVE_LINUX_CLOSE_RANGE_H) check_include_file(locale.h HAVE_LOCALE_H) -check_include_file(memory.h HAVE_MEMORY_H) check_include_file(signal.h HAVE_SIGNAL_H) check_include_file(stdint.h HAVE_STDINT_H) # dbus-pipe.h -check_include_file(stdlib.h HAVE_STDLIB_H) check_include_file(stdio.h HAVE_STDIO_H) # dbus-sysdeps.h -check_include_file(string.h HAVE_STRING_H) -check_include_file(strings.h HAVE_STRINGS_H) check_include_file(syslog.h HAVE_SYSLOG_H) check_include_files("stdint.h;sys/types.h;sys/event.h" HAVE_SYS_EVENT_H) check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H) check_include_file(sys/random.h HAVE_SYS_RANDOM_H) check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H) -check_include_file(sys/stat.h HAVE_SYS_STAT_H) check_include_file(sys/syscall.h HAVE_SYS_SYSCALL_H) -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(sys/uio.h HAVE_SYS_UIO_H) check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H) check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H) # dbus-sysdeps-unix.c check_include_file(sys/time.h HAVE_SYS_TIME_H)# dbus-sysdeps-win.c -check_include_file(sys/wait.h HAVE_SYS_WAIT_H)# dbus-sysdeps-win.c -check_include_file(time.h HAVE_TIME_H) # dbus-sysdeps-win.c check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c check_include_file(unistd.h HAVE_UNISTD_H) # dbus-sysdeps-util-win.c check_include_file(sys/inotify.h DBUS_BUS_ENABLE_INOTIFY) @@ -75,8 +62,6 @@ check_symbol_exists(getrandom "sys/random.h" HAVE_GETRANDOM) check_symbol_exists(getrlimit "sys/resource.h;sys/time.h" HAVE_GETRLIMIT) check_symbol_exists(prlimit "sys/resource.h;sys/time.h" HAVE_PRLIMIT) check_symbol_exists(setrlimit "sys/resource.h;sys/time.h" HAVE_SETRLIMIT) -check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF) -check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF) check_symbol_exists(MSG_NOSIGNAL "sys/socket.h" HAVE_DECL_MSG_NOSIGNAL) check_symbol_exists(environ "unistd.h" HAVE_DECL_ENVIRON) check_symbol_exists(LOG_PERROR "syslog.h" HAVE_DECL_LOG_PERROR) @@ -147,32 +132,6 @@ int main() { } " DBUS_USE_SYNC) -CHECK_C_SOURCE_COMPILES(" -#include -#include -int main( - DIR *dirp; - dirp = opendir(\".\"); - dirfd(dirp); - closedir(dirp); -) -" HAVE_DIRFD) - -if(NOT HAVE_DIRFD) - CHECK_C_SOURCE_COMPILES(" - #include - #include - int main() - { - DIR *dirp; - int fd; - dirp = opendir(\".\"); - fd = dirp->dd_fd; - closedir(dirp); - } - " HAVE_DDFD) -endif() - check_type_size("short" SIZEOF_SHORT) check_type_size("int" SIZEOF_INT) check_type_size("long" SIZEOF_LONG) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index f0fb75e2..75509524 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -101,17 +101,9 @@ /* Define to 1 if you have dirent.h */ #cmakedefine HAVE_DIRENT_H 1 -#cmakedefine HAVE_DLFCN_H 1 - /* Define to 1 if you have errno.h */ #cmakedefine HAVE_ERRNO_H 1 -#cmakedefine HAVE_EXECINFO_H 1 -#cmakedefine HAVE_EXPAT_H 1 - -/* Define to 1 if you have grp.h */ -#cmakedefine HAVE_GRP_H 1 - /* Define to 1 if you have inttypes.h */ #cmakedefine HAVE_INTTYPES_H 1 @@ -121,8 +113,6 @@ /* Define to 1 if you have locale.h */ #cmakedefine HAVE_LOCALE_H 1 -#cmakedefine HAVE_MEMORY_H 1 - /* Define to 1 if you have poll */ #cmakedefine HAVE_POLL 1 @@ -132,20 +122,15 @@ /* Define to 1 if you have stdint.h */ #cmakedefine HAVE_STDINT_H 1 -#cmakedefine HAVE_STDLIB_H 1 - /* Define to 1 if you have stdio.h */ #cmakedefine HAVE_STDIO_H 1 -#cmakedefine HAVE_STRINGS_H 1 -#cmakedefine HAVE_STRING_H 1 #cmakedefine HAVE_SYSLOG_H 1 #cmakedefine HAVE_SYS_EVENTS_H 1 #cmakedefine HAVE_SYS_INOTIFY_H 1 #cmakedefine HAVE_SYS_PRCTL_H 1 #cmakedefine HAVE_SYS_RANDOM_H 1 #cmakedefine HAVE_SYS_RESOURCE_H 1 -#cmakedefine HAVE_SYS_STAT_H 1 /* Define to 1 if you have sys/syslimits.h */ #cmakedefine HAVE_SYS_SYSLIMITS_H 1 @@ -153,16 +138,6 @@ /* Define to 1 if you have sys/time.h */ #cmakedefine HAVE_SYS_TIME_H 1 -#cmakedefine HAVE_SYS_TYPES_H 1 - -#cmakedefine HAVE_SYS_UIO_H 1 - -/* Define to 1 if you have sys/wait.h */ -#cmakedefine HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have time.h */ -#cmakedefine HAVE_TIME_H 1 - /* Define to 1 if you have unistd.h */ #cmakedefine HAVE_UNISTD_H 1 @@ -226,12 +201,6 @@ #cmakedefine HAVE_ACCEPT4 1 -/* Have dirfd function */ -#cmakedefine HAVE_DIRFD 1 - -/* Have the ddfd member of DIR */ -#cmakedefine HAVE_DDFD 1 - #cmakedefine HAVE_INOTIFY_INIT1 1 #cmakedefine HAVE_GETRANDOM 1 #cmakedefine HAVE_GETRLIMIT 1 @@ -241,16 +210,12 @@ #cmakedefine HAVE_SETRLIMIT 1 #cmakedefine HAVE_UNIX_FD_PASSING 1 #cmakedefine HAVE_SYSTEMD -#cmakedefine HAVE_VASPRINTF 1 -#cmakedefine HAVE_VSNPRINTF 1 /* Define to use epoll(4) on Linux */ #cmakedefine DBUS_HAVE_LINUX_EPOLL 1 /* Use the gcc __sync extension */ #cmakedefine01 DBUS_USE_SYNC -#cmakedefine HAVE_VASPRINTF 1 -#cmakedefine HAVE_VSNPRINTF 1 #cmakedefine HAVE_SETRESUID 1 #cmakedefine HAVE_GETRESUID 1 @@ -314,13 +279,6 @@ #define SIGHUP 1 #endif -#cmakedefine DBUS_VERBOSE_C_S 1 -#ifdef DBUS_VERBOSE_C_S -#define _dbus_verbose_C_S printf -#else -#define _dbus_verbose_C_S _dbus_verbose -#endif - # if defined(_MSC_VER) && !defined(inline) #define inline __inline #endif diff --git a/cmake/meson.build b/cmake/meson.build new file mode 100644 index 00000000..bba68c23 --- /dev/null +++ b/cmake/meson.build @@ -0,0 +1,44 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +cmake_config = configuration_data() +cmake_config.set('CMAKE_INSTALL_INCLUDEDIR',get_option('prefix') / get_option('includedir')) +cmake_config.set('CMAKE_INSTALL_LIBDIR', get_option('prefix') / get_option('libdir')) +cmake_config.set('DBUS_PREFIX', get_option('prefix')) +cmake_config.set('DBUS_RELOCATABLE', relocation) +cmake_config.set('DBUS_VERSION', version) + +cmake_files = [ + configure_file( + input: 'DBus1Config.pkgconfig.in', + output: 'DBus1Config.cmake', + configuration: cmake_config, + ), + configure_file( + input: 'DBus1ConfigVersion.cmake.in', + output: 'DBus1ConfigVersion.cmake', + configuration: cmake_config, + ) +] + +install_data(cmake_files, + install_dir: get_option('libdir') / 'cmake' / 'DBus1', +) diff --git a/configure.ac b/configure.ac index 3b225a29..d72d8f7c 100644 --- a/configure.ac +++ b/configure.ac @@ -647,41 +647,6 @@ if test "x$ac_cv_header_syslog_h" = "xyes"; then AC_CHECK_DECLS([LOG_PERROR], [], [], [[#include ]]) fi -AC_MSG_CHECKING(for dirfd) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -]], [[ -DIR *dirp; -dirp = opendir("."); -dirfd(dirp); -closedir(dirp); -]])], -[dbus_have_dirfd=yes], -[dbus_have_dirfd=no]) -AC_MSG_RESULT($dbus_have_dirfd) -if test "$dbus_have_dirfd" = yes; then - AC_DEFINE(HAVE_DIRFD,1,[Have dirfd function]) -else - AC_MSG_CHECKING(for DIR *dirp->dd_fd) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#include -#include - ]], [[ -DIR *dirp; -int fd; -dirp = opendir("."); -fd = dirp->dd_fd; -closedir(dirp); - ]])], - [dbus_have_ddfd=yes], - [dbus_have_ddfd=no]) - AC_MSG_RESULT($dbus_have_ddfd) - if test "$dbus_have_ddfd" = yes; then - AC_DEFINE(HAVE_DDFD,1,[Have the ddfd member of DIR]) - fi -fi - AC_CHECK_HEADERS([execinfo.h], [AC_SEARCH_LIBS([backtrace], [execinfo], [AC_DEFINE([HAVE_BACKTRACE], [1], diff --git a/dbus/Makefile.am b/dbus/Makefile.am index fbd81758..3c2ea87c 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -329,6 +329,9 @@ endif noinst_PROGRAMS = +EXTRA_DIST += meson.build +EXTRA_DIST += test-version-script + # Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE include $(top_srcdir)/aminclude_static.am diff --git a/dbus/meson.build b/dbus/meson.build new file mode 100644 index 00000000..2fd7cc72 --- /dev/null +++ b/dbus/meson.build @@ -0,0 +1,239 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +dbus_dependencies = [ + threads, + network_libs, + systemd, + valgrind.partial_dependency(compile_args: true), +] + +# source code that goes in the installed client library +# and is specific to library functionality +dbus_lib_sources = [ + 'dbus-address.c', + 'dbus-auth.c', + 'dbus-bus.c', + 'dbus-connection.c', + 'dbus-credentials.c', + 'dbus-errors.c', + 'dbus-keyring.c', + 'dbus-marshal-byteswap.c', + 'dbus-marshal-header.c', + 'dbus-marshal-recursive.c', + 'dbus-marshal-validate.c', + 'dbus-message.c', + 'dbus-misc.c', + 'dbus-nonce.c', + 'dbus-object-tree.c', + 'dbus-pending-call.c', + 'dbus-resources.c', + 'dbus-server-debug-pipe.c', + 'dbus-server-socket.c', + 'dbus-server.c', + 'dbus-sha.c', + 'dbus-signature.c', + 'dbus-syntax.c', + 'dbus-threads.c', + 'dbus-timeout.c', + 'dbus-transport-socket.c', + 'dbus-transport.c', + 'dbus-watch.c', +] + +# source code that goes in the installed client library +# AND is generic utility functionality used by the +# daemon or test programs (all symbols in here should +# be underscore-prefixed) + +dbus_shared_sources = [ + 'dbus-dataslot.c', + 'dbus-file.c', + 'dbus-hash.c', + 'dbus-internals.c', + 'dbus-list.c', + 'dbus-marshal-basic.c', + 'dbus-memory.c', + 'dbus-mempool.c', + 'dbus-pipe.c', + 'dbus-string.c', + 'dbus-sysdeps.c', +] + +if embedded_tests + dbus_shared_sources += 'dbus-test-tap.c' +endif + + +# source code that is generic utility functionality used +# by the bus daemon or test apps, but is NOT included +# in the D-Bus client library (all symbols in here +# should be underscore-prefixed but don't really need +# to be unless they move to DBUS_SHARED_SOURCES later) + +dbus_util_sources = [ + 'dbus-asv-util.c', + 'dbus-mainloop.c', + 'dbus-message-util.c', + 'dbus-pollable-set-poll.c', + 'dbus-pollable-set.c', + 'dbus-shell.c', + 'dbus-string-util.c', + 'dbus-sysdeps-util.c', +] + +if platform_windows + dbus_lib_sources += [ + 'dbus-init-win.cpp', + 'dbus-server-win.c', + ] + + dbus_lib_sources += windows.compile_resources(configure_file( + input: 'versioninfo.rc.in', + output: 'versioninfo.rc', + configuration: data_config, + )) + + dbus_shared_sources += [ + 'dbus-file-win.c', + 'dbus-pipe-win.c', + 'dbus-sysdeps-thread-win.c', + 'dbus-sysdeps-win.c', + 'dbus-transport-win.c', + ] + + if platform_win32ce + dbus_shared_sources += 'dbus-sysdeps-wince-glue.c' + endif + + dbus_util_sources += 'dbus-sysdeps-util-win.c' + + if use_traditional_activation + dbus_util_sources += 'dbus-spawn-win.c' + endif + +else # Unix + + dbus_lib_sources += [ + 'dbus-uuidgen.c', + 'dbus-server-unix.c', + ] + + dbus_shared_sources += [ + 'dbus-file-unix.c', + 'dbus-pipe-unix.c', + 'dbus-sysdeps-pthread.c', + 'dbus-sysdeps-unix.c', + 'dbus-transport-unix.c', + 'dbus-userdb.c', + ] + + if use_launchd + dbus_shared_sources += 'dbus-server-launchd.c' + endif + + dbus_util_sources += [ + 'dbus-sysdeps-util-unix.c', + 'dbus-userdb-util.c', + ] + + if use_traditional_activation + dbus_util_sources += 'dbus-spawn-unix.c' + endif + +endif + + +if use_linux_epoll + dbus_util_sources += 'dbus-pollable-set-epoll.c' +endif + +version_script = configure_file( + input: 'Version.in', + output: 'version_script', + configuration: data_config, +) + +# We can't use version_script to check for support, because it hasn't been +# generated yet, so use a static source file instead. +if cc.has_link_argument( + '-Wl,--version-script,@0@'.format( + meson.current_source_dir() / 'test-version-script' + ) +) + version_flags = ['-Wl,--version-script,@0@'.format(version_script)] +else + version_flags = [] +endif + +libdbus = library('dbus-1', + dbus_lib_sources, + dbus_shared_sources, + + include_directories: root_include, + c_args: '-Ddbus_1_EXPORTS', + + link_args: version_flags, + soversion: soversion, + version: version_info, + + dependencies: dbus_dependencies, + install: true, +) + +libdbus_internal = static_library('dbus-internal', + dbus_util_sources, + + include_directories: root_include, + link_with: libdbus, + dependencies: dbus_dependencies, +) + + +install_headers( + 'dbus-address.h', + 'dbus-bus.h', + 'dbus-connection.h', + 'dbus-errors.h', + 'dbus-macros.h', + 'dbus-memory.h', + 'dbus-message.h', + 'dbus-misc.h', + 'dbus-pending-call.h', + 'dbus-protocol.h', + 'dbus-server.h', + 'dbus-shared.h', + 'dbus-signature.h', + 'dbus-syntax.h', + 'dbus-threads.h', + 'dbus-types.h', + 'dbus.h', + subdir: 'dbus-1.0' / 'dbus', +) + +dbus_arch_deps_h = configure_file( + input: 'dbus-arch-deps.h.in', + output: 'dbus-arch-deps.h', + configuration: arch_config, +) +install_data(dbus_arch_deps_h, + install_dir: get_option('libdir') / 'dbus-1.0' / 'include' / 'dbus', +) diff --git a/dbus/test-version-script b/dbus/test-version-script new file mode 100644 index 00000000..c0f8462d --- /dev/null +++ b/dbus/test-version-script @@ -0,0 +1,10 @@ +NOT_REALLY_LIBDBUS_1_3 { + global: + dbus_*; + local: + *; +}; +NOT_REALLY_LIBDBUS_PRIVATE_1.2.3 { + global: + _dbus_*; +}; diff --git a/doc/Makefile.am b/doc/Makefile.am index 471ac2b5..315c9349 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -223,3 +223,8 @@ clean-local: rm -rf dbus-docs dbus-docs.tmp rm -f *.1.html rm -f doxygen.stamp + +EXTRA_DIST += list-doc-source.py +EXTRA_DIST += maintainer-upload-docs.sh +EXTRA_DIST += meson.build +EXTRA_DIST += meson_post_install.py diff --git a/doc/list-doc-source.py b/doc/list-doc-source.py new file mode 100644 index 00000000..2ed442ca --- /dev/null +++ b/doc/list-doc-source.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 +# Copyright © 2019-2020 Salamandar +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +import glob +import sys + +print('\n'.join(glob.glob(sys.argv[1] + '/*.[ch]'))) diff --git a/doc/maintainer-upload-docs.sh b/doc/maintainer-upload-docs.sh new file mode 100644 index 00000000..f090cf46 --- /dev/null +++ b/doc/maintainer-upload-docs.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set -eux + +: "${DOC_SERVER:=dbus.freedesktop.org}" +: "${DOC_WWW_DIR:=/srv/dbus.freedesktop.org/www}" + +: "${SPECIFICATION_SERVER:=specifications.freedesktop.org}" +: "${SPECIFICATION_PATH:=/srv/specifications.freedesktop.org/www/dbus/1.0}" + +if [ -n "${MESON_BUILD_ROOT-}" ]; then + cd "${MESON_BUILD_ROOT}" +fi + +if [ -n "${MESON_SOURCE_ROOT-}" ]; then + top_srcdir="${MESON_SOURCE_ROOT}" +else + # assume build directory is inside source directory + top_srcdir=".." +fi + +TMPDIR=$(mktemp -d) + +mkdir -p "$TMPDIR/api" +cp -r doc/api/html "$TMPDIR/api" +cp -r "$@" "$TMPDIR" +mv "$TMPDIR" dbus-docs +tar --xz -c -f dbus-docs.tar.xz dbus-docs + +scp dbus-docs.tar.xz "$DOC_SERVER:$DOC_WWW_DIR/" +rsync -rpvzP --chmod=Dg+s,ug+rwX,o=rX dbus-docs/ "$DOC_SERVER:$DOC_WWW_DIR/doc/" + +scp -p "$top_srcdir"/doc/*.dtd "$SPECIFICATION_SERVER:$SPECIFICATION_PATH/" diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 00000000..3e5f52a8 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,251 @@ +# Copyright © 2019-2020 Salamandar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# XML files used for Man and html doc +xmls_mans_htmls_names = [ + 'dbus-cleanup-sockets.1', + 'dbus-daemon.1', + 'dbus-launch.1', + 'dbus-monitor.1', + 'dbus-run-session.1', + 'dbus-send.1', + 'dbus-test-tool.1', + 'dbus-update-activation-environment.1', + 'dbus-uuidgen.1', +] +xml_files = [] +man_html_list = [] +foreach xml_in : xmls_mans_htmls_names + xml_file = configure_file( + input : xml_in + '.xml.in', + output: xml_in + '.xml', + configuration: data_config, + ) + man_html_list += { + 'xml' : xml_file, + 'man' : xml_in, + 'html' : xml_in + '.html', + } + xml_files += xml_file +endforeach + +# XML files used for html doc +xmls_names = [ + 'dbus-faq', + 'dbus-specification', + 'dbus-test-plan', + 'dbus-tutorial', +] +html_list = [] +foreach xml_in : xmls_names + html_list += { + 'xml' : xml_in + '.xml', + 'html' : xml_in + '.html', + } +endforeach + +# uploaded and distributed, but not installed +static_docs = files( + 'dbus-api-design.duck', + 'dbus-faq.xml', + 'dbus-specification.xml', + 'dbus-test-plan.xml', + 'dbus-tutorial.xml', + 'dcop-howto.txt', + 'introspect.xsl', +) + +############################################################################### +# Install man files + +if build_xml_docs + foreach man: man_html_list + custom_target(man.get('man'), + input: man.get('xml'), + output: man.get('man'), + command: [ + xsltproc, + '--nonet', + '--xinclude', + '--stringparam', 'man.output.quietly', '1', + '-o', '@OUTPUT@', + 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', + '@INPUT@', + ], + install: true, + install_dir: get_option('mandir') / 'man1', + ) + endforeach +endif + +############################################################################### +# Install html doc files + +html_files = [] +if build_xml_docs + foreach man: man_html_list + html_list + html_files += custom_target(man.get('html'), + input: man.get('xml'), + output: man.get('html'), + command: [ + xsltproc, + '--nonet', + '--xinclude', + '--stringparam', 'generate.consistent.ids', '1', + '-o', '@OUTPUT@', + 'http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl', + '@INPUT@', + ], + install: true, + install_dir: docs_dir, + ) + endforeach +endif + +docs_files = [ + 'system-activation.txt', + 'diagram.png', + 'diagram.svg', +] + +install_data( + sources: docs_files, + install_dir: docs_dir, +) + +configure_file( + input: 'index.html.in', + output: 'index.html', + configuration: data_config, + install_dir: docs_dir, +) + +############################################################################### +# Install dtd files + + +xml_dir = get_option('datadir') / 'xml' / 'dbus-1' +dtd_files = [ + 'busconfig.dtd', + 'introspect.dtd', +] + +install_data( + sources: dtd_files, + install_dir: xml_dir, +) + +configure_file( + input: 'catalog.xml.in', + output: 'catalog.xml', + install_dir: xml_dir, + configuration: {'DBUS_DTD_DIR': get_option('prefix') / xml_dir}, +) + +############################################################################### +# Doxygen +if doxygen.found() + qch_dir = get_option('qch_dir') + if qch_dir == '' + qch_dir = docs_dir + endif + + doxyfile = configure_file( + input: '../Doxyfile.in', + output: 'Doxyfile', + configuration: data_config, + ) + + dbus_srcs = run_command( + python, + files('list-doc-source.py'), + meson.project_source_root() / 'dbus', + check: true + ).stdout().strip().split('\n') + dbus_srcs += dbus_arch_deps_h + + doxygen_tgt = custom_target('doxygen', + input: doxyfile, + output: 'api', + depend_files: dbus_srcs, + command: [doxygen, doxyfile], + ) + alias_target('doxygen', doxygen_tgt) + + meson.add_install_script( + 'meson_post_install.py', + meson.current_build_dir(), + docs_dir, + meson.current_build_dir() / 'api/qch/dbus-@0@.qch'.format(version), + qch_dir, + # ignored further arguments, but for dependency + doxygen_tgt, + ) + + if xsltproc.found() + custom_target('dbus.devhelp2', + input: 'doxygen_to_devhelp.xsl', + output: 'dbus.devhelp2', + depends: [doxygen_tgt], + command: [ xsltproc, '-o', '@OUTPUT@', '@INPUT@', meson.current_build_dir() / 'api/xml/index.xml' ], + install: true, + install_dir: docs_dir, + ) + endif +endif + +if ducktype.found() and yelpbuild.found() + design_page = custom_target('dbus-api-design.page', + input: 'dbus-api-design.duck', + output: 'dbus-api-design.page', + command: [ ducktype, '-o', '@OUTPUT@', '@INPUT@' ], + ) + html_files += custom_target('dbus-api-design.html', + input: design_page, + output: [ + 'dbus-api-design.html', + 'yelp.js', + 'C.css', + 'highlight.pack.js', + ], + command: [ + yelpbuild, 'html', + '-o', meson.current_build_dir(), + '@INPUT@', + ], + install: true, + install_dir: docs_dir, + ) +endif + +if can_upload_docs + run_target('maintainer-upload-docs', + command: [ + find_program('maintainer-upload-docs.sh'), + files(docs_files), + files(dtd_files), + static_docs, + html_files, + xml_files, + bonus_files, + ], + depends: doxygen_tgt, + ) +endif diff --git a/doc/meson_post_install.py b/doc/meson_post_install.py new file mode 100644 index 00000000..be8e3b29 --- /dev/null +++ b/doc/meson_post_install.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# Copyright © 2019-2020 Salamandar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import sys +import shutil +from pathlib import Path + + +if __name__ == "__main__": + arg_builddir = sys.argv[1] + arg_docdir = sys.argv[2] + arg_qch = sys.argv[3] + arg_qchdir = sys.argv[4] + env_destdir = os.getenv('MESON_INSTALL_DESTDIR_PREFIX') + + builddir = Path(arg_builddir) + docdir = Path(arg_docdir) + qch = Path(arg_qch) + qchdir = Path(arg_qchdir) + destdir = Path(env_destdir) + apidir = Path(destdir /docdir / 'api') + shutil.rmtree(apidir, ignore_errors=True) + shutil.copytree(builddir / 'api/html', apidir) + if qch.is_file(): + shutil.copy(qch, destdir / qchdir) diff --git a/maint/i686-w64-mingw32.txt b/maint/i686-w64-mingw32.txt new file mode 100644 index 00000000..dd92c458 --- /dev/null +++ b/maint/i686-w64-mingw32.txt @@ -0,0 +1,33 @@ +# Copyright 2018-2020 Meson contributors +# SPDX-License-Identifier: Apache-2.0 + +[binaries] +c = '/usr/bin/i686-w64-mingw32-gcc' +cpp = '/usr/bin/i686-w64-mingw32-g++' +objc = '/usr/bin/i686-w64-mingw32-gcc' +ar = '/usr/bin/i686-w64-mingw32-ar' +strip = '/usr/bin/i686-w64-mingw32-strip' +pkgconfig = '/usr/bin/i686-w64-mingw32-pkg-config' +windres = '/usr/bin/i686-w64-mingw32-windres' +exe_wrapper = ['xvfb-run', '-a', 'wine'] +ld = '/usr/bin/i686-w64-mingw32-ld' +cmake = '/usr/bin/cmake' + +[properties] +# Directory that contains 'bin', 'lib', etc +root = '/usr/i686-w64-mingw32' +# Directory that contains 'bin', 'lib', etc for the toolchain and system libraries +sys_root = '/usr/i686-w64-mingw32/sys-root/mingw' + +[host_machine] +system = 'windows' +cpu_family = 'x86' +cpu = 'i686' +endian = 'little' + +[cmake] +CMAKE_BUILD_WITH_INSTALL_RPATH = 'ON' +CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = 'NEVER' +CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = 'ONLY' diff --git a/maint/update-authors.sh b/maint/update-authors.sh new file mode 100755 index 00000000..9718811e --- /dev/null +++ b/maint/update-authors.sh @@ -0,0 +1,11 @@ +# Copyright 2010 Lennart Poettering +# Copyright 2022 Simon McVittie +# SPDX-License-Identifier: MIT + +set -eux + +if [ -n "${MESON_SOURCE_ROOT-}" ]; then + cd "${MESON_SOURCE_ROOT}" +fi + +git shortlog -s -e | cut -c 8- | sort > AUTHORS diff --git a/maint/x86_64-w64-mingw32.txt b/maint/x86_64-w64-mingw32.txt new file mode 100644 index 00000000..80c3607a --- /dev/null +++ b/maint/x86_64-w64-mingw32.txt @@ -0,0 +1,33 @@ +# Copyright 2018-2020 Meson contributors +# SPDX-License-Identifier: Apache-2.0 + +[binaries] +c = '/usr/bin/x86_64-w64-mingw32-gcc' +cpp = '/usr/bin/x86_64-w64-mingw32-g++' +objc = '/usr/bin/x86_64-w64-mingw32-gcc' +ar = '/usr/bin/x86_64-w64-mingw32-ar' +strip = '/usr/bin/x86_64-w64-mingw32-strip' +pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config' +windres = '/usr/bin/x86_64-w64-mingw32-windres' +exe_wrapper = ['xvfb-run', '-a', 'wine'] +ld = '/usr/bin/x86_64-w64-mingw32-ld' +cmake = '/usr/bin/cmake' + +[properties] +# Directory that contains 'bin', 'lib', etc +root = '/usr/x86_64-w64-mingw32' +# Directory that contains 'bin', 'lib', etc for the toolchain and system libraries +sys_root = '/usr/x86_64-w64-mingw32/sys-root/mingw' + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' + +[cmake] +CMAKE_BUILD_WITH_INSTALL_RPATH = 'ON' +CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = 'NEVER' +CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = 'ONLY' diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..fa269d3b --- /dev/null +++ b/meson.build @@ -0,0 +1,1188 @@ +# Copyright © 2019-2020 Salamandar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +project('dbus', + 'c', 'cpp', + version: '1.14.99', + meson_version: '>=0.56', +) + +project_url = 'https://gitlab.freedesktop.org/dbus/dbus' + +cc = meson.get_compiler('c') +cpp = meson.get_compiler('cpp') + +windows = import('windows') +pkgconfig = import('pkgconfig') + +config = configuration_data() +# Used for dbus-arch-deps.h, separated from config.h +arch_config = configuration_data() +# Non-quoted variables +data_config = configuration_data() + +# Those will be checked for compiler compatibility and added at the end +compile_args = [] +link_args = [] + +install_emptydirs = [] +install_symlinks = [] + +############################################################################### +# Project configuration + +not_found = dependency('', required: false) + +version = meson.project_version() +config.set_quoted('VERSION', version) +data_config.set('VERSION', version) +data_config.set('DBUS_VERSION', version) + +ver_array = version.split('.') +arch_config.set('DBUS_VERSION', version) +arch_config.set('DBUS_MAJOR_VERSION', ver_array[0]) +arch_config.set('DBUS_MINOR_VERSION', ver_array[1]) +arch_config.set('DBUS_MICRO_VERSION', ver_array[2]) + +config.set_quoted('DBUS_DAEMON_NAME', 'dbus-daemon') + +############################################################################### +# libtool versioning - this applies to libdbus +# http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 + +## increment if the interface has additions, changes, removals. +lt_current = 36 +## increment any time the source changes; +## set to 0 if you increment CURRENT +lt_revision = 0 +## increment if any interfaces have been added; +## set to 0 if any interfaces have been changed or removed. +## removal has precedence over adding, so set to 0 if both happened. +lt_age = 33 + +soversion = (lt_current - lt_age) +version_info = '@0@.@1@.@2@'.format(soversion, lt_age, lt_revision) + +data_config.set('SOVERSION', soversion) + +############################################################################### +# System detection + +python = find_program('python3') + +host_os = host_machine.system() + +platform_windows = host_os.contains('windows') + +platform_cygwin = host_os.contains('cygwin') + +# TODO: meson doesn't actually have WinCE support +platform_win32ce = host_os.contains('mingw32ce') + +platform_unix = not platform_windows + +config.set('DBUS_UNIX', platform_unix) +config.set('DBUS_CYGWIN', platform_cygwin) +config.set('DBUS_WIN', platform_windows) +config.set('DBUS_WINCE', platform_win32ce) + +if platform_unix + platform = 'Unix' +elif platform_cygwin + platform = 'cygwin' +elif platform_win32ce + platform = 'win32ce' +elif platform_windows + platform = 'windows' +else + platform = 'unknown' +endif +message('Detected platform : @0@ (@1@)'.format(platform, host_os)) + +if platform_windows + config.set('FD_SETSIZE', 8192, + description: 'The maximum number of connections that can be handled at once' + ) + if platform_win32ce + config.set('_WIN32_WCE', '0x0502', description: 'Get newer W32 CE APIs') + else + config.set('_WIN32_WINNT', '0x0600', + description: 'Define to the minimum supported Windows version (Vista)' + ) + endif + + build_timestamp = run_command( + find_program('tools/build-timestamp.py'), + check: true, + ).stdout().strip() + + data_config.set('BUILD_TIMESTAMP', build_timestamp) + data_config.set('BUILD_FILEVERSION', ','.join(version.split('.'))) + + data_config.set('DBUS_VER_FILE_TYPE', 'VFT_DLL') + data_config.set('DBUS_VER_INTERNAL_NAME', 'libdbus-1-@0@' .format(soversion)) + data_config.set('DBUS_VER_ORIGINAL_NAME', 'libdbus-1-@0@.dll' .format(soversion)) +endif + +if platform_windows + conf_maybe_external = '' +else + conf_maybe_external = 'EXTERNAL' +endif +data_config.set('DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL', conf_maybe_external) + +if host_os.contains('solaris') + compile_args += [ + # Solaris' C library apparently needs these runes to be threadsafe... + '-D_POSIX_PTHREAD_SEMANTICS', + # ... this opt-in to get sockaddr_in6 and sockaddr_storage... + '-D__EXTENSIONS__', + # ... and this opt-in to get file descriptor passing support + ' -D_XOPEN_SOURCE=500', + ] +endif + +if host_machine.endian() == 'big' + config.set('WORDS_BIGENDIAN', 1) +endif + +# Integer sizes +int_types = [ + { + 'type': 'short', + 'size': cc.sizeof('short'), + }, { + 'type': 'int', + 'size': cc.sizeof('int'), + 'type_c': '(val)', + 'type_u_c': '(val)', + 'type_m': '', + }, { + 'type': 'long', + 'size': cc.sizeof('long'), + 'type_c': '(val##L)', + 'type_u_c': '(val##UL)', + 'type_m': 'l', + }, { + 'type': 'long long', + 'size': cc.sizeof('long long'), + 'type_c': '(val##LL)', + 'type_u_c': '(val##ULL)', + 'type_m': 'll', + }, { + 'type': '__int64', + 'size': cc.sizeof('__int64'), + 'type_c': '(val##i64)', + 'type_u_c': '(val##ui64)', + 'type_m': 'I64', + }, { + 'type': 'err' + }, +] + +foreach type : int_types + if type.get('type') == 'err' + error('Could not find a 64-bit integer type.') + endif + if type.get('size') == 8 + arch_config.set('DBUS_INT64_TYPE', type.get('type')) + arch_config.set('DBUS_INT64_CONSTANT', type.get('type_c')) + arch_config.set('DBUS_UINT64_CONSTANT', type.get('type_u_c')) + if platform_windows + # MSVCRT.dll printf() doesn't support %lld + arch_config.set('DBUS_INT64_MODIFIER', 'I64') + else + arch_config.set('DBUS_INT64_MODIFIER', type.get('type_m')) + endif + break + endif +endforeach + +foreach type : int_types + if type.get('type') == 'err' + error('Could not find a 32-bit integer type.') + endif + if type.get('size') == 4 + arch_config.set('DBUS_INT32_TYPE', type.get('type')) + break + endif +endforeach + +foreach type : int_types + if type.get('type') == 'err' + error('Could not find a 16-bit integer type.') + endif + if type.get('size') == 2 + arch_config.set('DBUS_INT16_TYPE', type.get('type')) + break + endif +endforeach + +############################################################################### +# Dependencies + +xsltproc = find_program('xsltproc', required: get_option('xml_docs')) +build_xml_docs = false + +if xsltproc.found() + build_xml_docs = true + foreach fmt: [ 'html', 'manpages' ] + xsl = 'http://docbook.sourceforge.net/release/xsl/current/@0@/docbook.xsl'.format(fmt) + if run_command([xsltproc, '--nonet', xsl], check : false).returncode() == 0 + continue + endif + + build_xml_docs = false + if get_option('xml_docs').enabled() + error('Docbook XSL "@0@" not found'.format(fmt)) + else + message('Docbook XSL "@0@" not found, disabled automatically'.format(fmt)) + endif + endforeach +endif + +# For doxygen +doxygen = find_program('doxygen', required: get_option('doxygen_docs')) +ducktype = find_program('ducktype', required: get_option('ducktype_docs')) +yelpbuild = find_program('yelp-build', required: get_option('ducktype_docs')) + +can_upload_docs = doxygen.found() and xsltproc.found() and ducktype.found() + +qhelpgen = find_program('qhelpgenerator', 'qhelpgenerator-qt5', required: get_option('qt_help')) +qt_help_generate = doxygen.found() and qhelpgen.found() + +data_config.set('DBUS_GENERATE_MAN', platform_windows ? 'NO' : 'YES') +data_config.set('DOXYGEN_QCH_FILE', meson.current_build_dir() + / 'doc' / 'api' / 'qch' / 'dbus-@0@.qch'.format(version)) +if qhelpgen.found() + data_config.set('DOXYGEN_QHG_LOCATION', qhelpgen.full_path()) + data_config.set('DOXYGEN_GENERATE_QHP', 'YES') +else + data_config.set('DOXYGEN_QHG_LOCATION', '') + data_config.set('DOXYGEN_GENERATE_QHP', 'NO') +endif +data_config.set('top_srcdir', meson.project_source_root()) +data_config.set('top_builddir', meson.project_build_root()) + + +threads = dependency('threads') +config.set('HAVE_MONOTONIC_CLOCK', cc.has_header_symbol('pthread.h', 'CLOCK_MONOTONIC')) + +glib = dependency( + 'glib-2.0', version: '>=2.40', + required: get_option('modular_tests'), + fallback: ['glib', 'libglib_dep'], + default_options: [ + 'tests=false', + ], +) +if platform_windows + gio = dependency('gio-windows-2.0', required: glib.found()) + have_gio_unix = false +else + gio = dependency('gio-unix-2.0', required: glib.found()) + have_gio_unix = gio.found() +endif +use_glib = glib.found() and gio.found() +config.set('DBUS_WITH_GLIB', use_glib) + +expat = dependency('expat') +if expat.type_name() == 'internal' + # Configure-time checks can't act on subprojects that haven't been + # built yet, but we know that subprojects/expat.wrap is a new enough + # version to have this + config.set('HAVE_XML_SETHASHSALT', true) +else + config.set('HAVE_XML_SETHASHSALT', cc.has_function('XML_SetHashSalt', dependencies: expat)) +endif + +selinux = dependency('libselinux', version: '>=2.0.86', required: get_option('selinux')) + +# the selinux code creates threads which requires libpthread even on linux +# TODO: smcv: actually we've stopped doing that. We still include in +# selinux.c (but probably shouldn't), and we don't actually create the thread; +# so this can probably be simplified. +config.set('HAVE_SELINUX', selinux.found() and threads.found()) + +apparmor = dependency('libapparmor', version: '>=2.8.95', required: get_option('apparmor')) +config.set('HAVE_APPARMOR', apparmor.found()) +config.set('HAVE_APPARMOR_2_10', apparmor.version().version_compare('>=2.10')) + +if get_option('inotify').disabled() + use_inotify = false +else + use_inotify = cc.has_header('sys/inotify.h') + if get_option('inotify').enabled() and not use_inotify + error('inotify support requested but not found') + endif +endif + +if get_option('epoll').disabled() + use_linux_epoll = false +else + use_linux_epoll = ( + cc.has_header('sys/epoll.h') and + cc.has_function('epoll_create1', prefix: '#include ') + ) + if get_option('epoll').enabled() and not use_linux_epoll + error('epoll support requested but not found') + endif +endif +config.set('DBUS_HAVE_LINUX_EPOLL', use_linux_epoll) + +if get_option('kqueue').disabled() + use_kqueue = false +else + use_kqueue = ( + cc.has_header('sys/event.h') and + cc.has_function('kqueue', prefix: '#include ') + ) + if get_option('kqueue').enabled() and not use_kqueue + error('kqueue support requested but not found') + endif +endif +config.set('DBUS_BUS_ENABLE_KQUEUE', use_kqueue) + +if get_option('launchd').disabled() + use_launchd = false +else + launchctl = find_program('launchctl', required: get_option('launchd')) + use_launchd = cc.has_header('launch.h') and launchctl.found() + if get_option('launchd').enabled() and not use_launchd + error('launchd support requested but not found') + endif +endif +config.set('DBUS_BUS_ENABLE_LAUNCHD', use_launchd) + +if use_launchd + launchd_agent_dir = get_option('launchd_agent_dir') + if launchd_agent_dir == '' + launchd_agent_dir = '/Library/LaunchAgents' + endif +endif + +systemd = dependency('libsystemd', version: '>=209', required: get_option('systemd')) +use_systemd = systemd.found() +config.set('HAVE_SYSTEMD', use_systemd) + +if use_systemd + # If not found in $PATH, we might still have systemd and systemctl at runtime + # (perhaps dbus is being compiled in a minimal chroot with no systemd). + # Assume the upstream-recommended location. Distributors with split /usr + # can override this with --native-file (see https://mesonbuild.com/Machine-files.html) + systemctl = find_program('systemctl', required: false) + if systemctl.found() + systemctl = systemctl.full_path() + else + systemctl = '/usr/bin/systemctl' + endif + + systemd_system_unitdir = get_option('systemd_system_unitdir') + systemd_user_unitdir = get_option('systemd_user_unitdir') + + systemd_dirs = dependency('systemd', required: false) + if systemd_system_unitdir == '' + systemd_system_unitdir = (systemd_dirs.found() + ? systemd_dirs.get_variable(pkgconfig: 'systemdsystemunitdir') + : '/lib/systemd/system' + ) + endif + if systemd_user_unitdir == '' + systemd_user_unitdir = (systemd_dirs.found() + ? systemd_dirs.get_variable(pkgconfig: 'systemduserunitdir') + : '/usr/lib/systemd/user' + ) + endif +else + systemctl = '' +endif +data_config.set('SYSTEMCTL', systemctl) + + + +use_traditional_activation = get_option('traditional_activation') +config.set('ENABLE_TRADITIONAL_ACTIVATION', use_traditional_activation) + +if not (use_systemd or use_traditional_activation) + warning('Traditional activation and systemd activation are both disabled, ' + + 'so service activation (automatically starting services that ' + + 'receive messages) will not work') +endif + + +have_console_owner_file = false +console_owner_file = get_option('solaris_console_owner_file') +if console_owner_file != '' + if not host_os.contains('solaris') + error('solaris_console_owner_file is only supported on Solaris)') + endif + have_console_owner_file = true + if console_owner_file == 'auto' + console_owner_file = '/dev/console' + else + endif +endif +config.set('HAVE_CONSOLE_OWNER_FILE', have_console_owner_file) +config.set_quoted('DBUS_CONSOLE_OWNER_FILE', console_owner_file) + +if get_option('libaudit').disabled() + have_libaudit = false +else + libaudit = cc.find_library('audit', required: false) + libaudit_ok = cc.has_function('audit_log_user_avc_message', dependencies: libaudit) + cap_ng = cc.find_library('cap-ng', required: false) + cap_ng_ok = cc.has_function('capng_clear', dependencies: cap_ng) + have_libaudit = libaudit_ok and cap_ng_ok + if get_option('libaudit').enabled() and not have_libaudit + error('libaudit support requested but not found') + endif +endif +config.set('HAVE_LIBAUDIT', have_libaudit) + +if have_libaudit + selinux = [ selinux, libaudit, cap_ng ] +endif + +# Check for ADT API (Solaris Basic Security Mode auditing) +adt_api_check = cc.compiles(''' +#include +int main() { + adt_user_context = ADT_USER; + return 0; +} +''') +config.set('HAVE_ADT', adt_api_check) +if adt_api_check + adt_libs = cc.find_library('bsm') +else + adt_libs = dependency('', required: false) +endif + +# Check for SCM_RIGHTS +has_scm_rights = cc.compiles(''' +#include +#include +#include +int main() { + static int x = SCM_RIGHTS; + return 0; +} +''') +config.set('HAVE_UNIX_FD_PASSING', has_scm_rights) + +valgrind = dependency( + 'valgrind', + version: '>=3.6', + required: get_option('valgrind'), +) +config.set('WITH_VALGRIND', valgrind.found()) + +if platform_win32ce + network_libs = [ + cc.find_library('ws2'), + ] +elif platform_windows + network_libs = [ + cc.find_library('ws2_32'), + cc.find_library('iphlpapi'), + cc.find_library('dbghelp'), + ] +else + network_libs = [] +endif + +if get_option('x11_autolaunch').disabled() + use_x11_autolaunch = false + x11 = not_found +else + if get_option('x11_autolaunch').enabled() and platform_windows + error('X11 autolaunch is not supported on Windows') + endif + + x11 = dependency('x11', required: false) + use_x11_autolaunch = x11.found() + + if get_option('x11_autolaunch').enabled() and not use_x11_autolaunch + error('X11 autolaunch support requested but not found') + endif +endif +config.set('DBUS_BUILD_X11', use_x11_autolaunch) +config.set('DBUS_ENABLE_X11_AUTOLAUNCH', use_x11_autolaunch) + + +check_functions = [ + 'accept4', + 'clearenv', + 'closefrom', + 'close_range', + 'fpathconf', + 'getgrouplist', + 'getpeereid', + 'getpeerucred', + 'getpwnam_r', + 'getrandom', + 'getresuid', + 'getrlimit', + 'inotify_init1', + 'issetugid', + 'localeconv', + 'nanosleep', + 'pipe2', + 'poll', + 'prctl', + 'prlimit', + 'raise', + 'setenv', + 'setlocale', + 'setresuid', + 'setrlimit', + 'socketpair', + 'strtoll', + 'strtoull', + 'unsetenv', + 'usleep', +] + +foreach function : check_functions + macro = 'HAVE_' + function.underscorify().to_upper() + config.set(macro, cc.has_function(function) ? 1 : false) +endforeach + +check_headers = [ + 'alloca.h', + 'byteswap.h', + 'crt_externs.h', + 'dirent.h', + 'errno.h', + 'inttypes.h', + 'io.h', + 'locale.h', + 'linux/close_range.h', + 'locale.h', + 'signal.h', + 'stdint.h', + 'syslog.h', + 'sys/prctl.h', + 'sys/random.h', + 'sys/resource.h', + 'sys/syscall.h', + 'sys/syslimits.h', + 'sys/time.h', + 'unistd.h', + 'ws2tcpip.h', +] + +foreach header : check_headers + macro = 'HAVE_' + header.underscorify().to_upper() + config.set(macro, cc.has_header(header) ? 1 : false) +endforeach + +execinfo = cc.find_library('execinfo', required: false) +have_backtrace = (cc.has_header('execinfo.h') + and cc.has_function('backtrace', dependencies: execinfo) +) +config.set('HAVE_BACKTRACE', have_backtrace) + + +# ********************************** +# *** va_copy checks (from GLib) *** +# ********************************** +# we currently check for all three va_copy possibilities, so we get +# all results in config.log for bug reports. + +# Can't use cc.has_function here because va_copy is not +# exactly a function +va_copy_check = ''' +#include +#include + +static void f (int i, ...) +{ + va_list args1, args2; + va_start (args1, i); + @0@ (args2, args1); + + if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) + exit (1); + + va_end (args1); + va_end (args2); +} + +int main() +{ + f (0, 42); + return 0; +} +''' + +has_va_copy = cc.links(va_copy_check.format('va_copy')) +has___va_copy = cc.links(va_copy_check.format('__va_copy')) + +if has_va_copy + va_copy = 'va_copy' +elif has___va_copy + va_copy = '__va_copy' +elif cc.get_id() == 'msvc' + va_copy = '_DBUS_VA_COPY_ASSIGN' + config.set('_DBUS_VA_COPY_ASSIGN(a1,a2)', '{ a1 = a2; }') +else + error('dbus requires an ISO C99-compatible va_copy() macro, ' + + 'or a compatible __va_copy()') +endif +config.set('DBUS_VA_COPY', va_copy) + + +# Can't use cc.has_function here because atomic operations are not +# exactly functions +config.set10( + 'DBUS_USE_SYNC', + cc.links(''' + int main(void) + { + int a = 4; + int b = __sync_sub_and_fetch (&a, 4); + return b; + } + ''') +) + +config.set10('HAVE_DECL_ENVIRON', cc.has_header_symbol('unistd.h', 'environ')) +config.set10('HAVE_DECL_LOG_PERROR', + cc.has_header_symbol('syslog.h', 'LOG_PERROR') +) +config.set10('HAVE_DECL_MSG_NOSIGNAL', + cc.has_header_symbol('sys/socket.h', 'MSG_NOSIGNAL') +) +config.set('HAVE_SOCKLEN_T', + cc.has_type('socklen_t', prefix: '#include ') +) +config.set('HAVE_CMSGCRED', + cc.has_type('struct cmsgcred', prefix: '#include ') +) + +config.set('HAVE_WRITEV', + cc.has_header_symbol('sys/uio.h', 'writev') +) + +config.set('HAVE_UNPCBID', + cc.has_member('struct unpcbid', 'unp_pid', prefix: '#include ') +) + + +############################################################################### +# Project options + +# Verbose mode +verbose_mode = get_option('verbose_mode') +config.set('DBUS_ENABLE_VERBOSE_MODE', verbose_mode) + +# Asserts defaults to developer mode +asserts = get_option('asserts') +config.set('DBUS_ENABLE_ASSERT', asserts ? 1 : false) +config.set('DBUS_DISABLE_ASSERT', not asserts ? 1 : false) + +# -rdynamic is needed for glibc's backtrace_symbols to work. +# No clue how much overhead this adds, but it's useful +# to do this on any assertion failure, +# so for now it's enabled anytime asserts are (currently not +# in production builds). +# To get -rdynamic you pass -export-dynamic to libtool. +config.set('DBUS_BUILT_R_DYNAMIC', asserts ? 1 : false) +if asserts + link_args += '-export-dynamic' +endif + +if not asserts + compile_args += [ + '-Wno-unused-but-set-variable', + '-Wno-unused-variable', + '-Wno-unused-function', + ] +endif + + +checks = get_option('checks') +config.set('DBUS_ENABLE_CHECKS', checks ? 1 : false) +config.set('DBUS_DISABLE_CHECKS', not checks ? 1 : false) +config.set('G_DISABLE_CHECKS', not checks ? 1 : false) +config.set('HAVE_GIO_UNIX', have_gio_unix ? 1 : false) +# Ignore post-2.38 deprecations, prevent use of post-2.44 APIs. +config.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_38') +config.set('GLIB_VERSION_MAX_ALLOWED', 'G_ENCODE_VERSION(2,44)') + +windows_output_debug = get_option('windows_output_debug_string') +config.set('DBUS_USE_OUTPUT_DEBUG_STRING', windows_output_debug) + +dbus_static_flags = ( get_option('default_library') == 'static' + ? '-DDBUS_STATIC_BUILD' + : [] +) +compile_args += dbus_static_flags + + +# DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files +# and some stuff in the test/ subdir. +embedded_tests = get_option('embedded_tests') +config.set('DBUS_ENABLE_EMBEDDED_TESTS', embedded_tests) + + +# DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API. +# These use GTest, from GLib, because life's too short. They're enabled by +# default (unless you don't have GLib), because they don't bloat the library +# or binaries. +dbus_enable_modular_tests = ( + not get_option('modular_tests').disabled() + and glib.version().version_compare('>=2.40') + and gio.found() +) + +############################################################################### +# Paths and directories + +docs_dir = get_option('datadir') / 'doc' / 'dbus' + +# TODO: If a future Meson version gets a runstatedir option, try both. +# https://github.com/mesonbuild/meson/issues/4141 +runstatedir = get_option('runtime_dir') + +if runstatedir == '' + if get_option('prefix') == '/usr' + runstatedir = '/run' + else + runstatedir = get_option('localstatedir') / 'run' + endif +endif + +data_config.set('EXPANDED_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir')) +data_config.set('EXPANDED_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir')) +data_config.set('EXPANDED_RUNSTATEDIR', get_option('prefix') / runstatedir) +data_config.set('EXPANDED_BINDIR', get_option('prefix') / get_option('bindir')) +data_config.set('EXPANDED_DATADIR', get_option('prefix') / get_option('datadir')) + +data_config.set('DBUS_PREFIX', get_option('prefix')) +config.set_quoted('DBUS_PREFIX', get_option('prefix')) +config.set_quoted('DBUS_BINDIR', get_option('prefix') / get_option('bindir')) +config.set_quoted('DBUS_DATADIR',get_option('prefix') / get_option('datadir')) +data_config.set('DBUS_LIBEXECDIR', get_option('prefix') / get_option('libexecdir')) + +config.set_quoted('DBUS_RUNSTATEDIR', + get_option('prefix') / runstatedir +) +config.set_quoted('DBUS_MACHINE_UUID_FILE', + get_option('prefix') / get_option('localstatedir') / 'lib'/'dbus'/'machine-id' +) +config.set_quoted('DBUS_SYSTEM_CONFIG_FILE', + get_option('prefix') / get_option('datadir') / 'dbus-1' / 'system.conf' +) +config.set_quoted('DBUS_SESSION_CONFIG_FILE', + get_option('prefix') / get_option('datadir') / 'dbus-1' / 'session.conf' +) + + +system_socket = get_option('system_socket') +if system_socket == '' + # We don't use runstatedir for this (yet?), because /var/run has been the + # interoperable system bus socket for 10+ years. + # See https://bugs.freedesktop.org/show_bug.cgi?id=101628 + system_socket = ( + get_option('prefix') + / get_option('localstatedir') + /'run'/'dbus'/'system_bus_socket' + ) +endif +data_config.set('DBUS_SYSTEM_SOCKET', system_socket) + +## System bus only listens on local domain sockets, and never +## on an abstract socket (so only root can create the socket). +## +## This won't work on Windows. It's not meant to - the system bus is +## meaningless on Windows anyway. +## +## This has to be suitable for hard-coding in client libraries as well as +## in the dbus-daemon's configuration, so it has to be valid to listen on +## and also to connect to. If this ever changes, it'll need to be split into +## two variables, one for the listening address and one for the connecting +## address. +system_bus_default_address = 'unix:path=@0@'.format(system_socket) +data_config.set('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS', system_bus_default_address) +config.set_quoted('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS', system_bus_default_address) + + +system_pid_file = get_option('system_pid_file') +if system_pid_file == '' + system_pid_file = get_option('prefix') / runstatedir / 'dbus'/'pid' +endif +data_config.set('DBUS_SYSTEM_PID_FILE', system_pid_file) + + +dbus_user = get_option('dbus_user') +data_config.set('DBUS_USER', dbus_user) +config.set_quoted('DBUS_USER', dbus_user) + +test_user = get_option('test_user') +config.set_quoted('DBUS_TEST_USER', test_user) + +daemon_dir = get_option('dbus_daemondir') +if daemon_dir == '' + daemon_dir = get_option('prefix') / get_option('bindir') +endif +data_config.set('DBUS_DAEMONDIR', daemon_dir) +config.set_quoted('DBUS_DAEMONDIR', daemon_dir) + + + +# Relocation is disabled by default, let's check if we need to enable it +relocation = false +if get_option('relocation').enabled() + # Manually forced at true + relocation = true +endif +if get_option('relocation').auto() and platform_windows + # By default, on Windows we are relocatable if possible + relocation = true +endif + +# Now check if it's not possible +# Meson does not separate exec_prefix and prefix (hopefully) +if relocation and not (get_option('libdir') in [ 'lib', 'lib64', ]) + message = ( + 'Relocatable pkg-config metadata requires default libdir, ' + + 'not @0@'.format(get_option('libdir')) + ) + if get_option('relocation').enabled() + error(message) + else + warning(message) + endif +endif + +#### Directory to source sysconfdir configuration from + +# On Windows this is relative to where we put the bus setup, in +# ${datadir}/dbus-1. For simplicity, we only do this if +# ${sysconfdir} = ${prefix}/etc and ${datadir} = ${prefix}/share. +# +# On Unix, or on Windows with weird install layouts, it's the absolute path. +if (platform_windows + and data_config.get('EXPANDED_SYSCONFDIR') == get_option('prefix') / 'etc' + and data_config.get('EXPANDED_DATADIR') == get_option('prefix') / 'share' +) + sysconfdir_from_pkgdatadir = '../../etc' + datadir_from_pkgsysconfdir = '../../share' +else + sysconfdir_from_pkgdatadir = data_config.get('EXPANDED_SYSCONFDIR') + datadir_from_pkgsysconfdir = data_config.get('EXPANDED_DATADIR') +endif +data_config.set('SYSCONFDIR_FROM_PKGDATADIR', sysconfdir_from_pkgdatadir) +data_config.set('DATADIR_FROM_PKGSYSCONFDIR', datadir_from_pkgsysconfdir) + +#### Find socket directories +values = run_command(python, '-c', + 'import os; [print(os.getenv(e, "")) for e in ["TMPDIR", "TEMP", "TMP"]]', + check: true, +).stdout() +values += '/tmp' +default_socket_dir = values.strip().split('\n')[0] + +test_socket_dir = get_option('test_socket_dir') +if test_socket_dir == '' + test_socket_dir = default_socket_dir +endif +test_listen = platform_unix ? 'unix:tmpdir=' + test_socket_dir : 'tcp:host=localhost' +config.set_quoted('TEST_LISTEN', test_listen) +data_config.set('TEST_LISTEN', test_listen) + +session_socket_dir = get_option('session_socket_dir') +if session_socket_dir == '' + session_socket_dir = default_socket_dir +endif +config.set_quoted('DBUS_SESSION_SOCKET_DIR', session_socket_dir) + +# This must be a listening address. It doesn't necessarily need to be an +# address you can connect to - it can be something vague like +# "nonce-tcp:". +session_bus_listen_address = get_option('dbus_session_bus_listen_address') +if session_bus_listen_address == '' + if platform_windows + # On Windows, you can (and should) listen on autolaunch addresses, + # because autolaunching is not the same as X11 autolaunching. + session_bus_listen_address = 'autolaunch:' + elif use_launchd + # macOS default is to use launchd + session_bus_listen_address = 'launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET' + else + # The default on all other Unix platforms (notably Linux) + # is to create a randomly named socket in /tmp or similar + session_bus_listen_address = 'unix:tmpdir=@0@'.format(session_socket_dir) + endif +endif +data_config.set('DBUS_SESSION_BUS_LISTEN_ADDRESS', session_bus_listen_address) + + +# This must be an address you can connect to. It doesn't necessarily +# need to be an address you can listen on - it can be "autolaunch:", +# even on Unix. +session_bus_connect_address = get_option('dbus_session_bus_connect_address') +if session_bus_connect_address == '' + session_bus_connect_address = 'autolaunch:' +endif +config.set_quoted('DBUS_SESSION_BUS_CONNECT_ADDRESS', session_bus_connect_address) + + +config.set('DBUS_ENABLE_STATS', get_option('stats')) +config.set('DBUS_ENABLE_CONTAINERS', get_option('containers')) +enable_user_session = get_option('user_session') + + +config.set('DBUS_COMPILATION', true) + +exe_ext = platform_windows ? '.exe' : '' +config.set_quoted('DBUS_EXEEXT', exe_ext) + +compile_args_c = [] +compile_args += [ + '-D_GNU_SOURCE', +] + +if cc.get_id() == 'msvc' + compile_args += [ + # once + '/wo4018', # 'expression' : signed/unsigned mismatch + # disabled + '/wd4090', # 'operation' : different 'modifier' qualifiers + '/wd4101', # 'identifier' : unreferenced local variable + '/wd4127', # conditional expression is constant + '/wd4244', # 'argument' : conversion from 'type1' to 'type2', possible loss of data + # error + '/we4002', # too many actual parameters for macro 'identifier' + '/we4003', # not enough actual parameters for macro 'identifier' + '/we4013', # 'function' undefined; assuming extern returning int + '/we4028', # formal parameter 'number' different from declaration + '/we4031', # second formal parameter list longer than the first list + '/we4047', # operator' : 'identifier1' differs in levels of indirection from 'identifier2' + '/we4114', # same type qualifier used more than once + '/we4133', # 'type' : incompatible types - from 'type1' to 'type2' + ] +else + compile_args += [ + '-Wno-missing-field-initializers', + '-Wno-unused-parameter', + '-Wchar-subscripts', + '-Wfloat-equal', + # On Windows, we expect to be using msvcrt.dll-compatible printf + # (%I64u instead of %llu) + '-D__USE_MINGW_ANSI_STDIO=0', + ] + + compile_args_c += [ + '-Wpointer-sign', + ] +endif + +compile_args_c = cc .get_supported_arguments(compile_args + compile_args_c) +compile_args_cpp= cpp.get_supported_arguments(compile_args) +link_args = cc.get_supported_link_arguments(link_args) +add_project_arguments(compile_args_c, language: 'c') +add_project_arguments(compile_args_cpp, language: 'cpp') +add_project_link_arguments(link_args, language: [ 'c', 'cpp' ]) + +root_include = include_directories('.') + +configure_file( + output: 'config.h', + configuration: config, +) + +bonus_files = files( + 'AUTHORS', + 'CONTRIBUTING.md', + 'COPYING', + 'NEWS', + 'README', +) + +if platform_unix + run_target( + 'maintainer-update-authors', + command: 'maint/update-authors.sh', + ) +endif + +subdir('dbus') +subdir('bus') +subdir('tools') +subdir('test') +subdir('doc') +subdir('cmake') + +meson.add_install_script('meson_post_install.py', + '@0@'.format(relocation), +) + +pkgconfig.generate( + libdbus, + name: 'dbus', + filebase: 'dbus-1', + description: 'Free desktop message bus', + subdirs: [ 'dbus-1.0' ], + extra_cflags: [ + '-I${libdir}/dbus-1.0/include', + ] + dbus_static_flags, + variables: { + 'original_prefix': get_option('prefix'), + + 'exec_prefix': '${prefix}', + 'bindir': '${prefix}' / get_option('bindir'), + 'datadir': '${prefix}' / get_option('datadir'), + 'datarootdir': '${prefix}' / get_option('datadir'), + 'sysconfdir': '${prefix}' / get_option('sysconfdir'), + + 'daemondir': '${bindir}', + 'system_bus_default_address': system_bus_default_address, + 'session_bus_services_dir': '${datadir}/dbus-1/services', + 'system_bus_services_dir': '${datadir}/dbus-1/system-services', + 'interfaces_dir': '${datadir}/dbus-1/interfaces', + } +) + +if meson.version().version_compare('>=0.60.0') + foreach dir : install_emptydirs + install_emptydir(dir) + endforeach +else + meson.add_install_script( + 'tools/meson-compat-install-emptydirs.py', + ':'.join(install_emptydirs), + ) +endif + +foreach symlink : install_symlinks + if not platform_unix + warning( + 'Not creating symbolic link @0@/@1@ -> @2@'.format( + symlink['install_dir'], + symlink['link_name'], + symlink['pointing_to'], + ) + ) + elif meson.version().version_compare('>=0.61.0') + install_symlink( + symlink['link_name'], + install_dir : symlink['install_dir'], + pointing_to : symlink['pointing_to'], + ) + else + meson.add_install_script( + 'tools/meson-compat-install-symlink.py', + symlink['link_name'], + symlink['install_dir'], + symlink['pointing_to'], + ) + endif +endforeach + +summary_dict = { + 'prefix': get_option('prefix'), + 'exec_prefix': get_option('prefix'), + 'libdir': get_option('prefix') / get_option('libdir'), + 'libexecdir': get_option('prefix') / get_option('libexecdir'), + 'bindir': get_option('prefix') / get_option('bindir'), + 'sysconfdir': data_config.get('EXPANDED_SYSCONFDIR'), + 'localstatedir': data_config.get('EXPANDED_LOCALSTATEDIR'), + 'runstatedir': data_config.get('EXPANDED_RUNSTATEDIR'), + 'datadir': data_config.get('EXPANDED_DATADIR'), + 'source code location': meson.project_source_root(), + 'compiler': cc.get_id(), + 'cflags': compile_args_c, + 'cxxflags': compile_args_cpp, + 'ldflags': (link_args.length() == 0) ? '[]' : link_args, + '64-bit int': arch_config.get('DBUS_INT64_TYPE'), + '32-bit int': arch_config.get('DBUS_INT32_TYPE'), + '16-bit int': arch_config.get('DBUS_INT16_TYPE'), + 'xsltproc': xsltproc.found() ? xsltproc.full_path() : '', + 'Doxygen': doxygen.found() ? doxygen.full_path() : '', + 'ducktype': ducktype.found() ? ducktype.full_path() : '', + 'yelp-build': yelpbuild.found() ? yelpbuild.full_path() : '', + + 'gcc coverage': get_option('b_coverage'), + 'gcc profiling': get_option('b_pgo'), + 'Building embedded tests': embedded_tests, + 'Building modular tests': dbus_enable_modular_tests, + '- with GLib': use_glib, + 'Installing tests': get_option('installed_tests'), + 'Building verbose mode': verbose_mode, + 'Building assertions': asserts, + 'Building checks': checks, + 'Building bus stats API': get_option('stats'), + 'Building container API': get_option('containers'), + 'Building SELinux support': config.get('HAVE_SELINUX'), + 'Building AppArmor support': apparmor.found(), + 'Building inotify support': use_inotify, + 'Building kqueue support': use_kqueue, + 'Building systemd support': use_systemd, + 'Traditional activation': use_traditional_activation, + 'Building X11 code': config.get('DBUS_BUILD_X11'), + 'Building Doxygen docs': doxygen.found(), + 'Building Qt help file': qt_help_generate, + 'Building Ducktype docs': ducktype.found(), + 'Building XML docs': build_xml_docs, + 'Building launchd support': use_launchd, + 'System bus socket': data_config.get('DBUS_SYSTEM_SOCKET'), + 'System bus address': config.get('DBUS_SYSTEM_BUS_DEFAULT_ADDRESS'), + 'System bus PID file': data_config.get('DBUS_SYSTEM_PID_FILE'), + 'Session bus listens on': data_config.get('DBUS_SESSION_BUS_LISTEN_ADDRESS'), + 'Session clients connect to': config.get('DBUS_SESSION_BUS_CONNECT_ADDRESS'), + 'System bus user': dbus_user, + 'Session bus services dir': + get_option('prefix') / get_option('datadir') / 'dbus-1' / 'services', + 'Tests socket dir': test_socket_dir, +} + +if host_os.contains('solaris') + summary_dict += { + 'Console owner file': console_owner_file, + } +endif + +summary(summary_dict, bool_yn: true) + +if embedded_tests + warning('building with unit tests increases the size of the installed library and renders it insecure.') + if not asserts + warning('building with embedded tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)') + endif +endif + +if get_option('b_coverage') + warning('Building with coverage profiling is definitely for developers only.') +endif + +if verbose_mode + warning('building with verbose mode increases library size, may slightly increase security risk, and decreases performance.') +endif + +if asserts + warning('building with assertions increases library size and decreases performance.') +endif + +if not checks + warning('building without checks for arguments passed to public API makes it harder to debug apps using D-Bus, but will slightly decrease D-Bus library size and _very_ slightly improve performance.') +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..68f91f19 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,300 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +option( + 'apparmor', + type: 'feature', + value: 'auto', + description: 'AppArmor support' +) + +option( + 'asserts', + type: 'boolean', + value: false, + description: 'Include assertion checks' +) + +option( + 'checks', + type: 'boolean', + value: true, + description: 'Check for usage errors at public API' +) + +option( + 'containers', + type: 'boolean', + value: false, + description: 'Enable restricted servers for app containers' +) + +option( + 'dbus_daemondir', + type: 'string', + description: 'Directory for installing the dbus-daemon' +) + +option( + 'dbus_user', + type: 'string', + description: 'User for running the system dbus-daemon', + value: 'messagebus' +) + +option( + 'dbus_session_bus_connect_address', + type: 'string', + value: '', + description: 'Fallback address for a session bus client to connect to', +) + +option( + 'dbus_session_bus_listen_address', + type: 'string', + value: '', + description: 'Default address for a session bus to listen on', +) + +option( + 'doxygen_docs', + type: 'feature', + value: 'auto', + description: 'Build Doxygen documentation' +) + +option( + 'ducktype_docs', + type: 'feature', + value: 'auto', + description: 'Build Ducktype documentation' +) + +option( + 'embedded_tests', + type: 'boolean', + value: false, + description: 'Enable unit test code in the library and binaries' +) + +option( + 'epoll', + type: 'feature', + value: 'auto', + description: 'Use epoll(4) on Linux' +) + +option( + 'inotify', + type: 'feature', + value: 'auto', + description: 'Inotify support on Linux' +) + +option( + 'installed_tests', + type: 'boolean', + value: false, + description: 'Install automated tests for "as-installed" testing' +) + +option( + 'kqueue', + type: 'feature', + value: 'auto', + description: 'Kqueue support' +) + +option( + 'launchd', + type: 'feature', + value: 'auto', + description: 'Launchd auto-launch support' +) + +option( + 'launchd_agent_dir', + type: 'string', + description: 'Directory to put the launchd agent' +) + +option( + 'libaudit', + type: 'feature', + value: 'auto', + description: 'Audit logging support for SELinux and AppArmor' +) + +option( + 'modular_tests', + type: 'feature', + value: 'auto', + description: 'Enable modular regression tests (requires GLib)' +) + +option( + 'qch_dir', + type: 'string', + description: 'Directory to put the Qt help file' +) + +option( + 'qt_help', + type: 'feature', + value: 'auto', + description: 'Build Qt help documentation' +) + +option( + 'relocation', + type: 'feature', + value: 'auto', + description: 'Make pkg-config metadata relocatable' +) + +# Deliberately not named runstatedir to avoid colliding with +# https://github.com/mesonbuild/meson/issues/4141 +option( + 'runtime_dir', + type: 'string', + value: '', + description: 'Directory for transient runtime state [default: LOCALSTATEDIR/run or /run]' +) + +option( + 'selinux', + type: 'feature', + value: 'auto', + description: 'SELinux support' +) + +option( + 'session_socket_dir', + type: 'string', + description: 'Where to put sockets for the per-login-session message bus' +) + +option( + 'solaris_console_owner_file', + type: 'string', + value: '', + description: 'File to determine current console owner on Solaris (or "auto")' +) + +option( + 'stats', + type: 'boolean', + value: true, + description: 'Enable bus daemon usage statistics' +) + +option( + 'system_pid_file', + type: 'string', + description: 'PID file for systemwide daemon' +) + +option( + 'system_socket', + type: 'string', + description: 'UNIX domain socket for systemwide daemon' +) + +option( + 'systemd_system_unitdir', + type: 'string', + description: 'Directory for systemd system service files' +) + +option( + 'systemd_user_unitdir', + type: 'string', + description: 'Directory for systemd user service files' +) + +option( + 'systemd', + type: 'feature', + value: 'auto', + description: 'Systemd at_console support' +) + +option( + 'test_socket_dir', + type: 'string', + description: 'Where to put sockets for make check' +) + +option( + 'test_user', + type: 'string', + description: 'Unprivileged user for regression tests, other than root and the dbus_user', + value: 'nobody' +) + +option( + 'traditional_activation', + type: 'boolean', + value: true, + description: 'Build support for service activation without using SystemdService' +) + +option( + 'user_session', + type: 'boolean', + value: true, + description: 'Enable user-session semantics for session bus under systemd' +) + +option( + 'valgrind', + type: 'feature', + value: 'disabled', + description: 'Build with Valgrind instrumentation (note that this currently adds a hard dependency on valgrind)' +) + +option( + 'verbose_mode', + type: 'boolean', + value: false, + description: 'Support verbose debug mode' +) + +option( + 'x11_autolaunch', + type: 'feature', + value: 'auto', + description: 'Build with X11 auto-launch support' +) + +option( + 'xml_docs', + type: 'feature', + value: 'auto', + description: 'Build XML documentation' +) + +option( + 'windows_output_debug_string', + type: 'boolean', + value: false, + description: 'use OutputDebugString() to log messages to Windows debug port' +) diff --git a/meson_post_install.py b/meson_post_install.py new file mode 100755 index 00000000..30cb7bdf --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +# Copyright © 2019-2020 Salamandar +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os, sys, stat +from pathlib import Path +import shlex, subprocess, json + +meson = shlex.split(os.environ.get('MESONINTROSPECT', '')) +introspection = json.loads(subprocess.check_output(meson + ['-a']).decode()) +build_options = introspection['buildoptions'] +targets = introspection['targets'] + +def get_option(name): + for i in build_options: + if i['name'] == name: + return i['value'] + return None + +def get_target(name): + for i in targets: + if i['name'] == name: + return i + return None + +destdir = Path(os.getenv('DESTDIR')) if 'DESTDIR' in os.environ else None +prefix = Path(get_option('prefix')) +destdir_prefix = Path(os.getenv('MESON_INSTALL_DESTDIR_PREFIX')) + +def to_destdir(path): + path_abs = prefix / path + if destdir: + path_rel_root = path_abs.relative_to(path_abs.anchor) + path_final = destdir / path_rel_root + return path_final + else: + return path_abs + +############################################################################### + +# Define paths here +abs_libexecdir = destdir_prefix / get_option('libexecdir') + +relocation = sys.argv[1].lower() == 'true' + +def post_install_relocation(): + # Edit pkg-config file to replace the prefix + # + # TODO: Meson >=0.63 has a new feature, -Dpkgconfig.relocatable=true. + + if not relocation: + return + + pc_filepath = next( + v for (k,v) in introspection['installed'].items() if k.endswith('.pc') + ) + # Find the really installed path + pc_filepath = to_destdir(pc_filepath) + + with open(pc_filepath, 'r') as pcfile: + lines = pcfile.readlines() + with open(pc_filepath, 'w') as pcfile: + for line in lines: + if line.startswith('prefix='): + line = 'prefix=${pcfiledir}/../..\n' + pcfile.write(line) + +def post_install_exe(): + # Setuid, chmod and chown for dbus-daemon-launch-helper + daemon_launch_helper = get_target('dbus-daemon-launch-helper') + if daemon_launch_helper: + import grp + exe_name = os.path.basename(daemon_launch_helper['install_filename'][0]) + exe_path = abs_libexecdir / exe_name + dbus_user = get_option('dbus_user') + if os.getuid() == 0: + os.chown(exe_path, 0, grp.getgrnam(dbus_user).gr_gid) + os.chmod(exe_path, stat.S_ISUID | stat.S_IXUSR | stat.S_IXGRP) + else: + print('Not installing {0} binary setuid!'.format(exe_path)) + print('You\'ll need to manually set permissions to root:{0} and permissions 4750' + .format(dbus_user) + ) + + +if __name__ == "__main__": + post_install_relocation() + post_install_exe() diff --git a/subprojects/expat.wrap b/subprojects/expat.wrap new file mode 100644 index 00000000..26fe9677 --- /dev/null +++ b/subprojects/expat.wrap @@ -0,0 +1,14 @@ +# Copyright 2022 Meson contributors +# SPDX-License-Identifier: MIT + +[wrap-file] +directory = expat-2.4.8 +source_url = https://github.com/libexpat/libexpat/releases/download/R_2_4_8/expat-2.4.8.tar.xz +source_filename = expat-2.4.8.tar.bz2 +source_hash = f79b8f904b749e3e0d20afeadecf8249c55b2e32d4ebb089ae378df479dcaf25 +patch_filename = expat_2.4.8-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/expat_2.4.8-1/get_patch +patch_hash = 9aec253a2c6d1c0feb852c5c6920298d14701eeec7acc6832bb402438b52112a + +[provide] +expat = expat_dep diff --git a/subprojects/glib.wrap b/subprojects/glib.wrap new file mode 100644 index 00000000..b01294b6 --- /dev/null +++ b/subprojects/glib.wrap @@ -0,0 +1,13 @@ +# Copyright 2022 Meson contributors +# SPDX-License-Identifier: MIT + +[wrap-file] +directory = glib-2.72.2 +source_url = https://download.gnome.org/sources/glib/2.72/glib-2.72.2.tar.xz +source_filename = glib-2.72.2.tar.xz +source_hash = 78d599a133dba7fe2036dfa8db8fb6131ab9642783fc9578b07a20995252d2de +wrapdb_version = 2.72.2-1 + +[provide] +dependency_names = gthread-2.0, gobject-2.0, gmodule-no-export-2.0, gmodule-export-2.0, gmodule-2.0, glib-2.0, gio-2.0, gio-windows-2.0, gio-unix-2.0 +program_names = glib-genmarshal, glib-mkenums, glib-compile-schemas, glib-compile-resources, gio-querymodules, gdbus-codegen diff --git a/test/Makefile.am b/test/Makefile.am index e89d8ad4..1ee9dd21 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -610,6 +610,7 @@ in_data = \ data/valid-config-files/forbidding.conf.in \ data/valid-config-files/incoming-limit.conf.in \ data/valid-config-files/limit-containers.conf.in \ + data/valid-config-files/listen-autolaunch-win.conf.in \ data/valid-config-files/max-completed-connections.conf.in \ data/valid-config-files/max-connections-per-user.conf.in \ data/valid-config-files/max-containers.conf.in \ @@ -850,5 +851,12 @@ $(installable_test_meta_with_config): %_with_config.test: %$(EXEEXT) Makefile echo 'Exec=env DBUS_TEST_EXEC=$(testexecdir) DBUS_TEST_DATA=$(testexecdir)/data $(testexecdir)/$* --tap'; \ ) > $@.tmp && mv $@.tmp $@ +EXTRA_DIST += data/copy_data_for_tests.py +EXTRA_DIST += data/installable/meson.build +EXTRA_DIST += data/meson.build +EXTRA_DIST += meson.build +EXTRA_DIST += meta_template.test.in +EXTRA_DIST += mkdir-m700.py + # Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE include $(top_srcdir)/aminclude_static.am diff --git a/test/data/copy_data_for_tests.py b/test/data/copy_data_for_tests.py new file mode 100755 index 00000000..7a49c4c0 --- /dev/null +++ b/test/data/copy_data_for_tests.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import sys, os, shutil + +def pairs(args): + while args: + yield (args[0], args[1]) + args = args[2:] + +for src, dst in pairs(sys.argv[1:]): + os.makedirs(os.path.dirname(dst), exist_ok=True) + try: + shutil.copy(src, dst) + except (IOError, OSError) as e: + print(e.filename) diff --git a/test/data/installable/meson.build b/test/data/installable/meson.build new file mode 100644 index 00000000..68bc8705 --- /dev/null +++ b/test/data/installable/meson.build @@ -0,0 +1,45 @@ +# Copyright © 2019-2020 Salamandar +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Some configuration parameters used in installed-tests are not the same +# as the configuration parameters used during build-time testing. +installed_tests_config = configuration_data() +installed_tests_config.merge_from(data_config) +installed_tests_config.set('DBUS_TEST_DATA', get_option('prefix') / test_exec_dir / 'data') +installed_tests_config.set('DBUS_TEST_EXEC', get_option('prefix') / test_exec_dir) +installed_tests_config.set('EXEEXT', exe_ext) +installed_tests_config.set('TEST_LAUNCH_HELPER_BINARY', '/bin/false') + +foreach file : data_in_to_install + # Underscorify the output name because Meson doesn't allow subdir output files + configured_file = configure_file( + input : files('../' + file + '.in'), + output: file.underscorify(), + configuration: installed_tests_config, + ) + if install_tests + install_data(configured_file, + rename: file, + install_dir: test_exec_dir / 'data', + ) + endif +endforeach diff --git a/test/data/meson.build b/test/data/meson.build new file mode 100644 index 00000000..602fac7f --- /dev/null +++ b/test/data/meson.build @@ -0,0 +1,224 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +data_to_install = [ + 'auth/anonymous-client-successful.auth-script', + 'auth/anonymous-server-successful.auth-script', + 'auth/cancel.auth-script', + 'auth/client-out-of-mechanisms.auth-script', + 'auth/cookie-sha1-username.auth-script', + 'auth/cookie-sha1.auth-script', + 'auth/external-auto.auth-script', + 'auth/external-failed.auth-script', + 'auth/external-root.auth-script', + 'auth/external-silly.auth-script', + 'auth/external-successful.auth-script', + 'auth/external-username.auth-script', + 'auth/extra-bytes.auth-script', + 'auth/fail-after-n-attempts.auth-script', + 'auth/fallback.auth-script', + 'auth/invalid-command-client.auth-script', + 'auth/invalid-command.auth-script', + 'auth/invalid-hex-encoding.auth-script', + 'auth/mechanisms.auth-script', + 'equiv-config-files/basic/basic-1.conf', + 'equiv-config-files/basic/basic-2.conf', + 'equiv-config-files/basic/basic.d/basic.conf', + 'equiv-config-files/entities/basic.d/basic.conf', + 'equiv-config-files/entities/entities-1.conf', + 'equiv-config-files/entities/entities-2.conf', + 'invalid-config-files/apparmor-bad-attribute.conf', + 'invalid-config-files/apparmor-bad-mode.conf', + 'invalid-config-files/bad-attribute-2.conf', + 'invalid-config-files/bad-attribute.conf', + 'invalid-config-files/bad-element.conf', + 'invalid-config-files/bad-limit.conf', + 'invalid-config-files/badselinux-1.conf', + 'invalid-config-files/badselinux-2.conf', + 'invalid-config-files/circular-1.conf', + 'invalid-config-files/circular-2.conf', + 'invalid-config-files/circular-3.conf', + 'invalid-config-files/double-attribute.conf', + 'invalid-config-files/impossible-send.conf', + 'invalid-config-files/limit-no-name.conf', + 'invalid-config-files/ludicrous-limit.conf', + 'invalid-config-files/negative-limit.conf', + 'invalid-config-files/non-numeric-limit.conf', + 'invalid-config-files/not-well-formed.conf', + 'invalid-config-files/policy-bad-at-console.conf', + 'invalid-config-files/policy-bad-attribute.conf', + 'invalid-config-files/policy-bad-context.conf', + 'invalid-config-files/policy-bad-rule-attribute.conf', + 'invalid-config-files/policy-contradiction.conf', + 'invalid-config-files/policy-member-no-path.conf', + 'invalid-config-files/policy-mixed.conf', + 'invalid-config-files/policy-no-attributes.conf', + 'invalid-config-files/policy-no-rule-attribute.conf', + 'invalid-config-files/send-and-receive.conf', + 'invalid-config-files/truncated-file.conf', + 'invalid-config-files/unknown-limit.conf', + 'invalid-messages/boolean-has-no-value.message-raw', + 'sha-1/bit-hashes.sha1', + 'sha-1/bit-messages.sha1', + 'sha-1/byte-hashes.sha1', + 'sha-1/byte-messages.sha1', + 'sha-1/Readme.txt', + 'systemd-activation/com.example.ReceiveDenied.service', + 'systemd-activation/com.example.SendDenied.service', + 'systemd-activation/com.example.SendDeniedByAppArmorName.service', + 'systemd-activation/com.example.SendPrefixDenied.internal.service', + 'systemd-activation/com.example.SendPrefixDenied.SendPrefixAllowed.internal.service', + 'systemd-activation/com.example.SendPrefixDenied.service', + 'systemd-activation/com.example.SystemdActivatable1.service', + 'systemd-activation/com.example.SystemdActivatable2.service', + 'systemd-activation/org.freedesktop.systemd1.service', + 'valid-config-files-system/many-rules.conf', + 'valid-config-files-system/system.d/test.conf', + 'valid-config-files/basic.conf', + 'valid-config-files/basic.d/basic.conf', + 'valid-config-files/check-own-rules.conf', + 'valid-config-files/entities.conf', + 'valid-config-files/listen-unix-runtime.conf', + 'valid-config-files/many-rules.conf', + 'valid-config-files/minimal.conf', + 'valid-config-files/standard-session-dirs.conf', +] + +data_in_to_install = [ + 'dbus-installed-tests.aaprofile', + 'invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service', + 'invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service', + 'invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service', + 'systemd-activation/com.example.ReceiveDeniedByAppArmorLabel.service', + 'systemd-activation/com.example.SendDeniedByAppArmorLabel.service', + 'systemd-activation/com.example.SendDeniedByNonexistentAppArmorLabel.service', + 'systemd-activation/com.example.SystemdActivatable3.service', + 'valid-config-files-system/debug-allow-all-fail.conf', + 'valid-config-files-system/debug-allow-all-pass.conf', + 'valid-config-files-system/tmp-session-like-system.conf', + 'valid-config-files/as-another-user.conf', + 'valid-config-files/count-fds.conf', + 'valid-config-files/debug-allow-all-sha1.conf', + 'valid-config-files/debug-allow-all.conf', + 'valid-config-files/finite-timeout.conf', + 'valid-config-files/forbidding.conf', + 'valid-config-files/incoming-limit.conf', + 'valid-config-files/limit-containers.conf', + 'valid-config-files/listen-autolaunch-win.conf', + 'valid-config-files/max-completed-connections.conf', + 'valid-config-files/max-connections-per-user.conf', + 'valid-config-files/max-containers.conf', + 'valid-config-files/max-match-rules-per-connection.conf', + 'valid-config-files/max-names-per-connection.conf', + 'valid-config-files/max-replies-per-connection.conf', + 'valid-config-files/multi-user.conf', + 'valid-config-files/pending-fd-timeout.conf', + 'valid-config-files/send-destination-prefix-rules.conf', + 'valid-config-files/systemd-activation.conf', + 'valid-config-files/tmp-session.conf', + 'valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service', + 'valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service', + 'valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service', + 'valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service', + 'valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service', + 'valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service', + 'valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service', + 'valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service', + 'valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service', + 'valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service', +] + +foreach file : data_to_install + if install_tests + install_data(file, + rename: file, + install_dir: test_exec_dir / 'data', + ) + endif +endforeach + +foreach file : data_in_to_install + # Underscorify the output name because Meson doesn't allow subdir output files + configured_file = configure_file( + input : file + '.in', + output: file.underscorify(), + configuration: test_data_config, + ) + # We don't install this version: see test/data/installable/ for the + # version that we *do* install. +endforeach + +############################################################################### +# Copy files into correct places in build directory for tests + +files = [] +foreach file : data_to_install + src = meson.current_source_dir() / file + dst = meson.current_build_dir() / file + files += src + files += dst +endforeach + +foreach file : data_in_to_install + src = meson.current_build_dir() / file.underscorify() + dst = meson.current_build_dir() / file + files += src + files += dst +endforeach + +files += meson.project_build_root() / 'bus' / 'session.conf' +files += meson.current_build_dir() / 'valid-config-files/session.conf' + +if platform_unix + files += meson.project_build_root() / 'bus' / 'system.conf' + files += meson.current_build_dir() / 'valid-config-files-system/system.conf' +endif + + +run_result = run_command(find_program('copy_data_for_tests.py'), files, check: true) + +files_not_found = run_result.stdout().split() +if files_not_found.length() > 0 + error('Those files could not be copied for test : @0@'.format(files_not_found)) +endif + +if install_tests + subdir('installable') + + if platform_unix + install_symlinks += [ + { + 'link_name': 'session.conf', + 'install_dir': test_exec_dir / 'data' / 'valid-config-files', + 'pointing_to': + get_option('prefix') / get_option('datadir') / + 'dbus-1' / 'session.conf', + }, + { + 'link_name': 'system.conf', + 'install_dir': test_exec_dir / 'data' / 'valid-config-files-system', + 'pointing_to': + get_option('prefix') / get_option('datadir') / + 'dbus-1' / 'system.conf', + }, + ] + endif +endif diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 00000000..e6360900 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,692 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +############################################################################### +# Tests installation + +install_tests = get_option('installed_tests') + +test_exec_dir = get_option('libexecdir') / 'installed-tests' / 'dbus' +test_meta_dir = get_option('datadir') / 'installed-tests' / 'dbus' + +############################################################################### +# Test configuration needs some specific keys + +test_data_config = configuration_data() +test_data_config.merge_from(data_config) + +test_data_config.set('EXEEXT', exe_ext) +# / '' to convert \-separated dir to /-separated dir on win32 +test_data_config.set('DBUS_TEST_EXEC', meson.current_build_dir() / '') +test_data_config.set('DBUS_TEST_DATA', meson.current_build_dir() / 'data') + + +test_env = environment() + +test_env.set('DBUS_TOP_SRCDIR', meson.project_source_root()) +test_env.set('DBUS_TEST_SRCDIR', meson.current_source_dir()) + +test_env.set('DBUS_TOP_BUILDDIR', meson.project_build_root()) +test_env.set('DBUS_TEST_HOMEDIR', meson.project_build_root() / 'dbus') +test_env.set('HOME', meson.project_build_root() / 'dbus') +# Tests in bus/config-parser.c rely on this specific value +test_env.set('DBUS_TEST_BUILDDIR', meson.current_build_dir()) +test_env.set('DBUS_TEST_EXEC', meson.current_build_dir()) +test_env.set('DBUS_TEST_DATA', meson.current_build_dir() / 'data') + +test_env.set('DBUS_TEST_DAEMON', dbus_daemon.full_path()) +test_env.set('DBUS_TEST_DBUS_LAUNCH', dbus_launch.full_path()) +test_env.set('DBUS_TEST_DBUS_MONITOR', dbus_monitor.full_path()) +test_env.set('DBUS_TEST_DBUS_SEND', dbus_send.full_path()) + +if platform_unix + test_env.set('DBUS_TEST_DBUS_UUIDGEN', dbus_uuidgen.full_path()) +endif + +if platform_windows + # test-autolaunch-win relies on being able to find the just-built + # dbus-daemon in the PATH + if build_machine.system().contains('windows') + test_env.prepend('PATH', meson.project_build_root() / 'bus') + else + # Assume we'll use Wine to run tests while cross-compiling + test_env.prepend( + 'WINEPATH', + 'Z:' + meson.project_build_root() / 'bus', + separator: ';', + ) + endif +endif + +# Tests in bus/config-parser.c rely on these specific values for XDG_* +test_env.set('XDG_DATA_HOME', meson.current_build_dir() / 'XDG_DATA_HOME') +test_env.set('XDG_RUNTIME_DIR', meson.current_build_dir() / 'XDG_RUNTIME_DIR') +xdg_data_dirs = [ + meson.current_build_dir() / 'XDG_DATA_DIRS', + meson.current_build_dir() / 'XDG_DATA_DIRS2' +] +test_env.set('XDG_DATA_DIRS', xdg_data_dirs) + +test_env.set('DBUS_SESSION_BUS_ADDRESS', 'do-not-use-real-session:') + +test_env.set('DBUS_FATAL_WARNINGS', '1') +test_env.set('DBUS_TEST_UNINSTALLED', '1') + +xdgdir = custom_target('gen-xdgdir', + command: [ + python, + files('mkdir-m700.py'), + meson.current_build_dir() / 'XDG_RUNTIME_DIR', + ], + output: 'XDG_RUNTIME_DIR' +) + +installed_tests = [] + +############################################################################### +# Dbus testutils + + +libdbus_testutils_sources = [ + 'disable-crash-handling.c', + 'test-utils.c', +] + +if use_glib + libdbus_testutils_sources += 'test-utils-glib.c' +endif + +libdbus_testutils = static_library('dbus-testutils', + libdbus_testutils_sources, + + include_directories: root_include, + link_with: [ + libdbus, + libdbus_internal, + ], + dependencies: [ + glib, + gio, + dbus_dependencies, + ], +) + + +############################################################################### +# Test tools + +# these binaries are used in tests but are not themselves tests +test_exit = executable('test-exit', + 'test-exit.c', + include_directories: root_include, + link_with: libdbus_testutils, + dependencies: dbus_dependencies, +) +test_names = executable('test-names', + 'test-names.c', + include_directories: root_include, + link_with: libdbus_testutils, + dependencies: dbus_dependencies, +) +test_privserver = executable('test-privserver', + 'test-privserver.c', + include_directories: root_include, + link_with: libdbus_testutils, + dependencies: dbus_dependencies, +) +# This helper is meant to crash, so if we're compiling the rest with +# AddressSanitizer, we need to stop it from catching the SIGSEGV and +# turning it into _exit(1). +# We have to compile a separate copy of disable-crash-handling.c for +# test-segfault rather than using libdbus-testutils, because +# otherwise it would fail to link when using the AddressSanitizer. +test_segfault = executable('test-segfault', + 'test-segfault.c', 'disable-crash-handling.c', + include_directories: root_include, + dependencies: dbus_dependencies, + override_options: ['b_sanitize=none'], +) +test_shell_service = executable('test-shell-service', + 'test-shell-service.c', + include_directories: root_include, + link_with: libdbus_testutils, + dependencies: dbus_dependencies, +) + +if use_traditional_activation + test_spawn = executable('test-spawn', + 'spawn-test.c', + include_directories: root_include, + link_with: libdbus_testutils, + dependencies: dbus_dependencies, + ) +endif +if use_traditional_activation and platform_unix + launch_helper_for_tests = executable('launch-helper-for-tests', + 'bus/launch-helper-for-tests.c', + include_directories: root_include, + link_with: liblaunch_helper_internal, + dependencies: dbus_dependencies, + ) + test_data_config.set('TEST_LAUNCH_HELPER_BINARY', launch_helper_for_tests.full_path()) +else + # Dummy value, should not be used in practice + test_data_config.set('TEST_LAUNCH_HELPER_BINARY', '/bin/false') +endif + +if platform_unix and use_glib + test_apparmor_activation = executable('test-apparmor-activation', + 'sd-activation.c', + include_directories: root_include, + c_args: '-DDBUS_TEST_APPARMOR_ACTIVATION', + link_with: libdbus_testutils, + dependencies: [ + glib, gio, + apparmor, + ], + install: install_tests, + install_dir: test_exec_dir, + ) +endif + +############################################################################### +# Subdirectories need utilities above. + +subdir('data') + +# the "name-test" subdir in fact contains a bunch of tests now that need a +# temporary bus to be running to do stuff with. The directory should be renamed. +subdir('name-test') + +tests = [] + +if embedded_tests + + tests += [ + { + 'name': 'bus', + 'srcs': [ 'bus/main.c' ], + 'link': [ libdbus_testutils, libdbus_daemon_internal, ], + 'install': false, + }, + { + 'name': 'bus-dispatch-sha1', + 'srcs': [ 'bus/dispatch-sha1.c' ], + 'link': [ libdbus_testutils, libdbus_daemon_internal, ], + 'install': false, + 'suite': ['slow'], + }, + { + 'name': 'bus-dispatch', + 'srcs': [ 'bus/dispatch.c' ], + 'link': [ libdbus_testutils, libdbus_daemon_internal, ], + 'install': false, + 'suite': ['slow'], + 'timeout': 3000, + }, + { + 'name': 'marshal-recursive', + 'srcs': [ + 'internals/dbus-marshal-recursive-util.c', + 'internals/marshal-recursive.c', + ], + 'link': [ libdbus_testutils, ], + 'install': false, + 'timeout': 60, + }, + { + 'name': 'message-internals', + 'srcs': [ + 'internals/dbus-marshal-recursive-util.c', + 'internals/dbus-message-factory.c', + 'internals/dbus-message-util.c', + 'internals/message-internals.c', + ], + 'link': [ libdbus_testutils, ], + 'install': false, + 'suite': ['slow'], + }, + ] + + if use_traditional_activation and platform_unix + tests += [ + { + 'name': 'bus-launch-helper-oom', + 'srcs': [ 'bus/launch-helper-oom.c' ], + 'link': [ libdbus_testutils, liblaunch_helper_internal, ], + 'install': false, + }, + { + 'name': 'bus-system', + 'srcs': [ 'bus/system.c', ], + 'link': [ libdbus_testutils, liblaunch_helper_internal, ], + 'install': false, + }, + { + 'name': 'spawn-oom', + 'srcs': [ 'internals/spawn-oom.c', ], + 'link': [ libdbus_testutils, ], + 'install': false, + } + ] + endif +endif + +tests += [ + { + 'name': 'test-service', + 'srcs': [ 'test-service.c' ], + 'link': [ libdbus_testutils, ], + 'install': true, + 'test': false, + }, + { + 'name': 'test-sleep-forever', + 'srcs': [ 'test-sleep-forever.c' ], + 'link': [ libdbus_testutils, ], + 'install': true, + 'test': false, + } +] + +tests += [ + { + 'name': 'atomic', + 'srcs': [ 'internals/atomic.c' ], + 'link': [ libdbus_testutils, ], + }, + { + 'name': 'hash', + 'srcs': [ 'internals/hash.c' ], + 'link': [ libdbus_testutils, ], + }, + { + 'name': 'misc-internals', + 'srcs': [ + 'internals/address.c', + 'internals/dbus-auth-script.c', + 'internals/dbus-auth-util.c', + 'internals/dbus-credentials-util.c', + 'internals/dbus-marshal-byteswap-util.c', + 'internals/dbus-marshal-recursive-util.c', + 'internals/dbus-marshal-validate-util.c', + 'internals/dbus-string-util.c', + 'internals/dbus-sysdeps-util.c', + 'internals/mempool.c', + 'internals/misc-internals.c', + 'internals/sha.c', + ], + 'link': [ libdbus_testutils, ], + }, + { + 'name': 'shell', + 'srcs': [ 'shell-test.c' ], + 'link': [ libdbus_testutils, ], + }, + { + 'name': 'printf', + 'srcs': [ 'internals/printf.c' ], + 'link': [ libdbus_testutils, ], + }, + { + 'name': 'manual-backtrace', + 'srcs': [ 'manual-backtrace.c' ], + 'link': [ libdbus_testutils, ], + 'test': false, + }, + { + 'name': 'manual-dir-iter', + 'srcs': [ 'manual-dir-iter.c' ], + 'link': [ libdbus_testutils, ], + 'test': false, + }, + { + 'name': 'manual-tcp', + 'srcs': [ 'manual-tcp.c' ], + 'link': [ libdbus_testutils, ], + 'test': false, + } +] + +if platform_windows + tests += [ + { + 'name': 'manual-paths', + 'srcs': [ 'manual-paths.c' ], + 'link': [ libdbus_testutils, ], + 'test': false, + } + ] +endif + +if use_glib + tests += [ + { + 'name': 'assertions', + 'srcs': [ 'internals/assertions.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'corrupt', + 'srcs': [ 'corrupt.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'dbus-daemon', + 'srcs': [ 'dbus-daemon.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'suite': ['runs-dbus-daemon', 'slow'], + }, + { + 'name': 'dbus-daemon-eavesdrop', + 'srcs': [ 'dbus-daemon-eavesdrop.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'suite': ['runs-dbus-daemon'], + }, + { + 'name': 'desktop-file', + 'srcs': [ 'internals/desktop-file.c' ], + 'link': [ libdbus_testutils, libdbus_internal, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'fdpass', + 'srcs': [ 'fdpass.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'header-fields', + 'srcs': [ 'header-fields.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'suite': ['runs-dbus-daemon', 'slow'], + }, + { + 'name': 'message', + 'srcs': [ 'message.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'monitor', + 'srcs': [ 'monitor.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'suite': ['runs-dbus-daemon'], + 'timeout': 45, + }, + { + 'name': 'loopback', + 'srcs': [ 'loopback.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'marshal', + 'srcs': [ 'marshal.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'refs', + 'srcs': [ 'internals/refs.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'suite': ['slow'], + }, + { + 'name': 'relay', + 'srcs': [ 'relay.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'timeout': 60, + }, + { + 'name': 'server-oom', + 'srcs': [ 'internals/server-oom.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'syntax', + 'srcs': [ 'syntax.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'sysdeps', + 'srcs': [ 'internals/sysdeps.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'syslog', + 'srcs': [ 'internals/syslog.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'uid-permissions', + 'srcs': [ 'uid-permissions.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'suite': ['runs-dbus-daemon'], + }, + { + 'name': 'variant', + 'srcs': [ 'internals/variant.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + }, + { + 'name': 'manual-authz', + 'srcs': [ 'manual-authz.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'test': false, + }, + { + 'name': 'manual-test-thread-blocking', + 'srcs': [ 'thread-blocking.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'test': false, + }, + ] + + if platform_unix + tests += [ + { 'name': 'containers', + 'srcs': [ 'containers.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'suite': ['runs-dbus-daemon'], + }, + { 'name': 'sd-activation', + 'srcs': [ 'sd-activation.c' ], + 'link': [ libdbus_testutils, ], + 'deps': [ glib, gio, ], + 'suite': ['runs-dbus-daemon'], + }, + ] + + endif +endif + +foreach test: tests + name = test.get('name') + srcs = test.get('srcs') + link = test.get('link', []) + deps = test.get('deps', []) + suites = test.get('suite', ['dbus']) + install = test.get('install', true) + + if test.get('test', true) + exe_name = 'test-' + name + else + exe_name = name + endif + + if 'slow' in suites + timeout = 300 + else + timeout = 30 + endif + + timeout = test.get('timeout', timeout) + + test_exe = executable(exe_name, + srcs, + link_with: link, + dependencies: deps, + include_directories: root_include, + install: install_tests and install, + install_dir: test_exec_dir, + ) + + # Some binaries are used in tests but are not themselves tests, + # and some might be "as-installed" integration tests that aren't + # guaranteed to work at build-time + if test.get('build_time_test', true) and test.get('test', true) + test(name, + test_exe, + args: ['--tap'], + env: test_env, + protocol: 'tap', + suite: suites, + timeout: timeout, + ) + endif + + if install and test.get('test', true) + installed_tests += [{ + 'name': exe_name, + 'exe': exe_name + exe_ext, + }] + endif +endforeach + + +############################################################################### +# Scripts + +scripts = [] + +if platform_unix and use_glib + scripts += [ + { 'name': 'test-dbus-daemon-fork.sh', }, + { 'name': 'transient-services.sh', + 'subdir': 'integration', + 'build_time_test': false }, + { 'name': 'test-apparmor-activation.sh', + 'build_time_test': false }, + ] + + # Testing dbus-launch relies on special code in that binary. + if embedded_tests + scripts += { 'name': 'test-dbus-launch-eval.sh' } + endif + if embedded_tests and use_x11_autolaunch + scripts += { 'name': 'test-dbus-launch-x11.sh' } + endif +endif + +foreach script: scripts + name = script.get('name') + install = script.get('install', true) + suites = script.get('suite', ['dbus']) + test_subdir = script.get('subdir', '') + + if test_subdir == '' + install_dir = test_exec_dir + else + install_dir = test_exec_dir / test_subdir + endif + + if install_tests and install + install_data(test_subdir / name, + install_mode: 'rwxr-xr-x', + install_dir: install_dir, + ) + installed_tests += [{ + 'name': name, + 'subdir': test_subdir, + }] + endif + + # Some scripts might be used in tests but not themselves tests, + # and some are "as-installed" integration tests that aren't + # guaranteed to work at build-time + if script.get('build_time_test', true) and script.get('test', true) + test(name, + find_program(script.get('subdir', '.') / name), + env: test_env, + depends: xdgdir, + suite: suites, + ) + endif +endforeach + + +foreach test_case: installed_tests + name = test_case.get('name') + exe = test_case.get('exe', name) + test_subdir = test_case.get('subdir', '') + + if test_subdir == '' + exe = get_option('prefix') / test_exec_dir / exe + install_dir = test_meta_dir + else + exe = get_option('prefix') / test_exec_dir / test_subdir / exe + install_dir = test_meta_dir / test_subdir + endif + + meta_config = configuration_data() + meta_config.set('command', + 'env @0@ --tap'.format(exe), + ) + configure_file( + input : 'meta_template.test.in', + output: name + '.test', + configuration: meta_config, + install: install_tests, + install_dir: install_dir, + ) + + meta_config = configuration_data() + meta_config.set('command', + 'env DBUS_TEST_EXEC=@0@ DBUS_TEST_DATA=@0@/data @1@ --tap'.format( + get_option('prefix') / test_exec_dir, exe, + )) + configure_file( + input : 'meta_template.test.in', + output: name + '_with_config.test', + configuration: meta_config, + install: install_tests, + install_dir: install_dir, + ) + +endforeach diff --git a/test/meta_template.test.in b/test/meta_template.test.in new file mode 100644 index 00000000..31915278 --- /dev/null +++ b/test/meta_template.test.in @@ -0,0 +1,4 @@ +[Test] +Type=session +Output=TAP +Exec=@command@ diff --git a/test/mkdir-m700.py b/test/mkdir-m700.py new file mode 100755 index 00000000..d8ebddbe --- /dev/null +++ b/test/mkdir-m700.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +import os +import sys + +# Note that we can't create the XDG_RUNTIME_DIR with permissions 0700 +# on MSYS2, which rejects attempts to change permissions, hence "|| true". +os.makedirs(sys.argv[1], exist_ok=True) + +try: + os.chmod(sys.argv[1], 0o700) +except OSError: + pass diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 527dbbff..e1cc82d2 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -121,3 +121,5 @@ test_autolaunch_LDADD = \ $(NULL) endif endif + +EXTRA_DIST += meson.build diff --git a/test/name-test/meson.build b/test/name-test/meson.build new file mode 100644 index 00000000..8e26e1b7 --- /dev/null +++ b/test/name-test/meson.build @@ -0,0 +1,103 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +if embedded_tests + + tests = [ + 'test-ids', + 'test-pending-call-disconnected', + 'test-shutdown', + ] + + if platform_windows + tests += ['test-autolaunch-win'] + else + tests += ['test-autolaunch'] + endif + + if use_traditional_activation + tests += [ + 'test-pending-call-dispatch', + 'test-pending-call-timeout', + 'test-privserver-client', + 'test-threads-init', + ] + endif + + foreach test: tests + test_exe = executable(test, + test + '.c', + include_directories: root_include, + link_with: [ + libdbus, + libdbus_internal, + libdbus_testutils, + ], + dependencies: dbus_dependencies, + ) + + if test == 'test-autolaunch' + # This one is run from run-test.sh, not directly + continue + endif + + if test == 'test-pending-call-timeout' + timeout = 75 + suites = ['name-test', 'slow'] + else + timeout = 30 + suites = ['name-test'] + endif + + test(test, + dbus_run_session, + args: [ + '--config-file=@0@'.format( + meson.project_build_root()/'test/data/valid-config-files/tmp-session.conf'), + '--dbus-daemon=@0@'.format(dbus_daemon.full_path()), + '--', + test_exe, + ], + env: test_env, + protocol: 'tap', + suite: suites, + timeout: timeout, + ) + endforeach + + + if platform_unix + test('run-test', + find_program('run-test.sh'), + env: test_env, + protocol: 'tap', + suite: 'name-test', + ) + + test('run-test-systemserver', + find_program('run-test-systemserver.sh'), + env: test_env, + protocol: 'tap', + suite: 'name-test', + ) + endif +endif diff --git a/test/name-test/run-test-systemserver.sh b/test/name-test/run-test-systemserver.sh index d8515a8c..c114322c 100755 --- a/test/name-test/run-test-systemserver.sh +++ b/test/name-test/run-test-systemserver.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh SCRIPTNAME=$0 MODE=$1 @@ -14,7 +14,7 @@ if test -z "$DBUS_TEST_NAME_IN_SYS_RUN_TEST"; then DBUS_TEST_NAME_IN_SYS_RUN_TEST=1 export DBUS_TEST_NAME_IN_SYS_RUN_TEST exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE -fi +fi if test -n "$DBUS_TEST_MONITOR"; then dbus-monitor --session >&2 & @@ -52,7 +52,12 @@ dbus_send_test () { shift 3 e=0 echo "# running test $t" - "${DBUS_TOP_BUILDDIR}/libtool" --mode=execute $DEBUG "$DBUS_TOP_BUILDDIR/tools/dbus-send" "$@" > output.tmp 2>&1 || e=$? + if [ -f "${DBUS_TOP_BUILDDIR}/libtool" ]; then + "${DBUS_TOP_BUILDDIR}/libtool" --mode=execute $DEBUG "$DBUS_TOP_BUILDDIR/tools/dbus-send" "$@" > output.tmp 2>&1 || e=$? + else + "$DBUS_TOP_BUILDDIR/tools/dbus-send" "$@" > output.tmp 2>&1 || e=$? + fi + if [ $e != $expected_exit ]; then sed -e 's/^/# /' < output.tmp interpret_result "1" "$t" "$@" "(expected exit status $expected_exit, got $e)" diff --git a/test/name-test/run-test.sh b/test/name-test/run-test.sh index 9c6a55cc..a96db46a 100755 --- a/test/name-test/run-test.sh +++ b/test/name-test/run-test.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh SCRIPTNAME=$0 MODE=$1 @@ -12,7 +12,7 @@ if test -z "$DBUS_TEST_NAME_IN_RUN_TEST"; then DBUS_TEST_NAME_IN_RUN_TEST=1 export DBUS_TEST_NAME_IN_RUN_TEST exec $DBUS_TOP_SRCDIR/tools/run-with-tmp-session-bus.sh $SCRIPTNAME $MODE -fi +fi if test -n "$DBUS_TEST_MONITOR"; then dbus-monitor --session >&2 & @@ -48,7 +48,11 @@ c_test () { shift e=0 echo "# running test $t" - "${DBUS_TOP_BUILDDIR}/libtool" --mode=execute $DEBUG "$DBUS_TOP_BUILDDIR/test/name-test/$t" "$@" >&2 || e=$? + if [ -f "${DBUS_TOP_BUILDDIR}/libtool" ]; then + "${DBUS_TOP_BUILDDIR}/libtool" --mode=execute $DEBUG "$DBUS_TOP_BUILDDIR/test/name-test/$t" "$@" >&2 || e=$? + else + "$DBUS_TOP_BUILDDIR/test/name-test/$t" "$@" >&2 || e=$? + fi echo "# exit status $e" interpret_result "$e" "$t" "$@" } diff --git a/tools/Makefile.am b/tools/Makefile.am index f8660c06..dee5f862 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -137,10 +137,7 @@ SUFFIXES = .rc .rc.o: $(RC) $< -o $@ -nodist_dbus_update_activation_environment_SOURCES = disable-uac.rc - -disable-uac.rc: Win32.Manifest - echo '1 24 "$<"' > $@ +dbus_update_activation_environment_SOURCES += disable-uac.rc endif EXTRA_DIST = run-with-tmp-session-bus.sh strtoll.c strtoull.c Win32.Manifest @@ -154,3 +151,8 @@ install-data-local: installcheck-local: test -d $(DESTDIR)$(localstatedir)/lib/dbus + +EXTRA_DIST += build-timestamp.py +EXTRA_DIST += meson.build +EXTRA_DIST += meson-compat-install-emptydirs.py +EXTRA_DIST += meson-compat-install-symlink.py diff --git a/tools/build-timestamp.py b/tools/build-timestamp.py new file mode 100755 index 00000000..f4dc5a00 --- /dev/null +++ b/tools/build-timestamp.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import datetime +import os + +if 'SOURCE_DATE_EPOCH' in os.environ: + stamp = int(os.environ['SOURCE_DATE_EPOCH']) + dt = datetime.datetime.utcfromtimestamp(stamp) +else: + dt = datetime.datetime.now() + +print(dt.isoformat(timespec='minutes')) diff --git a/tools/ci-build.sh b/tools/ci-build.sh index 3772daad..6e907deb 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -175,21 +175,31 @@ maybe_fail_tests () { # own checks. NOCONFIGURE=1 ./autogen.sh +# clean up directories from possible previous builds +rm -rf "$builddir" +rm -rf ci-build-dist +rm -rf src-from-dist + case "$ci_buildsys" in - (cmake-dist) - # clean up directories from possible previous builds - rm -rf ci-build-dist - # Do an Autotools `make dist`, then build *that* with CMake, + (cmake-dist|meson-dist) + # Do an Autotools `make dist`, then build *that* with CMake or Meson, # to assert that our official release tarballs will be enough - # to build with CMake. + # to build with CMake or Meson. mkdir -p ci-build-dist ( cd ci-build-dist; ../configure ) make -C ci-build-dist dist tar --xz -xvf ci-build-dist/dbus-1.*.tar.xz - cd dbus-1.*/ + mv dbus-1.*/ src-from-dist + srcdir="$(pwd)/src-from-dist" + ;; + (*) + srcdir="$(pwd)" ;; esac +mkdir -p "$builddir" +builddir="$(realpath "$builddir")" + # # cross compile setup # @@ -219,13 +229,33 @@ case "$ci_host" in ;; esac -srcdir="$(pwd)" -builddir="ci-build-${ci_variant}-${ci_host}" -# clean up directories from possible previous builds -rm -rf "$builddir" -mkdir -p "$builddir" cd "$builddir" +case "$ci_host" in + (*-w64-mingw32) + # If we're dynamically linking libgcc, make sure Wine will find it + if [ "$ci_test" = yes ]; then + if [ "${ci_distro%%-*}" = opensuse ] && [ "${ci_host%%-*}" = x86_64 ]; then + export WINEARCH=win64 + fi + libgcc_path= + if [ "$ci_runtime" = "shared" ]; then + libgcc_path=$(dirname "$("${ci_host}-gcc" -print-libgcc-file-name)") + fi + init_wine \ + "${builddir}/bin" \ + "${builddir}/subprojects/expat-2.4.8" \ + "${builddir}/subprojects/glib-2.72.2/gio" \ + "${builddir}/subprojects/glib-2.72.2/glib" \ + "${builddir}/subprojects/glib-2.72.2/gmodule" \ + "${builddir}/subprojects/glib-2.72.2/gobject" \ + "${builddir}/subprojects/glib-2.72.2/gthread" \ + "${dep_prefix}/bin" \ + ${libgcc_path:+"$libgcc_path"} + fi + ;; +esac + make="make -j${ci_parallel} V=1 VERBOSE=1" case "$ci_buildsys" in @@ -374,22 +404,12 @@ case "$ci_buildsys" in (*-w64-mingw32) # CFLAGS and CXXFLAGS does do work, checked with cmake 3.15 export LDFLAGS="-${ci_runtime}-libgcc" - # enable tests if supported - if [ "$ci_test" = yes ]; then - # choose correct wine architecture - if [ "${ci_distro%%-*}" = opensuse ]; then - if [ "${ci_host%%-*}" = x86_64 ]; then - export WINEARCH=win64 - cmake=mingw64-cmake - else - cmake=mingw32-cmake - fi + if [ "${ci_distro%%-*}" = opensuse ]; then + if [ "${ci_host%%-*}" = x86_64 ]; then + cmake=mingw64-cmake + else + cmake=mingw32-cmake fi - libgcc_path= - if [ "$ci_runtime" = "shared" ]; then - libgcc_path=$(dirname "$("${ci_host}-gcc" -print-libgcc-file-name)") - fi - init_wine "${dep_prefix}/bin" "$(pwd)/bin" ${libgcc_path:+"$libgcc_path"} cmdwrapper="xvfb-run -a" fi set _ "$@" @@ -427,6 +447,102 @@ case "$ci_buildsys" in ${make} install DESTDIR=$(pwd)/DESTDIR ( cd DESTDIR && find . -ls) ;; + + (meson|meson-dist) + # The test coverage for OOM-safety is too verbose to be useful on + # travis-ci, and too slow when running under wine. + export DBUS_TEST_MALLOC_FAILURES=0 + + meson_setup= + cross_file= + + # openSUSE has convenience wrappers that run Meson with appropriate + # cross options + case "$ci_host" in + (i686-w64-mingw32) + meson_setup=mingw32-meson + ;; + (x86_64-w64-mingw32) + meson_setup=mingw64-meson + ;; + esac + + case "$ci_host" in + (*-w64-mingw32) + cross_file="${srcdir}/maint/${ci_host}.txt" + # openSUSE's wrappers are designed for building predictable + # RPM packages, so they set --auto-features=enabled - + # but that includes some things that make no sense on + # Windows. + set -- -Dapparmor=disabled "$@" + set -- -Depoll=disabled "$@" + set -- -Dinotify=disabled "$@" + set -- -Dkqueue=disabled "$@" + set -- -Dlaunchd=disabled "$@" + set -- -Dlibaudit=disabled "$@" + set -- -Dselinux=disabled "$@" + set -- -Dsystemd=disabled "$@" + set -- -Dx11_autolaunch=disabled "$@" + # We seem to have trouble finding libexpat.dll when + # cross-building for Windows and running tests with Wine. + set -- -Dexpat:default_library=static "$@" + ;; + esac + + case "$ci_distro" in + (debian*|ubuntu*) + # We know how to install python3-mallard-ducktype + ;; + (*) + # TODO: We don't know the openSUSE equivalent of + # python3-mallard-ducktype + set -- -Dducktype_docs=disabled "$@" + ;; + esac + + set -- -Dmodular_tests=enabled "$@" + + case "$ci_variant" in + (debug) + set -- -Dasserts=true "$@" + set -- -Dembedded_tests=true "$@" + set -- -Dverbose_mode=true "$@" + + case "$ci_host" in + (*-w64-mingw32) + ;; + (*) + set -- -Db_sanitize=address,undefined "$@" + set -- -Db_pie=true "$@" + set -- -Duser_session=true "$@" + ;; + esac + + shift + ;; + esac + + # Debian doesn't have similar convenience wrappers, but we can use + # a cross-file + if [ -z "$meson_setup" ] || ! command -v "$meson_setup" >/dev/null; then + meson_setup="meson setup" + + if [ -n "$cross_file" ]; then + set -- --cross-file="$cross_file" "$@" + fi + fi + + # openSUSE's mingw*-meson wrappers are designed for self-contained + # package building, so they include --wrap-mode=nodownload. Switch + # the wrap mode back, so we can use wraps. + set -- "$@" --wrap=default + + $meson_setup "$@" "$srcdir" + meson compile -v + [ "$ci_test" = no ] || meson test + DESTDIR=DESTDIR meson install + ( cd DESTDIR && find . -ls) + ;; esac # vim:set sw=4 sts=4 et: diff --git a/tools/ci-install.sh b/tools/ci-install.sh index 40dde892..ee9d3499 100755 --- a/tools/ci-install.sh +++ b/tools/ci-install.sh @@ -159,6 +159,7 @@ case "$ci_distro" in ducktype g++ gcc + git gnome-desktop-testing libapparmor-dev libaudit-dev @@ -168,6 +169,8 @@ case "$ci_distro" in libselinux1-dev libsystemd-dev libx11-dev + meson + ninja-build sudo valgrind wget @@ -205,6 +208,7 @@ case "$ci_distro" in automake cmake libtool + meson ) # docs @@ -263,6 +267,8 @@ case "$ci_distro" in ( p=$(zypper lr | grep "windows_mingw_win${bits}" || true) if [ -z "$p" ]; then + $zypper ar --refresh --no-gpgcheck \ + "https://download.opensuse.org/repositories/windows:/mingw/$repo/windows:mingw.repo" $zypper ar --refresh --no-gpgcheck \ "https://download.opensuse.org/repositories/windows:/mingw:/win${bits}/$repo/windows:mingw:win${bits}.repo" fi @@ -270,8 +276,10 @@ case "$ci_distro" in packages=( "${packages[@]}" mingw${bits}-cross-gcc-c++ + mingw${bits}-cross-pkgconf mingw${bits}-libexpat-devel mingw${bits}-glib2-devel + mingw${bits}-cross-meson ) ;; diff --git a/tools/disable-uac.rc b/tools/disable-uac.rc new file mode 100644 index 00000000..af23c7e8 --- /dev/null +++ b/tools/disable-uac.rc @@ -0,0 +1 @@ +1 24 "Win32.Manifest" diff --git a/tools/docker/windows/Dockerfile b/tools/docker/windows/Dockerfile index c9a91200..bff4c501 100644 --- a/tools/docker/windows/Dockerfile +++ b/tools/docker/windows/Dockerfile @@ -29,7 +29,7 @@ RUN (New-Object System.Net.WebClient).DownloadString('https://wrapdb.mesonbuild. RUN (New-Object System.Net.WebClient).DownloadString('https://zlib.net/fossils/') >$null # MinGW environment -RUN c:\msys64\usr\bin\bash -lc 'pacman -S --noconfirm mingw-w64-ucrt-x86_64-toolchain expat glib2-devel' +RUN c:\msys64\usr\bin\bash -lc 'pacman -S --noconfirm mingw-w64-ucrt-x86_64-toolchain expat glib2-devel ninja' # Visual Studio can't be installed with choco. # It depends on dotnetfx v4.8.0.20190930, which requires a reboot: dotnetfx (exit code 3010) diff --git a/tools/meson-compat-install-emptydirs.py b/tools/meson-compat-install-emptydirs.py new file mode 100755 index 00000000..0fc76287 --- /dev/null +++ b/tools/meson-compat-install-emptydirs.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +# Compatibility shim for installing empty directories with Meson < 0.60 + +import os +import sys +from pathlib import Path + +for d in sys.argv[1].split(':'): + if os.path.isabs(d) and 'DESTDIR' in os.environ: + p = Path(d) + d = p.relative_to(p.anchor) + dest = os.path.join(os.environ['DESTDIR'], d) + else: + dest = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], d) + + os.makedirs(dest, mode=0o755, exist_ok=True) diff --git a/tools/meson-compat-install-symlink.py b/tools/meson-compat-install-symlink.py new file mode 100755 index 00000000..6e7ac333 --- /dev/null +++ b/tools/meson-compat-install-symlink.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2022 Simon McVittie +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +# Compatibility shim for installing symlinks with Meson < 0.61 + +import os +import sys +from pathlib import Path + +link_name, d, pointing_to = sys.argv[1:] + +if os.path.isabs(d): + p = Path(d) + d = p.relative_to(p.anchor) + dest = os.path.join(os.environ['DESTDIR'], d) +else: + dest = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], d) + +os.makedirs(dest, mode=0o755, exist_ok=True) +os.symlink(pointing_to, os.path.join(dest, link_name)) diff --git a/tools/meson.build b/tools/meson.build new file mode 100644 index 00000000..4c3d9d22 --- /dev/null +++ b/tools/meson.build @@ -0,0 +1,113 @@ +# Copyright © 2019-2020 Salamandar +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +if not platform_windows + dbus_cleanup_sockets = executable('dbus-cleanup-sockets', + 'dbus-cleanup-sockets.c', + include_directories: root_include, + install: true, + ) +endif + +if platform_windows + dbus_launch_sources = [ + 'dbus-launch-win.c' + ] +else + dbus_launch_sources = [ + 'dbus-launch.c', + 'dbus-launch-x11.c', + 'tool-common.c', + ] +endif + +dbus_launch = executable('dbus-launch', + dbus_launch_sources, + include_directories: root_include, + link_with: libdbus, + dependencies: [ x11, ], + install: true, +) + + +dbus_monitor = executable('dbus-monitor', + 'dbus-print-message.c', + 'dbus-monitor.c', + 'tool-common.c', + include_directories: root_include, + link_with: libdbus, + install: true, +) + +dbus_run_session = executable('dbus-run-session', + 'dbus-run-session.c', + 'tool-common.c', + include_directories: root_include, + link_with: libdbus_internal, + install: true, +) + +dbus_send = executable('dbus-send', + 'dbus-print-message.c', + 'dbus-send.c', + 'tool-common.c', + include_directories: root_include, + link_with: libdbus, + install: true, +) + +dbus_test_tool = executable('dbus-test-tool', + 'dbus-echo.c', + 'dbus-spam.c', + 'test-tool.c', + 'tool-common.c', + include_directories: root_include, + link_with: libdbus, + install: true, +) + +dbus_update_activation_environment = executable('dbus-update-activation-environment', + 'dbus-update-activation-environment.c', + 'tool-common.c', + platform_windows ? windows.compile_resources('disable-uac.rc') : [], + include_directories: root_include, + link_with: libdbus, + install: true, +) + +if not platform_windows + dbus_uuidgen = executable('dbus-uuidgen', + 'dbus-uuidgen.c', + include_directories: root_include, + link_with: libdbus, + install: true, + ) +endif + + +install_data('GetAllMatchRules.py', + install_dir: docs_dir / 'examples', +) + +# Create the empty directory to hold the machine ID +install_emptydirs += [ + get_option('localstatedir') / 'lib' / 'dbus', +]