In timestampToDate(), std::localtime() is called to convert the timestamp into
a date and time. Since std::localtime() is timezone-aware, we have to force a
specific timezone (UTC) in tests to make them timezone-agnostic. After each
test is run, we set the timezone back to its original value.
At the moment, we (unofficially) support also macOS, so differentiate only
between Windows and UNIX by defining the following two symbolic constants:
* OS_WINDOWS
* OS_UNIX
Based on #21:
The scripts will also fail on Cygwin, due to Cygwin's virtual paths (c:
becomes /cygdrive/c/, and so on), which are not transformed by readlink.
Instead, one needs to use cygpath, to get the real windows path. So I've
added get_realpath to retdec-utils.sh, to check if the scripts are running
on Cygwin, and if they do, to use cygpath -ma (-a = absolute path, and -m =
mixed, i.e., forward slashes rather than backward slashes). Otherwise it
just uses readlink.
Based on #21:
Right now, the scripts used by retdec (e.g. retdec-decompiler.sh) will fail
if they're symlinked, i.e., retdec-decompiler.sh symlinked to
~/bin/retdec-decompiler, because both ${BASH_SOURCE} and $0 will always
point at the symlinked path, rather than the original, so $SCRIPT_DIR would
become invalid.
This is easy enough to fix, by doing dirname "$(readlink -e "$0")", rather
than the pretty ancient style of cding to dirname "$0" (pretty sure this
has been out of date since the inception of Linux itself ...).
Reasons:
- Downloaded archives will have more meaningful names (e.g. capstone.zip
instead of 27c713fe4f6eaf9721785932d850b6291a6073fe.zip).
- This prevents collisions between projects (e.g. both yaracpp and yaramod are
in version 1.0.1 at the moment, so they were both downloaded as v1.0.1.zip).
When running cmake --build from Bash via the MSYS2 terminal, the use of /m
causes the following error:
$ cmake --build . --config Release -- /m
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1008: Only one project can be specified.
Switch: M:/
For switch syntax, type "MSBuild /help"
With -m, it works everywhere.
Instead of requiring a specific command prompt (MSBuild) and running
msbuild /m /p:Configuration=Release retdec.sln
msbuild /m /p:Configuration=Release INSTALL.vcxproj
we can just run the following commands from an arbitrary prompt:
cmake --build . --config Release -- /m
cmake --build . --config Release --target install
From https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_LIBRARY_PREFIXES.html:
This specifies what prefixes to add to library names when the
find_library() command looks for libraries.
What we want is CMAKE_STATIC_LIBRARY_PREFIX:
The prefix to use for the name of a static library, lib on UNIX.
Also, we are already using CMAKE_STATIC_LIBRARY_SUFFIX, so this change also
makes the used variables consistent.