muon: 0.4.0 -> 0.5.0, unbreak on darwin, enable tests (#435249)

authored by

Weijia Wang and committed by
GitHub
1650d032 08304afd

+171 -66
+15
pkgs/by-name/mu/muon/darwin-clang.patch
··· 1 + diff --git a/src/functions/kernel/dependency.c b/src/functions/kernel/dependency.c 2 + index fbfc86f6..46f9be9d 100644 3 + --- a/src/functions/kernel/dependency.c 4 + +++ b/src/functions/kernel/dependency.c 5 + @@ -377,10 +377,6 @@ get_dependency_extraframework(struct workspace *wk, struct dep_lookup_ctx *ctx, 6 + } 7 + 8 + struct obj_compiler *comp = get_obj_compiler(wk, compiler); 9 + - if (comp->type[toolchain_component_compiler] != compiler_apple_clang) { 10 + - L("skipping extraframework dependency lookup: compiler type is not apple clang"); 11 + - return true; 12 + - } 13 + 14 + if (!comp->fwdirs) { 15 + obj cmd;
+121 -66
pkgs/by-name/mu/muon/package.nix
··· 1 1 { 2 2 lib, 3 3 stdenv, 4 + fetchFromGitHub, 4 5 fetchFromSourcehut, 5 - fetchurl, 6 + callPackage, 7 + coreutils, 6 8 curl, 7 9 libarchive, 8 10 libpkgconf, 9 11 pkgconf, 10 - python3, 11 12 samurai, 12 - scdoc, 13 13 zlib, 14 14 embedSamurai ? false, 15 + # docs 15 16 buildDocs ? true, 17 + scdoc, 18 + # tests 19 + runTests ? false, 20 + gettext, 21 + muon, 22 + nasm, 23 + pkg-config, 24 + python3, 25 + writableTmpDirAsHomeHook, 16 26 }: 17 - 18 27 stdenv.mkDerivation (finalAttrs: { 19 28 pname = "muon" + lib.optionalString embedSamurai "-embedded-samurai"; 20 - version = "0.4.0"; 29 + version = "0.5.0"; 21 30 22 - src = fetchFromSourcehut { 23 - name = "muon-src"; 24 - owner = "~lattis"; 25 - repo = "muon"; 26 - tag = finalAttrs.version; 27 - hash = "sha256-xTdyqK8t741raMhjjJBMbWnAorLMMdZ02TeMXK7O+Yw="; 28 - }; 31 + srcs = builtins.attrValues (lib.filterAttrs (_: v: v.use or true) finalAttrs.passthru.srcsAttrs); 32 + 33 + sourceRoot = "muon-src"; 29 34 30 35 outputs = [ "out" ] ++ lib.optionals buildDocs [ "man" ]; 31 36 ··· 34 39 ] 35 40 ++ lib.optionals (!embedSamurai) [ samurai ] 36 41 ++ lib.optionals buildDocs [ 37 - (python3.withPackages (ps: [ ps.pyyaml ])) 38 42 scdoc 43 + ] 44 + ++ lib.optionals (buildDocs || finalAttrs.doCheck) [ 45 + (python3.withPackages (ps: [ ps.pyyaml ])) 39 46 ]; 40 47 41 48 buildInputs = [ ··· 47 54 48 55 strictDeps = true; 49 56 50 - postUnpack = 51 - let 52 - # URLs manually extracted from subprojects directory 53 - meson-docs-wrap = fetchurl { 54 - name = "meson-docs-wrap"; 55 - url = "https://github.com/muon-build/meson-docs/archive/5bc0b250984722389419dccb529124aed7615583.tar.gz"; 56 - hash = "sha256-5MmmiZfadCuUJ2jy5Rxubwf4twX0jcpr+TPj5ssdSbM="; 57 - }; 57 + postUnpack = '' 58 + for src in $srcs; do 59 + name=$(stripHash $src) 58 60 59 - meson-tests-wrap = fetchurl { 60 - name = "meson-tests-wrap"; 61 - url = "https://github.com/muon-build/meson-tests/archive/591b5a053f9aa15245ccbd1d334cf3f8031b1035.tar.gz"; 62 - hash = "sha256-6GXfcheZyB/S/xl/j7pj5EAWtsmx4N0fVhLPMJ2wC/w="; 63 - }; 64 - in 65 - '' 66 - mkdir -p $sourceRoot/subprojects/meson-docs 67 - pushd $sourceRoot/subprojects/meson-docs 68 - ${lib.optionalString buildDocs "tar xvf ${meson-docs-wrap} --strip-components=1"} 69 - popd 61 + # skip the main project, only move subprojects 62 + [ "$name" == "$sourceRoot" ] && continue 70 63 71 - mkdir -p $sourceRoot/subprojects/meson-tests 72 - pushd $sourceRoot/subprojects/meson-tests 73 - tar xvf ${meson-tests-wrap} --strip-components=1 74 - popd 75 - ''; 64 + cp -r "$name" "$sourceRoot/subprojects/$name" 65 + chmod +w -R "$sourceRoot/subprojects/$name" 66 + rm "$sourceRoot/subprojects/$name.wrap" 67 + done 68 + ''; 69 + 70 + patches = [ ./darwin-clang.patch ]; 76 71 77 72 postPatch = '' 78 - patchShebangs bootstrap.sh 73 + find subprojects -name "*.py" -exec chmod +x {} \; 74 + patchShebangs subprojects 79 75 '' 80 - + lib.optionalString buildDocs '' 81 - patchShebangs subprojects/meson-docs/docs/genrefman.py 76 + + lib.optionalString finalAttrs.doCheck '' 77 + substituteInPlace \ 78 + "subprojects/meson-tests/common/14 configure file/test.py.in" \ 79 + "subprojects/meson-tests/common/274 customtarget exe for test/generate.py" \ 80 + "subprojects/meson-tests/native/8 external program shebang parsing/script.int.in" \ 81 + --replace-fail "/usr/bin/env" "${coreutils}/bin/env" 82 + 83 + substituteInPlace \ 84 + "subprojects/meson-tests/meson.build" \ 85 + --replace-fail "['common/66 vcstag', {'python': true}]," "" 82 86 ''; 83 87 84 - # tests try to access "~" 85 - postConfigure = '' 86 - export HOME=$(mktemp -d) 87 - ''; 88 + enableParallelBuilding = true; 88 89 89 90 buildPhase = 90 91 let 91 92 muonBool = lib.mesonBool; 92 93 muonEnable = lib.mesonEnable; 94 + muonOption = lib.mesonOption; 93 95 96 + bootstrapFlags = lib.optionalString (!embedSamurai) "CFLAGS=\"$CFLAGS -DBOOTSTRAP_NO_SAMU\""; 97 + # see `muon options -a` to see built-in options 94 98 cmdlineForMuon = lib.concatStringsSep " " [ 99 + (muonOption "prefix" (placeholder "out")) 100 + # don't let muon override stdenv C flags 101 + (muonEnable "auto_features" true) 102 + (muonOption "buildtype" "plain") 103 + (muonOption "optimization" "plain") 104 + (muonOption "wrap_mode" "nodownload") 105 + # muon features 95 106 (muonBool "static" stdenv.targetPlatform.isStatic) 96 - (muonEnable "docs" buildDocs) 107 + (muonEnable "man-pages" buildDocs) 108 + (muonEnable "meson-docs" buildDocs) 109 + (muonEnable "meson-tests" finalAttrs.doCheck) 97 110 (muonEnable "samurai" embedSamurai) 111 + (muonEnable "tracy" false) 112 + (muonEnable "website" false) 98 113 ]; 99 114 cmdlineForSamu = "-j$NIX_BUILD_CORES"; 100 115 in 101 116 '' 102 117 runHook preBuild 103 118 104 - ${ 105 - lib.optionalString (!embedSamurai) "CFLAGS=\"$CFLAGS -DBOOTSTRAP_NO_SAMU\"" 106 - } ./bootstrap.sh stage-1 107 - 119 + ${bootstrapFlags} ./bootstrap.sh stage-1 108 120 ./stage-1/muon-bootstrap setup ${cmdlineForMuon} stage-2 109 121 ${lib.optionalString embedSamurai "./stage-1/muon-bootstrap"} samu ${cmdlineForSamu} -C stage-2 110 122 111 - ./stage-2/muon setup -Dprefix=$out ${cmdlineForMuon} stage-3 112 - ${lib.optionalString embedSamurai "./stage-2/muon"} samu ${cmdlineForSamu} -C stage-3 113 - 114 123 runHook postBuild 115 124 ''; 116 125 117 - # tests are failing because they don't find Python 118 - doCheck = false; 126 + # tests only pass when samurai is embedded 127 + doCheck = embedSamurai && runTests; 128 + 129 + nativeCheckInputs = [ 130 + # "common/220 fs module" 131 + writableTmpDirAsHomeHook 132 + # "common/44 pkgconfig-gen" 133 + pkg-config 134 + # "frameworks/6 gettext" 135 + gettext 136 + ] 137 + ++ lib.optionals stdenv.hostPlatform.isx86_64 [ 138 + # "nasm/*" tests 139 + nasm 140 + ]; 119 141 120 142 checkPhase = '' 121 143 runHook preCheck 122 144 123 - ./stage-3/muon -C stage-3 test 145 + ./stage-2/muon -C stage-2 test -d dots -S -j$NIX_BUILD_CORES 124 146 125 147 runHook postCheck 126 148 ''; ··· 128 150 installPhase = '' 129 151 runHook preInstall 130 152 131 - stage-3/muon -C stage-3 install 153 + stage-2/muon -C stage-2 install 132 154 133 155 runHook postInstall 134 156 ''; 135 157 136 - meta = with lib; { 137 - homepage = "https://muon.build/"; 138 - description = "Implementation of Meson build system in C99"; 139 - license = licenses.gpl3Only; 140 - maintainers = with maintainers; [ ]; 141 - platforms = platforms.unix; 142 - broken = stdenv.hostPlatform.isDarwin; # typical `ar failure` 158 + passthru.srcsAttrs = { 159 + muon-src = fetchFromSourcehut { 160 + name = "muon-src"; 161 + owner = "~lattis"; 162 + repo = "muon"; 163 + tag = finalAttrs.version; 164 + hash = "sha256-bWEYWUD+GK8R3yVnDTnzFWmm4KAuVPI+1yMfCXWcG/A="; 165 + }; 166 + meson-docs = fetchFromGitHub { 167 + name = "meson-docs"; 168 + repo = "meson-docs"; 169 + owner = "muon-build"; 170 + rev = "1017b3413601044fb41ad04977445e68a80e8181"; 171 + hash = "sha256-aFpyJFIqybLNKhm/kyfCjYylj7DE6muI1+OUh4Cq4WY="; 172 + passthru.use = buildDocs; 173 + }; 174 + meson-tests = fetchFromGitHub { 175 + name = "meson-tests"; 176 + repo = "meson-tests"; 177 + owner = "muon-build"; 178 + rev = "db92588773a24f67cda2f331b945825ca3a63fa7"; 179 + hash = "sha256-z4Fc1lr/m2MwIwhXJwoFWpzeNg+udzMxuw5Q/zVvpSM="; 180 + passthru.use = finalAttrs.doCheck; 181 + }; 182 + }; 183 + 184 + # tests are run here in package tests, rather than enabling doCheck by 185 + # default, to reduce the number of required dependencies. 186 + passthru.tests.test = (muon.overrideAttrs { pname = "muon-tests"; }).override { 187 + buildDocs = false; 188 + embedSamurai = true; 189 + runTests = true; 190 + }; 191 + 192 + passthru.updateScript = callPackage ./update.nix { }; 193 + 194 + meta = { 195 + homepage = "https://muon.build"; 196 + description = "Implementation of the meson build system in C99"; 197 + license = lib.licenses.gpl3Only; 198 + maintainers = [ ]; 199 + platforms = lib.platforms.unix; 143 200 mainProgram = "muon"; 144 201 }; 145 202 }) 146 203 # TODO LIST: 147 - # 1. automate sources acquisition (especially wraps) 148 - # 2. setup hook 149 - # 3. tests 204 + # 1. setup hook
+35
pkgs/by-name/mu/muon/update.nix
··· 1 + { 2 + lib, 3 + writeShellApplication, 4 + common-updater-scripts, 5 + curl, 6 + gnugrep, 7 + }: 8 + 9 + lib.getExe (writeShellApplication { 10 + name = "update-muon"; 11 + 12 + runtimeInputs = [ 13 + common-updater-scripts 14 + curl 15 + gnugrep 16 + ]; 17 + 18 + text = '' 19 + REPO=$(nix-instantiate --raw --eval -E "with import ./. {}; muon.srcsAttrs.muon-src.meta.homepage") 20 + MUON_VERSION=$(list-git-tags --url="$REPO" | tail -1) 21 + 22 + update-source-version "muon" \ 23 + "$MUON_VERSION" \ 24 + --version-key=version \ 25 + --source-key=srcsAttrs.muon-src 26 + update-source-version "muon" \ 27 + "$(curl -s "$REPO/blob/$MUON_VERSION/subprojects/meson-docs.wrap" | grep -oP "revision = \K.+$")" \ 28 + --version-key=srcsAttrs.meson-docs.rev \ 29 + --source-key=srcsAttrs.meson-docs 30 + update-source-version "muon" \ 31 + "$(curl -s "$REPO/blob/$MUON_VERSION/subprojects/meson-tests.wrap" | grep -oP "revision = \K.+$")" \ 32 + --version-key=srcsAttrs.meson-tests.rev \ 33 + --source-key=srcsAttrs.meson-tests 34 + ''; 35 + })