Unverified Commit 624fe3e9 authored by winston's avatar winston
Browse files

muon: 0.4.0 -> 0.5.0, enable tests

parent 16e07752
Loading
Loading
Loading
Loading
+67 −55
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@
  lib,
  stdenv,
  fetchFromSourcehut,
  fetchurl,
  fetchFromGitHub,
  coreutils,
  curl,
  libarchive,
  libpkgconf,
@@ -10,33 +11,51 @@
  python3,
  samurai,
  scdoc,
  writableTmpDirAsHomeHook,
  zlib,
  embedSamurai ? false,
  buildDocs ? true,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "muon" + lib.optionalString embedSamurai "-embedded-samurai";
  version = "0.4.0";
  version = "0.5.0";

  src = fetchFromSourcehut {
  srcs = [
    (fetchFromSourcehut {
      name = "muon-src";
      owner = "~lattis";
      repo = "muon";
      tag = finalAttrs.version;
    hash = "sha256-xTdyqK8t741raMhjjJBMbWnAorLMMdZ02TeMXK7O+Yw=";
  };
      hash = "sha256-bWEYWUD+GK8R3yVnDTnzFWmm4KAuVPI+1yMfCXWcG/A=";
    })
    (fetchFromGitHub {
      name = "meson-tests";
      repo = "meson-tests";
      owner = "muon-build";
      rev = "db92588773a24f67cda2f331b945825ca3a63fa7";
      hash = "sha256-z4Fc1lr/m2MwIwhXJwoFWpzeNg+udzMxuw5Q/zVvpSM=";
    })
  ]
  ++ lib.optionals buildDocs [
    (fetchFromGitHub {
      name = "meson-docs";
      repo = "meson-docs";
      owner = "muon-build";
      rev = "1017b3413601044fb41ad04977445e68a80e8181";
      hash = "sha256-aFpyJFIqybLNKhm/kyfCjYylj7DE6muI1+OUh4Cq4WY=";
    })
  ];

  sourceRoot = "./muon-src";

  outputs = [ "out" ] ++ lib.optionals buildDocs [ "man" ];

  nativeBuildInputs = [
    pkgconf
    (python3.withPackages (ps: [ ps.pyyaml ]))
  ]
  ++ lib.optionals (!embedSamurai) [ samurai ]
  ++ lib.optionals buildDocs [
    (python3.withPackages (ps: [ ps.pyyaml ]))
    scdoc
  ];
  ++ lib.optionals buildDocs [ scdoc ];

  buildInputs = [
    curl
@@ -47,54 +66,43 @@ stdenv.mkDerivation (finalAttrs: {

  strictDeps = true;

  postUnpack =
    let
      # URLs manually extracted from subprojects directory
      meson-docs-wrap = fetchurl {
        name = "meson-docs-wrap";
        url = "https://github.com/muon-build/meson-docs/archive/5bc0b250984722389419dccb529124aed7615583.tar.gz";
        hash = "sha256-5MmmiZfadCuUJ2jy5Rxubwf4twX0jcpr+TPj5ssdSbM=";
      };

      meson-tests-wrap = fetchurl {
        name = "meson-tests-wrap";
        url = "https://github.com/muon-build/meson-tests/archive/591b5a053f9aa15245ccbd1d334cf3f8031b1035.tar.gz";
        hash = "sha256-6GXfcheZyB/S/xl/j7pj5EAWtsmx4N0fVhLPMJ2wC/w=";
      };
    in
    ''
      mkdir -p $sourceRoot/subprojects/meson-docs
      pushd $sourceRoot/subprojects/meson-docs
      ${lib.optionalString buildDocs "tar xvf ${meson-docs-wrap} --strip-components=1"}
      popd

      mkdir -p $sourceRoot/subprojects/meson-tests
      pushd $sourceRoot/subprojects/meson-tests
      tar xvf ${meson-tests-wrap} --strip-components=1
      popd
  postUnpack = ''
    for subproject in ${lib.optionalString buildDocs "meson-docs"} meson-tests; do
      cp -r "$subproject" "$sourceRoot/subprojects/$subproject"
      chmod +w -R "$sourceRoot/subprojects/$subproject"
      rm "$sourceRoot/subprojects/$subproject.wrap"
    done
  '';

  postPatch = ''
    patchShebangs bootstrap.sh
  ''
  + lib.optionalString buildDocs ''
    patchShebangs subprojects/meson-docs/docs/genrefman.py
    find subprojects/meson-tests -name "*.py" -exec chmod +x {} \;
    patchShebangs .

    substituteInPlace \
      "subprojects/meson-tests/common/14 configure file/test.py.in" \
      "subprojects/meson-tests/common/274 customtarget exe for test/generate.py" \
      "subprojects/meson-tests/native/8 external program shebang parsing/script.int.in" \
        --replace-fail "/usr/bin/env" "${coreutils}/bin/env"

    substituteInPlace \
      "subprojects/meson-tests/meson.build" \
        --replace-fail "['common/66 vcstag', {'python': true}]," ""
  '';

  # tests try to access "~"
  postConfigure = ''
    export HOME=$(mktemp -d)
  '';
  enableParallelBuilding = true;

  buildPhase =
    let
      muonBool = lib.mesonBool;
      muonEnable = lib.mesonEnable;
      muonOption = lib.mesonOption;

      cmdlineForMuon = lib.concatStringsSep " " [
        (muonOption "prefix" (placeholder "out"))
        (muonBool "static" stdenv.targetPlatform.isStatic)
        (muonEnable "docs" buildDocs)
        (muonEnable "meson-docs" buildDocs)
        (muonEnable "samurai" embedSamurai)
        (muonEnable "tracy" false)
      ];
      cmdlineForSamu = "-j$NIX_BUILD_CORES";
    in
@@ -108,19 +116,24 @@ stdenv.mkDerivation (finalAttrs: {
      ./stage-1/muon-bootstrap setup ${cmdlineForMuon} stage-2
      ${lib.optionalString embedSamurai "./stage-1/muon-bootstrap"} samu ${cmdlineForSamu} -C stage-2

      ./stage-2/muon setup -Dprefix=$out ${cmdlineForMuon} stage-3
      ./stage-2/muon setup ${cmdlineForMuon} stage-3
      ${lib.optionalString embedSamurai "./stage-2/muon"} samu ${cmdlineForSamu} -C stage-3

      runHook postBuild
    '';

  # tests are failing because they don't find Python
  doCheck = false;
  # tests only pass when samurai is embedded
  doCheck = embedSamurai;

  nativeCheckInputs = [
    # needed for "common/220 fs module"
    writableTmpDirAsHomeHook
  ];

  checkPhase = ''
    runHook preCheck

    ./stage-3/muon -C stage-3 test
    ./stage-3/muon -C stage-3 test -d dots -S -j$NIX_BUILD_CORES

    runHook postCheck
  '';
@@ -146,4 +159,3 @@ stdenv.mkDerivation (finalAttrs: {
# TODO LIST:
# 1. automate sources acquisition (especially wraps)
# 2. setup hook
# 3. tests