tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
iniparser: use unity-test from nixpkgs
Ross Smyth
7 months ago
c811cf1d
db1e62b7
+196
-44
4 changed files
expand all
collapse all
unified
split
pkgs
by-name
in
iniparser
package.nix
remove-fetchcontent-usage.patch
un
unity-test
meson.patch
package.nix
+35
-32
pkgs/by-name/in/iniparser/package.nix
···
10
ruby,
11
validatePkgConfig,
12
testers,
0
0
13
}:
14
15
stdenv.mkDerivation (finalAttrs: {
···
19
src = fetchFromGitLab {
20
owner = "iniparser";
21
repo = "iniparser";
22
-
rev = "v${finalAttrs.version}";
23
hash = "sha256-z10S9ODLprd7CbL5Ecgh7H4eOwTetYwFXiWBUm6fIr4=";
24
};
25
26
-
patches = lib.optionals finalAttrs.finalPackage.doCheck [
27
-
(replaceVars ./remove-fetchcontent-usage.patch {
28
-
# Do not let cmake's fetchContent download unity
29
-
unitySrc = symlinkJoin {
30
-
paths = [
31
-
(fetchFromGitHub {
32
-
owner = "throwtheswitch";
33
-
repo = "unity";
34
-
rev = "v2.6.0";
35
-
hash = "sha256-SCcUGNN/UJlu3ALJiZ9bQKxYRZey3cm9QG+NOehp6Ow=";
36
-
})
37
-
];
38
-
postBuild = ''
39
-
ln -s ${finalAttrs.src}/test/unity_config.h $out/src/unity_config.h
40
-
'';
41
-
};
42
-
})
43
-
];
44
45
nativeBuildInputs = [
46
cmake
47
doxygen
48
validatePkgConfig
49
-
] ++ lib.optionals finalAttrs.finalPackage.doCheck [ ruby ];
50
51
-
cmakeFlags = [ "-DBUILD_TESTING=${if finalAttrs.finalPackage.doCheck then "ON" else "OFF"}" ];
52
-
53
-
doCheck = false;
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
54
55
postFixup = ''
56
ln -sv $out/include/iniparser/*.h $out/include/
57
'';
58
59
-
passthru.tests = {
60
-
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
61
-
iniparser-with-tests = finalAttrs.overrideAttrs (_: {
62
-
doCheck = true;
63
-
});
64
-
};
65
66
-
meta = with lib; {
67
homepage = "https://gitlab.com/iniparser/iniparser";
68
description = "Free standalone ini file parsing library";
69
changelog = "https://gitlab.com/iniparser/iniparser/-/releases/v${finalAttrs.version}";
70
-
license = licenses.mit;
71
-
platforms = platforms.unix;
72
pkgConfigModules = [ "iniparser" ];
73
maintainers = [ ];
74
};
···
10
ruby,
11
validatePkgConfig,
12
testers,
13
+
unity-test,
14
+
ctestCheckHook,
15
}:
16
17
stdenv.mkDerivation (finalAttrs: {
···
21
src = fetchFromGitLab {
22
owner = "iniparser";
23
repo = "iniparser";
24
+
tag = "v${finalAttrs.version}";
25
hash = "sha256-z10S9ODLprd7CbL5Ecgh7H4eOwTetYwFXiWBUm6fIr4=";
26
};
27
28
+
patches = lib.optional finalAttrs.doCheck (
29
+
# 1. Do not fetch the Unity GitHub repository
30
+
# 2. Lookup the Unity pkgconfig file
31
+
# 3. Get the generate_test_runner.rb file from the Unity share directory
32
+
replaceVars ./remove-fetchcontent-usage.patch {
33
+
# Get the test generator
34
+
UNITY-GENERATE-TEST-RUNNER = "${unity-test}/share/generate_test_runner.rb";
35
+
}
36
+
);
0
0
0
0
0
0
0
0
0
37
38
nativeBuildInputs = [
39
cmake
40
doxygen
41
validatePkgConfig
42
+
];
43
44
+
cmakeFlags = [
45
+
(lib.cmakeBool "BUILD_TESTING" finalAttrs.doCheck)
46
+
];
47
+
doCheck = true;
48
+
nativeCheckInputs = [
49
+
ruby
50
+
ctestCheckHook
51
+
];
52
+
checkInputs = [
53
+
(
54
+
(unity-test.override {
55
+
supportDouble = true;
56
+
}).overrideAttrs
57
+
{
58
+
doCheck = false;
59
+
}
60
+
)
61
+
];
62
63
postFixup = ''
64
ln -sv $out/include/iniparser/*.h $out/include/
65
'';
66
67
+
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
0
0
0
0
0
68
69
+
meta = {
70
homepage = "https://gitlab.com/iniparser/iniparser";
71
description = "Free standalone ini file parsing library";
72
changelog = "https://gitlab.com/iniparser/iniparser/-/releases/v${finalAttrs.version}";
73
+
license = lib.licenses.mit;
74
+
platforms = lib.platforms.unix;
75
pkgConfigModules = [ "iniparser" ];
76
maintainers = [ ];
77
};
+43
-8
pkgs/by-name/in/iniparser/remove-fetchcontent-usage.patch
···
1
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
2
-
index b28d151..33a6bcf 100644
3
--- a/test/CMakeLists.txt
4
+++ b/test/CMakeLists.txt
5
-
@@ -28,10 +28,8 @@ set(FETCHCONTENT_QUIET OFF)
0
0
6
7
-
FetchContent_Declare(
8
-
unity
9
- GIT_REPOSITORY "https://github.com/throwtheswitch/unity.git"
10
- GIT_PROGRESS TRUE
11
- PATCH_COMMAND ${CMAKE_COMMAND} -E copy
12
- ${CMAKE_CURRENT_LIST_DIR}/unity_config.h ./src/)
13
-
+ SOURCE_DIR @unitySrc@
14
-
+)
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
16
-
FetchContent_MakeAvailable(unity)
17
-
target_compile_definitions(unity PUBLIC UNITY_INCLUDE_CONFIG_H)
···
1
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
2
+
index 0735d27..32c5cdb 100644
3
--- a/test/CMakeLists.txt
4
+++ b/test/CMakeLists.txt
5
+
@@ -26,16 +26,8 @@ endif()
6
+
7
+
set(FETCHCONTENT_QUIET OFF)
8
9
+
-FetchContent_Declare(
10
+
- unity
11
- GIT_REPOSITORY "https://github.com/throwtheswitch/unity.git"
12
- GIT_PROGRESS TRUE
13
- PATCH_COMMAND ${CMAKE_COMMAND} -E copy
14
- ${CMAKE_CURRENT_LIST_DIR}/unity_config.h ./src/)
15
+
-
16
+
-FetchContent_MakeAvailable(unity)
17
+
-target_compile_definitions(unity PUBLIC UNITY_INCLUDE_CONFIG_H
18
+
- UNITY_USE_COMMAND_LINE_ARGS)
19
+
+find_package(PkgConfig REQUIRED)
20
+
+pkg_check_modules(UNITY REQUIRED unity)
21
+
22
+
function(create_test_runner)
23
+
set(options)
24
+
@@ -52,7 +44,7 @@ function(create_test_runner)
25
+
add_custom_command(
26
+
OUTPUT test_${TEST_RUNNER_NAME}_runner.c
27
+
COMMAND
28
+
- ${RUBY_EXECUTABLE} ${unity_SOURCE_DIR}/auto/generate_test_runner.rb
29
+
+ @UNITY-GENERATE-TEST-RUNNER@
30
+
${CMAKE_CURRENT_SOURCE_DIR}/test_${TEST_RUNNER_NAME}.c
31
+
test_${TEST_RUNNER_NAME}_runner.c ${CMAKE_CURRENT_LIST_DIR}/unity-config.yml
32
+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test_${TEST_RUNNER_NAME}.c
33
+
@@ -62,10 +54,18 @@ function(create_test_runner)
34
+
test_${TEST_RUNNER_NAME}_runner.c)
35
+
foreach(TARGET_TYPE ${TARGET_TYPES})
36
+
# if BUILD_STATIC_LIBS=ON shared takes precedence
37
+
+ target_include_directories(
38
+
+ test_${TEST_RUNNER_NAME}
39
+
+ PUBLIC
40
+
+ ${UNITY_INCLUDE_DIRS})
41
+
+ target_compile_options(
42
+
+ test_${TEST_RUNNER_NAME}
43
+
+ PUBLIC
44
+
+ ${UNITY_CFLAGS_OTHER})
45
+
target_link_libraries(
46
+
test_${TEST_RUNNER_NAME}
47
+
${PROJECT_NAME}-${TARGET_TYPE}
48
+
- unity)
49
+
+ ${UNITY_LIBRARIES})
50
+
endforeach()
51
+
endfunction()
52
0
0
+18
pkgs/by-name/un/unity-test/meson.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
diff --git a/meson.build b/meson.build
2
+
index 6585129..9489aef 100644
3
+
--- a/meson.build
4
+
+++ b/meson.build
5
+
@@ -64,10 +64,10 @@ unity_dep = declare_dependency(
6
+
if not meson.is_subproject()
7
+
pkg = import('pkgconfig')
8
+
pkg.generate(
9
+
- name: meson.project_name(),
10
+
+ unity_lib,
11
+
version: meson.project_version(),
12
+
- libraries: [ unity_lib ],
13
+
- description: 'C Unit testing framework.'
14
+
+ subdirs: 'unity',
15
+
+ extra_cflags: unity_args,
16
+
)
17
+
endif
18
+
+100
-4
pkgs/by-name/un/unity-test/package.nix
···
2
lib,
3
stdenv,
4
fetchFromGitHub,
5
-
cmake,
6
-
}:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
0
0
0
0
0
0
0
0
0
8
stdenv.mkDerivation (finalAttrs: {
9
pname = "unity-test";
10
version = "2.6.1";
···
16
hash = "sha256-g0ubq7RxGQmL1R6vz9RIGJpVWYsgrZhsTWSrL1ySEug=";
17
};
18
19
-
nativeBuildInputs = [ cmake ];
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20
doCheck = true;
21
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
22
meta = {
23
description = "Unity Unit Testing Framework";
24
homepage = "https://www.throwtheswitch.org/unity";
0
25
license = lib.licenses.mit;
26
-
maintainers = [ lib.maintainers.i01011001 ];
0
0
0
0
0
27
};
28
})
···
2
lib,
3
stdenv,
4
fetchFromGitHub,
5
+
fetchpatch2,
6
+
meson,
7
+
ninja,
8
+
ruby,
9
+
python3Minimal,
10
+
nix-update-script,
11
+
testers,
12
+
iniparser,
13
+
validatePkgConfig,
14
+
# Adds test groups and extra CLI flags.
15
+
buildFixture ? false,
16
+
# Adds the ablilty to track malloc and free calls.
17
+
# Note that if fixtures are enabled, this option is ignored
18
+
# and will always be enabled.
19
+
buildMemory ? buildFixture,
20
+
# Adds double precision floating point assertions
21
+
supportDouble ? false,
22
23
+
}:
24
+
let
25
+
# On newer versions of Clang, Weverything is too much of everything.
26
+
ignoredErrors = [
27
+
"-Wno-unsafe-buffer-usage"
28
+
"-Wno-reserved-identifier"
29
+
"-Wno-extra-semi-stmt"
30
+
];
31
+
in
32
stdenv.mkDerivation (finalAttrs: {
33
pname = "unity-test";
34
version = "2.6.1";
···
40
hash = "sha256-g0ubq7RxGQmL1R6vz9RIGJpVWYsgrZhsTWSrL1ySEug=";
41
};
42
43
+
patches = [
44
+
# The meson file does not have the subdir set correctly
45
+
(fetchpatch2 {
46
+
url = "https://patch-diff.githubusercontent.com/raw/ThrowTheSwitch/Unity/pull/771.patch";
47
+
hash = "sha256-r8ldVb7WrzVwTC2CtGul9Jk4Rzt+6ejk+paYAfFlR5M=";
48
+
})
49
+
# Fix up the shebangs in the auto directory as not all are correct
50
+
(fetchpatch2 {
51
+
url = "https://patch-diff.githubusercontent.com/raw/ThrowTheSwitch/Unity/pull/790.patch";
52
+
hash = "sha256-K+OxMe/ZMXPPjZXjGhgc5ULLN7plBwL0hV5gwmgA3FM=";
53
+
})
54
+
];
55
+
56
+
postPatch = ''
57
+
patchShebangs --build auto
58
+
'';
59
+
60
+
outputs = [
61
+
"out"
62
+
"dev"
63
+
];
64
+
65
+
strictDeps = true;
66
+
nativeBuildInputs = [
67
+
meson
68
+
ninja
69
+
python3Minimal
70
+
validatePkgConfig
71
+
];
72
+
73
+
# For the helper shebangs
74
+
buildInputs = [
75
+
python3Minimal
76
+
ruby
77
+
];
78
+
79
+
mesonFlags = [
80
+
(lib.mesonBool "extension_memory" buildMemory)
81
+
(lib.mesonBool "extension_fixture" buildFixture)
82
+
(lib.mesonBool "support_double" supportDouble)
83
+
];
84
+
85
doCheck = true;
86
87
+
checkPhase = ''
88
+
runHook preCheck
89
+
90
+
make -C../test -j $NIX_BUILD_CORES ${lib.optionalString stdenv.cc.isClang "CC=clang"} E="-Weverything ${lib.escapeShellArgs ignoredErrors}" test
91
+
92
+
runHook postCheck
93
+
'';
94
+
95
+
# Various helpers
96
+
postInstall = ''
97
+
mkdir -p "$out/share"
98
+
install -Dm755 ../auto/* -t "$out/share/"
99
+
'';
100
+
101
+
passthru = {
102
+
updateScript = nix-update-script { };
103
+
tests = {
104
+
inherit iniparser;
105
+
pkg-config = testers.hasPkgConfigModules {
106
+
package = finalAttrs.finalPackage;
107
+
versionCheck = true;
108
+
};
109
+
};
110
+
};
111
+
112
meta = {
113
description = "Unity Unit Testing Framework";
114
homepage = "https://www.throwtheswitch.org/unity";
115
+
changelog = "https://github.com/ThrowTheSwitch/Unity/releases/tag/v${finalAttrs.version}";
116
license = lib.licenses.mit;
117
+
platforms = lib.platforms.all;
118
+
pkgConfigModules = [ "unity" ];
119
+
maintainers = with lib.maintainers; [
120
+
i01011001
121
+
RossSmyth
122
+
];
123
};
124
})