Re: ident hash usage question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eugene Sajine <euguess@xxxxxxxxx> writes:

>> If the project is already arranged to be compiled with decent automation,
>> I do not think you need any change to the workflow.
>>
>> You would have a version.cc file with
>>
>>        static char program_version[] = "My Program " VERSION_STRING;
>>
>> in it, and teach the build procedure how to compile and link this file.
>> Something like:
>>
>>    version.o: version.cc
>>        $(CXX) -o $@ -DVERSION_STRING=\""$(git describe HEAD)"\" $?
>>
>
> Please, correct me if I'm mistaken and forgive me if I'm not correct
> in using C++ terms.
>
> Your solution proposes to have a version file which will carry the
> info about last state the program was built from.
> But as I understand in case of static linking the executable will get
> only obj files from a library, which are necessary and everything
> irrelevant will be thrown away by linker.

I am not sure what you mean by "static linking" anymore.  Usually the word
means that everything you tell the linker to link to the executable is
linked, together with objects from libraries.  The resulting executable is
usable on its own and it does not change behaviour regardless of which
version of dynamic libraries you depend on happen to be installed on the
target system (because by definition a statically linked executable does
not depend on dynamic libraries---that is the whole point of static
linking).

So as long as you make sure version.o is linked to the final executable,
you will be fine.  One way to do so might be to have

	printf("Program version: %s", program_version);

at the beginning of main() ;-)

If your product ships as one main executable _dynamically_ linked with two
dynamic libraries, and all three components are built from the source
material under your source control, obviously you would need to make sure
that the above version.o or some equivalent of what embeds output from
"git describe HEAD" are linked to the main executable and to the two
libraries, but the idea is the same.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]