Skip to content

Commit eee25bb

Browse files
pks-tgitster
authored andcommitted
meson: drop separate version library
When building `libgit.a` we link it against a `libgit_version.a` library that contains the version information that we inject at build time. The intent of this is to avoid rebuilding all of `libgit.a` whenever the version changes. But that wouldn't happen in the first place, as we know to just rebuild the files that depend on the generated "version-def.h" file. This is an artifact of an earlier version of the Meson build infra that didn't ultimately land. We didn't yet have "version-def.h", and instead injected the version via preprocessor directives. And here we would have rebuilt all of `libgit.a` indeed in case the version changes, because the preprocessor directive applied to all files. Stop building the separate library and instead add "version-def.h" to the list of source files directly. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5fac42 commit eee25bb

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

meson.build

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ libgit_sources = [
478478
'userdiff.c',
479479
'utf8.c',
480480
'varint.c',
481+
'version.c',
481482
'versioncmp.c',
482483
'walker.c',
483484
'wildmatch.c',
@@ -1542,26 +1543,14 @@ version_def_h = custom_target(
15421543
depends: [git_version_file],
15431544
env: version_gen_environment,
15441545
)
1545-
1546-
# Build a separate library for "version.c" so that we do not have to rebuild
1547-
# everything when the current Git commit changes.
1548-
libgit_version_library = static_library('git-version',
1549-
sources: [
1550-
'version.c',
1551-
version_def_h,
1552-
],
1553-
c_args: libgit_c_args + [
1554-
'-DGIT_VERSION_H="' + version_def_h.full_path() + '"',
1555-
],
1556-
dependencies: libgit_dependencies,
1557-
include_directories: libgit_include_directories,
1558-
)
1546+
libgit_sources += version_def_h
15591547

15601548
libgit = declare_dependency(
15611549
link_with: static_library('git',
15621550
sources: libgit_sources,
1563-
c_args: libgit_c_args,
1564-
link_with: libgit_version_library,
1551+
c_args: libgit_c_args + [
1552+
'-DGIT_VERSION_H="' + version_def_h.full_path() + '"',
1553+
],
15651554
dependencies: libgit_dependencies,
15661555
include_directories: libgit_include_directories,
15671556
),

0 commit comments

Comments
 (0)