depot/third_party/nixpkgs/pkgs/by-name/li/libiconv-darwin/package.nix
Default email 5c370c0b2a Project import generated by Copybara.
GitOrigin-RevId: 33d1e753c82ffc557b4a585c77de43d4c922ebb5
2024-05-15 17:35:15 +02:00

95 lines
2.3 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
atf,
libiconvReal,
meson,
ninja,
pkg-config,
gitUpdater,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libiconv";
version = "99";
outputs = [
"out"
"dev"
];
src = fetchFromGitHub {
owner = "apple-oss-distributions";
repo = "libiconv";
rev = "libiconv-${finalAttrs.version}";
hash = "sha256-TGt6rsU52ztfW2rCqwnhMAExLbexI/59IoDOGY+XGu0=";
};
inherit (libiconvReal) setupHooks;
postPatch =
''
substitute ${./meson.build} meson.build --subst-var version
cp ${./meson.options} meson.options
# Work around unnecessary private API usage in libcharset
mkdir -p libcharset/os && cat <<-header > libcharset/os/variant_private.h
#pragma once
#include <stdbool.h>
static inline bool os_variant_has_internal_content(const char*) { return false; }
header
cp ${./nixpkgs_test.c} tests/libiconv/nixpkgs_test.c
'';
strictDeps = true;
nativeBuildInputs = [
meson
ninja
];
mesonBuildType = "release";
mesonFlags = [ (lib.mesonBool "tests" finalAttrs.doInstallCheck) ];
postInstall = lib.optionalString stdenv.isDarwin ''
${stdenv.cc.targetPrefix}install_name_tool "$out/lib/libiconv.2.dylib" \
-change '@rpath/libcharset.1.dylib' "$out/lib/libcharset.1.dylib"
'';
# Tests have to be run in `installCheckPhase` because libiconv expects to `dlopen`
# modules from `$out/lib/i18n`.
nativeInstallCheckInputs = [ pkg-config ];
installCheckInputs = [ atf ];
doInstallCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
# Cant use `mesonCheckPhase` because it runs the wrong hooks for `installCheckPhase`.
installCheckPhase = ''
runHook preInstallCheck
meson test --no-rebuild
runHook postInstallCheck
'';
passthru.updateScript = gitUpdater { rev-prefix = "libiconv-"; };
__structuredAttrs = true;
meta = {
description = "An iconv(3) implementation";
homepage = "https://opensource.apple.com/releases/";
license =
with lib.licenses;
[
bsd2
bsd3
]
++ lib.optional finalAttrs.doInstallCheck apsl10;
mainProgram = "iconv";
maintainers = with lib.maintainers; [ reckenrode ];
platforms = lib.platforms.darwin;
};
})