git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 05/11] meson: introduce `libgit_curl` dependency

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 29, 2025, 07:11 UTC
Message-ID
<20250129-b4-pks-meson-improvements-v1-5-ab709f0be12c@pks.im>
In-Reply-To
<20250129-b4-pks-meson-improvements-v1-0-ab709f0be12c@pks.im>

We've got a set of common source files that we use for those executables that link against libcurl. The setup is somewhat repetitive though. Simplify it by declaring a `libgit_curl` dependency that bundles all of it together.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 meson.build | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/meson.build b/meson.build
index 6f62728117..e022235815 100644
--- a/meson.build
+++ b/meson.build
@@ -1623,30 +1623,32 @@ bin_wrappers += executable('scalar',
 )
 
 if get_option('curl').enabled()
-  curl_sources = [
-    'http.c',
-    'http-walker.c',
-  ]
-
-  git_remote_http = executable('git-remote-http',
-    sources: curl_sources + 'remote-curl.c',
+  libgit_curl = declare_dependency(
+    sources: [
+      'http.c',
+      'http-walker.c',
+    ],
     dependencies: [libgit_commonmain, curl],
+  )
+
+  test_dependencies += executable('git-remote-http',
+    sources: 'remote-curl.c',
+    dependencies: libgit_curl,
     install: true,
     install_dir: get_option('libexecdir') / 'git-core',
   )
-  test_dependencies += git_remote_http
 
   test_dependencies += executable('git-http-fetch',
-    sources: curl_sources + 'http-fetch.c',
-    dependencies: [libgit_commonmain, curl],
+    sources: 'http-fetch.c',
+    dependencies: libgit_curl,
     install: true,
     install_dir: get_option('libexecdir') / 'git-core',
   )
 
   if expat.found()
     test_dependencies += executable('git-http-push',
-      sources: curl_sources + 'http-push.c',
-      dependencies: [libgit_commonmain, curl],
+      sources: 'http-push.c',
+      dependencies: libgit_curl,
       install: true,
       install_dir: get_option('libexecdir') / 'git-core',
     )
@@ -1654,8 +1656,8 @@ if get_option('curl').enabled()
 
   foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]
     test_dependencies += executable(alias,
-      objects: git_remote_http.extract_all_objects(recursive: false),
-      dependencies: [libgit, curl],
+      sources: 'remote-curl.c',
+      dependencies: libgit_curl,
     )
 
     install_symlink(alias + executable_suffix,
@@ -1665,16 +1667,9 @@ if get_option('curl').enabled()
   endforeach
 endif
 
-imap_send_sources = ['imap-send.c']
-imap_send_dependencies = [libgit_commonmain]
-if use_curl_for_imap_send
-  imap_send_sources += curl_sources
-  imap_send_dependencies += curl
-endif
-
 test_dependencies += executable('git-imap-send',
-  sources: imap_send_sources,
-  dependencies: imap_send_dependencies,
+  sources: 'imap-send.c',
+  dependencies: use_curl_for_imap_send ? [libgit_curl] : [libgit_commonmain],
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
-- 
2.48.1.362.g079036d154.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 8 of 35 in “meson: cleanups, improvements, smallish fixes”
  1. 00/11 meson: cleanups, improvements, smallish fixesPatrick Steinhardt, Jan 29, 2025
  2. 01/11 meson: fix exec path with enabled runtime prefixPatrick Steinhardt, Jan 29, 2025
  3. Justin ToblerJan 29, 2025
  4. Patrick SteinhardtJan 30, 2025
  5. 02/11 meson: inline the static 'git' libraryPatrick Steinhardt, Jan 29, 2025
  6. 04/11 meson: stop linking libcurl into all executablesPatrick Steinhardt, Jan 29, 2025
  7. 03/11 meson: simplify use of the common-main libraryPatrick Steinhardt, Jan 29, 2025
  8. 05/11 meson: introduce `libgit_curl` dependencyPatrick Steinhardt, Jan 29, 2025
  9. 07/11 meson: deduplicate the list of required programsPatrick Steinhardt, Jan 29, 2025
  10. Justin ToblerJan 29, 2025
  11. 06/11 meson: drop separate version libraryPatrick Steinhardt, Jan 29, 2025
  12. 08/11 meson: simplify setup of PATH environment variablePatrick Steinhardt, Jan 29, 2025
  13. Justin ToblerJan 29, 2025
  14. Patrick SteinhardtJan 30, 2025
  15. 09/11 meson: prevent finding sed(1) in a loopPatrick Steinhardt, Jan 29, 2025
  16. 10/11 meson: fix overwritten `git` variablePatrick Steinhardt, Jan 29, 2025
  17. 11/11 meson: consistently use custom program paths to resolve programsPatrick Steinhardt, Jan 29, 2025
  18. 00/13 meson: cleanups, improvements, smallish fixesPatrick Steinhardt, Jan 30, 2025
  19. 02/13 meson: fix OpenSSL fallback when not explicitly requiredPatrick Steinhardt, Jan 30, 2025
  20. 01/13 meson: fix exec path with enabled runtime prefixPatrick Steinhardt, Jan 30, 2025
  21. 03/13 meson: inline the static 'git' libraryPatrick Steinhardt, Jan 30, 2025
  22. 04/13 meson: simplify use of the common-main libraryPatrick Steinhardt, Jan 30, 2025
  23. 06/13 meson: stop linking libcurl into all executablesPatrick Steinhardt, Jan 30, 2025
  24. 05/13 meson: introduce `libgit_curl` dependencyPatrick Steinhardt, Jan 30, 2025
  25. 07/13 meson: drop separate version libraryPatrick Steinhardt, Jan 30, 2025
  26. Toon ClaesFeb 7, 2025
  27. 08/13 meson: improve PATH handlingPatrick Steinhardt, Jan 30, 2025
  28. 09/13 meson: improve handling of `sane_tool_path` optionPatrick Steinhardt, Jan 30, 2025
  29. Toon ClaesFeb 7, 2025
  30. Patrick SteinhardtFeb 7, 2025
  31. 10/13 meson: prevent finding sed(1) in a loopPatrick Steinhardt, Jan 30, 2025
  32. 11/13 meson: fix overwritten `git` variablePatrick Steinhardt, Jan 30, 2025
  33. 12/13 meson: consistently use custom program paths to resolve programsPatrick Steinhardt, Jan 30, 2025
  34. 13/13 gitlab-ci: restrict maximum number of link jobs on WindowsPatrick Steinhardt, Jan 30, 2025
  35. Justin ToblerFeb 7, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.