iniparser: use unity-test from nixpkgs
This commit is contained in:
parent
db1e62b7c0
commit
c811cf1dbb
@ -10,6 +10,8 @@
|
|||||||
ruby,
|
ruby,
|
||||||
validatePkgConfig,
|
validatePkgConfig,
|
||||||
testers,
|
testers,
|
||||||
|
unity-test,
|
||||||
|
ctestCheckHook,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
@ -19,56 +21,57 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
src = fetchFromGitLab {
|
src = fetchFromGitLab {
|
||||||
owner = "iniparser";
|
owner = "iniparser";
|
||||||
repo = "iniparser";
|
repo = "iniparser";
|
||||||
rev = "v${finalAttrs.version}";
|
tag = "v${finalAttrs.version}";
|
||||||
hash = "sha256-z10S9ODLprd7CbL5Ecgh7H4eOwTetYwFXiWBUm6fIr4=";
|
hash = "sha256-z10S9ODLprd7CbL5Ecgh7H4eOwTetYwFXiWBUm6fIr4=";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = lib.optionals finalAttrs.finalPackage.doCheck [
|
patches = lib.optional finalAttrs.doCheck (
|
||||||
(replaceVars ./remove-fetchcontent-usage.patch {
|
# 1. Do not fetch the Unity GitHub repository
|
||||||
# Do not let cmake's fetchContent download unity
|
# 2. Lookup the Unity pkgconfig file
|
||||||
unitySrc = symlinkJoin {
|
# 3. Get the generate_test_runner.rb file from the Unity share directory
|
||||||
paths = [
|
replaceVars ./remove-fetchcontent-usage.patch {
|
||||||
(fetchFromGitHub {
|
# Get the test generator
|
||||||
owner = "throwtheswitch";
|
UNITY-GENERATE-TEST-RUNNER = "${unity-test}/share/generate_test_runner.rb";
|
||||||
repo = "unity";
|
}
|
||||||
rev = "v2.6.0";
|
);
|
||||||
hash = "sha256-SCcUGNN/UJlu3ALJiZ9bQKxYRZey3cm9QG+NOehp6Ow=";
|
|
||||||
})
|
|
||||||
];
|
|
||||||
postBuild = ''
|
|
||||||
ln -s ${finalAttrs.src}/test/unity_config.h $out/src/unity_config.h
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
cmake
|
cmake
|
||||||
doxygen
|
doxygen
|
||||||
validatePkgConfig
|
validatePkgConfig
|
||||||
] ++ lib.optionals finalAttrs.finalPackage.doCheck [ ruby ];
|
];
|
||||||
|
|
||||||
cmakeFlags = [ "-DBUILD_TESTING=${if finalAttrs.finalPackage.doCheck then "ON" else "OFF"}" ];
|
cmakeFlags = [
|
||||||
|
(lib.cmakeBool "BUILD_TESTING" finalAttrs.doCheck)
|
||||||
doCheck = false;
|
];
|
||||||
|
doCheck = true;
|
||||||
|
nativeCheckInputs = [
|
||||||
|
ruby
|
||||||
|
ctestCheckHook
|
||||||
|
];
|
||||||
|
checkInputs = [
|
||||||
|
(
|
||||||
|
(unity-test.override {
|
||||||
|
supportDouble = true;
|
||||||
|
}).overrideAttrs
|
||||||
|
{
|
||||||
|
doCheck = false;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
postFixup = ''
|
postFixup = ''
|
||||||
ln -sv $out/include/iniparser/*.h $out/include/
|
ln -sv $out/include/iniparser/*.h $out/include/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.tests = {
|
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
||||||
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
|
||||||
iniparser-with-tests = finalAttrs.overrideAttrs (_: {
|
|
||||||
doCheck = true;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = with lib; {
|
meta = {
|
||||||
homepage = "https://gitlab.com/iniparser/iniparser";
|
homepage = "https://gitlab.com/iniparser/iniparser";
|
||||||
description = "Free standalone ini file parsing library";
|
description = "Free standalone ini file parsing library";
|
||||||
changelog = "https://gitlab.com/iniparser/iniparser/-/releases/v${finalAttrs.version}";
|
changelog = "https://gitlab.com/iniparser/iniparser/-/releases/v${finalAttrs.version}";
|
||||||
license = licenses.mit;
|
license = lib.licenses.mit;
|
||||||
platforms = platforms.unix;
|
platforms = lib.platforms.unix;
|
||||||
pkgConfigModules = [ "iniparser" ];
|
pkgConfigModules = [ "iniparser" ];
|
||||||
maintainers = [ ];
|
maintainers = [ ];
|
||||||
};
|
};
|
||||||
|
@ -1,17 +1,52 @@
|
|||||||
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
|
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
|
||||||
index b28d151..33a6bcf 100644
|
index 0735d27..32c5cdb 100644
|
||||||
--- a/test/CMakeLists.txt
|
--- a/test/CMakeLists.txt
|
||||||
+++ b/test/CMakeLists.txt
|
+++ b/test/CMakeLists.txt
|
||||||
@@ -28,10 +28,8 @@ set(FETCHCONTENT_QUIET OFF)
|
@@ -26,16 +26,8 @@ endif()
|
||||||
|
|
||||||
FetchContent_Declare(
|
set(FETCHCONTENT_QUIET OFF)
|
||||||
unity
|
|
||||||
|
-FetchContent_Declare(
|
||||||
|
- unity
|
||||||
- GIT_REPOSITORY "https://github.com/throwtheswitch/unity.git"
|
- GIT_REPOSITORY "https://github.com/throwtheswitch/unity.git"
|
||||||
- GIT_PROGRESS TRUE
|
- GIT_PROGRESS TRUE
|
||||||
- PATCH_COMMAND ${CMAKE_COMMAND} -E copy
|
- PATCH_COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
- ${CMAKE_CURRENT_LIST_DIR}/unity_config.h ./src/)
|
- ${CMAKE_CURRENT_LIST_DIR}/unity_config.h ./src/)
|
||||||
+ SOURCE_DIR @unitySrc@
|
-
|
||||||
+)
|
-FetchContent_MakeAvailable(unity)
|
||||||
|
-target_compile_definitions(unity PUBLIC UNITY_INCLUDE_CONFIG_H
|
||||||
|
- UNITY_USE_COMMAND_LINE_ARGS)
|
||||||
|
+find_package(PkgConfig REQUIRED)
|
||||||
|
+pkg_check_modules(UNITY REQUIRED unity)
|
||||||
|
|
||||||
|
function(create_test_runner)
|
||||||
|
set(options)
|
||||||
|
@@ -52,7 +44,7 @@ function(create_test_runner)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT test_${TEST_RUNNER_NAME}_runner.c
|
||||||
|
COMMAND
|
||||||
|
- ${RUBY_EXECUTABLE} ${unity_SOURCE_DIR}/auto/generate_test_runner.rb
|
||||||
|
+ @UNITY-GENERATE-TEST-RUNNER@
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test_${TEST_RUNNER_NAME}.c
|
||||||
|
test_${TEST_RUNNER_NAME}_runner.c ${CMAKE_CURRENT_LIST_DIR}/unity-config.yml
|
||||||
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test_${TEST_RUNNER_NAME}.c
|
||||||
|
@@ -62,10 +54,18 @@ function(create_test_runner)
|
||||||
|
test_${TEST_RUNNER_NAME}_runner.c)
|
||||||
|
foreach(TARGET_TYPE ${TARGET_TYPES})
|
||||||
|
# if BUILD_STATIC_LIBS=ON shared takes precedence
|
||||||
|
+ target_include_directories(
|
||||||
|
+ test_${TEST_RUNNER_NAME}
|
||||||
|
+ PUBLIC
|
||||||
|
+ ${UNITY_INCLUDE_DIRS})
|
||||||
|
+ target_compile_options(
|
||||||
|
+ test_${TEST_RUNNER_NAME}
|
||||||
|
+ PUBLIC
|
||||||
|
+ ${UNITY_CFLAGS_OTHER})
|
||||||
|
target_link_libraries(
|
||||||
|
test_${TEST_RUNNER_NAME}
|
||||||
|
${PROJECT_NAME}-${TARGET_TYPE}
|
||||||
|
- unity)
|
||||||
|
+ ${UNITY_LIBRARIES})
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
FetchContent_MakeAvailable(unity)
|
|
||||||
target_compile_definitions(unity PUBLIC UNITY_INCLUDE_CONFIG_H)
|
|
||||||
|
18
pkgs/by-name/un/unity-test/meson.patch
Normal file
18
pkgs/by-name/un/unity-test/meson.patch
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
diff --git a/meson.build b/meson.build
|
||||||
|
index 6585129..9489aef 100644
|
||||||
|
--- a/meson.build
|
||||||
|
+++ b/meson.build
|
||||||
|
@@ -64,10 +64,10 @@ unity_dep = declare_dependency(
|
||||||
|
if not meson.is_subproject()
|
||||||
|
pkg = import('pkgconfig')
|
||||||
|
pkg.generate(
|
||||||
|
- name: meson.project_name(),
|
||||||
|
+ unity_lib,
|
||||||
|
version: meson.project_version(),
|
||||||
|
- libraries: [ unity_lib ],
|
||||||
|
- description: 'C Unit testing framework.'
|
||||||
|
+ subdirs: 'unity',
|
||||||
|
+ extra_cflags: unity_args,
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
@ -2,9 +2,33 @@
|
|||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
cmake,
|
fetchpatch2,
|
||||||
}:
|
meson,
|
||||||
|
ninja,
|
||||||
|
ruby,
|
||||||
|
python3Minimal,
|
||||||
|
nix-update-script,
|
||||||
|
testers,
|
||||||
|
iniparser,
|
||||||
|
validatePkgConfig,
|
||||||
|
# Adds test groups and extra CLI flags.
|
||||||
|
buildFixture ? false,
|
||||||
|
# Adds the ablilty to track malloc and free calls.
|
||||||
|
# Note that if fixtures are enabled, this option is ignored
|
||||||
|
# and will always be enabled.
|
||||||
|
buildMemory ? buildFixture,
|
||||||
|
# Adds double precision floating point assertions
|
||||||
|
supportDouble ? false,
|
||||||
|
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
# On newer versions of Clang, Weverything is too much of everything.
|
||||||
|
ignoredErrors = [
|
||||||
|
"-Wno-unsafe-buffer-usage"
|
||||||
|
"-Wno-reserved-identifier"
|
||||||
|
"-Wno-extra-semi-stmt"
|
||||||
|
];
|
||||||
|
in
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "unity-test";
|
pname = "unity-test";
|
||||||
version = "2.6.1";
|
version = "2.6.1";
|
||||||
@ -16,13 +40,85 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
hash = "sha256-g0ubq7RxGQmL1R6vz9RIGJpVWYsgrZhsTWSrL1ySEug=";
|
hash = "sha256-g0ubq7RxGQmL1R6vz9RIGJpVWYsgrZhsTWSrL1ySEug=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ];
|
patches = [
|
||||||
|
# The meson file does not have the subdir set correctly
|
||||||
|
(fetchpatch2 {
|
||||||
|
url = "https://patch-diff.githubusercontent.com/raw/ThrowTheSwitch/Unity/pull/771.patch";
|
||||||
|
hash = "sha256-r8ldVb7WrzVwTC2CtGul9Jk4Rzt+6ejk+paYAfFlR5M=";
|
||||||
|
})
|
||||||
|
# Fix up the shebangs in the auto directory as not all are correct
|
||||||
|
(fetchpatch2 {
|
||||||
|
url = "https://patch-diff.githubusercontent.com/raw/ThrowTheSwitch/Unity/pull/790.patch";
|
||||||
|
hash = "sha256-K+OxMe/ZMXPPjZXjGhgc5ULLN7plBwL0hV5gwmgA3FM=";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
patchShebangs --build auto
|
||||||
|
'';
|
||||||
|
|
||||||
|
outputs = [
|
||||||
|
"out"
|
||||||
|
"dev"
|
||||||
|
];
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
nativeBuildInputs = [
|
||||||
|
meson
|
||||||
|
ninja
|
||||||
|
python3Minimal
|
||||||
|
validatePkgConfig
|
||||||
|
];
|
||||||
|
|
||||||
|
# For the helper shebangs
|
||||||
|
buildInputs = [
|
||||||
|
python3Minimal
|
||||||
|
ruby
|
||||||
|
];
|
||||||
|
|
||||||
|
mesonFlags = [
|
||||||
|
(lib.mesonBool "extension_memory" buildMemory)
|
||||||
|
(lib.mesonBool "extension_fixture" buildFixture)
|
||||||
|
(lib.mesonBool "support_double" supportDouble)
|
||||||
|
];
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
|
checkPhase = ''
|
||||||
|
runHook preCheck
|
||||||
|
|
||||||
|
make -C../test -j $NIX_BUILD_CORES ${lib.optionalString stdenv.cc.isClang "CC=clang"} E="-Weverything ${lib.escapeShellArgs ignoredErrors}" test
|
||||||
|
|
||||||
|
runHook postCheck
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Various helpers
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p "$out/share"
|
||||||
|
install -Dm755 ../auto/* -t "$out/share/"
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
updateScript = nix-update-script { };
|
||||||
|
tests = {
|
||||||
|
inherit iniparser;
|
||||||
|
pkg-config = testers.hasPkgConfigModules {
|
||||||
|
package = finalAttrs.finalPackage;
|
||||||
|
versionCheck = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Unity Unit Testing Framework";
|
description = "Unity Unit Testing Framework";
|
||||||
homepage = "https://www.throwtheswitch.org/unity";
|
homepage = "https://www.throwtheswitch.org/unity";
|
||||||
|
changelog = "https://github.com/ThrowTheSwitch/Unity/releases/tag/v${finalAttrs.version}";
|
||||||
license = lib.licenses.mit;
|
license = lib.licenses.mit;
|
||||||
maintainers = [ lib.maintainers.i01011001 ];
|
platforms = lib.platforms.all;
|
||||||
|
pkgConfigModules = [ "unity" ];
|
||||||
|
maintainers = with lib.maintainers; [
|
||||||
|
i01011001
|
||||||
|
RossSmyth
|
||||||
|
];
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user