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