-
Notifications
You must be signed in to change notification settings - Fork 6
/
crypto3.nix
60 lines (52 loc) · 1.84 KB
/
crypto3.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ lib,
stdenv,
ninja,
pkg-config,
cmake,
boost,
gdb,
lldb,
cmake_modules,
enableDebugging,
enableDebug ? false,
runTests ? false,
sanitize ? false,
benchmarkTests ? false,
}:
let
inherit (lib) optional;
in stdenv.mkDerivation {
name = "Crypto3";
src = lib.sourceByRegex ./. ["^crypto3(/.*)?$" "CMakeLists.txt"];
hardeningDisable = [ "fortify" ];
nativeBuildInputs = [ cmake ninja pkg-config ] ++
(lib.optional (!stdenv.isDarwin) gdb) ++
(lib.optional (stdenv.isDarwin) lldb);
# enableDebugging will keep debug symbols in boost
propagatedBuildInputs = [ (if enableDebug then (enableDebugging boost) else boost) ];
buildInputs = [cmake_modules];
cmakeFlags =
[
(if runTests then "-DBUILD_CRYPTO3_TESTS=TRUE" else "-DBUILD_CRYPTO3_TESTS=False")
(if sanitize then "-DSANITIZE=ON" else "-DSANITIZE=OFF")
(if benchmarkTests then "-DBUILD_CRYPTO3_BENCH_TESTS=ON" else "-DBUILD_CRYPTO3_BENCH_TESTS=OFF")
"-G Ninja"
];
cmakeBuildType = if enableDebug then "Debug" else "Release";
doCheck = runTests; # tests are inside crypto3-tests derivation
checkPhase = ''
# JUNIT file without explicit file name is generated after the name of the master test suite inside `CMAKE_CURRENT_SOURCE_DIR`
export BOOST_TEST_LOGGER=JUNIT:HRF
cd crypto3
# remove || true after all tests are fixed under clang-sanitizers check:
ctest --verbose --output-on-failure -R > test_errors.txt || true
cd ..
mkdir -p ${placeholder "out"}/test-logs
find .. -type f -name '*_test.xml' -exec cp {} ${placeholder "out"}/test-logs \;
cp crypto3/test_errors.txt ${placeholder "out"}/test-logs \
'';
shellHook = ''
PS1="\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
echo "Welcome to Crypto3 development environment!"
'';
}