Commit 921bd99f authored by Alyssa Ross's avatar Alyssa Ross Committed by Florian Klink
Browse files

wayland-scanner: split from wayland

We've used a wayland-scanner = wayland.bin alias for ages, to make
packages clearer and allow them to be independently overridden.
Going the whole way into splitting them into separate packages is
useful because it means we can have different meta.platforms
attributes for libwayland and wayland-scanner.

There is no duplication in outputs between the two packages — they
don't install any files in common.

Since we're no longer pulling just one output into nativeBuildInputs
of packages using wayland-scanner, we can use upstream's
wayland-scanner.pc, which gets installed into the dev output, rather
than providing our own.
parent 2aa25051
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -9,8 +9,6 @@
, darwin
}:

assert wayland.withLibraries;

let
  stdenv = clangStdenv;
in
+6 −37
Original line number Diff line number Diff line
@@ -5,13 +5,10 @@
, pkg-config
, ninja
, wayland-scanner
, expat
, libxml2
, withLibraries ? stdenv.isLinux || stdenv.isDarwin
, withTests ? stdenv.isLinux
, libffi
, epoll-shim
, withDocumentation ? withLibraries && stdenv.hostPlatform == stdenv.buildPlatform
, withDocumentation ? stdenv.hostPlatform == stdenv.buildPlatform
, graphviz-nox
, doxygen
, libxslt
@@ -23,15 +20,6 @@
, testers
}:

# Documentation is only built when building libraries.
assert withDocumentation -> withLibraries;

# Tests are only built when building libraries.
assert withTests -> withLibraries;

let
  isCross = stdenv.buildPlatform != stdenv.hostPlatform;
in
stdenv.mkDerivation (finalAttrs: {
  pname = "wayland";
  version = "1.23.0";
@@ -53,13 +41,13 @@ stdenv.mkDerivation (finalAttrs: {
    sed -i '/os-wrappers-test/d' tests/meson.build
  '';

  outputs = [ "out" "bin" "dev" ] ++ lib.optionals withDocumentation [ "doc" "man" ];
  outputs = [ "out" "dev" ] ++ lib.optionals withDocumentation [ "doc" "man" ];
  separateDebugInfo = true;

  mesonFlags = [
    "-Ddocumentation=${lib.boolToString withDocumentation}"
    "-Dlibraries=${lib.boolToString withLibraries}"
    "-Dtests=${lib.boolToString withTests}"
    (lib.mesonBool "documentation" withDocumentation)
    (lib.mesonBool "tests" withTests)
    (lib.mesonBool "scanner" false) # wayland-scanner is a separate derivation
  ];

  depsBuildBuild = [
@@ -70,7 +58,6 @@ stdenv.mkDerivation (finalAttrs: {
    meson
    pkg-config
    ninja
  ] ++ lib.optionals isCross [
    wayland-scanner
  ] ++ lib.optionals withDocumentation [
    (graphviz-nox.override { pango = null; }) # To avoid an infinite recursion
@@ -83,11 +70,8 @@ stdenv.mkDerivation (finalAttrs: {
  ];

  buildInputs = [
    expat
    libxml2
  ] ++ lib.optionals withLibraries [
    libffi
  ] ++ lib.optionals (withLibraries && !stdenv.hostPlatform.isLinux) [
  ] ++ lib.optionals (!stdenv.hostPlatform.isLinux) [
    epoll-shim
  ] ++ lib.optionals withDocumentation [
    docbook_xsl
@@ -95,20 +79,7 @@ stdenv.mkDerivation (finalAttrs: {
    docbook_xml_dtd_42
  ];

  postFixup = ''
    # The pkg-config file is required for cross-compilation:
    mkdir -p $bin/lib/pkgconfig/
    cat <<EOF > $bin/lib/pkgconfig/wayland-scanner.pc
    wayland_scanner=$bin/bin/wayland-scanner

    Name: Wayland Scanner
    Description: Wayland scanner
    Version: ${finalAttrs.version}
    EOF
  '';

  passthru = {
    inherit withLibraries;
    tests.pkg-config = testers.hasPkgConfigModules {
      package = finalAttrs.finalPackage;
    };
@@ -130,8 +101,6 @@ stdenv.mkDerivation (finalAttrs: {
    platforms = platforms.unix;
    maintainers = with maintainers; [ primeos codyopel qyliss ];
    pkgConfigModules = [
      "wayland-scanner"
    ] ++ lib.optionals withLibraries [
      "wayland-client"
      "wayland-cursor"
      "wayland-egl"
+4 −2
Original line number Diff line number Diff line
@@ -8,8 +8,9 @@ stdenv.mkDerivation rec {
  pname = "wayland-protocols";
  version = "1.36";

  doCheck = stdenv.hostPlatform == stdenv.buildPlatform &&
  # https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/48
  doCheck = stdenv.hostPlatform == stdenv.buildPlatform && stdenv.hostPlatform.linker == "bfd" && wayland.withLibraries;
  stdenv.hostPlatform.linker == "bfd" && lib.meta.availableOn stdenv.hostPlatform wayland;

  src = fetchurl {
    url = "https://gitlab.freedesktop.org/wayland/${pname}/-/releases/${version}/downloads/${pname}-${version}.tar.xz";
@@ -22,7 +23,8 @@ stdenv.mkDerivation rec {

  depsBuildBuild = [ pkg-config ];
  nativeBuildInputs = [ meson ninja wayland-scanner ];
  nativeCheckInputs = [ python3 wayland ];
  nativeCheckInputs = [ python3 ];
  checkInputs = [ wayland ];

  mesonFlags = [ "-Dtests=${lib.boolToString doCheck}" ];

+48 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  wayland,
  meson,
  pkg-config,
  ninja,
  wayland-scanner,
  expat,
  libxml2,
}:

stdenv.mkDerivation {
  pname = "wayland-scanner";
  inherit (wayland) version src;

  outputs = [
    "out"
    "bin"
    "dev"
  ];
  separateDebugInfo = true;

  mesonFlags = [
    (lib.mesonBool "documentation" false)
    (lib.mesonBool "libraries" false)
    (lib.mesonBool "tests" false)
  ];

  depsBuildBuild = [ pkg-config ];

  nativeBuildInputs = [
    meson
    pkg-config
    ninja
  ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) wayland-scanner;

  buildInputs = [
    expat
    libxml2
  ];

  meta = with lib; {
    inherit (wayland.meta) homepage license maintainers;
    description = "C code generator for Wayland protocol XML files";
    platforms = platforms.unix;
  };
}
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ buildPythonPackage rec {
  };

  depsBuildBuild = [ pkg-config ];
  nativeBuildInputs = [ pkg-config wayland-scanner ];
  nativeBuildInputs = [ wayland-scanner ];
  propagatedNativeBuildInputs = [ cffi ];
  buildInputs = [ wayland ];
  propagatedBuildInputs = [ cffi ];
Loading