Skip to content

Commit ebb3536

Browse files
pks-tgitster
authored andcommitted
meson: simplify use of the common-main library
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce94328 commit ebb3536

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

meson.build

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,59 +1604,58 @@ if host_machine.system() == 'windows'
16041604
error('Unsupported compiler ' + compiler.get_id())
16051605
endif
16061606
endif
1607-
common_main_library = static_library('common-main',
1608-
sources: common_main_sources,
1609-
c_args: libgit_c_args,
1610-
dependencies: libgit_dependencies,
1611-
include_directories: libgit_include_directories,
1612-
)
1613-
common_main = declare_dependency(
1614-
link_with: common_main_library,
1607+
1608+
libgit_commonmain = declare_dependency(
1609+
link_with: static_library('common-main',
1610+
sources: common_main_sources,
1611+
dependencies: [ libgit ],
1612+
),
16151613
link_args: common_main_link_args,
1614+
dependencies: [ libgit ],
16161615
)
16171616

16181617
bin_wrappers = [ ]
16191618
test_dependencies = [ ]
16201619

16211620
git = executable('git',
16221621
sources: builtin_sources + 'git.c',
1623-
dependencies: [libgit, common_main],
1622+
dependencies: [libgit_commonmain],
16241623
install: true,
16251624
install_dir: get_option('libexecdir') / 'git-core',
16261625
)
16271626
bin_wrappers += git
16281627

16291628
test_dependencies += executable('git-daemon',
16301629
sources: 'daemon.c',
1631-
dependencies: [libgit, common_main],
1630+
dependencies: [libgit_commonmain],
16321631
install: true,
16331632
install_dir: get_option('libexecdir') / 'git-core',
16341633
)
16351634

16361635
test_dependencies += executable('git-sh-i18n--envsubst',
16371636
sources: 'sh-i18n--envsubst.c',
1638-
dependencies: [libgit, common_main],
1637+
dependencies: [libgit_commonmain],
16391638
install: true,
16401639
install_dir: get_option('libexecdir') / 'git-core',
16411640
)
16421641

16431642
bin_wrappers += executable('git-shell',
16441643
sources: 'shell.c',
1645-
dependencies: [libgit, common_main],
1644+
dependencies: [libgit_commonmain],
16461645
install: true,
16471646
install_dir: get_option('libexecdir') / 'git-core',
16481647
)
16491648

16501649
test_dependencies += executable('git-http-backend',
16511650
sources: 'http-backend.c',
1652-
dependencies: [libgit, common_main],
1651+
dependencies: [libgit_commonmain],
16531652
install: true,
16541653
install_dir: get_option('libexecdir') / 'git-core',
16551654
)
16561655

16571656
bin_wrappers += executable('scalar',
16581657
sources: 'scalar.c',
1659-
dependencies: [libgit, common_main],
1658+
dependencies: [libgit_commonmain],
16601659
install: true,
16611660
install_dir: get_option('libexecdir') / 'git-core',
16621661
)
@@ -1669,23 +1668,23 @@ if get_option('curl').enabled()
16691668

16701669
git_remote_http = executable('git-remote-http',
16711670
sources: curl_sources + 'remote-curl.c',
1672-
dependencies: [libgit, common_main],
1671+
dependencies: [libgit_commonmain],
16731672
install: true,
16741673
install_dir: get_option('libexecdir') / 'git-core',
16751674
)
16761675
test_dependencies += git_remote_http
16771676

16781677
test_dependencies += executable('git-http-fetch',
16791678
sources: curl_sources + 'http-fetch.c',
1680-
dependencies: [libgit, common_main],
1679+
dependencies: [libgit_commonmain],
16811680
install: true,
16821681
install_dir: get_option('libexecdir') / 'git-core',
16831682
)
16841683

16851684
if expat.found()
16861685
test_dependencies += executable('git-http-push',
16871686
sources: curl_sources + 'http-push.c',
1688-
dependencies: [libgit, common_main],
1687+
dependencies: [libgit_commonmain],
16891688
install: true,
16901689
install_dir: get_option('libexecdir') / 'git-core',
16911690
)
@@ -1694,7 +1693,7 @@ if get_option('curl').enabled()
16941693
foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]
16951694
test_dependencies += executable(alias,
16961695
objects: git_remote_http.extract_all_objects(recursive: false),
1697-
dependencies: [libgit, common_main],
1696+
dependencies: [libgit_commonmain],
16981697
)
16991698

17001699
install_symlink(alias + executable_suffix,
@@ -1711,15 +1710,15 @@ endif
17111710

17121711
test_dependencies += executable('git-imap-send',
17131712
sources: imap_send_sources,
1714-
dependencies: [libgit, common_main],
1713+
dependencies: [libgit_commonmain],
17151714
install: true,
17161715
install_dir: get_option('libexecdir') / 'git-core',
17171716
)
17181717

17191718
foreach alias : [ 'git-receive-pack', 'git-upload-archive', 'git-upload-pack' ]
17201719
bin_wrappers += executable(alias,
17211720
objects: git.extract_all_objects(recursive: false),
1722-
dependencies: [libgit, common_main],
1721+
dependencies: [libgit_commonmain],
17231722
)
17241723

17251724
install_symlink(alias + executable_suffix,

oss-fuzz/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ foreach fuzz_program : fuzz_programs
1515
'dummy-cmd-main.c',
1616
fuzz_program,
1717
],
18-
dependencies: [libgit, common_main],
18+
dependencies: [libgit_commonmain],
1919
)
2020
endforeach

t/helper/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ test_tool_sources = [
7979

8080
test_tool = executable('test-tool',
8181
sources: test_tool_sources,
82-
dependencies: [libgit, common_main],
82+
dependencies: [libgit_commonmain],
8383
)
8484
bin_wrappers += test_tool
8585
test_dependencies += test_tool
8686

8787
test_fake_ssh = executable('test-fake-ssh',
8888
sources: 'test-fake-ssh.c',
89-
dependencies: [libgit, common_main],
89+
dependencies: [libgit_commonmain],
9090
)
9191
bin_wrappers += test_fake_ssh
9292
test_dependencies += test_fake_ssh

t/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ clar_sources += custom_target(
3939

4040
clar_unit_tests = executable('unit-tests',
4141
sources: clar_sources + clar_test_suites,
42-
dependencies: [libgit, common_main],
42+
dependencies: [libgit_commonmain],
4343
)
4444
test('unit-tests', clar_unit_tests)
4545

@@ -72,7 +72,7 @@ foreach unit_test_program : unit_test_programs
7272
'unit-tests/lib-reftable.c',
7373
unit_test_program,
7474
],
75-
dependencies: [libgit, common_main],
75+
dependencies: [libgit_commonmain],
7676
)
7777
test(unit_test_name, unit_test,
7878
workdir: meson.current_source_dir(),

0 commit comments

Comments
 (0)