Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it possible to build reproducibly #143

Merged
merged 1 commit into from
Feb 1, 2021
Merged

make it possible to build reproducibly #143

merged 1 commit into from
Feb 1, 2021

Conversation

mirabilos
Copy link
Contributor

By default, the date and time of the build are embedded into the binary as sort of origin/version/etc. marker. This is not, however, reproducible. This patch makes it so that packagers can define a præprocessor macro, ANTIMICROX_PKG_VERSION, to a C string which is then used instead; if this macro is not defined nothing changes.

The diff comes from Debian; by upstreaming the new string can be translated.

Example use: add -DANTIMICROX_PKG_VERSION=\"'3.1.4-1 (Debian sid/amd64)'\" to CPPFLAGS. Check the Hel̲p → A̲bout dialogue, tab Info, second line, to see its effect.

By default, the date and time of the build are embedded into the
binary as sort of origin/version/etc. marker. This is not, however,
reproducible. This patch makes it so that packagers can define a
præprocessor macro, ANTIMICROX_PKG_VERSION, to a C string which is
then used instead; if this macro is not defined nothing changes.

The diff comes from Debian; by upstreaming the new string can be
translated.
@mirabilos mirabilos mentioned this pull request Feb 1, 2021
2 tasks
@pktiuk
Copy link
Member

pktiuk commented Feb 1, 2021

obraz

During compilation i get:

/home/pawel/antimicrox/src/aboutdialog.cpp:64:64: warning: character constant too long for its type
   64 |     finalInfoText.append(tr("compiled from packaging: %1").arg(ANTIMICROX_PKG_VERSION));

@pktiuk
Copy link
Member

pktiuk commented Feb 1, 2021

It works nicely when integrated with CMake
add_compile_definitions(ANTIMICROX_PKG_VERSION="3.1.4-1 \(Debian sid/amd64\)")

I will merge it with master and later (maybe today) I will integrate it with CMake and our CI and mention it in docs

@pktiuk pktiuk merged commit b9aa279 into AntiMicroX:master Feb 1, 2021
@mirabilos
Copy link
Contributor Author

Yes, you need a string constant, so for a compiler commandline something like c++ -DANTIMICROX_PKG_VERSION=\"foo\ bar\" or =\""foo bar"\" or ="\"foo bar\"" or ='"foo bar"' or =\"'foo bar'\"; that is shell-escaped and of course needs to be adjusted for the build system you use around the invocations.

In debian/rules I actually need to input the shell-escaped versions, and the canonical form for passing string constants to builds (i.e. the one that fails the least with various tools (hand-written Makefiles, autoconf, …)) is =\"foo\" so I just did =\"${var}\" except I needed to shell-escape the $var content so =\"${var:Q}\" in BSD make, or the GNU make variant =\"$(call shellescape,${OUR_VSN})\" with the helper macro…

shellescape='$(subst ','\'',$(1))'
shellexport=$(1)=$(call shellescape,${$(1)})

… defined to emulate something BSD make can do natively.

Glad it helps!

@mirabilos mirabilos deleted the avoid-Wdatetime branch February 1, 2021 19:28
Gallxz pushed a commit to Gallxz/antimicrox that referenced this pull request Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants