[vlc-devel] [PATCH] libvlc/core: Use a revision.h in build dir instead of .c file

Marvin Scholz epirat07 at gmail.com
Fri Jun 21 11:18:01 CEST 2019


On 21 Jun 2019, at 9:36, Rémi Denis-Courmont wrote:

> Hi,
>
> How does this work from tarball?

Hi,
it still works fine from the tarball just like before
as the revision.txt is still in the tarball and it uses
that when it fails to get the revision from git.
(I tested it with a make dist tarball)

I mainly need this change for meson and I do not want the
code to diverge between the meson branch and our current
buildsystem.


(Longer explanation why what are are doing currently causes
problems with meson:)

In meson the revision file is generated similar to how it is
done in autotools, during the build phase (as it has to be
always up to date).

Given that two different libraries depend on that file, I add
the dependency to the two libraries by adding the target output
to the library sources.

If the file is a .c file though, meson will compile + link
the file into both libraries. The problem with that is that
lib/core.c additionally includes the .c file, so now the
library would end up with the symbol twice, one time from the
linked revision.o, one time from the included revision.c,
which will fail to link.

So the easiest solution and the one that seemed the cleanest to me
is to change it to a .h file. I generate it in the build dir
instead of in the src dir to prevent conflicts with the meson
builds, if it had the automake generated revision.h in the source
dir it would always prefer that instead of the one generated in the
meson build dir by meson, which is very annoying when working on
the meson port and switching between meson/autotools builds.

>
> Le 21 juin 2019 00:33:17 GMT+02:00, Marvin Scholz <epirat07 at gmail.com> 
> a écrit :
>> Instead of generating the revision.c file in the source tree
>> and including the c file in lib/core.c, generate a .h file in the
>> build dir and include that instead.
>> ---
>> lib/core.c      | 2 +-
>> src/Makefile.am | 7 +++----
>> src/libvlc.c    | 1 +
>> 3 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/lib/core.c b/lib/core.c
>> index 06fd52fbfa..c1fb78b7cf 100644
>> --- a/lib/core.c
>> +++ b/lib/core.c
>> @@ -34,7 +34,7 @@
>> #include <limits.h>
>> #include <assert.h>
>>
>> -#include "../src/revision.c"
>> +#include "../src/revision.h"
>>
>> libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
>> {
>> diff --git a/src/Makefile.am b/src/Makefile.am
>> index 3f73999fdb..b25df0b56e 100644
>> --- a/src/Makefile.am
>> +++ b/src/Makefile.am
>> @@ -198,7 +198,6 @@ libvlccore_la_SOURCES = \
>> 	libvlc.h \
>> 	libvlc-module.c \
>> 	missing.c \
>> -	revision.c \
>> 	version.c \
>> 	config/configuration.h \
>> 	config/core.c \
>> @@ -618,10 +617,10 @@ LDADD = libvlccore.la \
>> # GIT revision
>> ###############################################################################
>>
>> -BUILT_SOURCES += stamp-revision
>> -MAINTAINERCLEANFILES = $(srcdir)/revision.txt $(srcdir)/revision.c
>> +BUILT_SOURCES += stamp-revision revision.h
>> +MAINTAINERCLEANFILES = $(srcdir)/revision.txt revision.h
>>
>> -$(srcdir)/revision.c: $(srcdir)/revision.txt
>> +revision.h: $(srcdir)/revision.txt
>> 	$(AM_V_at)rm -f -- $@
>> 	$(AM_V_GEN)echo "const char psz_vlc_changeset[] = \"$$(cat $<)\";" \
>> 		> $@
>> diff --git a/src/libvlc.c b/src/libvlc.c
>> index 018987f0bf..d65258761f 100644
>> --- a/src/libvlc.c
>> +++ b/src/libvlc.c
>> @@ -65,6 +65,7 @@
>> #include <vlc_thumbnailer.h>
>>
>> #include "libvlc.h"
>> +#include "revision.h"
>>
>> #include <vlc_vlm.h>
>>
>> -- 
>> 2.20.1 (Apple Git-117)
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>
> -- 
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez 
> excuser ma brièveté._______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list