git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Justin Tobler <jltobler@gmail.com>, Toon Claes <toon@iotcl.com>,
	 Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v3 04/13] meson: simplify use of the common-main library
Date: Wed, 26 Feb 2025 09:22:14 +0100	[thread overview]
Message-ID: <20250226-b4-pks-meson-improvements-v3-4-60c77cf673ae@pks.im> (raw)
In-Reply-To: <20250226-b4-pks-meson-improvements-v3-0-60c77cf673ae@pks.im>

The "common-main.c" file is used by multiple executables. In order to
make it easy to set it up we have created a separate library that these
executables can link against. All of these executables also want to link
against `libgit.a` though, which makes it necessary to specify both of
these as dependencies for every executable.

Simplify this a bit by declaring the library as a source dependency:
instead of creating a static library, we now instead compile the common
set of files into each executable separately.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 meson.build          | 39 +++++++++++++++++++--------------------
 oss-fuzz/meson.build |  2 +-
 t/helper/meson.build |  4 ++--
 t/meson.build        |  4 ++--
 4 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/meson.build b/meson.build
index a124101a73a..7236c163374 100644
--- a/meson.build
+++ b/meson.build
@@ -1604,15 +1604,14 @@ if host_machine.system() == 'windows'
     error('Unsupported compiler ' + compiler.get_id())
   endif
 endif
-common_main_library = static_library('common-main',
-  sources: common_main_sources,
-  c_args: libgit_c_args,
-  dependencies: libgit_dependencies,
-  include_directories: libgit_include_directories,
-)
-common_main = declare_dependency(
-  link_with: common_main_library,
+
+libgit_commonmain = declare_dependency(
+  link_with: static_library('common-main',
+    sources: common_main_sources,
+    dependencies: [ libgit ],
+  ),
   link_args: common_main_link_args,
+  dependencies: [ libgit ],
 )
 
 bin_wrappers = [ ]
@@ -1620,7 +1619,7 @@ test_dependencies = [ ]
 
 git = executable('git',
   sources: builtin_sources + 'git.c',
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
@@ -1628,35 +1627,35 @@ bin_wrappers += git
 
 test_dependencies += executable('git-daemon',
   sources: 'daemon.c',
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
 
 test_dependencies += executable('git-sh-i18n--envsubst',
   sources: 'sh-i18n--envsubst.c',
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
 
 bin_wrappers += executable('git-shell',
   sources: 'shell.c',
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
 
 test_dependencies += executable('git-http-backend',
   sources: 'http-backend.c',
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
 
 bin_wrappers += executable('scalar',
   sources: 'scalar.c',
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
@@ -1669,7 +1668,7 @@ if get_option('curl').enabled()
 
   git_remote_http = executable('git-remote-http',
     sources: curl_sources + 'remote-curl.c',
-    dependencies: [libgit, common_main],
+    dependencies: [libgit_commonmain],
     install: true,
     install_dir: get_option('libexecdir') / 'git-core',
   )
@@ -1677,7 +1676,7 @@ if get_option('curl').enabled()
 
   test_dependencies += executable('git-http-fetch',
     sources: curl_sources + 'http-fetch.c',
-    dependencies: [libgit, common_main],
+    dependencies: [libgit_commonmain],
     install: true,
     install_dir: get_option('libexecdir') / 'git-core',
   )
@@ -1685,7 +1684,7 @@ if get_option('curl').enabled()
   if expat.found()
     test_dependencies += executable('git-http-push',
       sources: curl_sources + 'http-push.c',
-      dependencies: [libgit, common_main],
+      dependencies: [libgit_commonmain],
       install: true,
       install_dir: get_option('libexecdir') / 'git-core',
     )
@@ -1694,7 +1693,7 @@ 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, common_main],
+      dependencies: [libgit_commonmain],
     )
 
     install_symlink(alias + executable_suffix,
@@ -1711,7 +1710,7 @@ endif
 
 test_dependencies += executable('git-imap-send',
   sources: imap_send_sources,
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
   install: true,
   install_dir: get_option('libexecdir') / 'git-core',
 )
@@ -1719,7 +1718,7 @@ test_dependencies += executable('git-imap-send',
 foreach alias : [ 'git-receive-pack', 'git-upload-archive', 'git-upload-pack' ]
   bin_wrappers += executable(alias,
     objects: git.extract_all_objects(recursive: false),
-    dependencies: [libgit, common_main],
+    dependencies: [libgit_commonmain],
   )
 
   install_symlink(alias + executable_suffix,
diff --git a/oss-fuzz/meson.build b/oss-fuzz/meson.build
index ed796655016..878afd8426f 100644
--- a/oss-fuzz/meson.build
+++ b/oss-fuzz/meson.build
@@ -15,6 +15,6 @@ foreach fuzz_program : fuzz_programs
       'dummy-cmd-main.c',
       fuzz_program,
     ],
-    dependencies: [libgit, common_main],
+    dependencies: [libgit_commonmain],
   )
 endforeach
diff --git a/t/helper/meson.build b/t/helper/meson.build
index f502d1aaa36..ae01b3fc45d 100644
--- a/t/helper/meson.build
+++ b/t/helper/meson.build
@@ -79,14 +79,14 @@ test_tool_sources = [
 
 test_tool = executable('test-tool',
   sources: test_tool_sources,
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
 )
 bin_wrappers += test_tool
 test_dependencies += test_tool
 
 test_fake_ssh = executable('test-fake-ssh',
   sources: 'test-fake-ssh.c',
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
 )
 bin_wrappers += test_fake_ssh
 test_dependencies += test_fake_ssh
diff --git a/t/meson.build b/t/meson.build
index 35f25ca4a1d..dae50601fec 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -39,7 +39,7 @@ clar_sources += custom_target(
 
 clar_unit_tests = executable('unit-tests',
   sources: clar_sources + clar_test_suites,
-  dependencies: [libgit, common_main],
+  dependencies: [libgit_commonmain],
 )
 test('unit-tests', clar_unit_tests)
 
@@ -72,7 +72,7 @@ foreach unit_test_program : unit_test_programs
       'unit-tests/lib-reftable.c',
       unit_test_program,
     ],
-    dependencies: [libgit, common_main],
+    dependencies: [libgit_commonmain],
   )
   test(unit_test_name, unit_test,
     workdir: meson.current_source_dir(),

-- 
2.48.1.741.g8a9f3a5cdc.dirty


  parent reply	other threads:[~2025-02-26  8:22 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-29  7:11 [PATCH 00/11] meson: cleanups, improvements, smallish fixes Patrick Steinhardt
2025-01-29  7:11 ` [PATCH 01/11] meson: fix exec path with enabled runtime prefix Patrick Steinhardt
2025-01-29 20:12   ` Justin Tobler
2025-01-30  7:06     ` Patrick Steinhardt
2025-01-29  7:11 ` [PATCH 02/11] meson: inline the static 'git' library Patrick Steinhardt
2025-01-29  7:11 ` [PATCH 03/11] meson: simplify use of the common-main library Patrick Steinhardt
2025-01-29  7:11 ` [PATCH 04/11] meson: stop linking libcurl into all executables Patrick Steinhardt
2025-01-29  7:11 ` [PATCH 05/11] meson: introduce `libgit_curl` dependency Patrick Steinhardt
2025-01-29  7:11 ` [PATCH 06/11] meson: drop separate version library Patrick Steinhardt
2025-01-29  7:12 ` [PATCH 07/11] meson: deduplicate the list of required programs Patrick Steinhardt
2025-01-29 20:28   ` Justin Tobler
2025-01-29  7:12 ` [PATCH 08/11] meson: simplify setup of PATH environment variable Patrick Steinhardt
2025-01-29 20:42   ` Justin Tobler
2025-01-30  7:06     ` Patrick Steinhardt
2025-01-29  7:12 ` [PATCH 09/11] meson: prevent finding sed(1) in a loop Patrick Steinhardt
2025-01-29  7:12 ` [PATCH 10/11] meson: fix overwritten `git` variable Patrick Steinhardt
2025-01-29  7:12 ` [PATCH 11/11] meson: consistently use custom program paths to resolve programs Patrick Steinhardt
2025-01-30 14:43 ` [PATCH v2 00/13] meson: cleanups, improvements, smallish fixes Patrick Steinhardt
2025-01-30 14:43   ` [PATCH v2 01/13] meson: fix exec path with enabled runtime prefix Patrick Steinhardt
2025-01-30 14:43   ` [PATCH v2 02/13] meson: fix OpenSSL fallback when not explicitly required Patrick Steinhardt
2025-01-30 14:43   ` [PATCH v2 03/13] meson: inline the static 'git' library Patrick Steinhardt
2025-01-30 14:43   ` [PATCH v2 04/13] meson: simplify use of the common-main library Patrick Steinhardt
2025-01-30 14:43   ` [PATCH v2 05/13] meson: introduce `libgit_curl` dependency Patrick Steinhardt
2025-01-30 14:43   ` [PATCH v2 06/13] meson: stop linking libcurl into all executables Patrick Steinhardt
2025-01-30 14:43   ` [PATCH v2 07/13] meson: drop separate version library Patrick Steinhardt
2025-02-07 13:24     ` Toon Claes
2025-01-30 14:44   ` [PATCH v2 08/13] meson: improve PATH handling Patrick Steinhardt
2025-01-30 14:44   ` [PATCH v2 09/13] meson: improve handling of `sane_tool_path` option Patrick Steinhardt
2025-02-07 13:49     ` Toon Claes
2025-02-07 14:29       ` Patrick Steinhardt
2025-01-30 14:44   ` [PATCH v2 10/13] meson: prevent finding sed(1) in a loop Patrick Steinhardt
2025-01-30 14:44   ` [PATCH v2 11/13] meson: fix overwritten `git` variable Patrick Steinhardt
2025-01-30 14:44   ` [PATCH v2 12/13] meson: consistently use custom program paths to resolve programs Patrick Steinhardt
2025-01-30 14:44   ` [PATCH v2 13/13] gitlab-ci: restrict maximum number of link jobs on Windows Patrick Steinhardt
2025-02-07 15:22   ` [PATCH v2 00/13] meson: cleanups, improvements, smallish fixes Justin Tobler
2025-02-26  8:22 ` [PATCH v3 " Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 01/13] meson: fix exec path with enabled runtime prefix Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 02/13] meson: fix OpenSSL fallback when not explicitly required Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 03/13] meson: inline the static 'git' library Patrick Steinhardt
2025-02-26  8:22   ` Patrick Steinhardt [this message]
2025-02-26  8:22   ` [PATCH v3 05/13] meson: introduce `libgit_curl` dependency Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 06/13] meson: stop linking libcurl into all executables Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 07/13] meson: drop separate version library Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 08/13] meson: improve PATH handling Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 09/13] meson: improve handling of `sane_tool_path` option Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 10/13] meson: prevent finding sed(1) in a loop Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 11/13] meson: fix overwritten `git` variable Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 12/13] meson: consistently use custom program paths to resolve programs Patrick Steinhardt
2025-02-26  8:22   ` [PATCH v3 13/13] gitlab-ci: restrict maximum number of link jobs on Windows Patrick Steinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250226-b4-pks-meson-improvements-v3-4-60c77cf673ae@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@gmail.com \
    --cc=toon@iotcl.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).