cosmopolitan: rewrite

This commit is contained in:
Anderson Torres 2023-10-16 23:04:31 -03:00
parent f8d72a6def
commit 037d5af018

View file

@ -1,60 +1,85 @@
{ lib, stdenv, fetchFromGitHub, unzip, bintools-unwrapped, coreutils, substituteAll }: { lib
, stdenv
, fetchFromGitHub
, bintools-unwrapped
, coreutils
, substituteAll
, unzip
}:
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "cosmopolitan"; pname = "cosmopolitan";
version = "2.2"; version = "2.2";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "jart"; owner = "jart";
repo = pname; repo = "cosmopolitan";
rev = version; rev = finalAttrs.version;
sha256 = "sha256-DTL1dXH+LhaxWpiCrsNjV74Bw5+kPbhEAA2Z1NKiPDk="; hash = "sha256-DTL1dXH+LhaxWpiCrsNjV74Bw5+kPbhEAA2Z1NKiPDk=";
}; };
patches = [ patches = [
# make sure tests set PATH correctly # make sure tests set PATH correctly
(substituteAll { src = ./fix-paths.patch; inherit coreutils; }) (substituteAll {
src = ./fix-paths.patch;
inherit coreutils;
})
]; ];
nativeBuildInputs = [ bintools-unwrapped unzip ]; nativeBuildInputs = [
bintools-unwrapped
unzip
];
strictDeps = true;
outputs = [ "out" "dist" ]; outputs = [ "out" "dist" ];
# slashes are significant because upstream uses o/$(MODE)/foo.o # slashes are significant because upstream uses o/$(MODE)/foo.o
buildFlags = [ "o/cosmopolitan.h" "o//cosmopolitan.a" "o//libc/crt/crt.o" "o//ape/ape.o" "o//ape/ape.lds" ]; buildFlags = [
"o/cosmopolitan.h"
"o//cosmopolitan.a"
"o//libc/crt/crt.o"
"o//ape/ape.o"
"o//ape/ape.lds"
];
checkTarget = "o//test"; checkTarget = "o//test";
enableParallelBuilding = true; enableParallelBuilding = true;
doCheck = true; doCheck = true;
dontConfigure = true; dontConfigure = true;
dontFixup = true; dontFixup = true;
preCheck = '' preCheck = let
# some syscall tests fail because we're in a sandbox failingTests = [
rm test/libc/calls/sched_setscheduler_test.c # some syscall tests fail because we're in a sandbox
rm test/libc/thread/pthread_create_test.c "test/libc/calls/sched_setscheduler_test.c"
rm test/libc/calls/getgroups_test.c "test/libc/thread/pthread_create_test.c"
"test/libc/calls/getgroups_test.c"
# fails # fails
rm test/libc/stdio/posix_spawn_test.c "test/libc/stdio/posix_spawn_test.c"
''; ];
in lib.concatStringsSep ";\n" (map (t: "rm -v ${t}") failingTests);
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/{include,lib} mkdir -p $out/{include,lib}
install o/cosmopolitan.h $out/include install o/cosmopolitan.h $out/include
install o/cosmopolitan.a o/libc/crt/crt.o o/ape/ape.{o,lds} o/ape/ape-no-modify-self.o $out/lib install o/cosmopolitan.a o/libc/crt/crt.o o/ape/ape.{o,lds} o/ape/ape-no-modify-self.o $out/lib
cp -RT . "$dist" cp -RT . "$dist"
runHook postInstall runHook postInstall
''; '';
meta = with lib; { meta = {
homepage = "https://justine.lol/cosmopolitan/"; homepage = "https://justine.lol/cosmopolitan/";
description = "Your build-once run-anywhere c library"; description = "Your build-once run-anywhere c library";
platforms = platforms.x86_64; license = lib.licenses.isc;
badPlatforms = platforms.darwin; maintainers = lib.teams.cosmopolitan.members;
license = licenses.isc; platforms = lib.platforms.x86_64;
maintainers = teams.cosmopolitan.members; badPlatforms = lib.platforms.darwin;
}; };
} })