{"thread":{"id":"62866","subject":"[PATCH 00/11] meson: cleanups, improvements, smallish fixes","startedAt":"2025-01-29T07:12:07Z","lastAt":"2025-02-07T15:25:45Z","messageCount":35,"participants":["Patrick Steinhardt","Justin Tobler","Toon Claes"],"isPatch":true,"patchVersion":1,"patchTotal":11},"messages":[{"id":"511386","messageId":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":null,"subject":"[PATCH 00/11] meson: cleanups, improvements, smallish fixes","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:11:53Z","receivedAt":"2025-01-29T07:12:07Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series contains a mostly-random set of smallish improvements,\nsimplifications and fixes to the Meson build instructions.\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (11):\n      meson: fix exec path with enabled runtime prefix\n      meson: inline the static 'git' library\n      meson: simplify use of the common-main library\n      meson: stop linking libcurl into all executables\n      meson: introduce `libgit_curl` dependency\n      meson: drop separate version library\n      meson: deduplicate the list of required programs\n      meson: simplify setup of PATH environment variable\n      meson: prevent finding sed(1) in a loop\n      meson: fix overwritten `git` variable\n      meson: consistently use custom program paths to resolve programs\n\n Documentation/howto/meson.build |   2 +-\n Documentation/meson.build       |  13 ++---\n meson.build                     | 124 +++++++++++++++++-----------------------\n t/helper/meson.build            |   4 +-\n t/meson.build                   |   4 +-\n 5 files changed, 63 insertions(+), 84 deletions(-)\n\n\n---\nbase-commit: da898a5c645ce9b6d72c2d39abe1bc3d48cb0fdb\nchange-id: 20250121-b4-pks-meson-improvements-3e575363e91c\n\n"},{"id":"511387","messageId":"20250129-b4-pks-meson-improvements-v1-1-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 01/11] meson: fix exec path with enabled runtime prefix","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:11:54Z","receivedAt":"2025-01-29T07:12:08Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When the runtime prefix option is enabled, Git is built such that it\nknows to locate its binaries relative to the directory a binary is being\nexecuted from. This requires us to figure out relative paths, which is\nhandled in `system_prefix()` by trying to strip a couple of well-known\npaths.\n\nOne of these paths, GIT_EXEC_PATH, is expected to be absolute when\nruntime prefixes are enabled, but relative otherwise. And while our\nMakefile gets this correcty, in Meson we always wire up the absolute\npath, which may result in us not being able to find binaries.\n\nFix this by conditionally injecting the paths depending on whether or\nnot the `runtime_prefix` option is enabled.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex c54ccd2162..fd83df8c42 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -675,7 +675,6 @@ libgit_c_args = [\n   '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n   '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n   '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n-  '-DGIT_EXEC_PATH=\"' + get_option('prefix') / get_option('libexecdir') / 'git-core\"',\n   '-DGIT_HOST_CPU=\"' + host_machine.cpu_family() + '\"',\n   '-DGIT_HTML_PATH=\"' + get_option('datadir') / 'doc/git-doc\"',\n   '-DGIT_INFO_PATH=\"' + get_option('infodir') + '\"',\n@@ -1437,6 +1436,7 @@ endif\n if get_option('runtime_prefix')\n   libgit_c_args += '-DRUNTIME_PREFIX'\n   build_options_config.set('RUNTIME_PREFIX', 'true')\n+  git_exec_path = get_option('libexecdir') / 'git-core'\n \n   if compiler.has_header('mach-o/dyld.h')\n     libgit_c_args += '-DHAVE_NS_GET_EXECUTABLE_PATH'\n@@ -1473,7 +1473,9 @@ if get_option('runtime_prefix')\n   endif\n else\n   build_options_config.set('RUNTIME_PREFIX', 'false')\n+  git_exec_path = get_option('prefix') / get_option('libexecdir') / 'git-core'\n endif\n+libgit_c_args += '-DGIT_EXEC_PATH=\"' + git_exec_path + '\"'\n \n git_version_file = custom_target(\n   command: [\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511388","messageId":"20250129-b4-pks-meson-improvements-v1-2-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 02/11] meson: inline the static 'git' library","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:11:55Z","receivedAt":"2025-01-29T07:12:08Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When setting up `libgit.a` we first create the static library itself,\nand then declare it as part of a dependency such that compile arguments,\ninclude directories and transitive dependencies get propagated to the\nusers of that library. As such, the static library isn't expected to be\nused by anything but the declared dependency.\n\nInline the static library so that we don't even use a separate variable\nfor it. This avoids any kind of confusion that may arise and clarifies\nhow the library is supposed to be used.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 16 +++++++---------\n 1 file changed, 7 insertions(+), 9 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex fd83df8c42..84d100fd25 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1521,17 +1521,15 @@ libgit_version_library = static_library('git-version',\n   include_directories: libgit_include_directories,\n )\n \n-libgit_library = static_library('git',\n-  sources: libgit_sources,\n-  c_args: libgit_c_args,\n-  link_with: libgit_version_library,\n-  dependencies: libgit_dependencies,\n-  include_directories: libgit_include_directories,\n-)\n-\n libgit = declare_dependency(\n+  link_with: static_library('git',\n+    sources: libgit_sources,\n+    c_args: libgit_c_args,\n+    link_with: libgit_version_library,\n+    dependencies: libgit_dependencies,\n+    include_directories: libgit_include_directories,\n+  ),\n   compile_args: libgit_c_args,\n-  link_with: libgit_library,\n   dependencies: libgit_dependencies,\n   include_directories: libgit_include_directories,\n )\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511389","messageId":"20250129-b4-pks-meson-improvements-v1-4-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 04/11] meson: stop linking libcurl into all executables","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:11:57Z","receivedAt":"2025-01-29T07:12:09Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We set up libcurl via the `libgit_dependencies` variable, which gets\npropagated into every user of the `libgit` dependency. This is not\nnecessary though, as most of our executables aren't even supposed to\nlink against libcurl.\n\nFix this by only linking against libcurl as required.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex 82b6e62029..6f62728117 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -911,7 +911,6 @@ if curl.found()\n     use_curl_for_imap_send = true\n   endif\n \n-  libgit_dependencies += curl\n   libgit_c_args += '-DCURL_DISABLE_TYPECHECK'\n   build_options_config.set('NO_CURL', '')\n else\n@@ -1631,7 +1630,7 @@ if get_option('curl').enabled()\n \n   git_remote_http = executable('git-remote-http',\n     sources: curl_sources + 'remote-curl.c',\n-    dependencies: [libgit_commonmain],\n+    dependencies: [libgit_commonmain, curl],\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n@@ -1639,7 +1638,7 @@ if get_option('curl').enabled()\n \n   test_dependencies += executable('git-http-fetch',\n     sources: curl_sources + 'http-fetch.c',\n-    dependencies: [libgit_commonmain],\n+    dependencies: [libgit_commonmain, curl],\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n@@ -1647,7 +1646,7 @@ if get_option('curl').enabled()\n   if expat.found()\n     test_dependencies += executable('git-http-push',\n       sources: curl_sources + 'http-push.c',\n-      dependencies: [libgit_commonmain],\n+      dependencies: [libgit_commonmain, curl],\n       install: true,\n       install_dir: get_option('libexecdir') / 'git-core',\n     )\n@@ -1656,7 +1655,7 @@ if get_option('curl').enabled()\n   foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]\n     test_dependencies += executable(alias,\n       objects: git_remote_http.extract_all_objects(recursive: false),\n-      dependencies: [libgit],\n+      dependencies: [libgit, curl],\n     )\n \n     install_symlink(alias + executable_suffix,\n@@ -1667,13 +1666,15 @@ if get_option('curl').enabled()\n endif\n \n imap_send_sources = ['imap-send.c']\n+imap_send_dependencies = [libgit_commonmain]\n if use_curl_for_imap_send\n   imap_send_sources += curl_sources\n+  imap_send_dependencies += curl\n endif\n \n test_dependencies += executable('git-imap-send',\n   sources: imap_send_sources,\n-  dependencies: [libgit_commonmain],\n+  dependencies: imap_send_dependencies,\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511390","messageId":"20250129-b4-pks-meson-improvements-v1-3-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 03/11] meson: simplify use of the common-main library","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:11:56Z","receivedAt":"2025-01-29T07:12:09Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"common-main.c\" file is used by multiple executables. In order to\nmake it easy to set it up we have created a separate library that these\nexecutables can link against. All of these executables also want to link\nagainst `libgit.a` though, which makes it necessary to specify both of\nthese as dependencies for every executable.\n\nSimplify this a bit by declaring the library as a source dependency:\ninstead of creating a static library, we now instead compile the common\nset of files into each executable separately.\n\nThis change surfaces an issue when linking aliases for git-remote-http:\nwe extract all objects from `git-remote-http` et al and then link them\ninto the new executable. As such, these objects would already contain\na `main()` function. But now that we also compile \"common-main.c\" into\nthese aliased executables we see a linker error due to `main()` being\ndefined twice. We fix this by only linking against `libgit.a`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build          | 34 +++++++++++++++-------------------\n t/helper/meson.build |  4 ++--\n t/meson.build        |  4 ++--\n 3 files changed, 19 insertions(+), 23 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex 84d100fd25..82b6e62029 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1570,15 +1570,11 @@ if host_machine.system() == 'windows'\n     error('Unsupported compiler ' + compiler.get_id())\n   endif\n endif\n-common_main_library = static_library('common-main',\n+\n+libgit_commonmain = declare_dependency(\n   sources: common_main_sources,\n-  c_args: libgit_c_args,\n-  dependencies: libgit_dependencies,\n-  include_directories: libgit_include_directories,\n-)\n-common_main = declare_dependency(\n-  link_with: common_main_library,\n   link_args: common_main_link_args,\n+  dependencies: [ libgit ],\n )\n \n bin_wrappers = [ ]\n@@ -1586,7 +1582,7 @@ test_dependencies = [ ]\n \n git = executable('git',\n   sources: builtin_sources + 'git.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n@@ -1594,35 +1590,35 @@ bin_wrappers += git\n \n test_dependencies += executable('git-daemon',\n   sources: 'daemon.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n test_dependencies += executable('git-sh-i18n--envsubst',\n   sources: 'sh-i18n--envsubst.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n bin_wrappers += executable('git-shell',\n   sources: 'shell.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n test_dependencies += executable('git-http-backend',\n   sources: 'http-backend.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n bin_wrappers += executable('scalar',\n   sources: 'scalar.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n@@ -1635,7 +1631,7 @@ if get_option('curl').enabled()\n \n   git_remote_http = executable('git-remote-http',\n     sources: curl_sources + 'remote-curl.c',\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit_commonmain],\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n@@ -1643,7 +1639,7 @@ if get_option('curl').enabled()\n \n   test_dependencies += executable('git-http-fetch',\n     sources: curl_sources + 'http-fetch.c',\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit_commonmain],\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n@@ -1651,7 +1647,7 @@ if get_option('curl').enabled()\n   if expat.found()\n     test_dependencies += executable('git-http-push',\n       sources: curl_sources + 'http-push.c',\n-      dependencies: [libgit, common_main],\n+      dependencies: [libgit_commonmain],\n       install: true,\n       install_dir: get_option('libexecdir') / 'git-core',\n     )\n@@ -1660,7 +1656,7 @@ if get_option('curl').enabled()\n   foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]\n     test_dependencies += executable(alias,\n       objects: git_remote_http.extract_all_objects(recursive: false),\n-      dependencies: [libgit, common_main],\n+      dependencies: [libgit],\n     )\n \n     install_symlink(alias + executable_suffix,\n@@ -1677,7 +1673,7 @@ endif\n \n test_dependencies += executable('git-imap-send',\n   sources: imap_send_sources,\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n@@ -1685,7 +1681,7 @@ test_dependencies += executable('git-imap-send',\n foreach alias : [ 'git-receive-pack', 'git-upload-archive', 'git-upload-pack' ]\n   bin_wrappers += executable(alias,\n     objects: git.extract_all_objects(recursive: false),\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit],\n   )\n \n   install_symlink(alias + executable_suffix,\ndiff --git a/t/helper/meson.build b/t/helper/meson.build\nindex 5e83884246..05bf35bd26 100644\n--- a/t/helper/meson.build\n+++ b/t/helper/meson.build\n@@ -78,14 +78,14 @@ test_tool_sources = [\n \n test_tool = executable('test-tool',\n   sources: test_tool_sources,\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n )\n bin_wrappers += test_tool\n test_dependencies += test_tool\n \n test_fake_ssh = executable('test-fake-ssh',\n   sources: 'test-fake-ssh.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n )\n bin_wrappers += test_fake_ssh\n test_dependencies += test_fake_ssh\ndiff --git a/t/meson.build b/t/meson.build\nindex 14fea8dddf..8896314b88 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -39,7 +39,7 @@ clar_sources += custom_target(\n \n clar_unit_tests = executable('unit-tests',\n   sources: clar_sources + clar_test_suites,\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n )\n test('unit-tests', clar_unit_tests)\n \n@@ -72,7 +72,7 @@ foreach unit_test_program : unit_test_programs\n       'unit-tests/lib-reftable.c',\n       unit_test_program,\n     ],\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit_commonmain],\n   )\n   test(unit_test_name, unit_test,\n     workdir: meson.current_source_dir(),\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511394","messageId":"20250129-b4-pks-meson-improvements-v1-5-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 05/11] meson: introduce `libgit_curl` dependency","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:11:58Z","receivedAt":"2025-01-29T07:12:10Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We've got a set of common source files that we use for those executables\nthat link against libcurl. The setup is somewhat repetitive though.\nSimplify it by declaring a `libgit_curl` dependency that bundles all of\nit together.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 41 ++++++++++++++++++-----------------------\n 1 file changed, 18 insertions(+), 23 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex 6f62728117..e022235815 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1623,30 +1623,32 @@ bin_wrappers += executable('scalar',\n )\n \n if get_option('curl').enabled()\n-  curl_sources = [\n-    'http.c',\n-    'http-walker.c',\n-  ]\n-\n-  git_remote_http = executable('git-remote-http',\n-    sources: curl_sources + 'remote-curl.c',\n+  libgit_curl = declare_dependency(\n+    sources: [\n+      'http.c',\n+      'http-walker.c',\n+    ],\n     dependencies: [libgit_commonmain, curl],\n+  )\n+\n+  test_dependencies += executable('git-remote-http',\n+    sources: 'remote-curl.c',\n+    dependencies: libgit_curl,\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n-  test_dependencies += git_remote_http\n \n   test_dependencies += executable('git-http-fetch',\n-    sources: curl_sources + 'http-fetch.c',\n-    dependencies: [libgit_commonmain, curl],\n+    sources: 'http-fetch.c',\n+    dependencies: libgit_curl,\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n \n   if expat.found()\n     test_dependencies += executable('git-http-push',\n-      sources: curl_sources + 'http-push.c',\n-      dependencies: [libgit_commonmain, curl],\n+      sources: 'http-push.c',\n+      dependencies: libgit_curl,\n       install: true,\n       install_dir: get_option('libexecdir') / 'git-core',\n     )\n@@ -1654,8 +1656,8 @@ if get_option('curl').enabled()\n \n   foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]\n     test_dependencies += executable(alias,\n-      objects: git_remote_http.extract_all_objects(recursive: false),\n-      dependencies: [libgit, curl],\n+      sources: 'remote-curl.c',\n+      dependencies: libgit_curl,\n     )\n \n     install_symlink(alias + executable_suffix,\n@@ -1665,16 +1667,9 @@ if get_option('curl').enabled()\n   endforeach\n endif\n \n-imap_send_sources = ['imap-send.c']\n-imap_send_dependencies = [libgit_commonmain]\n-if use_curl_for_imap_send\n-  imap_send_sources += curl_sources\n-  imap_send_dependencies += curl\n-endif\n-\n test_dependencies += executable('git-imap-send',\n-  sources: imap_send_sources,\n-  dependencies: imap_send_dependencies,\n+  sources: 'imap-send.c',\n+  dependencies: use_curl_for_imap_send ? [libgit_curl] : [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511391","messageId":"20250129-b4-pks-meson-improvements-v1-7-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 07/11] meson: deduplicate the list of required programs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:12:00Z","receivedAt":"2025-01-29T07:12:11Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When setting up Meson we detect a couple of executables that we rely on\nin order to build Git and prepend their respective directories to PATH.\nThis is done so that Windows can locate these tools at build time in\ncase they aren't included in the default PATH, as we know to pick up\nthose required build tools from the Git for Windows path explicitly.\n\nThe list of executables we check against is somewhat excessive though,\nas many of the tools are all part of coreutils. Let's deduplicate them\nso that we only check for one binary that is part of it, namely cat(1).\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex 1e1e478d17..48eb068fd8 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -187,7 +187,7 @@ shell = find_program('sh', dirs: program_path)\n tar = find_program('tar', dirs: program_path)\n \n script_environment = environment()\n-foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']\n+foreach tool : ['cat', 'grep', 'sed']\n   program = find_program(tool, dirs: program_path)\n   script_environment.prepend('PATH', fs.parent(program.full_path()))\n endforeach\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511392","messageId":"20250129-b4-pks-meson-improvements-v1-6-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 06/11] meson: drop separate version library","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:11:59Z","receivedAt":"2025-01-29T07:12:11Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When building `libgit.a` we link it against a `libgit_version.a` library\nthat contains the version information that we inject at build time. The\nintent of this is to avoid rebuilding all of `libgit.a` whenever the\nversion changes. But that wouldn't happen in the first place, as we know\nto just rebuild the files that depend on the generated \"version-def.h\"\nfile.\n\nThis is an artifact of an earlier version of the Meson build infra that\ndidn't ultimately land. We didn't yet have \"version-def.h\", and instead\ninjected the version via preprocessor directives. And here we would have\nrebuilt all of `libgit.a` indeed in case the version changes, because\nthe preprocessor directive applied to all files.\n\nStop building the separate library and instead add \"version-def.h\" to\nthe list of source files directly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 21 +++++----------------\n 1 file changed, 5 insertions(+), 16 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex e022235815..1e1e478d17 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -462,6 +462,7 @@ libgit_sources = [\n   'userdiff.c',\n   'utf8.c',\n   'varint.c',\n+  'version.c',\n   'versioncmp.c',\n   'walker.c',\n   'wildmatch.c',\n@@ -1505,26 +1506,14 @@ version_def_h = custom_target(\n   depends: [git_version_file],\n   env: version_gen_environment,\n )\n-\n-# Build a separate library for \"version.c\" so that we do not have to rebuild\n-# everything when the current Git commit changes.\n-libgit_version_library = static_library('git-version',\n-  sources: [\n-    'version.c',\n-    version_def_h,\n-  ],\n-  c_args: libgit_c_args + [\n-    '-DGIT_VERSION_H=\"' + version_def_h.full_path() + '\"',\n-  ],\n-  dependencies: libgit_dependencies,\n-  include_directories: libgit_include_directories,\n-)\n+libgit_sources += version_def_h\n \n libgit = declare_dependency(\n   link_with: static_library('git',\n     sources: libgit_sources,\n-    c_args: libgit_c_args,\n-    link_with: libgit_version_library,\n+    c_args: libgit_c_args + [\n+      '-DGIT_VERSION_H=\"' + version_def_h.full_path() + '\"',\n+    ],\n     dependencies: libgit_dependencies,\n     include_directories: libgit_include_directories,\n   ),\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511393","messageId":"20250129-b4-pks-meson-improvements-v1-8-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 08/11] meson: simplify setup of PATH environment variable","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:12:01Z","receivedAt":"2025-01-29T07:12:12Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We're setting up the PATH environment variable such that a set of\nnecessary build tools can be found at build time. Make this step a bit\nless repetitive by only looping through the set of found programs once.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 17 ++++++++---------\n 1 file changed, 8 insertions(+), 9 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex 48eb068fd8..e3829f2365 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -181,22 +181,21 @@ if host_machine.system() == 'windows'\n   program_path += [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]\n endif\n \n+cat = find_program('cat', dirs: program_path)\n cygpath = find_program('cygpath', dirs: program_path, required: false)\n diff = find_program('diff', dirs: program_path)\n+git = find_program('git', dirs: program_path, required: false)\n+grep = find_program('grep', dirs: program_path)\n+sed = find_program('sed', dirs: program_path)\n shell = find_program('sh', dirs: program_path)\n tar = find_program('tar', dirs: program_path)\n \n script_environment = environment()\n-foreach tool : ['cat', 'grep', 'sed']\n-  program = find_program(tool, dirs: program_path)\n-  script_environment.prepend('PATH', fs.parent(program.full_path()))\n+foreach program : [cat, cygpath, diff, git, grep, sed, shell, tar]\n+  if program.found()\n+    script_environment.prepend('PATH', fs.parent(program.full_path()))\n+  endif\n endforeach\n-\n-git = find_program('git', dirs: program_path, required: false)\n-if git.found()\n-  script_environment.prepend('PATH', fs.parent(git.full_path()))\n-endif\n-\n if get_option('sane_tool_path') != ''\n   script_environment.prepend('PATH', get_option('sane_tool_path'))\n endif\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511395","messageId":"20250129-b4-pks-meson-improvements-v1-9-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 09/11] meson: prevent finding sed(1) in a loop","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:12:02Z","receivedAt":"2025-01-29T07:12:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We're searching for the sed(1) executable in a loop, which will make us\ntry to find it multiple times. Starting with the preceding commit we\nalready declare a variable for that program in the top-level build file.\nUse it so that we only need to search for the program once.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/howto/meson.build | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/howto/meson.build b/Documentation/howto/meson.build\nindex c023c10416..92a08b13ee 100644\n--- a/Documentation/howto/meson.build\n+++ b/Documentation/howto/meson.build\n@@ -41,7 +41,7 @@ custom_target(\n foreach howto : howto_sources\n   howto_stripped = custom_target(\n     command: [\n-      find_program('sed'),\n+      sed,\n       '-e',\n       '1,/^$/d',\n       '@INPUT@',\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511396","messageId":"20250129-b4-pks-meson-improvements-v1-10-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 10/11] meson: fix overwritten `git` variable","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:12:03Z","receivedAt":"2025-01-29T07:12:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We're assigning the `git` variable in three places:\n\n  - In \"meson.build\" to store the external Git executable.\n\n  - In \"meson.build\" to store the compiled Git executable.\n\n  - In \"Documentation/meson.build\" to store the external Git executable,\n    a second time.\n\nThe last case is only needed because we overwrite the original variable\nwith the built version. Rename the variable used for the built Git\nexecutable so that we don't have to resolve the external Git executable\nmultiple times.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/meson.build | 1 -\n meson.build               | 6 +++---\n 2 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 2a26fa8a5f..6438fa6792 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -283,7 +283,6 @@ elif docs_backend == 'asciidoctor'\n   ]\n endif\n \n-git = find_program('git', required: false)\n xmlto = find_program('xmlto')\n \n cmd_lists = [\ndiff --git a/meson.build b/meson.build\nindex e3829f2365..828fbae8b0 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1567,13 +1567,13 @@ libgit_commonmain = declare_dependency(\n bin_wrappers = [ ]\n test_dependencies = [ ]\n \n-git = executable('git',\n+git_builtin = executable('git',\n   sources: builtin_sources + 'git.c',\n   dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n-bin_wrappers += git\n+bin_wrappers += git_builtin\n \n test_dependencies += executable('git-daemon',\n   sources: 'daemon.c',\n@@ -1664,7 +1664,7 @@ test_dependencies += executable('git-imap-send',\n \n foreach alias : [ 'git-receive-pack', 'git-upload-archive', 'git-upload-pack' ]\n   bin_wrappers += executable(alias,\n-    objects: git.extract_all_objects(recursive: false),\n+    objects: git_builtin.extract_all_objects(recursive: false),\n     dependencies: [libgit],\n   )\n \n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511397","messageId":"20250129-b4-pks-meson-improvements-v1-11-ab709f0be12c@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH 11/11] meson: consistently use custom program paths to resolve programs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-29T07:12:04Z","receivedAt":"2025-01-29T07:12:15Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The calls to `find_program()` in our documentation don't use our custom\nprogram path. This variable gets populated on Windows with the location\nof Git for Windows so that we can use it to provide our build tools.\nConsequently, we may not be able to find all necessary binaries on\nWindows.\n\nAdapt the calls to use the program path to fix this. While at it, drop\n`required: true` arguments, which are the default anyway.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/meson.build | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 6438fa6792..c6117366ff 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -206,9 +206,9 @@ manpages = {\n \n docs_backend = get_option('docs_backend')\n if docs_backend == 'auto'\n-  if find_program('asciidoc', required: false).found()\n+  if find_program('asciidoc', dirs: program_path, required: false).found()\n     docs_backend = 'asciidoc'\n-  elif find_program('asciidoctor', required: false).found()\n+  elif find_program('asciidoctor', dirs: program_path, required: false).found()\n     docs_backend = 'asciidoctor'\n   else\n     error('Neither asciidoc nor asciidoctor were found.')\n@@ -216,7 +216,7 @@ if docs_backend == 'auto'\n endif\n \n if docs_backend == 'asciidoc'\n-  asciidoc = find_program('asciidoc', required: true)\n+  asciidoc = find_program('asciidoc', dirs: program_path)\n   asciidoc_html = 'xhtml11'\n   asciidoc_docbook = 'docbook'\n   xmlto_extra = [ ]\n@@ -245,7 +245,7 @@ if docs_backend == 'asciidoc'\n     asciidoc_conf,\n   ]\n elif docs_backend == 'asciidoctor'\n-  asciidoctor = find_program('asciidoctor', required: true)\n+  asciidoctor = find_program('asciidoctor', dirs: program_path)\n   asciidoc_html = 'xhtml5'\n   asciidoc_docbook = 'docbook5'\n   xmlto_extra = [\n@@ -283,7 +283,7 @@ elif docs_backend == 'asciidoctor'\n   ]\n endif\n \n-xmlto = find_program('xmlto')\n+xmlto = find_program('xmlto', dirs: program_path)\n \n cmd_lists = [\n   'cmds-ancillaryinterrogators.txt',\n@@ -404,7 +404,7 @@ if get_option('docs').contains('html')\n     pointing_to: 'git.html',\n   )\n \n-  xsltproc = find_program('xsltproc')\n+  xsltproc = find_program('xsltproc', dirs: program_path)\n \n   user_manual_xml = custom_target(\n     command: asciidoc_common_options + [\n\n-- \n2.48.1.362.g079036d154.dirty\n\n"},{"id":"511430","messageId":"7rnnfxsi4taxtyqek5udyplp767w6jdbw3zshvbbsbc5qxmjs6@ftjofkjsnzyb","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-1-ab709f0be12c@pks.im","subject":"Re: [PATCH 01/11] meson: fix exec path with enabled runtime prefix","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-01-29T20:12:35Z","receivedAt":"2025-01-29T20:15:29Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/01/29 08:11AM, Patrick Steinhardt wrote:\n> When the runtime prefix option is enabled, Git is built such that it\n> knows to locate its binaries relative to the directory a binary is being\n> executed from. This requires us to figure out relative paths, which is\n> handled in `system_prefix()` by trying to strip a couple of well-known\n> paths.\n\nOk if I understand this correctly, when the runtime prefix option is\nenabled, the prefix that gets setup by `system_prefix()` is expected to\nbe relative from the directory the binary is being executed at.\n\n> One of these paths, GIT_EXEC_PATH, is expected to be absolute when\n> runtime prefixes are enabled, but relative otherwise. And while our\n> Makefile gets this correcty, in Meson we always wire up the absolute\n\ns/correcty/correctly/\n\n> path, which may result in us not being able to find binaries.\n\nSo the problem is that since GIT_EXEC_PATH is always defined as\nabsolute, when the runtime prefix option is enabled, the relative prefix\nis not able to be correctly set and thus always uses the\n`FALLBACK_RUNTIME_PREFIX`.\n\n> Fix this by conditionally injecting the paths depending on whether or\n> not the `runtime_prefix` option is enabled.\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  meson.build | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n> \n> diff --git a/meson.build b/meson.build\n> index c54ccd2162..fd83df8c42 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -675,7 +675,6 @@ libgit_c_args = [\n>    '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n>    '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n>    '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n> -  '-DGIT_EXEC_PATH=\"' + get_option('prefix') / get_option('libexecdir') / 'git-core\"',\n>    '-DGIT_HOST_CPU=\"' + host_machine.cpu_family() + '\"',\n>    '-DGIT_HTML_PATH=\"' + get_option('datadir') / 'doc/git-doc\"',\n>    '-DGIT_INFO_PATH=\"' + get_option('infodir') + '\"',\n> @@ -1437,6 +1436,7 @@ endif\n>  if get_option('runtime_prefix')\n>    libgit_c_args += '-DRUNTIME_PREFIX'\n>    build_options_config.set('RUNTIME_PREFIX', 'true')\n> +  git_exec_path = get_option('libexecdir') / 'git-core'\n>  \n>    if compiler.has_header('mach-o/dyld.h')\n>      libgit_c_args += '-DHAVE_NS_GET_EXECUTABLE_PATH'\n> @@ -1473,7 +1473,9 @@ if get_option('runtime_prefix')\n>    endif\n>  else\n>    build_options_config.set('RUNTIME_PREFIX', 'false')\n> +  git_exec_path = get_option('prefix') / get_option('libexecdir') / 'git-core'\n>  endif\n> +libgit_c_args += '-DGIT_EXEC_PATH=\"' + git_exec_path + '\"'\n\nOk, so now we conditionally set `GIT_EXEC_PATH` depending on whether the\nruntime prefix option is enabled. Makes sense\n\n>  \n>  git_version_file = custom_target(\n>    command: [\n> \n> -- \n> 2.48.1.362.g079036d154.dirty\n> \n> \n"},{"id":"511431","messageId":"5ytcbgq73mpxqgz4vsxg4trk456c7b44x74ch64xw54agjlj74@5dd6jtifg5xd","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-7-ab709f0be12c@pks.im","subject":"Re: [PATCH 07/11] meson: deduplicate the list of required programs","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-01-29T20:28:36Z","receivedAt":"2025-01-29T20:31:31Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/01/29 08:12AM, Patrick Steinhardt wrote:\n> When setting up Meson we detect a couple of executables that we rely on\n> in order to build Git and prepend their respective directories to PATH.\n> This is done so that Windows can locate these tools at build time in\n> case they aren't included in the default PATH, as we know to pick up\n> those required build tools from the Git for Windows path explicitly.\n> \n> The list of executables we check against is somewhat excessive though,\n> as many of the tools are all part of coreutils. Let's deduplicate them\n> so that we only check for one binary that is part of it, namely cat(1).\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  meson.build | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/meson.build b/meson.build\n> index 1e1e478d17..48eb068fd8 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -187,7 +187,7 @@ shell = find_program('sh', dirs: program_path)\n>  tar = find_program('tar', dirs: program_path)\n>  \n>  script_environment = environment()\n> -foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']\n> +foreach tool : ['cat', 'grep', 'sed']\n\nIt might be nice to leave a comment here noting that checking for cat(1)\nalone is sufficient to account for the other tools part of coreutils.\n\n>    program = find_program(tool, dirs: program_path)\n>    script_environment.prepend('PATH', fs.parent(program.full_path()))\n>  endforeach\n> \n> -- \n> 2.48.1.362.g079036d154.dirty\n> \n> \n"},{"id":"511433","messageId":"ujdktdisdk56ow3f2uudfgyh4lkya372wennuh7xsurbmylkgx@gh6p3l5hx3nf","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-8-ab709f0be12c@pks.im","subject":"Re: [PATCH 08/11] meson: simplify setup of PATH environment variable","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-01-29T20:42:07Z","receivedAt":"2025-01-29T20:45:01Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/01/29 08:12AM, Patrick Steinhardt wrote:\n> We're setting up the PATH environment variable such that a set of\n> necessary build tools can be found at build time. Make this step a bit\n> less repetitive by only looping through the set of found programs once.\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  meson.build | 17 ++++++++---------\n>  1 file changed, 8 insertions(+), 9 deletions(-)\n> \n> diff --git a/meson.build b/meson.build\n> index 48eb068fd8..e3829f2365 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -181,22 +181,21 @@ if host_machine.system() == 'windows'\n>    program_path += [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]\n>  endif\n>  \n> +cat = find_program('cat', dirs: program_path)\n>  cygpath = find_program('cygpath', dirs: program_path, required: false)\n>  diff = find_program('diff', dirs: program_path)\n> +git = find_program('git', dirs: program_path, required: false)\n> +grep = find_program('grep', dirs: program_path)\n> +sed = find_program('sed', dirs: program_path)\n>  shell = find_program('sh', dirs: program_path)\n>  tar = find_program('tar', dirs: program_path)\n\nAt first I was curious to why we wouldn't just invoke `find_program()`\nduring the loop as well, but some of these programs are not required and\nmarked as such here.\n\n>  script_environment = environment()\n> -foreach tool : ['cat', 'grep', 'sed']\n> -  program = find_program(tool, dirs: program_path)\n> -  script_environment.prepend('PATH', fs.parent(program.full_path()))\n> +foreach program : [cat, cygpath, diff, git, grep, sed, shell, tar]\n> +  if program.found()\n> +    script_environment.prepend('PATH', fs.parent(program.full_path()))\n> +  endif\n\nIt looks like cygpath, diff, shell, and tar were previously not being\nappended to the path environment. With this change now they are.\n\n>  endforeach\n> -\n> -git = find_program('git', dirs: program_path, required: false)\n> -if git.found()\n> -  script_environment.prepend('PATH', fs.parent(git.full_path()))\n> -endif\n> -\n>  if get_option('sane_tool_path') != ''\n>    script_environment.prepend('PATH', get_option('sane_tool_path'))\n>  endif\n> \n> -- \n> 2.48.1.362.g079036d154.dirty\n> \n> \n"},{"id":"511470","messageId":"Z5sk2bbyou4Wslgu@pks.im","threadId":"62866","inReplyTo":"ujdktdisdk56ow3f2uudfgyh4lkya372wennuh7xsurbmylkgx@gh6p3l5hx3nf","subject":"Re: [PATCH 08/11] meson: simplify setup of PATH environment variable","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T07:06:01Z","receivedAt":"2025-01-30T07:06:11Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Jan 29, 2025 at 02:42:07PM -0600, Justin Tobler wrote:\n> On 25/01/29 08:12AM, Patrick Steinhardt wrote:\n> >  script_environment = environment()\n> > -foreach tool : ['cat', 'grep', 'sed']\n> > -  program = find_program(tool, dirs: program_path)\n> > -  script_environment.prepend('PATH', fs.parent(program.full_path()))\n> > +foreach program : [cat, cygpath, diff, git, grep, sed, shell, tar]\n> > +  if program.found()\n> > +    script_environment.prepend('PATH', fs.parent(program.full_path()))\n> > +  endif\n> \n> It looks like cygpath, diff, shell, and tar were previously not being\n> appended to the path environment. With this change now they are.\n\nYou know, I think I've been approaching this from the wrong angle. It's\nnot like we need to add these tools to PATH in case they have been found\nvia the usual PATH lookup: Meson knows to remember PATH just fine, so\nthe scripts would be able to find them anyway.\n\nThe actual issue is that we sometimes end up looking up programs via\nsomething else but PATH, namely on Windows, where we may instead look up\nprograms via the Git for Windows installation. So the proper way to\nhandle this is to add these system-specific paths to PATH, not every\nsingle binary's parent directory.\n\nWill adapt, thanks for making me rethink.\n\nPatrick\n"},{"id":"511471","messageId":"Z5sk4iIDTHDG3Gi_@pks.im","threadId":"62866","inReplyTo":"7rnnfxsi4taxtyqek5udyplp767w6jdbw3zshvbbsbc5qxmjs6@ftjofkjsnzyb","subject":"Re: [PATCH 01/11] meson: fix exec path with enabled runtime prefix","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T07:06:10Z","receivedAt":"2025-01-30T07:06:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Jan 29, 2025 at 02:12:35PM -0600, Justin Tobler wrote:\n> On 25/01/29 08:11AM, Patrick Steinhardt wrote:\n> > When the runtime prefix option is enabled, Git is built such that it\n> > knows to locate its binaries relative to the directory a binary is being\n> > executed from. This requires us to figure out relative paths, which is\n> > handled in `system_prefix()` by trying to strip a couple of well-known\n> > paths.\n> \n> Ok if I understand this correctly, when the runtime prefix option is\n> enabled, the prefix that gets setup by `system_prefix()` is expected to\n> be relative from the directory the binary is being executed at.\n> \n> > One of these paths, GIT_EXEC_PATH, is expected to be absolute when\n> > runtime prefixes are enabled, but relative otherwise. And while our\n> > Makefile gets this correcty, in Meson we always wire up the absolute\n> \n> s/correcty/correctly/\n> \n> > path, which may result in us not being able to find binaries.\n> \n> So the problem is that since GIT_EXEC_PATH is always defined as\n> absolute, when the runtime prefix option is enabled, the relative prefix\n> is not able to be correctly set and thus always uses the\n> `FALLBACK_RUNTIME_PREFIX`.\n\nYup, excatly.\n\nPatrick\n"},{"id":"511491","messageId":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im","subject":"[PATCH v2 00/13] meson: cleanups, improvements, smallish fixes","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:43:52Z","receivedAt":"2025-01-30T14:44:12Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series contains a mostly-random set of smallish improvements,\nsimplifications and fixes to the Meson build instructions.\n\nChanges in v2:\n  - Redo the two commits regarding PATH handling. We now only prepend\n    system-specific paths to PATH and handle the `-Dsane_tool_path`\n    option the same.\n  - Continue to propagate libcurl include directories into libgit, as we\n    need it for \"help.c\" to resolve LIBCURL_VERSION. Reorder the patch\n    to minimize the required changes.\n  - Fix a commit message typo.\n  - Include another commit that fixes the OpenSSL fallback on Windows.\n  - Include another commit to fix linker errors due to out-of-memory\n    situations on Windows with GitLab CI.\n  - Link to v1: https://lore.kernel.org/r/20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im\n\nI have furthermore pulled in ps/build-meson-fixes at 7304bd2bc3 (ci:\nwire up Visual Studio build with Meson, 2025-01-22) as a dependency of\nthis series. This is due to a semantic conflict with 28911f7dca (meson:\nwire up fuzzers, 2025-01-22).\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (13):\n      meson: fix exec path with enabled runtime prefix\n      meson: fix OpenSSL fallback when not explicitly required\n      meson: inline the static 'git' library\n      meson: simplify use of the common-main library\n      meson: introduce `libgit_curl` dependency\n      meson: stop linking libcurl into all executables\n      meson: drop separate version library\n      meson: improve PATH handling\n      meson: improve handling of `sane_tool_path` option\n      meson: prevent finding sed(1) in a loop\n      meson: fix overwritten `git` variable\n      meson: consistently use custom program paths to resolve programs\n      gitlab-ci: restrict maximum number of link jobs on Windows\n\n .gitlab-ci.yml                  |   2 +-\n Documentation/howto/meson.build |   2 +-\n Documentation/meson.build       |  13 ++--\n meson.build                     | 151 +++++++++++++++++++---------------------\n meson_options.txt               |   4 +-\n oss-fuzz/meson.build            |   2 +-\n t/helper/meson.build            |   4 +-\n t/meson.build                   |   4 +-\n 8 files changed, 85 insertions(+), 97 deletions(-)\n\nRange-diff versus v1:\n\n 1:  a4f1eb695a !  1:  932d79a814 meson: fix exec path with enabled runtime prefix\n    @@ Commit message\n     \n         One of these paths, GIT_EXEC_PATH, is expected to be absolute when\n         runtime prefixes are enabled, but relative otherwise. And while our\n    -    Makefile gets this correcty, in Meson we always wire up the absolute\n    +    Makefile gets this correctly, in Meson we always wire up the absolute\n         path, which may result in us not being able to find binaries.\n     \n         Fix this by conditionally injecting the paths depending on whether or\n -:  ---------- >  2:  6bd07f35a6 meson: fix OpenSSL fallback when not explicitly required\n 2:  da61c2a679 =  3:  94f9e45c56 meson: inline the static 'git' library\n 3:  744754959e !  4:  669c811eb6 meson: simplify use of the common-main library\n    @@ meson.build: test_dependencies += executable('git-imap-send',\n      \n        install_symlink(alias + executable_suffix,\n     \n    + ## oss-fuzz/meson.build ##\n    +@@ oss-fuzz/meson.build: foreach fuzz_program : fuzz_programs\n    +       'dummy-cmd-main.c',\n    +       fuzz_program,\n    +     ],\n    +-    dependencies: [libgit, common_main],\n    ++    dependencies: [libgit_commonmain],\n    +   )\n    + endforeach\n    +\n      ## t/helper/meson.build ##\n     @@ t/helper/meson.build: test_tool_sources = [\n      \n 4:  172d3e07a5 <  -:  ---------- meson: stop linking libcurl into all executables\n 5:  a0a1e548cc !  5:  edb9fba4b3 meson: introduce `libgit_curl` dependency\n    @@ Commit message\n         Simplify it by declaring a `libgit_curl` dependency that bundles all of\n         it together.\n     \n    +    Note that we don't include curl itself as a dependency. This is because\n    +    we already pull it in transitively via the libgit dependency, which is\n    +    unfortunate because libgit itself shouldn't actually link against curl\n    +    in the first place. This will get fixed in the next commit.\n    +\n         Signed-off-by: Patrick Steinhardt <ps@pks.im>\n     \n      ## meson.build ##\n    @@ meson.build: bin_wrappers += executable('scalar',\n     +      'http.c',\n     +      'http-walker.c',\n     +    ],\n    -     dependencies: [libgit_commonmain, curl],\n    +     dependencies: [libgit_commonmain],\n     +  )\n     +\n     +  test_dependencies += executable('git-remote-http',\n     +    sources: 'remote-curl.c',\n    -+    dependencies: libgit_curl,\n    ++    dependencies: [libgit_curl],\n          install: true,\n          install_dir: get_option('libexecdir') / 'git-core',\n        )\n    @@ meson.build: bin_wrappers += executable('scalar',\n      \n        test_dependencies += executable('git-http-fetch',\n     -    sources: curl_sources + 'http-fetch.c',\n    --    dependencies: [libgit_commonmain, curl],\n    +-    dependencies: [libgit_commonmain],\n     +    sources: 'http-fetch.c',\n    -+    dependencies: libgit_curl,\n    ++    dependencies: [libgit_curl],\n          install: true,\n          install_dir: get_option('libexecdir') / 'git-core',\n        )\n    @@ meson.build: bin_wrappers += executable('scalar',\n        if expat.found()\n          test_dependencies += executable('git-http-push',\n     -      sources: curl_sources + 'http-push.c',\n    --      dependencies: [libgit_commonmain, curl],\n    +-      dependencies: [libgit_commonmain],\n     +      sources: 'http-push.c',\n    -+      dependencies: libgit_curl,\n    ++      dependencies: [libgit_curl],\n            install: true,\n            install_dir: get_option('libexecdir') / 'git-core',\n          )\n    @@ meson.build: if get_option('curl').enabled()\n        foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]\n          test_dependencies += executable(alias,\n     -      objects: git_remote_http.extract_all_objects(recursive: false),\n    --      dependencies: [libgit, curl],\n    +-      dependencies: [libgit],\n     +      sources: 'remote-curl.c',\n    -+      dependencies: libgit_curl,\n    ++      dependencies: [libgit_curl],\n          )\n      \n          install_symlink(alias + executable_suffix,\n    @@ meson.build: if get_option('curl').enabled()\n      endif\n      \n     -imap_send_sources = ['imap-send.c']\n    --imap_send_dependencies = [libgit_commonmain]\n     -if use_curl_for_imap_send\n     -  imap_send_sources += curl_sources\n    --  imap_send_dependencies += curl\n     -endif\n     -\n      test_dependencies += executable('git-imap-send',\n     -  sources: imap_send_sources,\n    --  dependencies: imap_send_dependencies,\n    +-  dependencies: [libgit_commonmain],\n     +  sources: 'imap-send.c',\n    -+  dependencies: use_curl_for_imap_send ? [libgit_curl] : [libgit_commonmain],\n    ++  dependencies: [ use_curl_for_imap_send ? libgit_curl : libgit_commonmain ],\n        install: true,\n        install_dir: get_option('libexecdir') / 'git-core',\n      )\n -:  ---------- >  6:  95ceafc2f4 meson: stop linking libcurl into all executables\n 6:  ab55efa559 =  7:  65d00e36b8 meson: drop separate version library\n 7:  7226cd6388 <  -:  ---------- meson: deduplicate the list of required programs\n 8:  55a372a559 <  -:  ---------- meson: simplify setup of PATH environment variable\n -:  ---------- >  8:  3dc35872a3 meson: improve PATH handling\n -:  ---------- >  9:  e996dc571c meson: improve handling of `sane_tool_path` option\n 9:  2abab952c0 ! 10:  2730e0166b meson: prevent finding sed(1) in a loop\n    @@ Documentation/howto/meson.build: custom_target(\n            '-e',\n            '1,/^$/d',\n            '@INPUT@',\n    +\n    + ## meson.build ##\n    +@@ meson.build: endif\n    + cygpath = find_program('cygpath', dirs: program_path, required: false)\n    + diff = find_program('diff', dirs: program_path)\n    + git = find_program('git', dirs: program_path, required: false)\n    ++sed = find_program('sed', dirs: program_path)\n    + shell = find_program('sh', dirs: program_path)\n    + tar = find_program('tar', dirs: program_path)\n    + \n    + # Sanity-check that programs required for the build exist.\n    +-foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']\n    ++foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname']\n    +   find_program(tool, dirs: program_path)\n    + endforeach\n    + \n10:  a36529b4dd = 11:  9a54f2c2b7 meson: fix overwritten `git` variable\n11:  2c60ae4349 = 12:  4604460ba2 meson: consistently use custom program paths to resolve programs\n -:  ---------- > 13:  9a6fd5435d gitlab-ci: restrict maximum number of link jobs on Windows\n\n---\nbase-commit: 6dd4e543f2219290db9faa61b30f7f30a34e4b50\nchange-id: 20250121-b4-pks-meson-improvements-3e575363e91c\n\n"},{"id":"511492","messageId":"20250130-b4-pks-meson-improvements-v2-2-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 02/13] meson: fix OpenSSL fallback when not explicitly required","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:43:54Z","receivedAt":"2025-01-30T14:44:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When OpenSSL isn't provided by the system we know to fall back to the\nsubproject wrapper. This is especially helpful on Windows systems, where\nyou typically don't have OpenSSL available, in order to reduce the\nnumber of required dependencies.\n\nThe fallback is broken though when the OpenSSL backend is set to 'auto'\nas we end up calling `dependency('openssl', required: false)` in that\ncase, which implicitly disables falling back to the wrapper.\n\nFix the issue by re-allowing the fallback in case either OpenSSL is\nrequired or in case the backend is set to 'auto'. While at it, fix\nreporting of the backend in case the user asked us to pick no HTTPS\nbackend at all.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex 1f83dc58c2..83ed55c75c 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1352,7 +1352,11 @@ if https_backend == 'auto' and security_framework.found()\n endif\n \n openssl_required = 'openssl' in [csprng_backend, https_backend, sha1_backend, sha1_unsafe_backend, sha256_backend]\n-openssl = dependency('openssl', required: openssl_required, default_options: ['default_library=static'])\n+openssl = dependency('openssl',\n+  required: openssl_required,\n+  allow_fallback: openssl_required or https_backend == 'auto',\n+  default_options: ['default_library=static'],\n+)\n if https_backend == 'auto' and openssl.found()\n   https_backend = 'openssl'\n endif\n@@ -1366,6 +1370,7 @@ elif https_backend == 'openssl'\n else\n   # We either couldn't find any dependencies with 'auto' or the user requested\n   # 'none'. Both cases are benign.\n+  https_backend = 'none'\n endif\n \n if https_backend != 'openssl'\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511495","messageId":"20250130-b4-pks-meson-improvements-v2-1-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 01/13] meson: fix exec path with enabled runtime prefix","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:43:53Z","receivedAt":"2025-01-30T14:44:13Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When the runtime prefix option is enabled, Git is built such that it\nknows to locate its binaries relative to the directory a binary is being\nexecuted from. This requires us to figure out relative paths, which is\nhandled in `system_prefix()` by trying to strip a couple of well-known\npaths.\n\nOne of these paths, GIT_EXEC_PATH, is expected to be absolute when\nruntime prefixes are enabled, but relative otherwise. And while our\nMakefile gets this correctly, in Meson we always wire up the absolute\npath, which may result in us not being able to find binaries.\n\nFix this by conditionally injecting the paths depending on whether or\nnot the `runtime_prefix` option is enabled.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/meson.build b/meson.build\nindex dbc1dab605..1f83dc58c2 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -691,7 +691,6 @@ libgit_c_args = [\n   '-DETC_GITATTRIBUTES=\"' + get_option('gitattributes') + '\"',\n   '-DETC_GITCONFIG=\"' + get_option('gitconfig') + '\"',\n   '-DFALLBACK_RUNTIME_PREFIX=\"' + get_option('prefix') + '\"',\n-  '-DGIT_EXEC_PATH=\"' + get_option('prefix') / get_option('libexecdir') / 'git-core\"',\n   '-DGIT_HOST_CPU=\"' + host_machine.cpu_family() + '\"',\n   '-DGIT_HTML_PATH=\"' + get_option('datadir') / 'doc/git-doc\"',\n   '-DGIT_INFO_PATH=\"' + get_option('infodir') + '\"',\n@@ -1466,6 +1465,7 @@ endif\n if get_option('runtime_prefix')\n   libgit_c_args += '-DRUNTIME_PREFIX'\n   build_options_config.set('RUNTIME_PREFIX', 'true')\n+  git_exec_path = get_option('libexecdir') / 'git-core'\n \n   if compiler.has_header('mach-o/dyld.h')\n     libgit_c_args += '-DHAVE_NS_GET_EXECUTABLE_PATH'\n@@ -1502,7 +1502,9 @@ if get_option('runtime_prefix')\n   endif\n else\n   build_options_config.set('RUNTIME_PREFIX', 'false')\n+  git_exec_path = get_option('prefix') / get_option('libexecdir') / 'git-core'\n endif\n+libgit_c_args += '-DGIT_EXEC_PATH=\"' + git_exec_path + '\"'\n \n git_version_file = custom_target(\n   command: [\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511493","messageId":"20250130-b4-pks-meson-improvements-v2-3-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 03/13] meson: inline the static 'git' library","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:43:55Z","receivedAt":"2025-01-30T14:44:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When setting up `libgit.a` we first create the static library itself,\nand then declare it as part of a dependency such that compile arguments,\ninclude directories and transitive dependencies get propagated to the\nusers of that library. As such, the static library isn't expected to be\nused by anything but the declared dependency.\n\nInline the static library so that we don't even use a separate variable\nfor it. This avoids any kind of confusion that may arise and clarifies\nhow the library is supposed to be used.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 16 +++++++---------\n 1 file changed, 7 insertions(+), 9 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex 83ed55c75c..a124101a73 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1555,17 +1555,15 @@ libgit_version_library = static_library('git-version',\n   include_directories: libgit_include_directories,\n )\n \n-libgit_library = static_library('git',\n-  sources: libgit_sources,\n-  c_args: libgit_c_args,\n-  link_with: libgit_version_library,\n-  dependencies: libgit_dependencies,\n-  include_directories: libgit_include_directories,\n-)\n-\n libgit = declare_dependency(\n+  link_with: static_library('git',\n+    sources: libgit_sources,\n+    c_args: libgit_c_args,\n+    link_with: libgit_version_library,\n+    dependencies: libgit_dependencies,\n+    include_directories: libgit_include_directories,\n+  ),\n   compile_args: libgit_c_args,\n-  link_with: libgit_library,\n   dependencies: libgit_dependencies,\n   include_directories: libgit_include_directories,\n )\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511494","messageId":"20250130-b4-pks-meson-improvements-v2-4-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 04/13] meson: simplify use of the common-main library","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:43:56Z","receivedAt":"2025-01-30T14:44:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"common-main.c\" file is used by multiple executables. In order to\nmake it easy to set it up we have created a separate library that these\nexecutables can link against. All of these executables also want to link\nagainst `libgit.a` though, which makes it necessary to specify both of\nthese as dependencies for every executable.\n\nSimplify this a bit by declaring the library as a source dependency:\ninstead of creating a static library, we now instead compile the common\nset of files into each executable separately.\n\nThis change surfaces an issue when linking aliases for git-remote-http:\nwe extract all objects from `git-remote-http` et al and then link them\ninto the new executable. As such, these objects would already contain\na `main()` function. But now that we also compile \"common-main.c\" into\nthese aliased executables we see a linker error due to `main()` being\ndefined twice. We fix this by only linking against `libgit.a`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build          | 34 +++++++++++++++-------------------\n oss-fuzz/meson.build |  2 +-\n t/helper/meson.build |  4 ++--\n t/meson.build        |  4 ++--\n 4 files changed, 20 insertions(+), 24 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex a124101a73..c7d597eda8 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1604,15 +1604,11 @@ if host_machine.system() == 'windows'\n     error('Unsupported compiler ' + compiler.get_id())\n   endif\n endif\n-common_main_library = static_library('common-main',\n+\n+libgit_commonmain = declare_dependency(\n   sources: common_main_sources,\n-  c_args: libgit_c_args,\n-  dependencies: libgit_dependencies,\n-  include_directories: libgit_include_directories,\n-)\n-common_main = declare_dependency(\n-  link_with: common_main_library,\n   link_args: common_main_link_args,\n+  dependencies: [ libgit ],\n )\n \n bin_wrappers = [ ]\n@@ -1620,7 +1616,7 @@ test_dependencies = [ ]\n \n git = executable('git',\n   sources: builtin_sources + 'git.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n@@ -1628,35 +1624,35 @@ bin_wrappers += git\n \n test_dependencies += executable('git-daemon',\n   sources: 'daemon.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n test_dependencies += executable('git-sh-i18n--envsubst',\n   sources: 'sh-i18n--envsubst.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n bin_wrappers += executable('git-shell',\n   sources: 'shell.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n test_dependencies += executable('git-http-backend',\n   sources: 'http-backend.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n \n bin_wrappers += executable('scalar',\n   sources: 'scalar.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n@@ -1669,7 +1665,7 @@ if get_option('curl').enabled()\n \n   git_remote_http = executable('git-remote-http',\n     sources: curl_sources + 'remote-curl.c',\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit_commonmain],\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n@@ -1677,7 +1673,7 @@ if get_option('curl').enabled()\n \n   test_dependencies += executable('git-http-fetch',\n     sources: curl_sources + 'http-fetch.c',\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit_commonmain],\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n@@ -1685,7 +1681,7 @@ if get_option('curl').enabled()\n   if expat.found()\n     test_dependencies += executable('git-http-push',\n       sources: curl_sources + 'http-push.c',\n-      dependencies: [libgit, common_main],\n+      dependencies: [libgit_commonmain],\n       install: true,\n       install_dir: get_option('libexecdir') / 'git-core',\n     )\n@@ -1694,7 +1690,7 @@ if get_option('curl').enabled()\n   foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]\n     test_dependencies += executable(alias,\n       objects: git_remote_http.extract_all_objects(recursive: false),\n-      dependencies: [libgit, common_main],\n+      dependencies: [libgit],\n     )\n \n     install_symlink(alias + executable_suffix,\n@@ -1711,7 +1707,7 @@ endif\n \n test_dependencies += executable('git-imap-send',\n   sources: imap_send_sources,\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n@@ -1719,7 +1715,7 @@ test_dependencies += executable('git-imap-send',\n foreach alias : [ 'git-receive-pack', 'git-upload-archive', 'git-upload-pack' ]\n   bin_wrappers += executable(alias,\n     objects: git.extract_all_objects(recursive: false),\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit],\n   )\n \n   install_symlink(alias + executable_suffix,\ndiff --git a/oss-fuzz/meson.build b/oss-fuzz/meson.build\nindex ed79665501..878afd8426 100644\n--- a/oss-fuzz/meson.build\n+++ b/oss-fuzz/meson.build\n@@ -15,6 +15,6 @@ foreach fuzz_program : fuzz_programs\n       'dummy-cmd-main.c',\n       fuzz_program,\n     ],\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit_commonmain],\n   )\n endforeach\ndiff --git a/t/helper/meson.build b/t/helper/meson.build\nindex f502d1aaa3..ae01b3fc45 100644\n--- a/t/helper/meson.build\n+++ b/t/helper/meson.build\n@@ -79,14 +79,14 @@ test_tool_sources = [\n \n test_tool = executable('test-tool',\n   sources: test_tool_sources,\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n )\n bin_wrappers += test_tool\n test_dependencies += test_tool\n \n test_fake_ssh = executable('test-fake-ssh',\n   sources: 'test-fake-ssh.c',\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n )\n bin_wrappers += test_fake_ssh\n test_dependencies += test_fake_ssh\ndiff --git a/t/meson.build b/t/meson.build\nindex 35f25ca4a1..dae50601fe 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -39,7 +39,7 @@ clar_sources += custom_target(\n \n clar_unit_tests = executable('unit-tests',\n   sources: clar_sources + clar_test_suites,\n-  dependencies: [libgit, common_main],\n+  dependencies: [libgit_commonmain],\n )\n test('unit-tests', clar_unit_tests)\n \n@@ -72,7 +72,7 @@ foreach unit_test_program : unit_test_programs\n       'unit-tests/lib-reftable.c',\n       unit_test_program,\n     ],\n-    dependencies: [libgit, common_main],\n+    dependencies: [libgit_commonmain],\n   )\n   test(unit_test_name, unit_test,\n     workdir: meson.current_source_dir(),\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511496","messageId":"20250130-b4-pks-meson-improvements-v2-6-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 06/13] meson: stop linking libcurl into all executables","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:43:58Z","receivedAt":"2025-01-30T14:44:16Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We set up libcurl via the `libgit_dependencies` variable, which gets\npropagated into every user of the `libgit` dependency. This is not\nnecessary though, as most of our executables aren't even supposed to\nlink against libcurl.\n\nFix this by only propagating include directories as a libgit dependency\nand propagating the full curl dependency via `libgit_curl`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex 820008f6de..4b641095a1 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -927,7 +927,9 @@ if curl.found()\n     use_curl_for_imap_send = true\n   endif\n \n-  libgit_dependencies += curl\n+  # Most executables don't have to link against libcurl, but we still need its\n+  # include directories so that we can resolve LIBCURL_VERSION in \"help.c\".\n+  libgit_dependencies += curl.partial_dependency(includes: true)\n   libgit_c_args += '-DCURL_DISABLE_TYPECHECK'\n   build_options_config.set('NO_CURL', '')\n else\n@@ -1663,7 +1665,7 @@ if get_option('curl').enabled()\n       'http.c',\n       'http-walker.c',\n     ],\n-    dependencies: [libgit_commonmain],\n+    dependencies: [libgit_commonmain, curl],\n   )\n \n   test_dependencies += executable('git-remote-http',\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511497","messageId":"20250130-b4-pks-meson-improvements-v2-5-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 05/13] meson: introduce `libgit_curl` dependency","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:43:57Z","receivedAt":"2025-01-30T14:44:16Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We've got a set of common source files that we use for those executables\nthat link against libcurl. The setup is somewhat repetitive though.\nSimplify it by declaring a `libgit_curl` dependency that bundles all of\nit together.\n\nNote that we don't include curl itself as a dependency. This is because\nwe already pull it in transitively via the libgit dependency, which is\nunfortunate because libgit itself shouldn't actually link against curl\nin the first place. This will get fixed in the next commit.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 39 ++++++++++++++++++---------------------\n 1 file changed, 18 insertions(+), 21 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex c7d597eda8..820008f6de 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1658,30 +1658,32 @@ bin_wrappers += executable('scalar',\n )\n \n if get_option('curl').enabled()\n-  curl_sources = [\n-    'http.c',\n-    'http-walker.c',\n-  ]\n-\n-  git_remote_http = executable('git-remote-http',\n-    sources: curl_sources + 'remote-curl.c',\n+  libgit_curl = declare_dependency(\n+    sources: [\n+      'http.c',\n+      'http-walker.c',\n+    ],\n     dependencies: [libgit_commonmain],\n+  )\n+\n+  test_dependencies += executable('git-remote-http',\n+    sources: 'remote-curl.c',\n+    dependencies: [libgit_curl],\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n-  test_dependencies += git_remote_http\n \n   test_dependencies += executable('git-http-fetch',\n-    sources: curl_sources + 'http-fetch.c',\n-    dependencies: [libgit_commonmain],\n+    sources: 'http-fetch.c',\n+    dependencies: [libgit_curl],\n     install: true,\n     install_dir: get_option('libexecdir') / 'git-core',\n   )\n \n   if expat.found()\n     test_dependencies += executable('git-http-push',\n-      sources: curl_sources + 'http-push.c',\n-      dependencies: [libgit_commonmain],\n+      sources: 'http-push.c',\n+      dependencies: [libgit_curl],\n       install: true,\n       install_dir: get_option('libexecdir') / 'git-core',\n     )\n@@ -1689,8 +1691,8 @@ if get_option('curl').enabled()\n \n   foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]\n     test_dependencies += executable(alias,\n-      objects: git_remote_http.extract_all_objects(recursive: false),\n-      dependencies: [libgit],\n+      sources: 'remote-curl.c',\n+      dependencies: [libgit_curl],\n     )\n \n     install_symlink(alias + executable_suffix,\n@@ -1700,14 +1702,9 @@ if get_option('curl').enabled()\n   endforeach\n endif\n \n-imap_send_sources = ['imap-send.c']\n-if use_curl_for_imap_send\n-  imap_send_sources += curl_sources\n-endif\n-\n test_dependencies += executable('git-imap-send',\n-  sources: imap_send_sources,\n-  dependencies: [libgit_commonmain],\n+  sources: 'imap-send.c',\n+  dependencies: [ use_curl_for_imap_send ? libgit_curl : libgit_commonmain ],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511499","messageId":"20250130-b4-pks-meson-improvements-v2-7-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 07/13] meson: drop separate version library","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:43:59Z","receivedAt":"2025-01-30T14:44:16Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When building `libgit.a` we link it against a `libgit_version.a` library\nthat contains the version information that we inject at build time. The\nintent of this is to avoid rebuilding all of `libgit.a` whenever the\nversion changes. But that wouldn't happen in the first place, as we know\nto just rebuild the files that depend on the generated \"version-def.h\"\nfile.\n\nThis is an artifact of an earlier version of the Meson build infra that\ndidn't ultimately land. We didn't yet have \"version-def.h\", and instead\ninjected the version via preprocessor directives. And here we would have\nrebuilt all of `libgit.a` indeed in case the version changes, because\nthe preprocessor directive applied to all files.\n\nStop building the separate library and instead add \"version-def.h\" to\nthe list of source files directly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 21 +++++----------------\n 1 file changed, 5 insertions(+), 16 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex 4b641095a1..e9af093024 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -478,6 +478,7 @@ libgit_sources = [\n   'userdiff.c',\n   'utf8.c',\n   'varint.c',\n+  'version.c',\n   'versioncmp.c',\n   'walker.c',\n   'wildmatch.c',\n@@ -1542,26 +1543,14 @@ version_def_h = custom_target(\n   depends: [git_version_file],\n   env: version_gen_environment,\n )\n-\n-# Build a separate library for \"version.c\" so that we do not have to rebuild\n-# everything when the current Git commit changes.\n-libgit_version_library = static_library('git-version',\n-  sources: [\n-    'version.c',\n-    version_def_h,\n-  ],\n-  c_args: libgit_c_args + [\n-    '-DGIT_VERSION_H=\"' + version_def_h.full_path() + '\"',\n-  ],\n-  dependencies: libgit_dependencies,\n-  include_directories: libgit_include_directories,\n-)\n+libgit_sources += version_def_h\n \n libgit = declare_dependency(\n   link_with: static_library('git',\n     sources: libgit_sources,\n-    c_args: libgit_c_args,\n-    link_with: libgit_version_library,\n+    c_args: libgit_c_args + [\n+      '-DGIT_VERSION_H=\"' + version_def_h.full_path() + '\"',\n+    ],\n     dependencies: libgit_dependencies,\n     include_directories: libgit_include_directories,\n   ),\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511501","messageId":"20250130-b4-pks-meson-improvements-v2-8-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 08/13] meson: improve PATH handling","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:44:00Z","receivedAt":"2025-01-30T14:44:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When locating programs required for the build we give some special\ntreatment to Windows systems so that we know to also look up tools\nprovided by a Git for Windows installation. This ensures that the build\ndoesn't have any prerequisites other than Microsoft Visual Studio, Meson\nand Git for Windows.\n\nConsequently, some of the programs returned by `find_program()` may not\nbe found via PATH, but via these extra directories. But while Meson can\nuse these tools directly without any special treatment, any scripts that\nwe execute may not be able to find those programs. To help them we thus\nprepend the directories of a subset of the found programs to PATH.\n\nThis doesn't make much sense though: we don't need to prepend PATH for\nany program that was found via PATH, but we really only need to do so\nfor programs located via the extraneous Windows-specific paths. So\ninstead of prepending all programs paths, we really only need to prepend\nthe Windows-specific paths.\n\nAdapt the code accordingly by only prepeding Windows-specific paths to\nPATH, which both simplifies the code and clarifies intent.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex e9af093024..bc42cd994c 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -198,19 +198,19 @@ endif\n \n cygpath = find_program('cygpath', dirs: program_path, required: false)\n diff = find_program('diff', dirs: program_path)\n+git = find_program('git', dirs: program_path, required: false)\n shell = find_program('sh', dirs: program_path)\n tar = find_program('tar', dirs: program_path)\n \n-script_environment = environment()\n+# Sanity-check that programs required for the build exist.\n foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']\n-  program = find_program(tool, dirs: program_path)\n-  script_environment.prepend('PATH', fs.parent(program.full_path()))\n+  find_program(tool, dirs: program_path)\n endforeach\n \n-git = find_program('git', dirs: program_path, required: false)\n-if git.found()\n-  script_environment.prepend('PATH', fs.parent(git.full_path()))\n-endif\n+script_environment = environment()\n+foreach path : program_path\n+  script_environment.prepend('PATH', path)\n+endforeach\n \n if get_option('sane_tool_path') != ''\n   script_environment.prepend('PATH', get_option('sane_tool_path'))\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511500","messageId":"20250130-b4-pks-meson-improvements-v2-9-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 09/13] meson: improve handling of `sane_tool_path` option","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:44:01Z","receivedAt":"2025-01-30T14:44:18Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `sane_tool_path` option can be used to override the PATH variable\nfrom which the build process, tests and ultimately Git will end up\npicking programs from. It is currently lacking though because we only\nuse it to populate the PATH environment variable for executed scripts\nand for the `BROKEN_PATH_FIX` mechanism, but we don't use it to find\nprograms used in the build process itself.\n\nFix this issue by treating it similar to the Windows-specific paths,\nwhich will make us use it both to find programs and to populate the PATH\nenvironment variable.\n\nTo help with this fix, change the type of the option to be an array of\npaths, which makes the handling a bit easier for us. It's also the\ncorrect thing to do as the input indeed is a list of paths.\n\nFurthermore, the option now overrides the default behaviour on Windows,\nwhich si to pick up tools from Git for Windows. This is done so that it\nbecomes easier to override that default behaviour in case it's not\ndesired.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n meson.build       | 17 ++++++++---------\n meson_options.txt |  4 ++--\n 2 files changed, 10 insertions(+), 11 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex bc42cd994c..7180fd58fd 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -191,9 +191,11 @@ project('git', 'c',\n fs = import('fs')\n \n program_path = []\n-# Git for Windows provides all the tools we need to build Git.\n-if host_machine.system() == 'windows'\n-  program_path += [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]\n+if get_option('sane_tool_path').length() != 0\n+  program_path = get_option('sane_tool_path')\n+elif host_machine.system() == 'windows'\n+  # Git for Windows provides all the tools we need to build Git.\n+  program_path = [ 'C:/Program Files/Git/bin', 'C:/Program Files/Git/usr/bin' ]\n endif\n \n cygpath = find_program('cygpath', dirs: program_path, required: false)\n@@ -212,10 +214,6 @@ foreach path : program_path\n   script_environment.prepend('PATH', path)\n endforeach\n \n-if get_option('sane_tool_path') != ''\n-  script_environment.prepend('PATH', get_option('sane_tool_path'))\n-endif\n-\n # The environment used by GIT-VERSION-GEN. Note that we explicitly override\n # environment variables that might be set by the user. This is by design so\n # that we always use whatever Meson has configured instead of what is present\n@@ -671,8 +669,9 @@ build_options_config.set('GIT_TEST_UTF8_LOCALE', '')\n build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))\n build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))\n \n-if get_option('sane_tool_path') != ''\n-  build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\\# @BROKEN_PATH_FIX@$|git_broken_path_fix \"' + get_option('sane_tool_path') + '\"|')\n+if get_option('sane_tool_path').length() != 0\n+  sane_tool_path = (host_machine.system() == 'windows' ? ';' : ':').join(get_option('sane_tool_path'))\n+  build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\\# @BROKEN_PATH_FIX@$|git_broken_path_fix \"' + sane_tool_path + '\"|')\n else\n   build_options_config.set_quoted('BROKEN_PATH_FIX', '/^\\# @BROKEN_PATH_FIX@$/d')\n endif\ndiff --git a/meson_options.txt b/meson_options.txt\nindex c102185ed5..e0e8089891 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -13,8 +13,8 @@ option('perl_cpan_fallback', type: 'boolean', value: true,\n   description: 'Install bundled copies of CPAN modules that serve as a fallback in case the modules are not available on the system.')\n option('runtime_prefix', type: 'boolean', value: false,\n   description: 'Resolve ancillary tooling and support files relative to the location of the runtime binary instead of hard-coding them into the binary.')\n-option('sane_tool_path', type: 'string', value: '',\n-  description: 'A colon-separated list of paths to prepend to PATH if your tools in /usr/bin are broken.')\n+option('sane_tool_path', type: 'array', value: [],\n+  description: 'An array of paths to pick up tools from in case the normal tools are broken or lacking.')\n \n # Build information compiled into Git and other parts like documentation.\n option('build_date', type: 'string', value: '',\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511502","messageId":"20250130-b4-pks-meson-improvements-v2-10-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 10/13] meson: prevent finding sed(1) in a loop","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:44:02Z","receivedAt":"2025-01-30T14:44:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We're searching for the sed(1) executable in a loop, which will make us\ntry to find it multiple times. Starting with the preceding commit we\nalready declare a variable for that program in the top-level build file.\nUse it so that we only need to search for the program once.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/howto/meson.build | 2 +-\n meson.build                     | 3 ++-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/howto/meson.build b/Documentation/howto/meson.build\nindex c023c10416..92a08b13ee 100644\n--- a/Documentation/howto/meson.build\n+++ b/Documentation/howto/meson.build\n@@ -41,7 +41,7 @@ custom_target(\n foreach howto : howto_sources\n   howto_stripped = custom_target(\n     command: [\n-      find_program('sed'),\n+      sed,\n       '-e',\n       '1,/^$/d',\n       '@INPUT@',\ndiff --git a/meson.build b/meson.build\nindex 7180fd58fd..b5e8aca288 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -201,11 +201,12 @@ endif\n cygpath = find_program('cygpath', dirs: program_path, required: false)\n diff = find_program('diff', dirs: program_path)\n git = find_program('git', dirs: program_path, required: false)\n+sed = find_program('sed', dirs: program_path)\n shell = find_program('sh', dirs: program_path)\n tar = find_program('tar', dirs: program_path)\n \n # Sanity-check that programs required for the build exist.\n-foreach tool : ['cat', 'cut', 'grep', 'sed', 'sort', 'tr', 'uname']\n+foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname']\n   find_program(tool, dirs: program_path)\n endforeach\n \n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511503","messageId":"20250130-b4-pks-meson-improvements-v2-11-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 11/13] meson: fix overwritten `git` variable","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:44:03Z","receivedAt":"2025-01-30T14:44:20Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We're assigning the `git` variable in three places:\n\n  - In \"meson.build\" to store the external Git executable.\n\n  - In \"meson.build\" to store the compiled Git executable.\n\n  - In \"Documentation/meson.build\" to store the external Git executable,\n    a second time.\n\nThe last case is only needed because we overwrite the original variable\nwith the built version. Rename the variable used for the built Git\nexecutable so that we don't have to resolve the external Git executable\nmultiple times.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/meson.build | 1 -\n meson.build               | 6 +++---\n 2 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 2a26fa8a5f..6438fa6792 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -283,7 +283,6 @@ elif docs_backend == 'asciidoctor'\n   ]\n endif\n \n-git = find_program('git', required: false)\n xmlto = find_program('xmlto')\n \n cmd_lists = [\ndiff --git a/meson.build b/meson.build\nindex b5e8aca288..cf3f0d59d5 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1605,13 +1605,13 @@ libgit_commonmain = declare_dependency(\n bin_wrappers = [ ]\n test_dependencies = [ ]\n \n-git = executable('git',\n+git_builtin = executable('git',\n   sources: builtin_sources + 'git.c',\n   dependencies: [libgit_commonmain],\n   install: true,\n   install_dir: get_option('libexecdir') / 'git-core',\n )\n-bin_wrappers += git\n+bin_wrappers += git_builtin\n \n test_dependencies += executable('git-daemon',\n   sources: 'daemon.c',\n@@ -1702,7 +1702,7 @@ test_dependencies += executable('git-imap-send',\n \n foreach alias : [ 'git-receive-pack', 'git-upload-archive', 'git-upload-pack' ]\n   bin_wrappers += executable(alias,\n-    objects: git.extract_all_objects(recursive: false),\n+    objects: git_builtin.extract_all_objects(recursive: false),\n     dependencies: [libgit],\n   )\n \n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511504","messageId":"20250130-b4-pks-meson-improvements-v2-12-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 12/13] meson: consistently use custom program paths to resolve programs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:44:04Z","receivedAt":"2025-01-30T14:44:21Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The calls to `find_program()` in our documentation don't use our custom\nprogram path. This variable gets populated on Windows with the location\nof Git for Windows so that we can use it to provide our build tools.\nConsequently, we may not be able to find all necessary binaries on\nWindows.\n\nAdapt the calls to use the program path to fix this. While at it, drop\n`required: true` arguments, which are the default anyway.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/meson.build | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 6438fa6792..c6117366ff 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -206,9 +206,9 @@ manpages = {\n \n docs_backend = get_option('docs_backend')\n if docs_backend == 'auto'\n-  if find_program('asciidoc', required: false).found()\n+  if find_program('asciidoc', dirs: program_path, required: false).found()\n     docs_backend = 'asciidoc'\n-  elif find_program('asciidoctor', required: false).found()\n+  elif find_program('asciidoctor', dirs: program_path, required: false).found()\n     docs_backend = 'asciidoctor'\n   else\n     error('Neither asciidoc nor asciidoctor were found.')\n@@ -216,7 +216,7 @@ if docs_backend == 'auto'\n endif\n \n if docs_backend == 'asciidoc'\n-  asciidoc = find_program('asciidoc', required: true)\n+  asciidoc = find_program('asciidoc', dirs: program_path)\n   asciidoc_html = 'xhtml11'\n   asciidoc_docbook = 'docbook'\n   xmlto_extra = [ ]\n@@ -245,7 +245,7 @@ if docs_backend == 'asciidoc'\n     asciidoc_conf,\n   ]\n elif docs_backend == 'asciidoctor'\n-  asciidoctor = find_program('asciidoctor', required: true)\n+  asciidoctor = find_program('asciidoctor', dirs: program_path)\n   asciidoc_html = 'xhtml5'\n   asciidoc_docbook = 'docbook5'\n   xmlto_extra = [\n@@ -283,7 +283,7 @@ elif docs_backend == 'asciidoctor'\n   ]\n endif\n \n-xmlto = find_program('xmlto')\n+xmlto = find_program('xmlto', dirs: program_path)\n \n cmd_lists = [\n   'cmds-ancillaryinterrogators.txt',\n@@ -404,7 +404,7 @@ if get_option('docs').contains('html')\n     pointing_to: 'git.html',\n   )\n \n-  xsltproc = find_program('xsltproc')\n+  xsltproc = find_program('xsltproc', dirs: program_path)\n \n   user_manual_xml = custom_target(\n     command: asciidoc_common_options + [\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"511505","messageId":"20250130-b4-pks-meson-improvements-v2-13-2f05581ffb44@pks.im","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"[PATCH v2 13/13] gitlab-ci: restrict maximum number of link jobs on Windows","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-30T14:44:05Z","receivedAt":"2025-01-30T14:44:22Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The hosted Windows runners on GitLab.com only have 7.5GB of RAM. Given\nthat \"link.exe\" provided by Microsoft Visual Studio is multi-threaded by\nitself already and thus quite memory hungry this can quickly lead to\nmemory starvation, out-of-memory situations and thus failed CI jobs.\n\nFix the issue by limiting the number of concurrent linker jobs. The same\nissue hasn't been observed on GitHub Actions yet, probably because it\ngot more than twice the amount of RAM with 16GB.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n .gitlab-ci.yml | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/.gitlab-ci.yml b/.gitlab-ci.yml\nindex 4976e18a05..7e1cecc6a7 100644\n--- a/.gitlab-ci.yml\n+++ b/.gitlab-ci.yml\n@@ -169,7 +169,7 @@ build:msvc-meson:\n   extends: .msvc-meson\n   stage: build\n   script:\n-    - meson setup build -Dperl=disabled\n+    - meson setup build -Dperl=disabled -Dbackend_max_links=1\n     - meson compile -C build\n   artifacts:\n     paths:\n\n-- \n2.48.1.468.gbf5f394be8.dirty\n\n"},{"id":"512095","messageId":"8734gp51lx.fsf@iotcl.com","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-7-2f05581ffb44@pks.im","subject":"Re: [PATCH v2 07/13] meson: drop separate version library","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-02-07T13:24:42Z","receivedAt":"2025-02-07T13:25:00Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> When building `libgit.a` we link it against a `libgit_version.a` library\n> that contains the version information that we inject at build time. The\n> intent of this is to avoid rebuilding all of `libgit.a` whenever the\n> version changes. But that wouldn't happen in the first place, as we know\n> to just rebuild the files that depend on the generated \"version-def.h\"\n> file.\n>\n> This is an artifact of an earlier version of the Meson build infra that\n> didn't ultimately land. We didn't yet have \"version-def.h\", and instead\n> injected the version via preprocessor directives. And here we would have\n> rebuilt all of `libgit.a` indeed in case the version changes, because\n> the preprocessor directive applied to all files.\n>\n> Stop building the separate library and instead add \"version-def.h\" to\n> the list of source files directly.\n\nI'm happy to see this \"optimazation\" go. The solution using\n\"version-def.h\" seems simpler and more straightforward. Thanks!\n\n--\nToon\n"},{"id":"512096","messageId":"87zfix3lwn.fsf@iotcl.com","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-9-2f05581ffb44@pks.im","subject":"Re: [PATCH v2 09/13] meson: improve handling of `sane_tool_path` option","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-02-07T13:49:12Z","receivedAt":"2025-02-07T13:49:31Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> The `sane_tool_path` option can be used to override the PATH variable\n> from which the build process, tests and ultimately Git will end up\n> picking programs from. It is currently lacking though because we only\n> use it to populate the PATH environment variable for executed scripts\n> and for the `BROKEN_PATH_FIX` mechanism, but we don't use it to find\n> programs used in the build process itself.\n>\n> Fix this issue by treating it similar to the Windows-specific paths,\n> which will make us use it both to find programs and to populate the PATH\n> environment variable.\n>\n> To help with this fix, change the type of the option to be an array of\n> paths, which makes the handling a bit easier for us. It's also the\n> correct thing to do as the input indeed is a list of paths.\n\nShould we consider this a breaking change, or aren't we because using\nMeson is still not the \"official\" installation method? I've noticed it\nbreaks my \"build\" directory which was set up before this change and now\nam trying to use these changes on:\n\n   $ cd build\n   $ meson configure\n\n   ERROR: The value of option \"sane_tool_path\" is \"[]\", which is not a string.\n\n   $ meson compile\n   INFO: autodetecting backend as ninja\n   INFO: calculating backend command to run: /home/toon/.local/bin/ninja\n   [0/1] Regenerating build files.\n   The Meson build system\n   Version: 1.6.1\n   Source dir: /home/toon/devel/git\n   Build dir: /home/toon/devel/git/build\n   Build type: native build\n   Program sh found: YES (/usr/bin/sh)\n\n   ../meson.build:171:0: ERROR: The value of option \"sane_tool_path\" is \"[]\", which is not a string.\n\n   A full log can be found at /home/toon/devel/git/build/meson-logs/meson-log.txt\n   FAILED: build.ninja\n   /home/toon/.local/bin/meson --internal regenerate /home/toon/devel/git .\n   ninja: error: rebuilding 'build.ninja': subcommand failed\n\n-- \nToon\n"},{"id":"512098","messageId":"Z6YYufqOOAGWru9r@pks.im","threadId":"62866","inReplyTo":"87zfix3lwn.fsf@iotcl.com","subject":"Re: [PATCH v2 09/13] meson: improve handling of `sane_tool_path` option","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-02-07T14:29:13Z","receivedAt":"2025-02-07T14:29:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Feb 07, 2025 at 02:49:12PM +0100, Toon Claes wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > The `sane_tool_path` option can be used to override the PATH variable\n> > from which the build process, tests and ultimately Git will end up\n> > picking programs from. It is currently lacking though because we only\n> > use it to populate the PATH environment variable for executed scripts\n> > and for the `BROKEN_PATH_FIX` mechanism, but we don't use it to find\n> > programs used in the build process itself.\n> >\n> > Fix this issue by treating it similar to the Windows-specific paths,\n> > which will make us use it both to find programs and to populate the PATH\n> > environment variable.\n> >\n> > To help with this fix, change the type of the option to be an array of\n> > paths, which makes the handling a bit easier for us. It's also the\n> > correct thing to do as the input indeed is a list of paths.\n> \n> Should we consider this a breaking change, or aren't we because using\n> Meson is still not the \"official\" installation method? I've noticed it\n> breaks my \"build\" directory which was set up before this change and now\n> am trying to use these changes on:\n\nMeson is still marked as experimental right now, so I don't think this\nneeds to be explicitly called out. We should start to be more mindful of\nany backwards-incompatible changes once Meson support has matured a bit,\nsay for example starting with Git v2.49 or v2.50. But until then it's\nkind of expected that we'll still have to iterate a bit.\n\nPatrick\n"},{"id":"512100","messageId":"bmwazsiuhhf2dk2hxyl76ubpsdtzk5thxohsjry7qwr2cnow53@cm4wqrrqjqu4","threadId":"62866","inReplyTo":"20250130-b4-pks-meson-improvements-v2-0-2f05581ffb44@pks.im","subject":"Re: [PATCH v2 00/13] meson: cleanups, improvements, smallish fixes","fromName":"Justin Tobler","fromEmail":"jltobler@gmail.com","sentAt":"2025-02-07T15:22:42Z","receivedAt":"2025-02-07T15:25:45Z","isPatch":true,"sender":{"key":"jltobler@gmail.com","avatar":"https://avatars.githubusercontent.com/u/53454972?v=4"},"body":"On 25/01/30 03:43PM, Patrick Steinhardt wrote:\n> Hi,\n> \n> this patch series contains a mostly-random set of smallish improvements,\n> simplifications and fixes to the Meson build instructions.\n> \n> Changes in v2:\n>   - Redo the two commits regarding PATH handling. We now only prepend\n>     system-specific paths to PATH and handle the `-Dsane_tool_path`\n>     option the same.\n>   - Continue to propagate libcurl include directories into libgit, as we\n>     need it for \"help.c\" to resolve LIBCURL_VERSION. Reorder the patch\n>     to minimize the required changes.\n>   - Fix a commit message typo.\n>   - Include another commit that fixes the OpenSSL fallback on Windows.\n>   - Include another commit to fix linker errors due to out-of-memory\n>     situations on Windows with GitLab CI.\n>   - Link to v1: https://lore.kernel.org/r/20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im\n> \n> I have furthermore pulled in ps/build-meson-fixes at 7304bd2bc3 (ci:\n> wire up Visual Studio build with Meson, 2025-01-22) as a dependency of\n> this series. This is due to a semantic conflict with 28911f7dca (meson:\n> wire up fuzzers, 2025-01-22).\n\nThanks Patrick! I've reviewed the changes in this version and tested\nbuilding locally. This version looks good to me.\n\n-Justin\n"}]}