cosmocc: move to cosmopolitan

Also, a refactor.
This commit is contained in:
Anderson Torres 2023-10-17 00:10:31 -03:00
parent 037d5af018
commit 3666c314f8
5 changed files with 39 additions and 35 deletions

View File

@ -0,0 +1,25 @@
{ runCommand, cosmopolitan }:
let
cosmocc = runCommand "cosmocc-${cosmopolitan.version}"
{
pname = "cosmocc";
inherit (cosmopolitan) version;
passthru.tests = {
cc = runCommand "c-test" { } ''
${cosmocc}/bin/cosmocc ${./hello.c}
./a.out > $out
'';
};
meta = cosmopolitan.meta // {
description = "compilers for Cosmopolitan C/C++ programs";
};
} ''
mkdir -p $out/bin
install ${cosmopolitan.dist}/tool/scripts/{cosmocc,cosmoc++} $out/bin
sed 's|/opt/cosmo\([ /]\)|${cosmopolitan.dist}\1|g' -i $out/bin/*
'';
in
cosmocc

View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}

View File

@ -2,6 +2,7 @@
, stdenv
, fetchFromGitHub
, bintools-unwrapped
, callPackage
, coreutils
, substituteAll
, unzip
@ -74,6 +75,12 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';
passthru = {
cosmocc = callPackage ./cosmocc.nix {
cosmopolitan = finalAttrs.finalPackage;
};
};
meta = {
homepage = "https://justine.lol/cosmopolitan/";
description = "Your build-once run-anywhere c library";

View File

@ -1,34 +0,0 @@
{ runCommand, cosmopolitan }:
let
inherit (cosmopolitan) version;
cosmocc =
runCommand "cosmocc-${version}"
{
pname = "cosmocc";
inherit version;
meta = cosmopolitan.meta // {
description = "compilers for Cosmopolitan C/C++ programs";
};
passthru.tests = {
cc = runCommand "c-test" { } ''
cat > hello.c << END
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
END
${cosmocc}/bin/cosmocc hello.c
./a.out > $out
'';
};
} ''
mkdir -p $out/bin
install ${cosmopolitan.dist}/tool/scripts/{cosmocc,cosmoc++} $out/bin
sed 's|/opt/cosmo\([ /]\)|${cosmopolitan.dist}\1|g' -i $out/bin/*
'';
in
cosmocc

View File

@ -20921,7 +20921,7 @@ with pkgs;
cog = callPackage ../development/web/cog { };
cosmocc = callPackage ../development/tools/cosmocc { };
inherit (cosmopolitan) cosmocc;
python-cosmopolitan = callPackage ../development/interpreters/python-cosmopolitan { };