From e0041efb940605cfab574fc0d3974f23fa54c52b Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:49:12 -0500 Subject: [PATCH] refactor: unity-test, add checks, pkg-config This now uses Meson, which causes it to output a pkg-config file, which is beter supported than cmake files. This also add the checkPhase. --- pkgs/by-name/un/unity-test/meson.patch | 12 +++++ pkgs/by-name/un/unity-test/package.nix | 62 ++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 pkgs/by-name/un/unity-test/meson.patch diff --git a/pkgs/by-name/un/unity-test/meson.patch b/pkgs/by-name/un/unity-test/meson.patch new file mode 100644 index 00000000000000..5324fa20202063 --- /dev/null +++ b/pkgs/by-name/un/unity-test/meson.patch @@ -0,0 +1,12 @@ +diff --git a/meson.build b/meson.build +index 6585129..d68f20d 100644 +--- a/meson.build ++++ b/meson.build +@@ -67,6 +67,7 @@ if not meson.is_subproject() + name: meson.project_name(), + version: meson.project_version(), + libraries: [ unity_lib ], ++ subdirs: 'unity', + description: 'C Unit testing framework.' + ) + endif diff --git a/pkgs/by-name/un/unity-test/package.nix b/pkgs/by-name/un/unity-test/package.nix index 4b0d280276c3f3..18342ede247f69 100644 --- a/pkgs/by-name/un/unity-test/package.nix +++ b/pkgs/by-name/un/unity-test/package.nix @@ -2,7 +2,20 @@ lib, stdenv, fetchFromGitHub, - cmake, + meson, + ninja, + python3, + nix-update-script, + ruby, + rubyPackages, + # 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, }: stdenv.mkDerivation (finalAttrs: { @@ -16,13 +29,56 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-g0ubq7RxGQmL1R6vz9RIGJpVWYsgrZhsTWSrL1ySEug="; }; - nativeBuildInputs = [ cmake ]; + nativeBuildInputs = [ + meson + ninja + python3 + ]; + + mesonFlags = [ + (lib.mesonBool "extension_memory" buildMemory) + (lib.mesonBool "extension_fixture" buildFixture) + (lib.mesonBool "support_double" supportDouble) + ]; + + # The meson file does not have the subdir set correctly + patches = [ ./meson.patch ]; + + postPatch = '' + patchShebangs --build auto + ''; + + # https://github.com/ThrowTheSwitch/Unity/blob/v2.6.1/.github/workflows/main.yml#L20-L35 doCheck = true; + nativeCheckInputs = [ + ruby + rubyPackages.rake + rubyPackages.rubocop + rubyPackages.rspec + ]; + + checkPhase = '' + runHook preCheck + + cd ../test + rake ci + + # Must do so the meson install hook works + cd ../build + + runHook postCheck + ''; + + passthru.updateScript = nix-update-script { }; meta = { description = "Unity Unit Testing Framework"; homepage = "https://www.throwtheswitch.org/unity"; license = lib.licenses.mit; - maintainers = [ lib.maintainers.i01011001 ]; + platforms = lib.platforms.all; + maintainers = [ + lib.maintainers.i01011001 + lib.maintainers.RossSmyth + ]; }; })